add popup tick to stroke panel

This commit is contained in:
2019-01-31 15:57:37 +01:00
parent 6159e71eed
commit 91d6905238
4 changed files with 25 additions and 2 deletions

View File

@@ -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)