Move app open routing into document helper

This commit is contained in:
2026-06-16 23:37:55 +02:00
parent 6b337b2d87
commit 42bae9db16
5 changed files with 67 additions and 19 deletions

View File

@@ -84,11 +84,11 @@ Current hotspot files:
- `src/canvas_modes.cpp`: 176 lines - `src/canvas_modes.cpp`: 176 lines
- `src/node.cpp`: 222 lines - `src/node.cpp`: 222 lines
- `src/main.cpp`: 130 lines - `src/main.cpp`: 130 lines
- `src/node_panel_brush.cpp`: 189 lines - `src/node_panel_brush.cpp`: 186 lines
- `src/node_stroke_preview.cpp`: 192 lines - `src/node_stroke_preview.cpp`: 192 lines
- `src/node_canvas.cpp`: 69 lines - `src/node_canvas.cpp`: 69 lines
- `src/app.cpp`: 113 lines - `src/app.cpp`: 105 lines
- `src/app_dialogs.cpp`: 168 lines - `src/app_dialogs.cpp`: 106 lines
Latest slice: Latest slice:
@@ -96,10 +96,21 @@ Latest slice:
`handle_legacy_node_canvas_event(...)` in `handle_legacy_node_canvas_event(...)` in
`src/legacy_canvas_tool_services.*`, leaving `src/node_canvas.cpp` as a much `src/legacy_canvas_tool_services.*`, leaving `src/node_canvas.cpp` as a much
thinner controller shell. thinner controller shell.
- `App::open_document()` now routes through
`src/legacy_document_open_services.cpp`, which moved the document route
classification and unsaved-project gating out of `src/app.cpp` and into the
retained document-open helper.
- `App::dialog_layer_rename()` now routes through
`open_legacy_document_layer_rename_dialog(...)` in
`src/legacy_document_layer_services.*`, which moved the remaining
overlay-open/wire/close workflow out of `src/app_dialogs.cpp`.
- The remaining low-level `NodeStrokePreview` viewport/query and texture-slot - The remaining low-level `NodeStrokePreview` viewport/query and texture-slot
plumbing now lives in plumbing now lives in
`src/legacy_node_stroke_preview_runtime_services.*` instead of staying `src/legacy_node_stroke_preview_runtime_services.*` instead of staying
inline in `src/node_stroke_preview.cpp`. inline in `src/node_stroke_preview.cpp`.
- `NodePanelBrushPreset` global panel registration now lives in
`src/legacy_brush_preset_list_services.*` instead of staying on the live
node type as a static registry field.
- The remaining generic `Node` geometry/state pocket for `SetSize(...)`, - The remaining generic `Node` geometry/state pocket for `SetSize(...)`,
`SetMinSize(...)`, `SetMaxSize(...)`, and `SetPosition(const glm::vec2)` now `SetMinSize(...)`, `SetMaxSize(...)`, and `SetPosition(const glm::vec2)` now
lives in `src/legacy_ui_node_style.*` instead of staying inline in lives in `src/legacy_ui_node_style.*` instead of staying inline in
@@ -185,8 +196,9 @@ Current architecture mismatches that must be treated as real blockers:
lives in lives in
`src/app_dialogs_export.cpp` and those `App::dialog_*` entrypoints are `src/app_dialogs_export.cpp` and those `App::dialog_*` entrypoints are
thinner too, while new/open/save/browse/resize workflow entrypoints now also thinner too, while new/open/save/browse/resize workflow entrypoints now also
live in `src/app_dialogs_workflow.cpp` and `src/app_dialogs.cpp` is now live in `src/app_dialogs_workflow.cpp`, while the layer-rename dialog open /
mostly a thin dialog dispatch surface. wire / close pocket now lives in `src/legacy_document_layer_services.*`, and
`src/app_dialogs.cpp` is now a thinner dialog dispatch surface.
- `App`, `Canvas`, `Node`, retained workers, and platform entrypoints still use - `App`, `Canvas`, `Node`, retained workers, and platform entrypoints still use
global singleton reach, raw observer pointers, retained static worker global singleton reach, raw observer pointers, retained static worker
ownership in several app families, and ad hoc mutex/condition-variable ownership in several app families, and ad hoc mutex/condition-variable
@@ -355,7 +367,11 @@ Current architecture mismatches that must be treated as real blockers:
`src/legacy_brush_preset_panel_ui.*` `src/legacy_brush_preset_panel_ui.*`
instead of staying inline in `src/node_panel_brush.cpp`, which removes the instead of staying inline in `src/node_panel_brush.cpp`, which removes the
last inline brush-panel popup close handler from the live node. The last inline brush-panel popup close handler from the live node. The
broader preset workflow pocket still remains, while `NodeCanvas::handle_event()` `NodePanelBrushPreset` registration/lifecycle pocket now also routes through
the preset-list helper registry instead of a node-local static vector,
which removes the remaining live preset-panel ownership glue from
`src/node_panel_brush.cpp`. The broader preset workflow pocket still remains,
while `NodeCanvas::handle_event()`
now also routes now also routes
through `execute_node_canvas_handle_event(...)`, which trims another coherent through `execute_node_canvas_handle_event(...)`, which trims another coherent
input-routing block from `src/node_canvas.cpp` even though the file is still input-routing block from `src/node_canvas.cpp` even though the file is still

View File

