add preset popup menu
This commit is contained in:
@@ -79,6 +79,9 @@
|
|||||||
<button-custom id="btn-remove" thickness="1" color="0 0" border-color=".0" shrink="1" margin="0 10 0 0">
|
<button-custom id="btn-remove" thickness="1" color="0 0" border-color=".0" shrink="1" margin="0 10 0 0">
|
||||||
<icon width="30" icon="bin_closed"/>
|
<icon width="30" icon="bin_closed"/>
|
||||||
</button-custom>
|
</button-custom>
|
||||||
|
<button-custom id="btn-menu" thickness="1" color="0 0" border-color=".0" shrink="1" margin="0 10 0 10">
|
||||||
|
<icon width="30" icon="resultset_next"/>
|
||||||
|
</button-custom>
|
||||||
</border>
|
</border>
|
||||||
</node>
|
</node>
|
||||||
</layout>
|
</layout>
|
||||||
@@ -94,6 +97,19 @@
|
|||||||
<stroke-preview id="canvas" width="1" grow="1" height="60"/>
|
<stroke-preview id="canvas" width="1" grow="1" height="60"/>
|
||||||
</button-custom>
|
</button-custom>
|
||||||
</layout>
|
</layout>
|
||||||
|
<layout id="tpl-brush-popup">
|
||||||
|
<popup-menu positioning="absolute" position="100 100" width="200" thickness="1" border-color=".1" color=".4 .4 .4 .8" dir="col">
|
||||||
|
<button-custom id="download" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
|
||||||
|
<text text="Download Brushes" grow="1" margin="0 0 0 5"/>
|
||||||
|
</button-custom>
|
||||||
|
<button-custom id="import" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
|
||||||
|
<text text="Import Brushes" grow="1" margin="0 0 0 5"/>
|
||||||
|
</button-custom>
|
||||||
|
<button-custom id="export" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
|
||||||
|
<text text="Export Brushes" grow="1" margin="0 0 0 5"/>
|
||||||
|
</button-custom>
|
||||||
|
</popup-menu>
|
||||||
|
</layout>
|
||||||
|
|
||||||
<!-- PANEL TIPS/PATTERN -->
|
<!-- PANEL TIPS/PATTERN -->
|
||||||
<layout id="tpl-panel-brushes">
|
<layout id="tpl-panel-brushes">
|
||||||
|
|||||||
@@ -516,10 +516,6 @@ void App::init_menu_file()
|
|||||||
popup->SetPosition(pos.x, pos.y);
|
popup->SetPosition(pos.x, pos.y);
|
||||||
layout[main_id]->add_child(popup);
|
layout[main_id]->add_child(popup);
|
||||||
layout[main_id]->update();
|
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<NodeButtonCustom>("file-newdoc"))
|
if (auto b = popup->find<NodeButtonCustom>("file-newdoc"))
|
||||||
b->on_click = [this, popup](Node*) {
|
b->on_click = [this, popup](Node*) {
|
||||||
@@ -621,10 +617,6 @@ void App::init_menu_file()
|
|||||||
subpopup->SetPosition(pos.x, pos.y);
|
subpopup->SetPosition(pos.x, pos.y);
|
||||||
layout[main_id]->add_child(subpopup);
|
layout[main_id]->add_child(subpopup);
|
||||||
layout[main_id]->update();
|
layout[main_id]->update();
|
||||||
subpopup->mouse_capture();
|
|
||||||
subpopup->m_mouse_ignore = false;
|
|
||||||
subpopup->m_flood_events = true;
|
|
||||||
subpopup->m_capture_children = false;
|
|
||||||
subpopup->find<NodeButtonCustom>("file-submenu-export-png")->on_click = [this, subpopup, popup](Node*) {
|
subpopup->find<NodeButtonCustom>("file-submenu-export-png")->on_click = [this, subpopup, popup](Node*) {
|
||||||
dialog_export(".png");
|
dialog_export(".png");
|
||||||
subpopup->mouse_release();
|
subpopup->mouse_release();
|
||||||
@@ -696,10 +688,6 @@ void App::init_menu_edit()
|
|||||||
popup->SetPosition(pos.x, pos.y);
|
popup->SetPosition(pos.x, pos.y);
|
||||||
layout[main_id]->add_child(popup);
|
layout[main_id]->add_child(popup);
|
||||||
layout[main_id]->update();
|
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);
|
popup_exp->SetPosition(pos.x, pos.y);
|
||||||
layout[main_id]->add_child(popup_exp);
|
layout[main_id]->add_child(popup_exp);
|
||||||
layout[main_id]->update();
|
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<NodeButtonCustom>("tools-timelapse-tick")) tick->on_click = [this, popup_exp](Node* b)
|
if (auto tick = popup_exp->find<NodeButtonCustom>("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);
|
popup_time->SetPosition(pos.x, pos.y);
|
||||||
layout[main_id]->add_child(popup_time);
|
layout[main_id]->add_child(popup_time);
|
||||||
layout[main_id]->update();
|
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<NodeButtonCustom>("timelapse-start"))
|
if (auto item = popup_time->find<NodeButtonCustom>("timelapse-start"))
|
||||||
{
|
{
|
||||||
@@ -784,10 +764,6 @@ void App::init_menu_tools()
|
|||||||
popup_time->SetPosition(pos.x, pos.y);
|
popup_time->SetPosition(pos.x, pos.y);
|
||||||
layout[main_id]->add_child(popup_time);
|
layout[main_id]->add_child(popup_time);
|
||||||
layout[main_id]->update();
|
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) {
|
auto visible = [this](Node* panel) {
|
||||||
if (!panel)
|
if (!panel)
|
||||||
@@ -1050,10 +1026,6 @@ void App::init_menu_about()
|
|||||||
popup->SetPosition(pos.x, pos.y);
|
popup->SetPosition(pos.x, pos.y);
|
||||||
layout[main_id]->add_child(popup);
|
layout[main_id]->add_child(popup);
|
||||||
layout[main_id]->update();
|
layout[main_id]->update();
|
||||||
popup->mouse_capture();
|
|
||||||
popup->m_mouse_ignore = false;
|
|
||||||
popup->m_flood_events = true;
|
|
||||||
popup->m_capture_children = false;
|
|
||||||
|
|
||||||
popup->find<NodeButtonCustom>("about-app")->on_click = [this, popup](Node*) {
|
popup->find<NodeButtonCustom>("about-app")->on_click = [this, popup](Node*) {
|
||||||
dialog_about();
|
dialog_about();
|
||||||
@@ -1171,10 +1143,6 @@ void App::init_menu_layer()
|
|||||||
popup->SetPosition(pos.x, pos.y);
|
popup->SetPosition(pos.x, pos.y);
|
||||||
layout[main_id]->add_child(popup);
|
layout[main_id]->add_child(popup);
|
||||||
layout[main_id]->update();
|
layout[main_id]->update();
|
||||||
popup->mouse_capture();
|
|
||||||
popup->m_mouse_ignore = false;
|
|
||||||
popup->m_flood_events = true;
|
|
||||||
popup->m_capture_children = false;
|
|
||||||
|
|
||||||
popup->find<NodeButtonCustom>("layer-clear")->on_click = [this, popup](Node*) {
|
popup->find<NodeButtonCustom>("layer-clear")->on_click = [this, popup](Node*) {
|
||||||
canvas->m_canvas->clear();
|
canvas->m_canvas->clear();
|
||||||
|
|||||||
10
src/layout.h
10
src/layout.h
@@ -34,10 +34,16 @@ public:
|
|||||||
auto i = m_layouts.find(id);
|
auto i = m_layouts.find(id);
|
||||||
return i == m_layouts.end() ? nullptr : i->second.get();
|
return i == m_layouts.end() ? nullptr : i->second.get();
|
||||||
}
|
}
|
||||||
class std::shared_ptr<Node> get_ref(const char* name)
|
template<class T = Node> std::shared_ptr<T> get_ref(const char* name)
|
||||||
{
|
{
|
||||||
auto i = m_layouts.find(const_hash(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<T>(i->second);
|
||||||
|
}
|
||||||
|
template<class T = Node> std::shared_ptr<T> instantiate(const char* name)
|
||||||
|
{
|
||||||
|
if (auto layout = get_ref(name))
|
||||||
|
return layout->m_children[0]->clone<T>();
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
void restore_context();
|
void restore_context();
|
||||||
void clear_context();
|
void clear_context();
|
||||||
|
|||||||
@@ -455,6 +455,15 @@ void NodePanelBrushPreset::init()
|
|||||||
}
|
}
|
||||||
save();
|
save();
|
||||||
};
|
};
|
||||||
|
m_btn_menu = find<NodeButtonCustom>("btn-menu");
|
||||||
|
m_btn_menu->on_click = [this](Node* b) {
|
||||||
|
auto popup = m_manager->instantiate<NodePopupMenu>("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())
|
if (Asset::exist(App::I->data_path + "/settings/presets.bin") && !restore())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ class NodePanelBrushPreset : public Node
|
|||||||
NodeButtonCustom* m_btn_down;
|
NodeButtonCustom* m_btn_down;
|
||||||
NodeButtonCustom* m_btn_delete;
|
NodeButtonCustom* m_btn_delete;
|
||||||
NodeButtonCustom* m_btn_save;
|
NodeButtonCustom* m_btn_save;
|
||||||
|
NodeButtonCustom* m_btn_menu;
|
||||||
public:
|
public:
|
||||||
Node* m_container;
|
Node* m_container;
|
||||||
std::function<void(Node* target, std::shared_ptr<Brush>& brush)> on_brush_changed;
|
std::function<void(Node* target, std::shared_ptr<Brush>& brush)> on_brush_changed;
|
||||||
|
|||||||
@@ -50,3 +50,11 @@ kEventResult NodePopupMenu::handle_event(Event* e)
|
|||||||
}
|
}
|
||||||
return kEventResult::Consumed;
|
return kEventResult::Consumed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NodePopupMenu::added(Node* parent)
|
||||||
|
{
|
||||||
|
mouse_capture();
|
||||||
|
m_mouse_ignore = false;
|
||||||
|
m_flood_events = true;
|
||||||
|
m_capture_children = false;
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,4 +8,5 @@ public:
|
|||||||
virtual Node* clone_instantiate() const override;
|
virtual Node* clone_instantiate() const override;
|
||||||
virtual void init() override;
|
virtual void init() override;
|
||||||
virtual kEventResult handle_event(Event* e) override;
|
virtual kEventResult handle_event(Event* e) override;
|
||||||
|
virtual void added(Node* parent) override;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user