Centralize retained popup close decorations
This commit is contained in:
@@ -490,9 +490,7 @@ void App::init_sidebar()
|
||||
auto scroll = stroke->find<NodeScroll>("scroller");
|
||||
//scroll->SetHeight(glm::max(100.f, screen.y - pos.y - 200.f));
|
||||
|
||||
stroke->on_popup_close = [this, tick](Node*) {
|
||||
tick->destroy();
|
||||
};
|
||||
pp::panopainter::bind_legacy_popup_close_destroys_overlay(*stroke, tick);
|
||||
};
|
||||
}
|
||||
//if (auto* button = layout[main_id]->find<NodeButtonCustom>("btn-brush"))
|
||||
@@ -531,9 +529,7 @@ void App::init_sidebar()
|
||||
color->SetPositioning(YGPositionTypeAbsolute);
|
||||
pp::panopainter::activate_legacy_popup_overlay(*color);
|
||||
|
||||
color->on_popup_close = [this, tick](Node*) {
|
||||
tick->destroy();
|
||||
};
|
||||
pp::panopainter::bind_legacy_popup_close_destroys_overlay(*color, tick);
|
||||
};
|
||||
}
|
||||
if (auto* button = layout[main_id]->find<NodeButtonCustom>("btn-layer"))
|
||||
@@ -566,9 +562,7 @@ void App::init_sidebar()
|
||||
auto scroll = layers->find<NodeScroll>("layers-container");
|
||||
scroll->SetMaxHeight(glm::max(100.f, screen.y - pos.y - 200.f));
|
||||
|
||||
layers->on_popup_close = [this, tick](Node*) {
|
||||
tick->destroy();
|
||||
};
|
||||
pp::panopainter::bind_legacy_popup_close_destroys_overlay(*layers, tick);
|
||||
};
|
||||
}
|
||||
if (auto* button = layout[main_id]->find<NodeButtonCustom>("btn-grids-panel"))
|
||||
@@ -601,9 +595,7 @@ void App::init_sidebar()
|
||||
auto scroll = grid->find<NodeScroll>("scroller");
|
||||
scroll->SetMaxHeight(glm::max(100.f, screen.y - pos.y - 250.f));
|
||||
|
||||
grid->on_popup_close = [this, tick](Node*) {
|
||||
tick->destroy();
|
||||
};
|
||||
pp::panopainter::bind_legacy_popup_close_destroys_overlay(*grid, tick);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,9 +116,7 @@ private:
|
||||
|
||||
activate_legacy_popup_overlay(*popup);
|
||||
|
||||
popup->on_popup_close = [tick](Node*) {
|
||||
tick->destroy();
|
||||
};
|
||||
pp::panopainter::bind_legacy_popup_close_destroys_overlay(*popup, tick);
|
||||
|
||||
auto* panel = &panel_;
|
||||
popup->on_brush_changed = [panel, button](Node*, std::shared_ptr<Brush>& b) {
|
||||
@@ -174,9 +172,7 @@ private:
|
||||
|
||||
auto c = static_cast<NodeBorder*>(target->m_children[0].get());
|
||||
panel_.m_picker->set_color(c->m_color);
|
||||
panel_.m_picker->on_popup_close = [tick](Node*) {
|
||||
tick->destroy();
|
||||
};
|
||||
pp::panopainter::bind_legacy_popup_close_destroys_overlay(*panel_.m_picker, tick);
|
||||
|
||||
auto* panel = &panel_;
|
||||
panel_.m_picker->on_color_change = [panel, c](Node*, glm::vec3 rgb) {
|
||||
|
||||
@@ -58,4 +58,16 @@ std::shared_ptr<T> add_legacy_overlay_node(App& app)
|
||||
return node;
|
||||
}
|
||||
|
||||
template <class PopupT>
|
||||
void bind_legacy_popup_close_destroys_overlay(
|
||||
PopupT& popup,
|
||||
const std::shared_ptr<Node>& overlay) noexcept
|
||||
{
|
||||
popup.on_popup_close = [overlay](Node*) {
|
||||
if (overlay) {
|
||||
overlay->destroy();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace pp::panopainter
|
||||
|
||||
@@ -333,9 +333,7 @@ void NodePanelStroke::init_controls()
|
||||
pp::panopainter::activate_legacy_popup_overlay(*App::I->presets);
|
||||
root()->update();
|
||||
|
||||
App::I->presets->on_popup_close = [this, tick](Node*) {
|
||||
tick->destroy();
|
||||
};
|
||||
pp::panopainter::bind_legacy_popup_close_destroys_overlay(*App::I->presets, tick);
|
||||
|
||||
App::I->presets->on_brush_changed = [this](Node* target, std::shared_ptr<Brush>& b) {
|
||||
// don't change some params
|
||||
@@ -378,9 +376,7 @@ void NodePanelStroke::init_controls()
|
||||
pp::panopainter::activate_legacy_popup_overlay(*m_brush_popup);
|
||||
root()->update();
|
||||
|
||||
m_brush_popup->on_popup_close = [this, tick](Node*) {
|
||||
tick->destroy();
|
||||
};
|
||||
pp::panopainter::bind_legacy_popup_close_destroys_overlay(*m_brush_popup, tick);
|
||||
|
||||
m_brush_popup->on_brush_changed = [this](Node*, int index) {
|
||||
if (on_brush_changed)
|
||||
@@ -415,9 +411,7 @@ void NodePanelStroke::init_controls()
|
||||
pp::panopainter::activate_legacy_popup_overlay(*m_brush_popup);
|
||||
root()->update();
|
||||
|
||||
m_brush_popup->on_popup_close = [this, tick](Node*) {
|
||||
tick->destroy();
|
||||
};
|
||||
pp::panopainter::bind_legacy_popup_close_destroys_overlay(*m_brush_popup, tick);
|
||||
|
||||
m_brush_popup->on_brush_changed = [this](Node*, int index) {
|
||||
m_dual_enabled->set_value(true, true);
|
||||
@@ -452,9 +446,7 @@ void NodePanelStroke::init_controls()
|
||||
pp::panopainter::activate_legacy_popup_overlay(*m_pattern_popup);
|
||||
root()->update();
|
||||
|
||||
m_pattern_popup->on_popup_close = [this, tick](Node*) {
|
||||
tick->destroy();
|
||||
};
|
||||
pp::panopainter::bind_legacy_popup_close_destroys_overlay(*m_pattern_popup, tick);
|
||||
|
||||
m_pattern_popup->on_brush_changed = [this](Node*, int index) {
|
||||
m_pattern_enabled->set_value(true, true);
|
||||
|
||||
Reference in New Issue
Block a user