diff --git a/data/ui/popup-tick.png b/data/ui/popup-tick.png new file mode 100644 index 0000000..33af9f5 Binary files /dev/null and b/data/ui/popup-tick.png differ diff --git a/src/node_panel_brush.cpp b/src/node_panel_brush.cpp index f45040f..4b7f8a6 100644 --- a/src/node_panel_brush.cpp +++ b/src/node_panel_brush.cpp @@ -83,6 +83,8 @@ kEventResult NodePanelBrush::handle_event(Event* e) { mouse_release(); parent->remove_child(this); + if (on_popup_close) + on_popup_close(this); } break; default: @@ -259,6 +261,8 @@ kEventResult NodePanelBrushPreset::handle_event(Event* e) { mouse_release(); parent->remove_child(this); + if (on_popup_close) + on_popup_close(this); } break; default: diff --git a/src/node_panel_brush.h b/src/node_panel_brush.h index dcb174e..62c3a90 100644 --- a/src/node_panel_brush.h +++ b/src/node_panel_brush.h @@ -28,6 +28,7 @@ class NodePanelBrush : public Node Node* m_container; public: std::function on_brush_changed; + std::function on_popup_close; virtual Node* clone_instantiate() const override; virtual void init() override; virtual kEventResult handle_event(Event* e) override; @@ -107,6 +108,7 @@ class NodePanelBrushPreset : public Node }; public: std::function& brush)> on_brush_changed; + std::function on_popup_close; virtual Node* clone_instantiate() const override; virtual void init() override; virtual kEventResult handle_event(Event* e) override; diff --git a/src/node_panel_stroke.cpp b/src/node_panel_stroke.cpp index 55a2257..a29bda3 100644 --- a/src/node_panel_stroke.cpp +++ b/src/node_panel_stroke.cpp @@ -91,13 +91,22 @@ 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); root()->add_child(m_presets_popup); + auto tick = root()->add_child(); + 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"); root()->update(); if ((pos.y + m_presets_popup->m_size.y) > screen.y) pos.y = screen.y - m_presets_popup->m_size.y; if (pos.y < 0) pos.y = 0; - m_presets_popup->SetPosition(pos.x, pos.y); + m_presets_popup->SetPosition(pos.x + 16, pos.y); m_presets_popup->mouse_capture(); root()->update(); + m_presets_popup->on_popup_close = [this, tick](Node*) { + tick->destroy(); + }; + m_presets_popup->on_brush_changed = [this](Node* target, std::shared_ptr& b) { // don't change some params //b->m_tip_size = Canvas::I->m_current_brush->m_tip_size; @@ -122,13 +131,21 @@ 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); root()->add_child(m_brush_popup); + auto tick = root()->add_child(); + 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"); root()->update(); if ((pos.y + m_brush_popup->m_size.y) > screen.y) pos.y = screen.y - m_brush_popup->m_size.y; if (pos.y < 0) pos.y = 0; - m_brush_popup->SetPosition(pos.x, pos.y); + m_brush_popup->SetPosition(pos.x + 16, pos.y); m_brush_popup->mouse_capture(); root()->update(); + m_brush_popup->on_popup_close = [this, tick](Node*) { + tick->destroy(); + }; m_brush_popup->on_brush_changed = [this](Node*, int index) { if (on_brush_changed)