Tweak StateManager update routine to fix overlap. Add create_push_fade to ProgressState. Cleanup some inconsistencies.

This commit is contained in:
J-D-K 2025-09-25 21:00:44 -04:00
parent fa7e5fac6d
commit f725908240
3 changed files with 23 additions and 6 deletions

View File

@ -1,6 +1,8 @@
#pragma once
#include "StateManager.hpp"
#include "appstates/BaseTask.hpp"
#include "appstates/FadeState.hpp"
#include "graphics/colors.hpp"
#include "sys/sys.hpp"
#include "ui/ui.hpp"
@ -31,6 +33,15 @@ class ProgressState final : public BaseTask
return newState;
}
static inline std::shared_ptr<ProgressState> create_push_fade(sys::threadpool::JobFunction function,
sys::Task::TaskData taskData)
{
auto newState = ProgressState::create(function, taskData);
auto fade =
FadeState::create_and_push(colors::DIM_BACKGROUND, colors::ALPHA_FADE_BEGIN, colors::ALPHA_FADE_END, newState);
return newState;
}
/// @brief Checks if the thread is finished and deactivates this state.
void update() override;

View File

@ -8,6 +8,11 @@ void StateManager::update()
if (stateVector.empty()) { return; }
{
auto &back = stateVector.back();
if (back->is_active() && back->has_focus()) { back->update(); }
}
// Purge uneeded states.
for (auto current = stateVector.begin(); current != stateVector.end();)
{
@ -27,9 +32,10 @@ void StateManager::update()
// Run sub update routines.
for (auto iter = stateVector.begin(); iter < stateVector.end() - 1; iter++) { (*iter)->sub_update(); }
std::shared_ptr<BaseState> &back = stateVector.back();
if (!back->has_focus()) { back->give_focus(); }
back->update();
{
auto &back = stateVector.back();
if (!back->has_focus()) { back->give_focus(); }
}
}
void StateManager::render() noexcept

View File

@ -241,7 +241,7 @@ void BackupMenuState::name_and_create_backup()
if (keepLocal) { m_dataStruct->path = m_directoryPath / name; }
m_dataStruct->remoteName = name;
ProgressState::create_and_push(tasks::backup::create_new_backup_remote, m_dataStruct);
ProgressState::create_push_fade(tasks::backup::create_new_backup_remote, m_dataStruct);
}
else
{
@ -249,7 +249,7 @@ void BackupMenuState::name_and_create_backup()
if (!hasZipExt && (autoUpload || exportZip)) { target += STRING_ZIP_EXT; } // We're going to append zip either way.
m_dataStruct->path = std::move(target);
ProgressState::create_and_push(tasks::backup::create_new_backup_local, m_dataStruct);
ProgressState::create_push_fade(tasks::backup::create_new_backup_local, m_dataStruct);
}
}
@ -384,7 +384,7 @@ void BackupMenuState::upload_backup()
ConfirmProgress::create_push_fade(query, holdRequired, tasks::backup::patch_backup, m_dataStruct);
}
else { ProgressState::create_and_push(tasks::backup::upload_backup, m_dataStruct); }
else { ProgressState::create_push_fade(tasks::backup::upload_backup, m_dataStruct); }
}
void BackupMenuState::pop_save_empty()