add popup tick to stroke panel
This commit is contained in:
BIN
data/ui/popup-tick.png
Normal file
BIN
data/ui/popup-tick.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 457 B |
@@ -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:
|
||||
|
||||
@@ -28,6 +28,7 @@ class NodePanelBrush : public Node
|
||||
Node* m_container;
|
||||
public:
|
||||
std::function<void(Node* target, int id)> on_brush_changed;
|
||||
std::function<void(Node* target)> 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<void(Node* target, std::shared_ptr<Brush>& brush)> on_brush_changed;
|
||||
std::function<void(Node* target)> on_popup_close;
|
||||
virtual Node* clone_instantiate() const override;
|
||||
virtual void init() override;
|
||||
virtual kEventResult handle_event(Event* e) override;
|
||||
|
||||
@@ -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<NodeImage>();
|
||||
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<Brush>& 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<NodeImage>();
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user