From a63246f716c03e6fcd1c4b29bc4f2e3176fdf883 Mon Sep 17 00:00:00 2001 From: omigamedev Date: Fri, 12 Jun 2026 15:19:31 +0200 Subject: [PATCH] Centralize retained popup panel closing --- docs/modernization/debt.md | 7 ++++++- docs/modernization/roadmap.md | 2 ++ src/legacy_ui_overlay_services.cpp | 13 +++++++++++++ src/legacy_ui_overlay_services.h | 4 ++++ src/node_panel_brush.cpp | 10 ++-------- src/node_panel_color.cpp | 6 ++---- src/node_panel_grid.cpp | 6 ++---- src/node_panel_layer.cpp | 6 ++---- src/node_panel_stroke.cpp | 5 +---- 9 files changed, 34 insertions(+), 25 deletions(-) diff --git a/docs/modernization/debt.md b/docs/modernization/debt.md index 0098943..21a3cd6 100644 --- a/docs/modernization/debt.md +++ b/docs/modernization/debt.md @@ -508,6 +508,11 @@ agent or engineer to remove them without reconstructing context from chat. `src/legacy_ui_overlay_services.*` instead of per-panel lambdas. Other raw popup callbacks, retained close policy, and broader `Node` handle adoption remain open. +- 2026-06-12: DEBT-0063 was narrowed again. Brush, brush-preset, color, layer, + grid, and stroke popup-panel outside-click close handling now routes through + `src/legacy_ui_overlay_services.*` for release, root removal, and callback + dispatch instead of repeating that sequence in each panel class. Broader + checked-handle and scoped-callback adoption remains open. - 2026-06-05: DEBT-0011 was narrowed. The Windows app package smoke target now passes the configure-time CMake executable into `package-smoke.ps1`, so VS 2026 generator validation does not depend on an older `cmake` on PATH, and @@ -774,7 +779,7 @@ agent or engineer to remove them without reconstructing context from chat. | DEBT-0060 | Open | Modernization | Retained Android package CMake generates a patched `nanort.h` overlay in the build tree for `native-lib` instead of modifying the `libs/nanort` submodule | Current SDK Manager NDK/Clang rejects `TriangleSAHPred::operator=` assigning to a `const size_t` member, but the retained grid/lightmap path still includes `nanort` before that dependency is replaced or updated | `powershell -ExecutionPolicy Bypass -File scripts\automation\android-legacy-package-build.ps1 -Packages standard`; Quest/Focus retained package configure checks; Windows app build | Update/replace `nanort`, move grid/lightmap baking behind a component that owns its dependency, or retire the retained Android package CMake path so no generated vendor overlay is required | | DEBT-0061 | Open | Modernization | Desktop XR runtime selection now lives in tested `pp_platform_api` policy and prefers OpenXR, but `WindowsPlatformServices` still reports OpenXR unavailable and reaches the retained OpenVR SDK bridge as a legacy fallback; Windows runtime deployment copies `openvr_api.dll` beside `PanoPainter.exe` until that fallback is removed | Preserve current desktop VR behavior while replacing OpenVR with OpenXR behind the platform/renderer boundary | `pp_platform_api_tests`; `ctest --preset desktop-fast --build-config Debug -R pp_platform_api_tests --output-on-failure`; `cmake --build --preset windows-msvc-default --config Debug --target PanoPainter` | Add an OpenXR SDK/package target, implement desktop OpenXR startup/shutdown/pose/controller submission behind `pp_platform_vr` or `PlatformServices`, validate parity with mocked/runtime smoke coverage, and remove `libs/openvr` plus the OpenVR link/include paths from root CMake | | DEBT-0062 | Open | Modernization | VS 2026 builds generate a patched fmt `format.h` overlay in the build tree for `pp_legacy_vendor`, disabling the old `_SECURE_SCL` checked-array iterator branch while leaving the fmt submodule clean | VS 2026's STL no longer exposes the legacy checked-array iterator used by this old fmt release, but replacing fmt is part of the dependency migration rather than this platform unblock | `cmake --build --preset windows-msvc-default --config Debug --target PanoPainter`; `cmake --build --preset windows-msvc-default --config Debug --target pp_platform_api_tests`; `ctest --preset desktop-fast --build-config Debug -R pp_platform_api_tests --output-on-failure` | Move fmt to a supported vcpkg/package version or update the vendored fmt release, then remove the generated fmt overlay from `pp_legacy_vendor` | -| DEBT-0063 | Open | Modernization | The retained UI tree still exposes `Node* m_parent`, public `std::vector> m_children`, raw `find()` lookup results, `add_child()` allocation through `new`, callbacks/observers that take or capture raw `Node*`, and manual `destroy()`/`m_destroyed` semantics. `pp_ui_core` now owns a tested `NodeLifetimeTree` target model with checked node handles, scoped callback connections, subtree destruction, pointer/keyboard capture release, whole-tree clear for layout reload, and mutation-safe dispatch, plus a tested `UiOverlayLifetime` popup/dialog stack model. Retained app-dialog root insertion, app-menu popup template cloning/root attachment, quick/stroke/brush panel popup root attachment, combo-box popup insertion, Open/Browse delete-confirmation dialog insertion, popup tick decoration insertion, top-toolbar panel popup insertion, repeated retained popup activation flag setup, repeated retained popup close/release execution, and popup tick-decoration close callback wiring are now centralized in `src/legacy_ui_overlay_services.*`, but retained `Node`/`NodePopupMenu`/`NodeDialog*` still have not adopted checked handles or scoped callback ownership | Preserve current UI behavior while making panel/dialog extraction safe instead of spreading lifetime hazards into the new architecture | `pp_ui_core_layout_xml_tests`; `pp_ui_core_node_lifetime_tests`; `pp_ui_core_overlay_lifetime_tests`; future `pp_panopainter_ui_dialog_lifetime_tests`; `ctest --preset desktop-fast --build-config Debug`; `cmake --build --preset windows-msvc-default --config Debug --target PanoPainter` | Retained `Node` and `pp_panopainter_ui` adopt checked node handles or equivalent non-owning references, scoped callback connection/disconnect semantics, mutation-safe event dispatch, parent/child invariants hidden behind APIs, and destroy-during-callback/capture-release/popup-close/layout-reload tests; retained `Node*` APIs are removed or isolated behind compatibility adapters | +| DEBT-0063 | Open | Modernization | The retained UI tree still exposes `Node* m_parent`, public `std::vector> m_children`, raw `find()` lookup results, `add_child()` allocation through `new`, callbacks/observers that take or capture raw `Node*`, and manual `destroy()`/`m_destroyed` semantics. `pp_ui_core` now owns a tested `NodeLifetimeTree` target model with checked node handles, scoped callback connections, subtree destruction, pointer/keyboard capture release, whole-tree clear for layout reload, and mutation-safe dispatch, plus a tested `UiOverlayLifetime` popup/dialog stack model. Retained app-dialog root insertion, app-menu popup template cloning/root attachment, quick/stroke/brush panel popup root attachment, combo-box popup insertion, Open/Browse delete-confirmation dialog insertion, popup tick decoration insertion, top-toolbar panel popup insertion, repeated retained popup activation flag setup, repeated retained popup close/release execution, popup tick-decoration close callback wiring, and popup-panel outside-click release/remove/callback dispatch are now centralized in `src/legacy_ui_overlay_services.*`, but retained `Node`/`NodePopupMenu`/`NodeDialog*` still have not adopted checked handles or scoped callback ownership | Preserve current UI behavior while making panel/dialog extraction safe instead of spreading lifetime hazards into the new architecture | `pp_ui_core_layout_xml_tests`; `pp_ui_core_node_lifetime_tests`; `pp_ui_core_overlay_lifetime_tests`; future `pp_panopainter_ui_dialog_lifetime_tests`; `ctest --preset desktop-fast --build-config Debug`; `cmake --build --preset windows-msvc-default --config Debug --target PanoPainter` | Retained `Node` and `pp_panopainter_ui` adopt checked node handles or equivalent non-owning references, scoped callback connection/disconnect semantics, mutation-safe event dispatch, parent/child invariants hidden behind APIs, and destroy-during-callback/capture-release/popup-close/layout-reload tests; retained `Node*` APIs are removed or isolated behind compatibility adapters | | DEBT-0057 | Open | Modernization | Default canvas allocation size now dispatches through `PlatformServices::default_canvas_resolution`, removing the `CANVAS_RES` platform macro from `src/canvas.h`; WebGL's retained 512 default now lives in tested `pp_platform_api::platform_policy`, but the Web shell still reaches it through the legacy platform fallback until injected Web services own the policy | Preserve WebGL memory behavior while moving canvas creation policy out of shared canvas headers and into the platform boundary | `pp_platform_api_tests`; `ctest --preset desktop-fast --build-config Debug -R pp_platform_api_tests`; Windows app build; WebGL package smoke once root Web build exists | Default canvas resolution is owned by injected `pp_platform_*` services for every supported platform, with no WebGL branch in the legacy fallback | | DEBT-0058 | Open | Modernization | App-level progress/message/input dialog metadata, including message-dialog OK/cancel captions, now consumes pure `pp_app_core` through `App::show_progress`, `App::message_box`, `App::input_box`, `pano_cli plan-app-dialog`, and `pp_app_core_app_dialog_tests`; live execution is centralized in `src/legacy_app_dialog_services.*`, and retained root insertion now routes through `src/legacy_ui_overlay_services.*`, but the bridge still creates retained `NodeProgressBar`, `NodeMessageBox`, and `NodeInputBox` instances with raw callback/lifetime ownership | Preserve current app-shell dialog behavior while moving shared dialog policy toward UI/app services | `pp_app_core_app_dialog_tests`; `pano_cli plan-app-dialog --kind progress --total -4`; `pano_cli plan-app-dialog --kind message --cancel`; `pano_cli plan-app-dialog --kind input --ok-caption Save`; `ctest --preset desktop-fast --build-config Debug`; Windows app build | Progress/message/input dialog creation, callback wiring, layout insertion, lifetime ownership, and headless automation are owned by injected app/UI services with `App` methods acting only as adapters | | DEBT-0059 | Open | Modernization | iOS root CMake headless builds assign generated bundle identifiers and disable code signing for executable test/tool targets | The current Apple gate is compile validation for shared component targets; signed iOS app/package validation is not migrated to root CMake yet | `powershell -ExecutionPolicy Bypass -File scripts\automation\apple-remote-build.ps1 -Presets macos,ios-simulator,ios-device`; `sh scripts/automation/platform-build.sh "ios-device"` on `panopainter-mac` | Root CMake owns the signed Apple app/package targets, package-smoke validates Apple bundles where signing material is available, and headless iOS test/tool targets are either excluded from signed package builds or use explicit test-runner signing policy | diff --git a/docs/modernization/roadmap.md b/docs/modernization/roadmap.md index 843a30c..a7b5dfc 100644 --- a/docs/modernization/roadmap.md +++ b/docs/modernization/roadmap.md @@ -493,6 +493,8 @@ popup mouse-ignore/flood/capture-child activation for those popup families. Repeated menu, submenu, combo-box, and brush-preset popup close/release execution now uses the same retained helper, and popup tick-decoration close callbacks are bound through the overlay service instead of per-panel lambdas. +Brush, brush-preset, color, layer, grid, and stroke popup-panel outside-click +close handling now shares the same retained release/remove/callback helper. Raw popup callback captures and full close/capture ownership remain part of `DEBT-0063`. `pano_cli inspect-image` exposes PNG IHDR metadata as JSON, diff --git a/src/legacy_ui_overlay_services.cpp b/src/legacy_ui_overlay_services.cpp index a0424d2..3ed1b2b 100644 --- a/src/legacy_ui_overlay_services.cpp +++ b/src/legacy_ui_overlay_services.cpp @@ -34,6 +34,19 @@ void close_legacy_popup_overlay(Node& node) noexcept node.destroy(); } +void close_legacy_popup_panel( + Node& node, + const std::function& on_close) +{ + node.mouse_release(); + if (node.m_parent) { + node.m_parent->remove_child(&node); + } + if (on_close) { + on_close(&node); + } +} + pp::foundation::Status attach_legacy_overlay_node( App& app, const std::shared_ptr& node) noexcept diff --git a/src/legacy_ui_overlay_services.h b/src/legacy_ui_overlay_services.h index 618dea3..fb2a287 100644 --- a/src/legacy_ui_overlay_services.h +++ b/src/legacy_ui_overlay_services.h @@ -3,6 +3,7 @@ #include "foundation/result.h" #include "node.h" +#include #include class App; @@ -15,6 +16,9 @@ void initialize_legacy_overlay_node(App& app, Node& node); void configure_legacy_popup_overlay(Node& node) noexcept; void activate_legacy_popup_overlay(Node& node) noexcept; void close_legacy_popup_overlay(Node& node) noexcept; +void close_legacy_popup_panel( + Node& node, + const std::function& on_close); [[nodiscard]] pp::foundation::Status attach_legacy_overlay_node( App& app, diff --git a/src/node_panel_brush.cpp b/src/node_panel_brush.cpp index 7664ad6..7a1b666 100644 --- a/src/node_panel_brush.cpp +++ b/src/node_panel_brush.cpp @@ -174,10 +174,7 @@ kEventResult NodePanelBrush::handle_event(Event* e) case kEventType::MouseUpL: if (!m_mouse_inside) { - mouse_release(); - m_parent->remove_child(this); - if (on_popup_close) - on_popup_close(this); + pp::panopainter::close_legacy_popup_panel(*this, on_popup_close); } break; default: @@ -668,10 +665,7 @@ kEventResult NodePanelBrushPreset::handle_event(Event* e) case kEventType::MouseUpL: if (!m_mouse_inside) { - mouse_release(); - m_parent->remove_child(this); - if (on_popup_close) - on_popup_close(this); + pp::panopainter::close_legacy_popup_panel(*this, on_popup_close); } break; default: diff --git a/src/node_panel_color.cpp b/src/node_panel_color.cpp index 2eb1327..c4aadfd 100644 --- a/src/node_panel_color.cpp +++ b/src/node_panel_color.cpp @@ -1,6 +1,7 @@ #include "pch.h" #include "log.h" #include "node_panel_color.h" +#include "legacy_ui_overlay_services.h" #include "canvas.h" Node* NodePanelColor::clone_instantiate() const @@ -66,10 +67,7 @@ kEventResult NodePanelColor::handle_event(Event* e) case kEventType::MouseUpL: if (!m_mouse_inside) { - mouse_release(); - m_parent->remove_child(this); - if (on_popup_close) - on_popup_close(this); + pp::panopainter::close_legacy_popup_panel(*this, on_popup_close); } break; default: diff --git a/src/node_panel_grid.cpp b/src/node_panel_grid.cpp index 68be916..32906ee 100644 --- a/src/node_panel_grid.cpp +++ b/src/node_panel_grid.cpp @@ -1,6 +1,7 @@ #include "pch.h" #include "app_core/grid_ui.h" #include "legacy_grid_ui_services.h" +#include "legacy_ui_overlay_services.h" #include "log.h" #include "node_panel_grid.h" #include "canvas.h" @@ -365,10 +366,7 @@ kEventResult NodePanelGrid::handle_event(Event* e) case kEventType::MouseUpL: if (!m_mouse_inside) { - mouse_release(); - m_parent->remove_child(this); - if (on_popup_close) - on_popup_close(this); + pp::panopainter::close_legacy_popup_panel(*this, on_popup_close); } break; default: diff --git a/src/node_panel_layer.cpp b/src/node_panel_layer.cpp index 70236ad..91e8eb4 100644 --- a/src/node_panel_layer.cpp +++ b/src/node_panel_layer.cpp @@ -1,5 +1,6 @@ #include "pch.h" #include "app_core/document_layer.h" +#include "legacy_ui_overlay_services.h" #include "log.h" #include "node_panel_layer.h" #include "canvas.h" @@ -410,10 +411,7 @@ kEventResult NodePanelLayer::handle_event(Event* e) case kEventType::MouseUpL: if (!m_mouse_inside) { - mouse_release(); - m_parent->remove_child(this); - if (on_popup_close) - on_popup_close(this); + pp::panopainter::close_legacy_popup_panel(*this, on_popup_close); } break; default: diff --git a/src/node_panel_stroke.cpp b/src/node_panel_stroke.cpp index 7217744..23501ac 100644 --- a/src/node_panel_stroke.cpp +++ b/src/node_panel_stroke.cpp @@ -715,10 +715,7 @@ kEventResult NodePanelStroke::handle_event(Event* e) case kEventType::MouseUpL: if (!m_mouse_inside) { - mouse_release(); - m_parent->remove_child(this); - if (on_popup_close) - on_popup_close(this); + pp::panopainter::close_legacy_popup_panel(*this, on_popup_close); } break; default: