From 91d69052386f74bebd8a5ad46589f310954412e9 Mon Sep 17 00:00:00 2001 From: omigamedev Date: Thu, 31 Jan 2019 15:57:37 +0100 Subject: [PATCH] add popup tick to stroke panel --- data/ui/popup-tick.png | Bin 0 -> 457 bytes src/node_panel_brush.cpp | 4 ++++ src/node_panel_brush.h | 2 ++ src/node_panel_stroke.cpp | 21 +++++++++++++++++++-- 4 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 data/ui/popup-tick.png diff --git a/data/ui/popup-tick.png b/data/ui/popup-tick.png new file mode 100644 index 0000000000000000000000000000000000000000..33af9f547d7cb7c611725baec3c97c8cde00a164 GIT binary patch literal 457 zcmV;)0XF`LP)#yKp2K$!siMIAyB}6 zD8M~f(CIp??c9r7Aohg*bZ&rz94U^`;{Y@N{Ff=X&g6X(pdd*MN8k6)sa3q|x}mP? zx6~@$G|l_6EJASBKX2#vD>C~-Cb zHO>NviAMus<52*PI2phdCjmI)!2s@f5I`dC4Umd^0VLz60O|N4KqI~j(26?&n(==C z?f4&nMf?ZQw(XNed>aqLFuZ>6Uo7J4|AwxCaU4I2qPXOF{y1p>cMED*TAppAg*q9y`+H?$Bqx~YM{*#v0>d?raE;5$(Yfsn}(2!t-+ zMu4)269MW%E(Buq90>*SEE`&PZ9$^BwA*!nSx(YA=OxKbSOU#f900000NkvXXu0mjfS}VCt literal 0 HcmV?d00001 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)