diff --git a/docs/modernization/debt.md b/docs/modernization/debt.md index 83dc545..2f41b4b 100644 --- a/docs/modernization/debt.md +++ b/docs/modernization/debt.md @@ -44,7 +44,7 @@ agent or engineer to remove them without reconstructing context from chat. | DEBT-0024 | Open | Modernization | Grid/heightmap/lightmap UI planning now consumes pure `pp_app_core` through `NodePanelGrid` and `pano_cli plan-grid-operation`, but live execution still performs legacy image loading, OpenGL texture updates, nanort lightmap baking, progress UI, and `Canvas::draw_objects` commit directly | Preserve grid/lightmap behavior while moving renderable grid commands toward app/renderer/document boundaries | `pp_app_core_grid_ui_tests`; `pano_cli plan-grid-operation --kind render --float32 --texture-resolution 1024 --samples 32`; `ctest --preset desktop-fast --build-config Debug` | Grid heightmap/lightmap execution is owned by app/renderer/document services with `NodePanelGrid` acting only as UI adapter | | DEBT-0025 | Open | Modernization | Quick brush/color slot and mini-state planning now consumes pure `pp_app_core` through `NodePanelQuick` and `pano_cli plan-quick-operation`, but live execution still mutates legacy quick UI widgets, `Brush` previews, color picker popup state, and preset popup state directly | Preserve quick-panel behavior while quick brush/color commands move toward a brush/app command boundary with safer automation coverage | `pp_app_core_quick_ui_tests`; `pano_cli plan-quick-operation --kind brush --current-index 0 --slot-index 2`; `pano_cli plan-quick-operation --kind restore --brush-index 2 --color-index 1 --fire-event`; `ctest --preset desktop-fast --build-config Debug` | Quick-panel selection, popup, restore, reset, brush preview, and color execution are owned by app/brush/UI services with `NodePanelQuick` acting only as UI adapter | | DEBT-0026 | Open | Modernization | Toolbar and canvas history command planning now consumes pure `pp_app_core` through `App::init_toolbar_main`, `NodeCanvas`, and `pano_cli plan-history-operation`, but live execution still mutates legacy `ActionManager` stacks and `Canvas::I` unsaved state directly | Preserve undo/redo/clear behavior while moving action history toward document/app command services | `pp_app_core_history_ui_tests`; `pano_cli plan-history-operation --kind undo --undo-count 2`; `pano_cli plan-history-operation --kind clear --undo-count 2 --redo-count 1 --memory-bytes 4096`; `ctest --preset desktop-fast --build-config Debug` | Undo/redo/clear execution is owned by document/app history services with toolbar and canvas input acting only as adapters | -| DEBT-0027 | Open | Modernization | Canvas draw-tool toolbar command and active-state planning now consume pure `pp_app_core` through `App::init_toolbar_draw`, `App::update`, `pano_cli plan-canvas-tool`, and `pano_cli plan-canvas-tool-state`, but live execution/state storage still mutates or reads legacy `Canvas` mode state, pen picking state, touch-lock state, and transform copy/cut action objects directly | Preserve current toolbar behavior while canvas input/tools move toward an app/document command boundary | `pp_app_core_canvas_tool_ui_tests`; `pano_cli plan-canvas-tool --kind copy`; `pano_cli plan-canvas-tool-state --mode draw --picking --touch-lock`; `ctest --preset desktop-fast --build-config Debug` | Canvas tool selection, toolbar state refresh, picking, touch lock, and transform action execution are owned by app/document/canvas services with toolbar callbacks acting only as adapters | +| DEBT-0027 | Open | Modernization | Canvas draw-tool toolbar command, canvas input mode switching, and active-state planning now consume pure `pp_app_core` through `App::init_toolbar_draw`, `App::update`, `NodeCanvas`, `pano_cli plan-canvas-tool`, and `pano_cli plan-canvas-tool-state`, but live execution/state storage still mutates or reads legacy `Canvas` mode state, pen picking state, touch-lock state, and transform copy/cut action objects directly | Preserve current toolbar, stylus eraser, and keyboard draw/erase behavior while canvas input/tools move toward an app/document command boundary | `pp_app_core_canvas_tool_ui_tests`; `pano_cli plan-canvas-tool --kind copy`; `pano_cli plan-canvas-tool-state --mode draw --picking --touch-lock`; `ctest --preset desktop-fast --build-config Debug` | Canvas tool selection, toolbar state refresh, picking, touch lock, stylus eraser/key mode switching, and transform action execution are owned by app/document/canvas services with toolbar/canvas callbacks acting only as adapters | ## Closed Debt diff --git a/docs/modernization/roadmap.md b/docs/modernization/roadmap.md index ad93be6..8c5150e 100644 --- a/docs/modernization/roadmap.md +++ b/docs/modernization/roadmap.md @@ -504,7 +504,9 @@ camera, grid, copy, cut, fill, mask, flood-fill, pick, and touch-lock toolbar commands before legacy `Canvas` mode, pen picking, touch-lock, and transform state mutation continue. `pano_cli plan-canvas-tool-state` exposes the matching toolbar active-state refresh used by `App::update` before legacy `Canvas` mode -state remains the source of truth. +state remains the source of truth. `NodeCanvas` stylus eraser and `E` key +draw/erase mode switching also consume the same app-core command planner before +legacy canvas mode execution continues. `pano_cli plan-grid-operation` exposes app-core planning for grid heightmap pick/load/reload/clear, lightmap render capability/limit checks, and heightmap commit used by the live grid panel before legacy image loading, OpenGL texture diff --git a/src/node_canvas.cpp b/src/node_canvas.cpp index 000935b..886f9e2 100644 --- a/src/node_canvas.cpp +++ b/src/node_canvas.cpp @@ -2,6 +2,7 @@ #include +#include "app_core/canvas_tool_ui.h" #include "app_core/history_ui.h" #include "app.h" #include "log.h" @@ -36,6 +37,24 @@ void run_history_redo_if_available() ActionManager::redo(); } +void run_canvas_tool_mode(pp::app::CanvasToolMode mode) +{ + const auto plan = pp::app::plan_canvas_tool_select(mode); + if (!plan.updates_canvas_mode) + return; + + switch (plan.mode) { + case pp::app::CanvasToolMode::draw: + Canvas::set_mode(kCanvasMode::Draw); + return; + case pp::app::CanvasToolMode::erase: + Canvas::set_mode(kCanvasMode::Erase); + return; + default: + return; + } +} + } Node* NodeCanvas::clone_instantiate() const @@ -588,9 +607,9 @@ kEventResult NodeCanvas::handle_event(Event* e) case kEventType::MouseMove: if (stylus_eraser != me->m_eraser) { - Canvas::set_mode(me->m_eraser ? - kCanvasMode::Erase : - kCanvasMode::Draw); + run_canvas_tool_mode(me->m_eraser ? + pp::app::CanvasToolMode::erase : + pp::app::CanvasToolMode::draw); stylus_eraser = me->m_eraser; } case kEventType::MouseScroll: @@ -613,7 +632,7 @@ kEventResult NodeCanvas::handle_event(Event* e) break; case kEventType::KeyDown: if (ke->m_key == kKey::KeyE) - Canvas::set_mode(kCanvasMode::Erase); + run_canvas_tool_mode(pp::app::CanvasToolMode::erase); if (ke->m_key == kKey::AndroidBack) run_history_undo_if_available(); if (ke->m_key == kKey::KeyAlt && m_mouse_focus) @@ -624,7 +643,7 @@ kEventResult NodeCanvas::handle_event(Event* e) case kEventType::KeyUp: update_cursor(); if (ke->m_key == kKey::KeyE) - Canvas::set_mode(kCanvasMode::Draw); + run_canvas_tool_mode(pp::app::CanvasToolMode::draw); if (ke->m_key == kKey::KeyTab) App::I->toggle_ui(); if (ke->m_key == kKey::KeyZ && App::I->keys[(int)kKey::KeyCtrl])