Centralize retained popup tick overlays

This commit is contained in:
2026-06-12 14:45:04 +02:00
parent 7be588d763
commit 2e98efa13a
7 changed files with 51 additions and 20 deletions

View File

@@ -473,14 +473,15 @@ void App::init_sidebar()
fp->destroy();
}
}
layout[main_id]->add_child(stroke);
(void)pp::panopainter::attach_legacy_overlay_node(*this, stroke);
stroke->SetSize(350, glm::max(100.f, screen.y - pos.y - 50.f));
stroke->find("title")->SetVisibility(true);
auto tick = layout[main_id]->add_child<NodeImage>();
auto tick = pp::panopainter::make_legacy_overlay_node_for_anchor<NodeImage>(*layout[main_id]);
tick->SetPositioning(YGPositionTypeAbsolute);
tick->SetSize(32, 16);
tick->SetPosition(pos.x - 16, pos.y);
tick->set_image("data/ui/popup-tick-up.png");
(void)pp::panopainter::attach_legacy_overlay_node(*this, tick);
layout[main_id]->update();
stroke->SetPosition(pos.x - stroke->m_size.x / 2.f, pos.y + 16);
@@ -517,14 +518,15 @@ void App::init_sidebar()
button->on_click = [this, button](Node*) {
auto screen = layout[main_id]->m_size;
glm::vec2 pos = button->m_pos + glm::vec2(button->m_size.x * 0.5f, button->m_size.y);
layout[main_id]->add_child(color);
(void)pp::panopainter::attach_legacy_overlay_node(*this, color);
color->find("title")->SetVisibility(true);
color->SetSize(350, 350);
auto tick = layout[main_id]->add_child<NodeImage>();
auto tick = pp::panopainter::make_legacy_overlay_node_for_anchor<NodeImage>(*layout[main_id]);
tick->SetPositioning(YGPositionTypeAbsolute);
tick->SetSize(32, 16);
tick->SetPosition(pos.x - 16, pos.y);
tick->set_image("data/ui/popup-tick-up.png");
(void)pp::panopainter::attach_legacy_overlay_node(*this, tick);
layout[main_id]->update();
color->SetPosition(pos.x - color->m_size.x / 2.f, pos.y + 16);
@@ -553,12 +555,13 @@ void App::init_sidebar()
fp->destroy();
}
}
layout[main_id]->add_child(layers);
auto tick = layout[main_id]->add_child<NodeImage>();
(void)pp::panopainter::attach_legacy_overlay_node(*this, layers);
auto tick = pp::panopainter::make_legacy_overlay_node_for_anchor<NodeImage>(*layout[main_id]);
tick->SetPositioning(YGPositionTypeAbsolute);
tick->SetSize(32, 16);
tick->SetPosition(pos.x - 16, pos.y);
tick->set_image("data/ui/popup-tick-up.png");
(void)pp::panopainter::attach_legacy_overlay_node(*this, tick);
layout[main_id]->update();
layers->SetPosition(pos.x - layers->m_size.x / 2.f, pos.y + 16);
@@ -589,12 +592,13 @@ void App::init_sidebar()
fp->destroy();
}
}
layout[main_id]->add_child(grid);
auto tick = layout[main_id]->add_child<NodeImage>();
(void)pp::panopainter::attach_legacy_overlay_node(*this, grid);
auto tick = pp::panopainter::make_legacy_overlay_node_for_anchor<NodeImage>(*layout[main_id]);
tick->SetPositioning(YGPositionTypeAbsolute);
tick->SetSize(32, 16);
tick->SetPosition(pos.x - 16, pos.y);
tick->set_image("data/ui/popup-tick-up.png");
(void)pp::panopainter::attach_legacy_overlay_node(*this, tick);
layout[main_id]->update();
grid->SetPosition(pos.x - grid->m_size.x / 2.f, pos.y + 16);

View File

@@ -84,12 +84,13 @@ private:
glm::vec2 tick_pos = button->m_pos + glm::vec2(button->m_size.x, 0);
glm::vec2 popup_pos = { tick_pos.x + tick_sz.x, tick_pos.y };
auto tick = panel_.root()->add_child<NodeImage>();
auto tick = make_legacy_overlay_node_for_anchor<NodeImage>(panel_);
tick->SetPositioning(YGPositionTypeAbsolute);
tick->SetPosition(tick_pos.x, tick_pos.y + (button->m_size.y - tick_sz.y) * 0.5f);
tick->SetSize(tick_sz);
tick->set_image("data/ui/popup-tick.png");
tick->m_scale = { 1, 1 };
(void)attach_legacy_overlay_node_to_root(panel_, tick);
float hh = popup->m_container->m_children.size() > 10 ? (screen.y - 90.f) : 400.f;
popup->SetWidth(350);
@@ -145,12 +146,13 @@ private:
glm::vec2 tick_pos = target->m_pos + glm::vec2(target->m_size.x, 0);
glm::vec2 popup_pos = { tick_pos.x + tick_sz.x, tick_pos.y - 140.f };
auto tick = panel_.root()->add_child<NodeImage>();
auto tick = make_legacy_overlay_node_for_anchor<NodeImage>(panel_);
tick->SetPositioning(YGPositionTypeAbsolute);
tick->SetPosition(tick_pos.x, tick_pos.y + (target->m_size.y - tick_sz.y) * 0.5f);
tick->SetSize(tick_sz);
tick->set_image("data/ui/popup-tick.png");
tick->m_scale = { 1, 1 };
(void)attach_legacy_overlay_node_to_root(panel_, tick);
popup->SetPositioning(YGPositionTypeAbsolute);
popup->SetPosition(popup_pos);

