refactor tools menu
This commit is contained in:
@@ -215,29 +215,17 @@
|
|||||||
</border>
|
</border>
|
||||||
-->
|
-->
|
||||||
<border dir="row" flood-events="1" >
|
<border dir="row" flood-events="1" >
|
||||||
<button-custom id="tools-panels" height="40" align="center" color=".2" pad="0 0 0 10" dir="row" grow="1">
|
<button-custom id="tools-panels" pad="0 10 0 10" height="40" width="40" align="center" justify="center" color=".2" dir="row" grow="1">
|
||||||
<text text="Panels" grow="1" margin="0 0 0 5"/>
|
<text text="Panels" grow="1" margin="0 0 0 5"/>
|
||||||
</button-custom>
|
|
||||||
<button-custom id="tools-panels-tick" height="40" width="40" align="center" justify="center" color=".2" dir="row">
|
|
||||||
<icon icon="resultset_next" width="20"/>
|
<icon icon="resultset_next" width="20"/>
|
||||||
</button-custom>
|
</button-custom>
|
||||||
</border>
|
</border>
|
||||||
<button-custom height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
|
<border dir="row" flood-events="1" >
|
||||||
<text text="UI Scale" margin="0 10 0 5" grow="1"/>
|
<button-custom id="tools-options" pad="0 10 0 10" height="40" width="40" align="center" justify="center" color=".2" dir="row" grow="1">
|
||||||
<combobox id="tools-ui-scale" height="30" width="50" margin="0 10 0 0" combo-list="0.50,0.75,0.80,0.90,1.00,1.25,1.50,2.00,2.50"/>
|
<text text="Options" grow="1" margin="0 0 0 5"/>
|
||||||
</button-custom>
|
<icon icon="resultset_next" width="20"/>
|
||||||
<button-custom height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
|
</button-custom>
|
||||||
<text text="VP Scale" margin="0 10 0 5" grow="1"/>
|
</border>
|
||||||
<combobox id="tools-vp-scale" height="30" width="50" margin="0 10 0 0" combo-list="0.25,0.33,0.50,0.66,1.00"/>
|
|
||||||
</button-custom>
|
|
||||||
<button-custom id="tools-rtl" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
|
|
||||||
<checkbox id="tools-rtl-check" width="20" height="20"/>
|
|
||||||
<text text="Left-handed UI" margin="0 0 0 5"/>
|
|
||||||
</button-custom>
|
|
||||||
<button-custom id="tools-vr" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
|
|
||||||
<checkbox id="tools-vr-check" width="20" height="20"/>
|
|
||||||
<text text="Enable VR" margin="0 0 0 5"/>
|
|
||||||
</button-custom>
|
|
||||||
<button-custom id="clear-grids" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
|
<button-custom id="clear-grids" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
|
||||||
<icon icon="bin" width="20"/>
|
<icon icon="bin" width="20"/>
|
||||||
<text text="Clear Guides" margin="0 0 0 5"/>
|
<text text="Clear Guides" margin="0 0 0 5"/>
|
||||||
@@ -259,20 +247,24 @@
|
|||||||
</popup-menu>
|
</popup-menu>
|
||||||
</layout>
|
</layout>
|
||||||
|
|
||||||
<!-- MENU TOOLS > TIMELAPSE -->
|
<!-- MENU TOOLS > OPTIONS -->
|
||||||
<layout id="timelapse-menu">
|
<layout id="options-menu">
|
||||||
<popup-menu positioning="absolute" position="100 100" width="150" thickness="1" border-color=".1" color=".4 .4 .4 .8" dir="col">
|
<popup-menu positioning="absolute" position="100 100" width="150" thickness="1" border-color=".1" color=".4 .4 .4 .8" dir="col">
|
||||||
<button-custom id="timelapse-start" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
|
<button-custom height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
|
||||||
<icon icon="camera" width="20"/>
|
<text text="UI Scale" margin="0 10 0 5" grow="1"/>
|
||||||
<text id="menu-label" text="Start Recording" margin="0 0 0 5"/>
|
<combobox id="tools-ui-scale" height="30" width="50" margin="0 10 0 0" combo-list="0.50,0.75,0.80,0.90,1.00,1.25,1.50,2.00,2.50"/>
|
||||||
</button-custom>
|
</button-custom>
|
||||||
<button-custom id="timelapse-clear" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
|
<button-custom height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
|
||||||
<icon icon="bin" width="20"/>
|
<text text="VP Scale" margin="0 10 0 5" grow="1"/>
|
||||||
<text id="menu-label" text="Clear Frames" margin="0 0 0 5"/>
|
<combobox id="tools-vp-scale" height="30" width="50" margin="0 10 0 0" combo-list="0.25,0.33,0.50,0.66,1.00"/>
|
||||||
</button-custom>
|
</button-custom>
|
||||||
<button-custom id="timelapse-export" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
|
<button-custom id="tools-rtl" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
|
||||||
<icon icon="film_save" width="20"/>
|
<checkbox id="tools-rtl-check" width="20" height="20"/>
|
||||||
<text id="menu-label" text="Export MP4" margin="0 0 0 5"/>
|
<text text="Left-handed UI" margin="0 0 0 5"/>
|
||||||
|
</button-custom>
|
||||||
|
<button-custom id="tools-vr" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
|
||||||
|
<checkbox id="tools-vr-check" width="20" height="20"/>
|
||||||
|
<text text="Enable VR" margin="0 0 0 5"/>
|
||||||
</button-custom>
|
</button-custom>
|
||||||
</popup-menu>
|
</popup-menu>
|
||||||
</layout>
|
</layout>
|
||||||
|
|||||||
@@ -727,306 +727,274 @@ void App::init_menu_tools()
|
|||||||
popup_exp->SetPosition(pos.x, pos.y);
|
popup_exp->SetPosition(pos.x, pos.y);
|
||||||
layout[main_id]->add_child(popup_exp);
|
layout[main_id]->add_child(popup_exp);
|
||||||
|
|
||||||
if (auto tick = popup_exp->find<NodeButtonCustom>("tools-timelapse-tick")) tick->on_click = [this, popup_exp](Node* b)
|
if (auto tick = popup_exp->find<NodeButtonCustom>("tools-panels")) tick->on_click = [this, popup_exp](Node* b)
|
||||||
{
|
{
|
||||||
if (auto menu_time = popup_exp->find<NodePopupMenu>("tools-timelapse"))
|
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<NodePopupMenu>();
|
||||||
glm::vec2 pos = b->m_pos + glm::vec2(b->m_size.x, 0);
|
popup_time->update();
|
||||||
auto popup_time = layout[const_hash("timelapse-menu")]->m_children[0]->clone<NodePopupMenu>();
|
if (YGNodeStyleGetDirection(layout[main_id]->y_node) == YGDirectionRTL)
|
||||||
popup_time->update();
|
pos.x = pos.x - popup_time->m_size.x + b->m_size.x;
|
||||||
if (YGNodeStyleGetDirection(layout[main_id]->y_node) == YGDirectionRTL)
|
popup_time->SetPositioning(YGPositionTypeAbsolute);
|
||||||
pos.x = pos.x - popup_time->m_size.x + b->m_size.x;
|
popup_time->SetPosition(pos.x, pos.y);
|
||||||
popup_time->SetPositioning(YGPositionTypeAbsolute);
|
layout[main_id]->add_child(popup_time);
|
||||||
popup_time->SetPosition(pos.x, pos.y);
|
|
||||||
layout[main_id]->add_child(popup_time);
|
|
||||||
|
|
||||||
if (auto item = popup_time->find<NodeButtonCustom>("timelapse-start"))
|
auto visible = [this](Node* panel) {
|
||||||
|
if (!panel)
|
||||||
|
return false;
|
||||||
|
for (auto& c : floatings_container->m_children)
|
||||||
{
|
{
|
||||||
if (auto text = popup_time->find<NodeText>("menu-label"))
|
if (auto fp = std::static_pointer_cast<NodePanelFloating>(c))
|
||||||
{
|
{
|
||||||
text->set_text(rec_running ? "Stop Recording" : "Start Recording");
|
if (fp->m_container->is_child(panel))
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
popup_time->find<NodeButtonCustom>("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<NodeButtonCustom>("timelapse-clear")->on_click = [this, popup_time, popup_exp](Node*) {
|
|
||||||
rec_clear();
|
|
||||||
popup_exp->destroy();
|
|
||||||
popup_time->destroy();
|
|
||||||
};
|
|
||||||
|
|
||||||
popup_time->find<NodeButtonCustom>("timelapse-export")->on_click = [this, popup_time, popup_exp](Node*) {
|
|
||||||
rec_export("");
|
|
||||||
popup_exp->destroy();
|
|
||||||
popup_time->destroy();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if (auto tick = popup_exp->find<NodeButtonCustom>("tools-panels-tick")) tick->on_click = [this, popup_exp](Node* b)
|
|
||||||
{
|
|
||||||
if (auto menu_time = popup_exp->find<NodePopupMenu>("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<NodePopupMenu>();
|
|
||||||
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<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->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<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(true, true);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fpanel->m_container->add_child(floating_presets);
|
|
||||||
}
|
|
||||||
popup_exp->destroy();
|
|
||||||
popup_time->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->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<NodePanelColor>();
|
|
||||||
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<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->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<NodeColorPicker>();
|
|
||||||
//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<NodeButtonCustom>("panel-layers")->on_click = [this, popup_time, popup_exp, visible](Node*) {
|
|
||||||
if (visible(layers.get()))
|
|
||||||
return;
|
|
||||||
auto fpanel = floatings_container->add_child<NodePanelFloating>();
|
|
||||||
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<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_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<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_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<NodeButtonCustom>("panel-animation")->on_click = [this, popup_time, popup_exp, visible](Node*) {
|
|
||||||
if (visible(grid.get()))
|
|
||||||
return;
|
|
||||||
auto fpanel = floatings_container->add_child<NodePanelFloating>();
|
|
||||||
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<NodeComboBox>("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<NodeComboBox>("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<NodeButtonCustom>("tools-rtl"))
|
|
||||||
{
|
|
||||||
NodeCheckBox* cb = rtl_btn->find<NodeCheckBox>("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<NodeCheckBox>("tools-rtl-check");
|
|
||||||
cb->set_value(!cb->checked, true);
|
|
||||||
};
|
|
||||||
|
|
||||||
rtl_btn->find<NodeCheckBox>("tools-rtl-check")->on_value_changed = [this, main](Node*, bool checked)
|
|
||||||
{
|
|
||||||
set_ui_rtl(checked);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (auto vr_btn = popup_exp->find<NodeButtonCustom>("tools-vr"))
|
|
||||||
{
|
|
||||||
NodeCheckBox* cb = vr_btn->find<NodeCheckBox>("tools-vr-check");
|
|
||||||
cb->set_value(has_vr);
|
|
||||||
|
|
||||||
vr_btn->on_click = [this, popup_exp, vr_btn](Node* b)
|
|
||||||
{
|
|
||||||
NodeCheckBox* cb = vr_btn->find<NodeCheckBox>("tools-vr-check");
|
|
||||||
cb->set_value(!cb->checked, true);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
vr_btn->find<NodeCheckBox>("tools-vr-check")->on_value_changed = [this, main](Node* target, bool checked)
|
popup_time->find<NodeButtonCustom>("panel-presets")->on_click = [this, popup_time, popup_exp, visible](Node*) {
|
||||||
{
|
if (visible(floating_presets.get()))
|
||||||
if (checked)
|
return;
|
||||||
|
auto fpanel = floatings_container->add_child<NodePanelFloating>();
|
||||||
|
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())
|
floating_presets = fpanel->m_container->add_child_ref<NodePanelBrushPreset>();
|
||||||
{
|
floating_presets->SetHeightP(100);
|
||||||
auto cb = static_cast<NodeCheckBox*>(target);
|
//floating_presets->SetFlexGrow(1);
|
||||||
cb->set_value(false);
|
//floating_presets->find("toolbar")->destroy();
|
||||||
message_box("VR Failed", "Couldn't start Virtual Reality mode");
|
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(true, true);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vr_stop();
|
fpanel->m_container->add_child(floating_presets);
|
||||||
}
|
}
|
||||||
|
popup_exp->destroy();
|
||||||
|
popup_time->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->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<NodePanelColor>();
|
||||||
|
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<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->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<NodeColorPicker>();
|
||||||
|
//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<NodeButtonCustom>("panel-layers")->on_click = [this, popup_time, popup_exp, visible](Node*) {
|
||||||
|
if (visible(layers.get()))
|
||||||
|
return;
|
||||||
|
auto fpanel = floatings_container->add_child<NodePanelFloating>();
|
||||||
|
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<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_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<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_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<NodeButtonCustom>("panel-animation")->on_click = [this, popup_time, popup_exp, visible](Node*) {
|
||||||
|
if (visible(grid.get()))
|
||||||
|
return;
|
||||||
|
auto fpanel = floatings_container->add_child<NodePanelFloating>();
|
||||||
|
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<NodeButtonCustom>("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<NodePopupMenu>();
|
||||||
|
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<NodeComboBox>("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<NodeComboBox>("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<NodeButtonCustom>("tools-rtl"))
|
||||||
|
{
|
||||||
|
NodeCheckBox* cb = rtl_btn->find<NodeCheckBox>("tools-rtl-check");
|
||||||
|
cb->set_value(ui_rtl, false);
|
||||||
|
|
||||||
|
rtl_btn->on_click = [this, rtl_btn](Node* b)
|
||||||
|
{
|
||||||
|
NodeCheckBox* cb = rtl_btn->find<NodeCheckBox>("tools-rtl-check");
|
||||||
|
cb->set_value(!cb->checked, true);
|
||||||
|
};
|
||||||
|
|
||||||
|
rtl_btn->find<NodeCheckBox>("tools-rtl-check")->on_value_changed = [this, main](Node*, bool checked)
|
||||||
|
{
|
||||||
|
set_ui_rtl(checked);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (auto vr_btn = popup_time->find<NodeButtonCustom>("tools-vr"))
|
||||||
|
{
|
||||||
|
NodeCheckBox* cb = vr_btn->find<NodeCheckBox>("tools-vr-check");
|
||||||
|
cb->set_value(has_vr);
|
||||||
|
|
||||||
|
vr_btn->on_click = [this, vr_btn](Node* b)
|
||||||
|
{
|
||||||
|
NodeCheckBox* cb = vr_btn->find<NodeCheckBox>("tools-vr-check");
|
||||||
|
cb->set_value(!cb->checked, true);
|
||||||
|
};
|
||||||
|
|
||||||
|
vr_btn->find<NodeCheckBox>("tools-vr-check")->on_value_changed = [this, main](Node* target, bool checked)
|
||||||
|
{
|
||||||
|
if (checked)
|
||||||
|
{
|
||||||
|
if (!vr_start())
|
||||||
|
{
|
||||||
|
auto cb = static_cast<NodeCheckBox*>(target);
|
||||||
|
cb->set_value(false);
|
||||||
|
message_box("VR Failed", "Couldn't start Virtual Reality mode");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vr_stop();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
popup_exp->find<NodeButtonCustom>("clear-grids")->on_click = [this, popup_exp](Node*) {
|
popup_exp->find<NodeButtonCustom>("clear-grids")->on_click = [this, popup_exp](Node*) {
|
||||||
CanvasModeGrid* mode = (CanvasModeGrid*)Canvas::modes[(int)kCanvasMode::Grid][0];
|
CanvasModeGrid* mode = (CanvasModeGrid*)Canvas::modes[(int)kCanvasMode::Grid][0];
|
||||||
|
|||||||
Reference in New Issue
Block a user