diff --git a/data/layout.xml b/data/layout.xml
index acb00c7..407e0bd 100644
--- a/data/layout.xml
+++ b/data/layout.xml
@@ -79,6 +79,9 @@
+
@@ -94,6 +97,19 @@
+
diff --git a/src/app_layout.cpp b/src/app_layout.cpp
index 7e0152f..0fc5abb 100644
--- a/src/app_layout.cpp
+++ b/src/app_layout.cpp
@@ -516,10 +516,6 @@ void App::init_menu_file()
popup->SetPosition(pos.x, pos.y);
layout[main_id]->add_child(popup);
layout[main_id]->update();
- popup->mouse_capture();
- popup->m_mouse_ignore = false;
- popup->m_flood_events = true;
- popup->m_capture_children = false;
if (auto b = popup->find("file-newdoc"))
b->on_click = [this, popup](Node*) {
@@ -621,10 +617,6 @@ void App::init_menu_file()
subpopup->SetPosition(pos.x, pos.y);
layout[main_id]->add_child(subpopup);
layout[main_id]->update();
- subpopup->mouse_capture();
- subpopup->m_mouse_ignore = false;
- subpopup->m_flood_events = true;
- subpopup->m_capture_children = false;
subpopup->find("file-submenu-export-png")->on_click = [this, subpopup, popup](Node*) {
dialog_export(".png");
subpopup->mouse_release();
@@ -696,10 +688,6 @@ void App::init_menu_edit()
popup->SetPosition(pos.x, pos.y);
layout[main_id]->add_child(popup);
layout[main_id]->update();
- popup->mouse_capture();
- popup->m_mouse_ignore = false;
- popup->m_flood_events = true;
- popup->m_capture_children = false;
};
}
}
@@ -720,10 +708,6 @@ void App::init_menu_tools()
popup_exp->SetPosition(pos.x, pos.y);
layout[main_id]->add_child(popup_exp);
layout[main_id]->update();
- popup_exp->mouse_capture();
- popup_exp->m_mouse_ignore = false;
- popup_exp->m_flood_events = true;
- popup_exp->m_capture_children = false;
if (auto tick = popup_exp->find("tools-timelapse-tick")) tick->on_click = [this, popup_exp](Node* b)
{
@@ -738,10 +722,6 @@ void App::init_menu_tools()
popup_time->SetPosition(pos.x, pos.y);
layout[main_id]->add_child(popup_time);
layout[main_id]->update();
- popup_time->mouse_capture();
- popup_time->m_mouse_ignore = false;
- popup_time->m_flood_events = true;
- popup_time->m_capture_children = false;
if (auto item = popup_time->find("timelapse-start"))
{
@@ -784,10 +764,6 @@ void App::init_menu_tools()
popup_time->SetPosition(pos.x, pos.y);
layout[main_id]->add_child(popup_time);
layout[main_id]->update();
- popup_time->mouse_capture();
- popup_time->m_mouse_ignore = false;
- popup_time->m_flood_events = true;
- popup_time->m_capture_children = false;
auto visible = [this](Node* panel) {
if (!panel)
@@ -1050,10 +1026,6 @@ void App::init_menu_about()
popup->SetPosition(pos.x, pos.y);
layout[main_id]->add_child(popup);
layout[main_id]->update();
- popup->mouse_capture();
- popup->m_mouse_ignore = false;
- popup->m_flood_events = true;
- popup->m_capture_children = false;
popup->find("about-app")->on_click = [this, popup](Node*) {
dialog_about();
@@ -1171,10 +1143,6 @@ void App::init_menu_layer()
popup->SetPosition(pos.x, pos.y);
layout[main_id]->add_child(popup);
layout[main_id]->update();
- popup->mouse_capture();
- popup->m_mouse_ignore = false;
- popup->m_flood_events = true;
- popup->m_capture_children = false;
popup->find("layer-clear")->on_click = [this, popup](Node*) {
canvas->m_canvas->clear();
diff --git a/src/layout.h b/src/layout.h
index 7374cc1..3527af1 100644
--- a/src/layout.h
+++ b/src/layout.h
@@ -34,10 +34,16 @@ public:
auto i = m_layouts.find(id);
return i == m_layouts.end() ? nullptr : i->second.get();
}
- class std::shared_ptr get_ref(const char* name)
+ template std::shared_ptr get_ref(const char* name)
{
auto i = m_layouts.find(const_hash(name));
- return i == m_layouts.end() ? nullptr : i->second;
+ return i == m_layouts.end() ? nullptr : std::dynamic_pointer_cast(i->second);
+ }
+ template std::shared_ptr instantiate(const char* name)
+ {
+ if (auto layout = get_ref(name))
+ return layout->m_children[0]->clone();
+ return nullptr;
}
void restore_context();
void clear_context();
diff --git a/src/node_panel_brush.cpp b/src/node_panel_brush.cpp
index ea51c91..2c14273 100644
--- a/src/node_panel_brush.cpp
+++ b/src/node_panel_brush.cpp
@@ -455,6 +455,15 @@ void NodePanelBrushPreset::init()
}
save();
};
+ m_btn_menu = find("btn-menu");
+ m_btn_menu->on_click = [this](Node* b) {
+ auto popup = m_manager->instantiate("tpl-brush-popup");
+ popup->SetPosition(b->m_pos.x + b->m_size.x, b->m_pos.y);
+ root()->add_child(popup);
+ root()->update();
+ auto bounds = root()->GetSize() - zw(popup->get_children_rect());
+ popup->SetPosition(glm::clamp(popup->m_pos, { 0, 0 }, bounds));
+ };
if (Asset::exist(App::I->data_path + "/settings/presets.bin") && !restore())
{
diff --git a/src/node_panel_brush.h b/src/node_panel_brush.h
index 5d1886f..c0f4766 100644
--- a/src/node_panel_brush.h
+++ b/src/node_panel_brush.h
@@ -81,6 +81,7 @@ class NodePanelBrushPreset : public Node
NodeButtonCustom* m_btn_down;
NodeButtonCustom* m_btn_delete;
NodeButtonCustom* m_btn_save;
+ NodeButtonCustom* m_btn_menu;
public:
Node* m_container;
std::function& brush)> on_brush_changed;
diff --git a/src/node_popup_menu.cpp b/src/node_popup_menu.cpp
index 7ff3d78..3b361c3 100644
--- a/src/node_popup_menu.cpp
+++ b/src/node_popup_menu.cpp
@@ -50,3 +50,11 @@ kEventResult NodePopupMenu::handle_event(Event* e)
}
return kEventResult::Consumed;
}
+
+void NodePopupMenu::added(Node* parent)
+{
+ mouse_capture();
+ m_mouse_ignore = false;
+ m_flood_events = true;
+ m_capture_children = false;
+}
diff --git a/src/node_popup_menu.h b/src/node_popup_menu.h
index c312b85..fe73f10 100644
--- a/src/node_popup_menu.h
+++ b/src/node_popup_menu.h
@@ -8,4 +8,5 @@ public:
virtual Node* clone_instantiate() const override;
virtual void init() override;
virtual kEventResult handle_event(Event* e) override;
+ virtual void added(Node* parent) override;
};