View File

@@ -1,11 +1,11 @@
#pragma once
#include "foundation/result.h"
#include "node.h"
#include <memory>
class App;
class Node;
class NodePopupMenu;
namespace pp::panopainter {
@@ -35,6 +35,17 @@ std::shared_ptr<T> make_legacy_overlay_node(App& app)
return node;
}
template <class T>
std::shared_ptr<T> make_legacy_overlay_node_for_anchor(Node& anchor)
{
auto node = std::make_shared<T>();
node->set_manager(anchor.m_manager);
node->init();
node->create();
node->loaded();
return node;
}
template <class T>
std::shared_ptr<T> add_legacy_overlay_node(App& app)
{

View File

@@ -578,7 +578,10 @@ void NodePanelBrushPreset::init()
};
m_btn_menu = find<NodeButtonCustom>("btn-menu");
m_btn_menu->on_click = [this](Node* b) {
auto popup = add_child_file<NodePopupMenu>("data/dialogs/panel-brushes.xml", "tpl-brush-popup");
auto popup = std::dynamic_pointer_cast<NodePopupMenu>(
load_template("data/dialogs/panel-brushes.xml", "tpl-brush-popup"));
if (!popup)
return;
popup->SetPosition(b->m_pos.x + b->m_size.x, b->m_pos.y);
(void)pp::panopainter::attach_legacy_overlay_node_to_root(*this, popup);
root()->update();

View File

@@ -318,11 +318,12 @@ void NodePanelStroke::init_controls()
auto screen = root()->m_size;
glm::vec2 pos = m_preset_button->m_pos + glm::vec2(m_preset_button->m_size.x, 0);
(void)pp::panopainter::attach_legacy_overlay_node_to_root(*this, App::I->presets);
auto tick = root()->add_child<NodeImage>();
auto tick = pp::panopainter::make_legacy_overlay_node_for_anchor<NodeImage>(*this);
tick->SetPositioning(YGPositionTypeAbsolute);
tick->SetSize(16, 32);
tick->SetPosition(pos.x, pos.y + (m_preset_button->m_size.y - 32) * 0.5f);
tick->set_image("data/ui/popup-tick.png");
(void)pp::panopainter::attach_legacy_overlay_node_to_root(*this, tick);
float hh = App::I->presets->m_container->m_children.size() > 10 ? App::I->height / App::I->zoom * .75f : 400.f;
App::I->presets->SetHeight(glm::max(hh, 400.f));
App::I->presets->SetWidth(300);
@@ -369,11 +370,12 @@ void NodePanelStroke::init_controls()
auto screen = root()->m_size;
glm::vec2 pos = m_brush_button->m_pos + glm::vec2(m_brush_button->m_size.x, 0);
(void)pp::panopainter::attach_legacy_overlay_node_to_root(*this, m_brush_popup);
auto tick = root()->add_child<NodeImage>();
auto tick = pp::panopainter::make_legacy_overlay_node_for_anchor<NodeImage>(*this);
tick->SetPositioning(YGPositionTypeAbsolute);
tick->SetSize(16, 32);
tick->SetPosition(pos.x, pos.y + (m_brush_button->m_size.y - 32) * 0.5f);
tick->set_image("data/ui/popup-tick.png");
(void)pp::panopainter::attach_legacy_overlay_node_to_root(*this, tick);
root()->update();
if ((pos.y + m_brush_popup->m_size.y) > screen.y)
pos.y = screen.y - m_brush_popup->m_size.y;
@@ -405,11 +407,12 @@ void NodePanelStroke::init_controls()
auto screen = root()->m_size;
glm::vec2 pos = m_dual_brush_button->m_pos + glm::vec2(m_dual_brush_button->m_size.x, 0);
(void)pp::panopainter::attach_legacy_overlay_node_to_root(*this, m_brush_popup);
auto tick = root()->add_child<NodeImage>();
auto tick = pp::panopainter::make_legacy_overlay_node_for_anchor<NodeImage>(*this);
tick->SetPositioning(YGPositionTypeAbsolute);
tick->SetSize(16, 32);
tick->SetPosition(pos.x, pos.y + (m_dual_brush_button->m_size.y - 32) * 0.5f);
tick->set_image("data/ui/popup-tick.png");
(void)pp::panopainter::attach_legacy_overlay_node_to_root(*this, tick);
root()->update();
if ((pos.y + m_brush_popup->m_size.y) > screen.y)
pos.y = screen.y - m_brush_popup->m_size.y;
@@ -441,11 +444,12 @@ void NodePanelStroke::init_controls()
auto screen = root()->m_size;
glm::vec2 pos = m_pattern_button->m_pos + glm::vec2(m_pattern_button->m_size.x, 0);
(void)pp::panopainter::attach_legacy_overlay_node_to_root(*this, m_pattern_popup);
auto tick = root()->add_child<NodeImage>();
auto tick = pp::panopainter::make_legacy_overlay_node_for_anchor<NodeImage>(*this);
tick->SetPositioning(YGPositionTypeAbsolute);
tick->SetSize(16, 32);
tick->SetPosition(pos.x, pos.y + (m_pattern_button->m_size.y - 32) * 0.5f);
tick->set_image("data/ui/popup-tick.png");
(void)pp::panopainter::attach_legacy_overlay_node_to_root(*this, tick);
root()->update();
if ((pos.y + m_pattern_popup->m_size.y) > screen.y)
pos.y = screen.y - m_pattern_popup->m_size.y;