Extract history UI operation planning
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#include "app_core/brush_ui.h"
|
||||
#include "app_core/document_layer.h"
|
||||
#include "app_core/app_status.h"
|
||||
#include "app_core/history_ui.h"
|
||||
#include "settings.h"
|
||||
#include "serializer.h"
|
||||
#include "font.h"
|
||||
@@ -119,19 +120,28 @@ void App::init_toolbar_main()
|
||||
if (auto* button = layout[main_id]->find<NodeButtonCustom>("btn-undo"))
|
||||
{
|
||||
button->on_click = [this, button](Node*) {
|
||||
ActionManager::undo();
|
||||
const auto plan = pp::app::plan_history_undo(static_cast<int>(ActionManager::I.m_actions.size()));
|
||||
if (plan && plan.value().invokes_undo)
|
||||
ActionManager::undo();
|
||||
};
|
||||
}
|
||||
if (auto* button = layout[main_id]->find<NodeButtonCustom>("btn-redo"))
|
||||
{
|
||||
button->on_click = [this, button](Node*) {
|
||||
ActionManager::redo();
|
||||
const auto plan = pp::app::plan_history_redo(static_cast<int>(ActionManager::I.m_redos.size()));
|
||||
if (plan && plan.value().invokes_redo)
|
||||
ActionManager::redo();
|
||||
};
|
||||
}
|
||||
if (auto* button = layout[main_id]->find<NodeButtonCustom>("btn-clean-memory"))
|
||||
{
|
||||
button->on_click = [this](Node*) {
|
||||
ActionManager::clear();
|
||||
const auto plan = pp::app::plan_history_clear(
|
||||
static_cast<int>(ActionManager::I.m_actions.size()),
|
||||
static_cast<int>(ActionManager::I.m_redos.size()),
|
||||
static_cast<int>(ActionManager::I.m_memory));
|
||||
if (plan && plan.value().clears_history)
|
||||
ActionManager::clear();
|
||||
};
|
||||
}
|
||||
if (auto* button = layout[main_id]->find<NodeButton>("btn-clear"))
|
||||
|
||||
Reference in New Issue
Block a user