add panels docking
This commit is contained in:
@@ -102,6 +102,7 @@ void App::init_sidebar()
|
||||
sidebar = layout[main_id]->find<NodeBorder>("sidebar");
|
||||
canvas = layout[main_id]->find<NodeCanvas>("paint-canvas");
|
||||
quick = layout[main_id]->find<NodePanelQuick>("panel-quick");
|
||||
floatings_container = layout[main_id]->find<Node>("floatings");
|
||||
|
||||
//brushes = layout[main_id]->find<NodePanelBrush>("panel-brush");
|
||||
//layers = layout[main_id]->find<NodePanelLayer>("panel-layer");
|
||||
@@ -274,6 +275,7 @@ void App::init_sidebar()
|
||||
auto screen = layout[main_id]->m_size;
|
||||
glm::vec2 pos = button->m_pos + glm::vec2(button->m_size.x * 0.5f, button->m_size.y);
|
||||
layout[main_id]->add_child(color);
|
||||
color->SetSize(350, 350);
|
||||
auto tick = layout[main_id]->add_child<NodeImage>();
|
||||
tick->SetPositioning(YGPositionTypeAbsolute);
|
||||
tick->SetSize(32, 16);
|
||||
@@ -728,6 +730,153 @@ void App::init_menu_experimental()
|
||||
}
|
||||
};
|
||||
|
||||
if (auto tick = popup_exp->find<NodeButtonCustom>("experimental-panels-tick")) tick->on_click = [this, popup_exp](Node* b)
|
||||
{
|
||||
if (auto menu_time = popup_exp->find<NodePopupMenu>("experimental-panels"))
|
||||
{
|
||||
glm::vec2 pos = b->m_pos + glm::vec2(b->m_size.x, 0);
|
||||
auto popup_time = (NodePopupMenu*)layout[const_hash("panels-menu")]->m_children[0]->clone();
|
||||
popup_time->update();
|
||||
if (YGNodeStyleGetDirection(layout[main_id]->y_node) == YGDirectionRTL)
|
||||
pos.x = pos.x - popup_time->m_size.x + b->m_size.x;
|
||||
popup_time->SetPositioning(YGPositionTypeAbsolute);
|
||||
popup_time->SetPosition(pos.x, pos.y);
|
||||
layout[main_id]->add_child(popup_time);
|
||||
layout[main_id]->update();
|
||||
popup_time->mouse_capture();
|
||||
popup_time->m_mouse_ignore = false;
|
||||
popup_time->m_flood_events = true;
|
||||
popup_time->m_capture_children = false;
|
||||
|
||||
auto visible = [this](Node* panel) {
|
||||
if (!panel)
|
||||
return false;
|
||||
for (auto& c : floatings_container->m_children)
|
||||
{
|
||||
if (auto fp = std::static_pointer_cast<NodePanelFloating>(c))
|
||||
{
|
||||
if (fp->m_container->is_child(panel))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
popup_time->find<NodeButtonCustom>("panel-presets")->on_click = [this, popup_time, popup_exp, visible](Node*) {
|
||||
if (visible(floating_presets.get()))
|
||||
return;
|
||||
auto fpanel = floatings_container->add_child<NodePanelFloating>();
|
||||
fpanel->SetMinHeight(300);
|
||||
if (!floating_presets)
|
||||
{
|
||||
floating_presets = fpanel->m_container->add_child_ref<NodePanelBrushPreset>();
|
||||
floating_presets->SetHeightP(100);
|
||||
//floating_presets->SetFlexGrow(1);
|
||||
floating_presets->find("toolbar")->destroy();
|
||||
floating_presets->on_brush_changed = [this](Node* target, std::shared_ptr<Brush>& b) {
|
||||
auto c = Canvas::I->m_current_brush->m_tip_color;
|
||||
*Canvas::I->m_current_brush = *b;
|
||||
Canvas::I->m_current_brush->m_tip_color = c;
|
||||
Canvas::I->m_current_brush->load();
|
||||
brush_update();
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
fpanel->m_container->add_child(floating_presets);
|
||||
}
|
||||
popup_time->destroy();
|
||||
popup_exp->destroy();
|
||||
};
|
||||
|
||||
popup_time->find<NodeButtonCustom>("panel-color")->on_click = [this, popup_time, popup_exp, visible](Node*) {
|
||||
if (visible(floating_color.get()))
|
||||
return;
|
||||
auto fpanel = floatings_container->add_child<NodePanelFloating>();
|
||||
fpanel->SetMinHeight(300);
|
||||
if (!floating_color)
|
||||
{
|
||||
floating_color = fpanel->m_container->add_child_ref<NodePanelColor>();
|
||||
floating_color->SetHeightP(100);
|
||||
//floating_color->SetMinHeight(300);
|
||||
floating_color->find("title")->destroy();
|
||||
floating_color->on_color_changed = [this](Node* target, glm::vec4 color) {
|
||||
Canvas::I->m_current_brush->m_tip_color = color;
|
||||
brush_update();
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
fpanel->m_container->add_child(floating_color);
|
||||
}
|
||||
popup_time->destroy();
|
||||
popup_exp->destroy();
|
||||
};
|
||||
popup_time->find<NodeButtonCustom>("panel-color-adv")->on_click = [this, popup_time, popup_exp, visible](Node*) {
|
||||
if (visible(floating_picker.get()))
|
||||
return;
|
||||
auto fpanel = floatings_container->add_child<NodePanelFloating>();
|
||||
fpanel->SetHeight(300);
|
||||
if (!floating_picker)
|
||||
{
|
||||
floating_picker = fpanel->m_container->add_child_ref<NodeColorPicker>();
|
||||
//floating_picker->SetHeightP(100);
|
||||
floating_picker->SetWidth(250);
|
||||
floating_picker->m_autohide = false;
|
||||
floating_picker->on_color_change = [this](Node* target, glm::vec3 color) {
|
||||
Canvas::I->m_current_brush->m_tip_color = glm::vec4(color, 1.f);
|
||||
brush_update();
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
fpanel->m_container->add_child(floating_picker);
|
||||
}
|
||||
popup_time->destroy();
|
||||
popup_exp->destroy();
|
||||
};
|
||||
popup_time->find<NodeButtonCustom>("panel-layers")->on_click = [this, popup_time, popup_exp, visible](Node*) {
|
||||
//if (visible(floating_layers.get()))
|
||||
// return;
|
||||
//auto fpanel = floatings_container->add_child<NodePanelFloating>();
|
||||
//if (!floating_layers)
|
||||
//{
|
||||
// floating_layers = fpanel->m_container->add_child_ref<NodePanelLayer>();
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// fpanel->m_container->add_child(floating_layers);
|
||||
//}
|
||||
|
||||
if (visible(layers.get()))
|
||||
return;
|
||||
auto fpanel = floatings_container->add_child<NodePanelFloating>();
|
||||
fpanel->m_container->add_child(layers);
|
||||
|
||||
popup_time->destroy();
|
||||
popup_exp->destroy();
|
||||
};
|
||||
popup_time->find<NodeButtonCustom>("panel-brush")->on_click = [this, popup_time, popup_exp, visible](Node*) {
|
||||
if (visible(stroke.get()))
|
||||
return;
|
||||
auto fpanel = floatings_container->add_child<NodePanelFloating>();
|
||||
fpanel->m_container->add_child(stroke);
|
||||
|
||||
popup_time->destroy();
|
||||
popup_exp->destroy();
|
||||
};
|
||||
popup_time->find<NodeButtonCustom>("panel-grids")->on_click = [this, popup_time, popup_exp, visible](Node*) {
|
||||
if (visible(grid.get()))
|
||||
return;
|
||||
auto fpanel = floatings_container->add_child<NodePanelFloating>();
|
||||
fpanel->m_container->add_child(grid);
|
||||
|
||||
popup_time->destroy();
|
||||
popup_exp->destroy();
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
if (auto rtl_btn = popup_exp->find<NodeButtonCustom>("experimental-rtl"))
|
||||
{
|
||||
rtl_btn->on_click = [this, popup_exp, rtl_btn](Node* b)
|
||||
@@ -1085,6 +1234,7 @@ void App::initLayout()
|
||||
};
|
||||
}
|
||||
|
||||
/*
|
||||
// test floating panel
|
||||
auto fp_presets = layout[main_id]->add_child<NodePanelFloating>();
|
||||
floating_presets = fp_presets->m_container->add_child<NodePanelBrushPreset>();
|
||||
@@ -1116,6 +1266,7 @@ void App::initLayout()
|
||||
};
|
||||
//picker->SetHeightP(100);
|
||||
//color->find("title")->destroy();
|
||||
*/
|
||||
|
||||
App::I.redraw = true;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user