Centralize legacy history bridge

This commit is contained in:
2026-06-03 20:45:33 +02:00
parent 6945ce7e23
commit d1bd4e9b46
9 changed files with 104 additions and 53 deletions

View File

@@ -7,8 +7,8 @@
#include "app_core/canvas_hotkey.h"
#include "app_core/canvas_tool_ui.h"
#include "app_core/history_ui.h"
#include "app.h"
#include "legacy_history_services.h"
#include "log.h"
#include "node_canvas.h"
#include "node_image_texture.h"
@@ -103,24 +103,6 @@ public:
}
};
class LegacyNodeCanvasHistoryServices final : public pp::app::HistoryUiServices {
public:
void invoke_undo() override
{
ActionManager::undo();
}
void invoke_redo() override
{
ActionManager::redo();
}
void clear_history() override
{
ActionManager::clear();
}
};
class LegacyNodeCanvasHotkeyServices final : public pp::app::CanvasHotkeyServices {
public:
pp::foundation::Status execute_tool(const pp::app::CanvasToolPlan& plan) override
@@ -131,8 +113,7 @@ public:
pp::foundation::Status execute_history(const pp::app::HistoryUiPlan& plan) override
{
LegacyNodeCanvasHistoryServices services;
return pp::app::execute_history_ui_plan(plan, services);
return pp::panopainter::execute_legacy_history_plan(plan);
}
void save_document(pp::app::DocumentSaveIntent intent) override
@@ -191,8 +172,9 @@ pp::app::CanvasHotkeyState canvas_hotkey_state(bool mouse_focused, int touch_fin
state.ctrl_down = App::I && App::I->keys[(int)kKey::KeyCtrl];
state.shift_down = App::I && App::I->keys[(int)kKey::KeyShift];
state.mouse_focused = mouse_focused;
state.undo_count = static_cast<int>(ActionManager::I.m_actions.size());
state.redo_count = static_cast<int>(ActionManager::I.m_redos.size());
const auto history = pp::panopainter::legacy_history_snapshot();
state.undo_count = history.undo_count;
state.redo_count = history.redo_count;
state.touch_finger_count = touch_finger_count;
return state;
}