|
|
|
|
@@ -41,7 +41,8 @@ void NodePanelQuick::init_controls()
|
|
|
|
|
|
|
|
|
|
m_slider_size = find<NodeSliderV>("quick-size");
|
|
|
|
|
m_slider_size->on_value_changed = [this](Node* target, float value) {
|
|
|
|
|
auto newpos = (m_slider_flow->m_pos + glm::vec2(100.f, m_slider_flow->m_size.y / 2.f)) * App::I.zoom;
|
|
|
|
|
float off = m_slider_flow->m_pos.x > App::I.width / 2.f ? -100.f : 100.f;
|
|
|
|
|
auto newpos = (m_slider_flow->m_pos + glm::vec2(off, m_slider_flow->m_size.y / 2.f)) * App::I.zoom;
|
|
|
|
|
if (auto m = dynamic_cast<CanvasModePen*>(Canvas::I->modes[(int)Canvas::I->m_current_mode][0]))
|
|
|
|
|
{
|
|
|
|
|
m->m_cur_pos = newpos;
|
|
|
|
|
@@ -59,7 +60,8 @@ void NodePanelQuick::init_controls()
|
|
|
|
|
};
|
|
|
|
|
m_slider_flow = find<NodeSliderV>("quick-flow");
|
|
|
|
|
m_slider_flow->on_value_changed = [this](Node* target, float value) {
|
|
|
|
|
auto newpos = (m_slider_flow->m_pos + glm::vec2(100.f, m_slider_flow->m_size.y / 2.f)) * App::I.zoom;
|
|
|
|
|
float off = m_slider_flow->m_pos.x > App::I.width / 2.f ? -100.f : 100.f;
|
|
|
|
|
auto newpos = (m_slider_flow->m_pos + glm::vec2(off, m_slider_flow->m_size.y / 2.f)) * App::I.zoom;
|
|
|
|
|
if (auto m = dynamic_cast<CanvasModePen*>(Canvas::I->modes[(int)Canvas::I->m_current_mode][0]))
|
|
|
|
|
{
|
|
|
|
|
m->m_cur_pos = newpos;
|
|
|
|
|
@@ -131,34 +133,50 @@ void NodePanelQuick::handle_button_brush_click(Node* button)
|
|
|
|
|
|
|
|
|
|
// if the box is already selected show the popup
|
|
|
|
|
|
|
|
|
|
auto popup = App::I.presets;
|
|
|
|
|
auto screen = root()->m_size;
|
|
|
|
|
glm::vec2 pos = button->m_pos + glm::vec2(button->m_size.x, 0);
|
|
|
|
|
root()->add_child(App::I.presets);
|
|
|
|
|
glm::vec2 tick_sz = { 16, 32 };
|
|
|
|
|
glm::vec2 tick_pos = button->m_pos + glm::vec2(button->m_size.x, 0);
|
|
|
|
|
glm::vec2 popup_pos = { tick_pos.x + tick_sz.x, tick_pos.y };
|
|
|
|
|
|
|
|
|
|
auto tick = root()->add_child<NodeImage>();
|
|
|
|
|
tick->SetPositioning(YGPositionTypeAbsolute);
|
|
|
|
|
tick->SetSize(16, 32);
|
|
|
|
|
tick->SetPosition(pos.x, pos.y + (button->m_size.y - 32) * 0.5f);
|
|
|
|
|
tick->SetPosition(tick_pos.x, tick_pos.y + (button->m_size.y - tick_sz.y) * 0.5f);
|
|
|
|
|
tick->SetSize(tick_sz);
|
|
|
|
|
tick->set_image("data/ui/popup-tick.png");
|
|
|
|
|
float hh = App::I.presets->m_container->m_children.size() > 10 ? (App::I.height / App::I.zoom - 90.f) : 400.f;
|
|
|
|
|
App::I.presets->SetHeight(glm::max(hh, 400.f));
|
|
|
|
|
root()->update();
|
|
|
|
|
if ((pos.y + App::I.presets->m_size.y) > screen.y)
|
|
|
|
|
pos.y = screen.y - App::I.presets->m_size.y;
|
|
|
|
|
if (pos.y < 0)
|
|
|
|
|
pos.y = 0;
|
|
|
|
|
App::I.presets->SetPosition(pos.x + 16, pos.y);
|
|
|
|
|
App::I.presets->SetPositioning(YGPositionTypeAbsolute);
|
|
|
|
|
App::I.presets->m_mouse_ignore = false;
|
|
|
|
|
App::I.presets->m_flood_events = true;
|
|
|
|
|
App::I.presets->m_capture_children = false;
|
|
|
|
|
App::I.presets->mouse_capture();
|
|
|
|
|
root()->update();
|
|
|
|
|
tick->m_scale = { 1, 1 };
|
|
|
|
|
|
|
|
|
|
App::I.presets->on_popup_close = [this, tick](Node*) {
|
|
|
|
|
float hh = popup->m_container->m_children.size() > 10 ? (screen.y / App::I.zoom - 90.f) : 400.f;
|
|
|
|
|
popup->SetHeight(glm::max(hh, 400.f));
|
|
|
|
|
popup->SetPositioning(YGPositionTypeAbsolute);
|
|
|
|
|
popup->SetPosition(popup_pos);
|
|
|
|
|
root()->add_child(popup);
|
|
|
|
|
|
|
|
|
|
root()->update();
|
|
|
|
|
popup->tick(0);
|
|
|
|
|
popup->update();
|
|
|
|
|
|
|
|
|
|
if (tick_pos.x + popup->m_size.x > screen.x)
|
|
|
|
|
{
|
|
|
|
|
tick_pos = button->m_pos - glm::vec2(tick_sz.x, 0);
|
|
|
|
|
popup_pos = { tick_pos.x - popup->GetWidth(), tick_pos.y };
|
|
|
|
|
tick->m_scale.x = -1.f;
|
|
|
|
|
}
|
|
|
|
|
popup_pos = glm::clamp(popup_pos, { 0, 0 }, screen - popup->m_size);
|
|
|
|
|
popup->SetPosition(popup_pos);
|
|
|
|
|
tick->SetPosition(tick_pos.x, tick_pos.y + (button->m_size.y - tick_sz.y) * 0.5f);
|
|
|
|
|
popup->update();
|
|
|
|
|
|
|
|
|
|
popup->m_mouse_ignore = false;
|
|
|
|
|
popup->m_flood_events = true;
|
|
|
|
|
popup->m_capture_children = false;
|
|
|
|
|
popup->mouse_capture();
|
|
|
|
|
|
|
|
|
|
popup->on_popup_close = [this, tick](Node*) {
|
|
|
|
|
tick->destroy();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
App::I.presets->on_brush_changed = [this, button](Node* target, std::shared_ptr<Brush>& b) {
|
|
|
|
|
popup->on_brush_changed = [this, button](Node* target, std::shared_ptr<Brush>& b) {
|
|
|
|
|
auto pr = static_cast<NodeStrokePreview*>(button->m_children[0].get());
|
|
|
|
|
*pr->m_brush = *b;
|
|
|
|
|
pr->m_brush->load();
|
|
|
|
|
@@ -184,26 +202,44 @@ void NodePanelQuick::handle_button_color_click(Node* target)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if the box is already selected show the popup
|
|
|
|
|
|
|
|
|
|
auto popup = m_picker;
|
|
|
|
|
auto screen = root()->m_size;
|
|
|
|
|
glm::vec2 pos = target->m_pos + glm::vec2(target->m_size.x, 0);
|
|
|
|
|
root()->add_child(m_picker);
|
|
|
|
|
glm::vec2 tick_sz = { 16, 32 };
|
|
|
|
|
glm::vec2 tick_pos = target->m_pos + glm::vec2(target->m_size.x, 0);
|
|
|
|
|
glm::vec2 popup_pos = { tick_pos.x + tick_sz.x, tick_pos.y - 140.f };
|
|
|
|
|
|
|
|
|
|
auto tick = root()->add_child<NodeImage>();
|
|
|
|
|
tick->SetPositioning(YGPositionTypeAbsolute);
|
|
|
|
|
tick->SetSize(16, 32);
|
|
|
|
|
tick->SetPosition(pos.x, pos.y + (target->m_size.y - 32) * 0.5f);
|
|
|
|
|
tick->SetPosition(tick_pos.x, tick_pos.y + (target->m_size.y - tick_sz.y) * 0.5f);
|
|
|
|
|
tick->SetSize(tick_sz);
|
|
|
|
|
tick->set_image("data/ui/popup-tick.png");
|
|
|
|
|
//float hh = m_picker->m_container->m_children.size() > 10 ? App::I.height / App::I.zoom * .75f : 400.f;
|
|
|
|
|
//m_picker->SetHeight(4);
|
|
|
|
|
root()->update();
|
|
|
|
|
pos.y -= 130;
|
|
|
|
|
if ((pos.y + m_picker->m_size.y) > screen.y)
|
|
|
|
|
pos.y = screen.y - m_picker->m_size.y;
|
|
|
|
|
if (pos.y < 0)
|
|
|
|
|
pos.y = 0;
|
|
|
|
|
m_picker->SetPosition(pos.x + 16, pos.y);
|
|
|
|
|
m_picker->mouse_capture();
|
|
|
|
|
tick->m_scale = { 1, 1 };
|
|
|
|
|
|
|
|
|
|
//float hh = popup->m_container->m_children.size() > 10 ? (screen.y / App::I.zoom - 90.f) : 400.f;
|
|
|
|
|
//popup->SetHeight(glm::max(hh, 400.f));
|
|
|
|
|
popup->SetPositioning(YGPositionTypeAbsolute);
|
|
|
|
|
popup->SetPosition(popup_pos);
|
|
|
|
|
root()->add_child(popup);
|
|
|
|
|
|
|
|
|
|
root()->update();
|
|
|
|
|
popup->tick(0);
|
|
|
|
|
popup->update();
|
|
|
|
|
|
|
|
|
|
if (tick_pos.x + popup->m_size.x > screen.x)
|
|
|
|
|
{
|
|
|
|
|
tick_pos = target->m_pos - glm::vec2(tick_sz.x, 0);
|
|
|
|
|
popup_pos = { tick_pos.x - popup->GetWidth(), tick_pos.y - 140.f };
|
|
|
|
|
tick->m_scale.x = -1.f;
|
|
|
|
|
}
|
|
|
|
|
popup_pos = glm::clamp(popup_pos, { 0, 0 }, screen - popup->m_size);
|
|
|
|
|
popup->SetPosition(popup_pos);
|
|
|
|
|
tick->SetPosition(tick_pos.x, tick_pos.y + (target->m_size.y - tick_sz.y) * 0.5f);
|
|
|
|
|
popup->update();
|
|
|
|
|
|
|
|
|
|
popup->m_mouse_ignore = false;
|
|
|
|
|
popup->m_flood_events = true;
|
|
|
|
|
popup->m_capture_children = false;
|
|
|
|
|
popup->mouse_capture();
|
|
|
|
|
|
|
|
|
|
auto c = static_cast<NodeBorder*>(target->m_children[0].get());
|
|
|
|
|
m_picker->set_color(c->m_color);
|
|
|
|
|
|