@@ -341,6 +341,15 @@ Current slice:
`handle_legacy_node_canvas_event(...)` in `handle_legacy_node_canvas_event(...)` in
`src/legacy_canvas_tool_services.*`, which moves the live input/controller `src/legacy_canvas_tool_services.*`, which moves the live input/controller
pocket out of `src/node_canvas.cpp` and keeps the node on a thinner shell. pocket out of `src/node_canvas.cpp` and keeps the node on a thinner shell.
- `App::dialog_layer_rename()` now routes through
`open_legacy_document_layer_rename_dialog(...)` in
`src/legacy_document_layer_services.*`, which moves the remaining dialog
overlay-open/wire/close workflow out of `src/app_dialogs.cpp` and leaves
the app dialog shell thinner.
- `App::open_document(...)` now routes through
`execute_legacy_document_open(...)` in `src/legacy_document_open_services.*`,
which moves route classification and unsaved-project gating out of
`src/app.cpp` and into the retained document-open helper.
- `NodeCanvas` restore/clear context, resize handling, camera reset, buffer - `NodeCanvas` restore/clear context, resize handling, camera reset, buffer
creation, cursor visibility/update, tick, and destroy ownership now also creation, cursor visibility/update, tick, and destroy ownership now also
live in `src/legacy_node_canvas_state_services.*` instead of staying inline live in `src/legacy_node_canvas_state_services.*` instead of staying inline
@@ -385,6 +394,10 @@ Current slice:
now also lives in `src/legacy_ui_node_style.*` instead of staying inline in now also lives in `src/legacy_ui_node_style.*` instead of staying inline in
`src/node.cpp`, which trims another coherent base scene-graph shell pocket `src/node.cpp`, which trims another coherent base scene-graph shell pocket
without changing the public surface. without changing the public surface.
- `NodePanelBrushPreset` global panel registration now also lives in
`src/legacy_brush_preset_list_services.*` instead of staying on the live
node type as a static registry field, which trims another retained
controller-state pocket from `src/node_panel_brush.cpp`.
Write scope: Write scope:
- `src/node_stroke_preview.cpp` - `src/node_stroke_preview.cpp`
@@ -533,7 +546,7 @@ Status: In Progress
Why now: Why now:
`src/app_dialogs.cpp` still mixes document workflow decisions, export routing, `src/app_dialogs.cpp` still mixes document workflow decisions, export routing,
dialog construction, and overlay ownership in one 168-line shell. dialog construction, and overlay ownership in one 106-line shell.
Current slice: Current slice:
- Informational overlay opener paths for user manual, changelog, about, - Informational overlay opener paths for user manual, changelog, about,
@@ -546,8 +559,15 @@ Current slice:
entrypoints are now thin call-throughs, but new/open/save/browse/resize and entrypoints are now thin call-throughs, but new/open/save/browse/resize and
retained dialog execution are still inline in `src/app_dialogs.cpp`. retained dialog execution are still inline in `src/app_dialogs.cpp`.
- New/open/save/browse/resize workflow entrypoints now also live in - New/open/save/browse/resize workflow entrypoints now also live in
`src/app_dialogs_workflow.cpp`, and `src/app_dialogs.cpp` is down to the `src/app_dialogs_workflow.cpp`, and the layer-rename dialog open / wire /
remaining thin entrypoints plus layer-rename retained dialog glue. close pocket now lives in `src/legacy_document_layer_services.*`, leaving
`src/app_dialogs.cpp` down to the remaining thin entrypoints plus other
retained dialog glue.
- `App::open_document()` now routes document classification and unsaved-
project gating through `src/legacy_document_open_services.cpp` instead of
keeping that shell pocket inline in `src/app.cpp`, which trims the live app
entry file a little further while preserving the retained open-action
behavior.
Write scope: Write scope:
- `src/app_dialogs.cpp` - `src/app_dialogs.cpp`

View File

@@ -35,16 +35,7 @@ void App::create()
void App::open_document(std::string path) void App::open_document(std::string path)
{ {
const auto route = pp::app::classify_document_open_path(path); pp::panopainter::execute_legacy_document_open(*this, std::move(path));
if (!route)
return;
const bool has_unsaved_project =
route.value().kind == pp::app::DocumentOpenKind::open_project && Canvas::I->m_unsaved;
const auto open_plan = pp::app::plan_document_open(route.value().kind, has_unsaved_project);
const auto status = pp::panopainter::execute_legacy_document_open_plan(*this, open_plan, route.value());
if (!status.ok())
LOG("Document open action failed: %s", status.message);
} }
bool App::request_close() bool App::request_close()

View File

@@ -163,6 +163,22 @@ pp::foundation::Status execute_legacy_document_open_plan(
return pp::app::execute_document_open_plan(action, route, services); return pp::app::execute_document_open_plan(action, route, services);
} }
pp::foundation::Status execute_legacy_document_open(App& app, std::string path)
{
const auto route = pp::app::classify_document_open_path(path);
if (!route)
return route.status();
const bool has_unsaved_project =
route.value().kind == pp::app::DocumentOpenKind::open_project && Canvas::I->m_unsaved;
const auto open_plan = pp::app::plan_document_open(route.value().kind, has_unsaved_project);
const auto status = execute_legacy_document_open_plan(app, open_plan, route.value());
if (!status.ok())
LOG("Document open action failed: %s", status.message);
return status;
}
void execute_legacy_downloaded_project_open( void execute_legacy_downloaded_project_open(
App& app, App& app,
std::string_view path, std::string_view path,

View File

@@ -3,12 +3,17 @@
#include "app_core/document_session.h" #include "app_core/document_session.h"
#include "foundation/result.h" #include "foundation/result.h"
#include <string>
#include <string_view> #include <string_view>
class App; class App;
namespace pp::panopainter { namespace pp::panopainter {
[[nodiscard]] pp::foundation::Status execute_legacy_document_open(
App& app,
std::string path);
[[nodiscard]] pp::foundation::Status execute_legacy_document_open_plan( [[nodiscard]] pp::foundation::Status execute_legacy_document_open_plan(
App& app, App& app,
pp::app::DocumentOpenPlanAction action, pp::app::DocumentOpenPlanAction action,