diff --git a/data/layout.xml b/data/layout.xml index 59fa51d..22bd537 100644 --- a/data/layout.xml +++ b/data/layout.xml @@ -215,29 +215,17 @@ --> - + - - - - - - - - - - - - - - - - - - + + + + + + @@ -259,20 +247,24 @@ - - + + - - - + + + - - - + + + - - - + + + + + + + diff --git a/src/app_layout.cpp b/src/app_layout.cpp index 15d8291..31d6c84 100644 --- a/src/app_layout.cpp +++ b/src/app_layout.cpp @@ -727,306 +727,274 @@ void App::init_menu_tools() popup_exp->SetPosition(pos.x, pos.y); layout[main_id]->add_child(popup_exp); - if (auto tick = popup_exp->find("tools-timelapse-tick")) tick->on_click = [this, popup_exp](Node* b) + if (auto tick = popup_exp->find("tools-panels")) tick->on_click = [this, popup_exp](Node* b) { - if (auto menu_time = popup_exp->find("tools-timelapse")) - { - glm::vec2 pos = b->m_pos + glm::vec2(b->m_size.x, 0); - auto popup_time = layout[const_hash("timelapse-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); + glm::vec2 pos = b->m_pos + glm::vec2(b->m_size.x, 0); + auto popup_time = 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); - if (auto item = popup_time->find("timelapse-start")) + auto visible = [this](Node* panel) { + if (!panel) + return false; + for (auto& c : floatings_container->m_children) { - if (auto text = popup_time->find("menu-label")) + if (auto fp = std::static_pointer_cast(c)) { - text->set_text(rec_running ? "Stop Recording" : "Start Recording"); + if (fp->m_container->is_child(panel)) + return true; } } - - popup_time->find("timelapse-start")->on_click = [this, popup_time, popup_exp](Node*) { - rec_running ? rec_stop() : rec_start(); - popup_exp->destroy(); - popup_time->destroy(); - }; - - popup_time->find("timelapse-clear")->on_click = [this, popup_time, popup_exp](Node*) { - rec_clear(); - popup_exp->destroy(); - popup_time->destroy(); - }; - - popup_time->find("timelapse-export")->on_click = [this, popup_time, popup_exp](Node*) { - rec_export(""); - popup_exp->destroy(); - popup_time->destroy(); - }; - } - }; - - if (auto tick = popup_exp->find("tools-panels-tick")) tick->on_click = [this, popup_exp](Node* b) - { - if (auto menu_time = popup_exp->find("tools-panels")) - { - glm::vec2 pos = b->m_pos + glm::vec2(b->m_size.x, 0); - auto popup_time = 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); - - auto visible = [this](Node* panel) { - if (!panel) - return false; - for (auto& c : floatings_container->m_children) - { - if (auto fp = std::static_pointer_cast(c)) - { - if (fp->m_container->is_child(panel)) - return true; - } - } - return false; - }; - - popup_time->find("panel-presets")->on_click = [this, popup_time, popup_exp, visible](Node*) { - if (visible(floating_presets.get())) - return; - auto fpanel = floatings_container->add_child(); - fpanel->m_class = NodePanelFloating::kClass::Presets; - fpanel->SetHeight(300); - fpanel->SetMinHeight(300); - fpanel->SetMinWidth(100); - fpanel->m_title->set_text("Brushes"); - if (!floating_presets) - { - floating_presets = fpanel->m_container->add_child_ref(); - floating_presets->SetHeightP(100); - //floating_presets->SetFlexGrow(1); - //floating_presets->find("toolbar")->destroy(); - floating_presets->on_brush_changed = [this](Node* target, std::shared_ptr& 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(true, true); - }; - } - else - { - fpanel->m_container->add_child(floating_presets); - } - popup_exp->destroy(); - popup_time->destroy(); - }; - - popup_time->find("panel-color")->on_click = [this, popup_time, popup_exp, visible](Node*) { - if (visible(floating_color.get())) - return; - auto fpanel = floatings_container->add_child(); - fpanel->m_class = NodePanelFloating::kClass::Color; - fpanel->SetHeight(300); - fpanel->SetMinHeight(300); - fpanel->m_title->set_text("Color Picker"); - if (!floating_color) - { - floating_color = fpanel->m_container->add_child_ref(); - floating_color->SetHeightP(100); - //floating_color->SetMinHeight(300); - floating_color->find("title")->SetVisibility(false); - floating_color->on_color_changed = [this](Node* target, glm::vec4 color) { - Canvas::I->m_current_brush->m_tip_color = color; - brush_update(true, false); - }; - } - else - { - fpanel->m_container->add_child(floating_color); - } - popup_exp->destroy(); - popup_time->destroy(); - }; - popup_time->find("panel-color-adv")->on_click = [this, popup_time, popup_exp, visible](Node*) { - if (visible(floating_picker.get())) - return; - auto fpanel = floatings_container->add_child(); - fpanel->m_class = NodePanelFloating::kClass::ColorAdv; - fpanel->SetHeight(300); - fpanel->SetWidth(300); - fpanel->m_title->set_text("Color Picker"); - if (!floating_picker) - { - floating_picker = fpanel->m_container->add_child_ref(); - //floating_picker->find("title")->SetVisibility(false); - //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(true, false); - }; - } - else - { - fpanel->m_container->add_child(floating_picker); - } - popup_exp->destroy(); - popup_time->destroy(); - }; - popup_time->find("panel-layers")->on_click = [this, popup_time, popup_exp, visible](Node*) { - if (visible(layers.get())) - return; - auto fpanel = floatings_container->add_child(); - fpanel->m_class = NodePanelFloating::kClass::Layers; - fpanel->SetMinHeight(100); - fpanel->SetHeight(300); - fpanel->m_container->add_child(layers); - fpanel->m_title->set_text("Layers"); - layers->SetPositioning(YGPositionTypeRelative); - layers->SetPosition(0, 0); - layers->SetWidthP(100); - layers->SetHeightP(100); - layers->SetFlexShrink(0); - layers->find("title")->SetVisibility(false); - - popup_exp->destroy(); - popup_time->destroy(); - }; - popup_time->find("panel-brush")->on_click = [this, popup_time, popup_exp, visible](Node*) { - if (visible(stroke.get())) - return; - auto fpanel = floatings_container->add_child(); - fpanel->m_class = NodePanelFloating::kClass::Brush; - fpanel->m_container->add_child(stroke); - fpanel->SetHeight(300); - fpanel->m_title->set_text("Brush Settings"); - stroke->SetPositioning(YGPositionTypeRelative); - stroke->SetPosition(0, 0); - stroke->SetWidthP(100); - stroke->SetHeightP(100); - stroke->find("title")->SetVisibility(false); - - popup_exp->destroy(); - popup_time->destroy(); - }; - popup_time->find("panel-grids")->on_click = [this, popup_time, popup_exp, visible](Node*) { - if (visible(grid.get())) - return; - auto fpanel = floatings_container->add_child(); - fpanel->m_class = NodePanelFloating::kClass::Grids; - fpanel->m_container->add_child(grid); - fpanel->SetHeight(300); - fpanel->m_title->set_text("Grid"); - grid->SetPositioning(YGPositionTypeRelative); - grid->SetPosition(0, 0); - grid->SetWidthP(100); - grid->SetHeightP(100); - grid->find("title")->SetVisibility(false); - - popup_exp->destroy(); - popup_time->destroy(); - }; - popup_time->find("panel-animation")->on_click = [this, popup_time, popup_exp, visible](Node*) { - if (visible(grid.get())) - return; - auto fpanel = floatings_container->add_child(); - fpanel->m_class = NodePanelFloating::kClass::Animation; - fpanel->m_container->add_child(animation); - fpanel->SetSize(500, 300); - fpanel->m_title->set_text("Animation"); - fpanel->m_droppable = false; - grid->SetPositioning(YGPositionTypeRelative); - grid->SetPosition(0, 0); - grid->SetWidthP(100); - grid->SetHeightP(100); - grid->find("title")->SetVisibility(false); - - popup_exp->destroy(); - popup_time->destroy(); - }; - } - }; - - if (auto ui_scale = popup_exp->find("tools-ui-scale")) - { - // set index to current zoom level (or at least the closest in list) - for (int i = 0; i < ui_scale->m_data.size(); i++) - if (App::I->zoom >= ui_scale->get_float(i)) - ui_scale->set_index(i); - - ui_scale->on_select = [ui_scale](Node* target, int index) - { - App::I->set_ui_scale(ui_scale->get_float(index)); - }; - } - - if (auto vp_scale = popup_exp->find("tools-vp-scale")) - { - // set index to current zoom level (or at least the closest in list) - for (int i = 0; i < vp_scale->m_data.size(); i++) - if (App::I->canvas->m_density >= vp_scale->get_float(i)) - vp_scale->set_index(i); - - vp_scale->on_select = [vp_scale](Node* target, int index) - { - float d = vp_scale->get_float(index); - App::I->canvas->set_density(d); - Settings::set("vp-scale", Serializer::Float(d)); - Settings::save(); - }; - } - - if (auto rtl_btn = popup_exp->find("tools-rtl")) - { - NodeCheckBox* cb = rtl_btn->find("tools-rtl-check"); - cb->set_value(ui_rtl, false); - - rtl_btn->on_click = [this, popup_exp, rtl_btn](Node* b) - { - NodeCheckBox* cb = rtl_btn->find("tools-rtl-check"); - cb->set_value(!cb->checked, true); - }; - - rtl_btn->find("tools-rtl-check")->on_value_changed = [this, main](Node*, bool checked) - { - set_ui_rtl(checked); - }; - } - - if (auto vr_btn = popup_exp->find("tools-vr")) - { - NodeCheckBox* cb = vr_btn->find("tools-vr-check"); - cb->set_value(has_vr); - - vr_btn->on_click = [this, popup_exp, vr_btn](Node* b) - { - NodeCheckBox* cb = vr_btn->find("tools-vr-check"); - cb->set_value(!cb->checked, true); + return false; }; - vr_btn->find("tools-vr-check")->on_value_changed = [this, main](Node* target, bool checked) - { - if (checked) + popup_time->find("panel-presets")->on_click = [this, popup_time, popup_exp, visible](Node*) { + if (visible(floating_presets.get())) + return; + auto fpanel = floatings_container->add_child(); + fpanel->m_class = NodePanelFloating::kClass::Presets; + fpanel->SetHeight(300); + fpanel->SetMinHeight(300); + fpanel->SetMinWidth(100); + fpanel->m_title->set_text("Brushes"); + if (!floating_presets) { - if (!vr_start()) - { - auto cb = static_cast(target); - cb->set_value(false); - message_box("VR Failed", "Couldn't start Virtual Reality mode"); - } + floating_presets = fpanel->m_container->add_child_ref(); + floating_presets->SetHeightP(100); + //floating_presets->SetFlexGrow(1); + //floating_presets->find("toolbar")->destroy(); + floating_presets->on_brush_changed = [this](Node* target, std::shared_ptr& 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(true, true); + }; } else { - vr_stop(); + fpanel->m_container->add_child(floating_presets); } + popup_exp->destroy(); + popup_time->destroy(); }; - } + + popup_time->find("panel-color")->on_click = [this, popup_time, popup_exp, visible](Node*) { + if (visible(floating_color.get())) + return; + auto fpanel = floatings_container->add_child(); + fpanel->m_class = NodePanelFloating::kClass::Color; + fpanel->SetHeight(300); + fpanel->SetMinHeight(300); + fpanel->m_title->set_text("Color Picker"); + if (!floating_color) + { + floating_color = fpanel->m_container->add_child_ref(); + floating_color->SetHeightP(100); + //floating_color->SetMinHeight(300); + floating_color->find("title")->SetVisibility(false); + floating_color->on_color_changed = [this](Node* target, glm::vec4 color) { + Canvas::I->m_current_brush->m_tip_color = color; + brush_update(true, false); + }; + } + else + { + fpanel->m_container->add_child(floating_color); + } + popup_exp->destroy(); + popup_time->destroy(); + }; + popup_time->find("panel-color-adv")->on_click = [this, popup_time, popup_exp, visible](Node*) { + if (visible(floating_picker.get())) + return; + auto fpanel = floatings_container->add_child(); + fpanel->m_class = NodePanelFloating::kClass::ColorAdv; + fpanel->SetHeight(300); + fpanel->SetWidth(300); + fpanel->m_title->set_text("Color Picker"); + if (!floating_picker) + { + floating_picker = fpanel->m_container->add_child_ref(); + //floating_picker->find("title")->SetVisibility(false); + //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(true, false); + }; + } + else + { + fpanel->m_container->add_child(floating_picker); + } + popup_exp->destroy(); + popup_time->destroy(); + }; + popup_time->find("panel-layers")->on_click = [this, popup_time, popup_exp, visible](Node*) { + if (visible(layers.get())) + return; + auto fpanel = floatings_container->add_child(); + fpanel->m_class = NodePanelFloating::kClass::Layers; + fpanel->SetMinHeight(100); + fpanel->SetHeight(300); + fpanel->m_container->add_child(layers); + fpanel->m_title->set_text("Layers"); + layers->SetPositioning(YGPositionTypeRelative); + layers->SetPosition(0, 0); + layers->SetWidthP(100); + layers->SetHeightP(100); + layers->SetFlexShrink(0); + layers->find("title")->SetVisibility(false); + + popup_exp->destroy(); + popup_time->destroy(); + }; + popup_time->find("panel-brush")->on_click = [this, popup_time, popup_exp, visible](Node*) { + if (visible(stroke.get())) + return; + auto fpanel = floatings_container->add_child(); + fpanel->m_class = NodePanelFloating::kClass::Brush; + fpanel->m_container->add_child(stroke); + fpanel->SetHeight(300); + fpanel->m_title->set_text("Brush Settings"); + stroke->SetPositioning(YGPositionTypeRelative); + stroke->SetPosition(0, 0); + stroke->SetWidthP(100); + stroke->SetHeightP(100); + stroke->find("title")->SetVisibility(false); + + popup_exp->destroy(); + popup_time->destroy(); + }; + popup_time->find("panel-grids")->on_click = [this, popup_time, popup_exp, visible](Node*) { + if (visible(grid.get())) + return; + auto fpanel = floatings_container->add_child(); + fpanel->m_class = NodePanelFloating::kClass::Grids; + fpanel->m_container->add_child(grid); + fpanel->SetHeight(300); + fpanel->m_title->set_text("Grid"); + grid->SetPositioning(YGPositionTypeRelative); + grid->SetPosition(0, 0); + grid->SetWidthP(100); + grid->SetHeightP(100); + grid->find("title")->SetVisibility(false); + + popup_exp->destroy(); + popup_time->destroy(); + }; + popup_time->find("panel-animation")->on_click = [this, popup_time, popup_exp, visible](Node*) { + if (visible(grid.get())) + return; + auto fpanel = floatings_container->add_child(); + fpanel->m_class = NodePanelFloating::kClass::Animation; + fpanel->m_container->add_child(animation); + fpanel->SetSize(500, 300); + fpanel->m_title->set_text("Animation"); + fpanel->m_droppable = false; + grid->SetPositioning(YGPositionTypeRelative); + grid->SetPosition(0, 0); + grid->SetWidthP(100); + grid->SetHeightP(100); + grid->find("title")->SetVisibility(false); + + popup_exp->destroy(); + popup_time->destroy(); + }; + }; + + if (auto options = popup_exp->find("tools-options")) options->on_click = [this, options, main](Node* b) + { + glm::vec2 pos = b->m_pos + glm::vec2(b->m_size.x, 0); + auto popup_time = layout[const_hash("options-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); + + if (auto ui_scale = popup_time->find("tools-ui-scale")) + { + // set index to current zoom level (or at least the closest in list) + for (int i = 0; i < ui_scale->m_data.size(); i++) + if (App::I->zoom >= ui_scale->get_float(i)) + ui_scale->set_index(i); + + ui_scale->on_select = [ui_scale](Node* target, int index) + { + App::I->set_ui_scale(ui_scale->get_float(index)); + }; + } + + if (auto vp_scale = popup_time->find("tools-vp-scale")) + { + // set index to current zoom level (or at least the closest in list) + for (int i = 0; i < vp_scale->m_data.size(); i++) + if (App::I->canvas->m_density >= vp_scale->get_float(i)) + vp_scale->set_index(i); + + vp_scale->on_select = [vp_scale](Node* target, int index) + { + float d = vp_scale->get_float(index); + App::I->canvas->set_density(d); + Settings::set("vp-scale", Serializer::Float(d)); + Settings::save(); + }; + } + + if (auto rtl_btn = popup_time->find("tools-rtl")) + { + NodeCheckBox* cb = rtl_btn->find("tools-rtl-check"); + cb->set_value(ui_rtl, false); + + rtl_btn->on_click = [this, rtl_btn](Node* b) + { + NodeCheckBox* cb = rtl_btn->find("tools-rtl-check"); + cb->set_value(!cb->checked, true); + }; + + rtl_btn->find("tools-rtl-check")->on_value_changed = [this, main](Node*, bool checked) + { + set_ui_rtl(checked); + }; + } + + if (auto vr_btn = popup_time->find("tools-vr")) + { + NodeCheckBox* cb = vr_btn->find("tools-vr-check"); + cb->set_value(has_vr); + + vr_btn->on_click = [this, vr_btn](Node* b) + { + NodeCheckBox* cb = vr_btn->find("tools-vr-check"); + cb->set_value(!cb->checked, true); + }; + + vr_btn->find("tools-vr-check")->on_value_changed = [this, main](Node* target, bool checked) + { + if (checked) + { + if (!vr_start()) + { + auto cb = static_cast(target); + cb->set_value(false); + message_box("VR Failed", "Couldn't start Virtual Reality mode"); + } + } + else + { + vr_stop(); + } + }; + } + }; popup_exp->find("clear-grids")->on_click = [this, popup_exp](Node*) { CanvasModeGrid* mode = (CanvasModeGrid*)Canvas::modes[(int)kCanvasMode::Grid][0];