Centralize retained popup panel closing
This commit is contained in:
@@ -34,6 +34,19 @@ void close_legacy_popup_overlay(Node& node) noexcept
|
||||
node.destroy();
|
||||
}
|
||||
|
||||
void close_legacy_popup_panel(
|
||||
Node& node,
|
||||
const std::function<void(Node*)>& 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>& node) noexcept
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "foundation/result.h"
|
||||
#include "node.h"
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
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<void(Node*)>& on_close);
|
||||
|
||||
[[nodiscard]] pp::foundation::Status attach_legacy_overlay_node(
|
||||
App& app,
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user