update quick panel popup for left handed option
This commit is contained in:
@@ -1500,12 +1500,12 @@ Here's a list of what's available in this release.
|
|||||||
<!--size-->
|
<!--size-->
|
||||||
<node dir="col" margin="0 4 0 0" height="100%" align="center">
|
<node dir="col" margin="0 4 0 0" height="100%" align="center">
|
||||||
<text text="Size" margin="0 0 10 0"/>
|
<text text="Size" margin="0 0 10 0"/>
|
||||||
<slider-v id="quick-size" height="1" grow="1" width="30"/>
|
<slider-v id="quick-size" height="100%" grow="1" width="30"/>
|
||||||
</node>
|
</node>
|
||||||
<!--flow-->
|
<!--flow-->
|
||||||
<node dir="col" align="center" height="100%">
|
<node dir="col" align="center" height="100%">
|
||||||
<text text="Flow" margin="0 0 10 0"/>
|
<text text="Flow" margin="0 0 10 0"/>
|
||||||
<slider-v id="quick-flow" height="1" grow="1" width="30"/>
|
<slider-v id="quick-flow" height="100%" grow="1" width="30"/>
|
||||||
</node>
|
</node>
|
||||||
</node>
|
</node>
|
||||||
<!--color-->
|
<!--color-->
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ kEventResult Node::on_event(Event* e)
|
|||||||
{
|
{
|
||||||
kEventResult ret = kEventResult::Available;
|
kEventResult ret = kEventResult::Available;
|
||||||
|
|
||||||
if (current_mouse_capture)
|
if (current_mouse_capture && current_mouse_capture != this)
|
||||||
{
|
{
|
||||||
if (e->m_cat == kEventCategory::MouseEvent &&
|
if (e->m_cat == kEventCategory::MouseEvent &&
|
||||||
child_mouse_focus != current_mouse_capture &&
|
child_mouse_focus != current_mouse_capture &&
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ void NodeImage::draw()
|
|||||||
ShaderManager::use(kShader::Texture);
|
ShaderManager::use(kShader::Texture);
|
||||||
}
|
}
|
||||||
ShaderManager::u_int(kShaderUniform::Tex, 0);
|
ShaderManager::u_int(kShaderUniform::Tex, 0);
|
||||||
ShaderManager::u_mat4(kShaderUniform::MVP, m_mvp);
|
ShaderManager::u_mat4(kShaderUniform::MVP, m_mvp * glm::scale(glm::vec3(m_scale, 1.f)));
|
||||||
m_plane.draw_fill();
|
m_plane.draw_fill();
|
||||||
sampler.unbind();
|
sampler.unbind();
|
||||||
TextureManager::get(m_tex_id).unbind();
|
TextureManager::get(m_tex_id).unbind();
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ public:
|
|||||||
glm::vec4 m_region;
|
glm::vec4 m_region;
|
||||||
glm::vec2 m_off;
|
glm::vec2 m_off;
|
||||||
glm::vec2 m_sz;
|
glm::vec2 m_sz;
|
||||||
|
glm::vec2 m_scale = { 1.f, 1.f };
|
||||||
std::string m_path;
|
std::string m_path;
|
||||||
uint16_t m_tex_id;
|
uint16_t m_tex_id;
|
||||||
static void static_init();
|
static void static_init();
|
||||||
|
|||||||
@@ -41,7 +41,8 @@ void NodePanelQuick::init_controls()
|
|||||||
|
|
||||||
m_slider_size = find<NodeSliderV>("quick-size");
|
m_slider_size = find<NodeSliderV>("quick-size");
|
||||||
m_slider_size->on_value_changed = [this](Node* target, float value) {
|
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]))
|
if (auto m = dynamic_cast<CanvasModePen*>(Canvas::I->modes[(int)Canvas::I->m_current_mode][0]))
|
||||||
{
|
{
|
||||||
m->m_cur_pos = newpos;
|
m->m_cur_pos = newpos;
|
||||||
@@ -59,7 +60,8 @@ void NodePanelQuick::init_controls()
|
|||||||
};
|
};
|
||||||
m_slider_flow = find<NodeSliderV>("quick-flow");
|
m_slider_flow = find<NodeSliderV>("quick-flow");
|
||||||
m_slider_flow->on_value_changed = [this](Node* target, float value) {
|
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]))
|
if (auto m = dynamic_cast<CanvasModePen*>(Canvas::I->modes[(int)Canvas::I->m_current_mode][0]))
|
||||||
{
|
{
|
||||||
m->m_cur_pos = newpos;
|
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
|
// if the box is already selected show the popup
|
||||||
|
|
||||||
|
auto popup = App::I.presets;
|
||||||
auto screen = root()->m_size;
|
auto screen = root()->m_size;
|
||||||
glm::vec2 pos = button->m_pos + glm::vec2(button->m_size.x, 0);
|
glm::vec2 tick_sz = { 16, 32 };
|
||||||
root()->add_child(App::I.presets);
|
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>();
|
auto tick = root()->add_child<NodeImage>();
|
||||||
tick->SetPositioning(YGPositionTypeAbsolute);
|
tick->SetPositioning(YGPositionTypeAbsolute);
|
||||||
tick->SetSize(16, 32);
|
tick->SetPosition(tick_pos.x, tick_pos.y + (button->m_size.y - tick_sz.y) * 0.5f);
|
||||||
tick->SetPosition(pos.x, pos.y + (button->m_size.y - 32) * 0.5f);
|
tick->SetSize(tick_sz);
|
||||||
tick->set_image("data/ui/popup-tick.png");
|
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;
|
tick->m_scale = { 1, 1 };
|
||||||
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();
|
|
||||||
|
|
||||||
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();
|
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());
|
auto pr = static_cast<NodeStrokePreview*>(button->m_children[0].get());
|
||||||
*pr->m_brush = *b;
|
*pr->m_brush = *b;
|
||||||
pr->m_brush->load();
|
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
|
// if the box is already selected show the popup
|
||||||
|
auto popup = m_picker;
|
||||||
auto screen = root()->m_size;
|
auto screen = root()->m_size;
|
||||||
glm::vec2 pos = target->m_pos + glm::vec2(target->m_size.x, 0);
|
glm::vec2 tick_sz = { 16, 32 };
|
||||||
root()->add_child(m_picker);
|
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>();
|
auto tick = root()->add_child<NodeImage>();
|
||||||
tick->SetPositioning(YGPositionTypeAbsolute);
|
tick->SetPositioning(YGPositionTypeAbsolute);
|
||||||
tick->SetSize(16, 32);
|
tick->SetPosition(tick_pos.x, tick_pos.y + (target->m_size.y - tick_sz.y) * 0.5f);
|
||||||
tick->SetPosition(pos.x, pos.y + (target->m_size.y - 32) * 0.5f);
|
tick->SetSize(tick_sz);
|
||||||
tick->set_image("data/ui/popup-tick.png");
|
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;
|
tick->m_scale = { 1, 1 };
|
||||||
//m_picker->SetHeight(4);
|
|
||||||
root()->update();
|
//float hh = popup->m_container->m_children.size() > 10 ? (screen.y / App::I.zoom - 90.f) : 400.f;
|
||||||
pos.y -= 130;
|
//popup->SetHeight(glm::max(hh, 400.f));
|
||||||
if ((pos.y + m_picker->m_size.y) > screen.y)
|
popup->SetPositioning(YGPositionTypeAbsolute);
|
||||||
pos.y = screen.y - m_picker->m_size.y;
|
popup->SetPosition(popup_pos);
|
||||||
if (pos.y < 0)
|
root()->add_child(popup);
|
||||||
pos.y = 0;
|
|
||||||
m_picker->SetPosition(pos.x + 16, pos.y);
|
|
||||||
m_picker->mouse_capture();
|
|
||||||
root()->update();
|
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());
|
auto c = static_cast<NodeBorder*>(target->m_children[0].get());
|
||||||
m_picker->set_color(c->m_color);
|
m_picker->set_color(c->m_color);
|
||||||
|
|||||||
Reference in New Issue
Block a user