Extract UI state and Win32 window shell
This commit is contained in:
@@ -21,8 +21,6 @@
|
||||
#include "legacy_canvas_tool_services.h"
|
||||
#include "legacy_document_layer_services.h"
|
||||
#include "legacy_preference_storage.h"
|
||||
#include "legacy_ui_overlay_services.h"
|
||||
#include "serializer.h"
|
||||
#include "font.h"
|
||||
#include "node_remote_page.h"
|
||||
#include "node_shorcuts.h"
|
||||
@@ -398,320 +396,3 @@ void App::set_ui_scale(float scale)
|
||||
pp::panopainter::save_legacy_ui_scale_preference(plan.scale);
|
||||
App::I->title_update();
|
||||
}
|
||||
|
||||
void App::set_ui_rtl(bool rtl)
|
||||
{
|
||||
const auto plan = pp::app::plan_interface_direction(rtl);
|
||||
ui_rtl = plan.direction == pp::app::InterfaceDirection::right_to_left;
|
||||
layout[main_id]->find("central-row")->SetRTL(
|
||||
ui_rtl ? YGDirectionRTL : YGDirectionLTR);
|
||||
}
|
||||
|
||||
bool App::get_ui_rtl() const
|
||||
{
|
||||
return ui_rtl;
|
||||
}
|
||||
|
||||
void App::ui_save()
|
||||
{
|
||||
Serializer::Descriptor d;
|
||||
d.class_id = "ui-state";
|
||||
|
||||
Serializer::List list_floatings;
|
||||
for (auto const& c : layout[main_id]->find("floatings")->m_children)
|
||||
{
|
||||
if (auto const& f = std::dynamic_pointer_cast<NodePanelFloating>(c))
|
||||
{
|
||||
auto fd = list_floatings.add<Serializer::Descriptor>();
|
||||
fd->class_id = "ui-flt";
|
||||
fd->set("pos", Serializer::Vec2(f->GetPosition()));
|
||||
fd->set("size", Serializer::Vec2(f->m_size));
|
||||
fd->set("class", Serializer::Integer((int)f->m_class));
|
||||
fd->set("title", Serializer::CString(f->m_title->m_text));
|
||||
}
|
||||
}
|
||||
d.set("floatings", list_floatings);
|
||||
|
||||
Serializer::List list_drop_left;
|
||||
for (auto const& c : layout[main_id]->find("drop-left")->m_children)
|
||||
{
|
||||
if (auto const& f = std::dynamic_pointer_cast<NodePanelFloating>(c))
|
||||
{
|
||||
auto fd = list_drop_left.add<Serializer::Descriptor>();
|
||||
fd->class_id = "ui-dpl";
|
||||
fd->set("size", Serializer::Vec2(f->m_size));
|
||||
fd->set("class", Serializer::Integer((int)f->m_class));
|
||||
fd->set("title", Serializer::CString(f->m_title->m_text));
|
||||
}
|
||||
}
|
||||
d.set("drop-left", list_drop_left);
|
||||
|
||||
Serializer::List list_drop_right;
|
||||
for (auto const& c : layout[main_id]->find("drop-right")->m_children)
|
||||
{
|
||||
if (auto const& f = std::dynamic_pointer_cast<NodePanelFloating>(c))
|
||||
{
|
||||
auto fd = list_drop_right.add<Serializer::Descriptor>();
|
||||
fd->class_id = "ui-dpr";
|
||||
fd->set("size", Serializer::Vec2(f->m_size));
|
||||
fd->set("class", Serializer::Integer((int)f->m_class));
|
||||
fd->set("title", Serializer::CString(f->m_title->m_text));
|
||||
}
|
||||
}
|
||||
d.set("drop-right", list_drop_right);
|
||||
|
||||
pp::panopainter::set_legacy_ui_state_preferences(d, ui_rtl);
|
||||
save_platform_ui_state();
|
||||
|
||||
pp::panopainter::save_legacy_preferences();
|
||||
}
|
||||
|
||||
void App::ui_restore()
|
||||
{
|
||||
const auto preferences = pp::panopainter::read_legacy_ui_preferences();
|
||||
if (preferences.has_rtl)
|
||||
set_ui_rtl(preferences.rtl);
|
||||
|
||||
if (!preferences.state)
|
||||
return;
|
||||
|
||||
auto floatings = layout[main_id]->find_ref("floatings");
|
||||
auto drop_left = layout[main_id]->find_ref("drop-left");
|
||||
auto drop_right = layout[main_id]->find_ref("drop-right");
|
||||
auto d = preferences.state;
|
||||
for (auto const& l : d->get<Serializer::List>("floatings")->items)
|
||||
{
|
||||
auto ld = std::static_pointer_cast<Serializer::Descriptor>(l);
|
||||
auto pos = ld->value<Serializer::Vec2>("pos");
|
||||
auto size = ld->value<Serializer::Vec2>("size");
|
||||
auto cls = static_cast<NodePanelFloating::kClass>(ld->value<Serializer::Integer>("class"));
|
||||
auto f = floatings->add_child<NodePanelFloating>();
|
||||
std::string title = "Floating Panel";
|
||||
ld->value<Serializer::CString>("title", title);
|
||||
f->m_title->set_text(title.c_str());
|
||||
switch (cls)
|
||||
{
|
||||
case NodePanelFloating::kClass::Presets:
|
||||
{
|
||||
floating_presets = f->m_container->add_child_ref<NodePanelBrushPreset>();
|
||||
floating_presets->SetHeightP(100);
|
||||
//floating_presets->find("toolbar")->destroy();
|
||||
floating_presets->on_brush_changed = [this](Node* target, std::shared_ptr<Brush>& b) {
|
||||
apply_brush_preset_plan(*this, b);
|
||||
};
|
||||
break;
|
||||
}
|
||||
case NodePanelFloating::kClass::Color:
|
||||
{
|
||||
floating_color = f->m_container->add_child_ref<NodePanelColor>();
|
||||
floating_color->SetHeightP(100);
|
||||
floating_color->find("title")->SetVisibility(false);
|
||||
floating_color->on_color_changed = [this](Node* target, glm::vec4 color) {
|
||||
apply_brush_color_plan(*this, color, false, false);
|
||||
};
|
||||
break;
|
||||
}
|
||||
case NodePanelFloating::kClass::ColorAdv:
|
||||
{
|
||||
floating_picker = f->m_container->add_child_ref<NodeColorPicker>();
|
||||
floating_picker->m_autohide = false;
|
||||
floating_picker->on_color_change = [this](Node* target, glm::vec3 color) {
|
||||
apply_brush_color_plan(*this, glm::vec4(color, 1.f), false, false);
|
||||
};
|
||||
break;
|
||||
}
|
||||
case NodePanelFloating::kClass::Layers:
|
||||
f->m_container->add_child(layers);
|
||||
f->SetMinHeight(100);
|
||||
f->SetHeight(300);
|
||||
layers->find("title")->SetVisibility(false);
|
||||
layers->SetPositioning(YGPositionTypeRelative);
|
||||
layers->SetPosition(0, 0);
|
||||
layers->SetWidthP(100);
|
||||
layers->SetHeightP(100);
|
||||
layers->SetFlexShrink(0);
|
||||
break;
|
||||
case NodePanelFloating::kClass::Brush:
|
||||
f->m_container->add_child(stroke);
|
||||
stroke->find("title")->SetVisibility(false);
|
||||
stroke->SetPositioning(YGPositionTypeRelative);
|
||||
stroke->SetPosition(0, 0);
|
||||
stroke->SetWidthP(100);
|
||||
stroke->SetHeightP(100);
|
||||
break;
|
||||
case NodePanelFloating::kClass::Grids:
|
||||
f->m_container->add_child(grid);
|
||||
grid->find("title")->SetVisibility(false);
|
||||
grid->SetPositioning(YGPositionTypeRelative);
|
||||
grid->SetPosition(0, 0);
|
||||
grid->SetWidthP(100);
|
||||
grid->SetHeightP(100);
|
||||
break;
|
||||
case NodePanelFloating::kClass::Animation:
|
||||
f->m_container->add_child(animation);
|
||||
f->m_droppable = false;
|
||||
//grid->find("title")->SetVisibility(false);
|
||||
animation->SetPositioning(YGPositionTypeRelative);
|
||||
animation->SetPosition(0, 0);
|
||||
animation->SetWidthP(100);
|
||||
animation->SetHeightP(100);
|
||||
break;
|
||||
case NodePanelFloating::kClass::Generic:
|
||||
default:
|
||||
f->m_container->add_child<Node>();
|
||||
break;
|
||||
}
|
||||
f->m_class = cls;
|
||||
f->SetSize(size);
|
||||
f->SetPosition(pos);
|
||||
f->SetPositioning(YGPositionTypeAbsolute);
|
||||
}
|
||||
|
||||
for (auto const& l : d->get<Serializer::List>("drop-left")->items)
|
||||
{
|
||||
auto ld = std::static_pointer_cast<Serializer::Descriptor>(l);
|
||||
auto size = ld->value<Serializer::Vec2>("size");
|
||||
auto cls = static_cast<NodePanelFloating::kClass>(ld->value<Serializer::Integer>("class"));
|
||||
auto f = drop_left->add_child<NodePanelFloating>();
|
||||
std::string title = "Floating Panel";
|
||||
ld->value<Serializer::CString>("title", title);
|
||||
f->m_title->set_text(title.c_str());
|
||||
switch (cls)
|
||||
{
|
||||
case NodePanelFloating::kClass::Presets:
|
||||
{
|
||||
auto floating_presets = f->m_container->add_child<NodePanelBrushPreset>();
|
||||
floating_presets->SetHeightP(100);
|
||||
//floating_presets->find("toolbar")->destroy();
|
||||
floating_presets->on_brush_changed = [this](Node* target, std::shared_ptr<Brush>& b) {
|
||||
apply_brush_preset_plan(*this, b);
|
||||
};
|
||||
break;
|
||||
}
|
||||
case NodePanelFloating::kClass::Color:
|
||||
{
|
||||
auto floating_color = f->m_container->add_child<NodePanelColor>();
|
||||
floating_color->SetHeightP(100);
|
||||
pp::panopainter::destroy_legacy_node(*floating_color->find("title"));
|
||||
floating_color->on_color_changed = [this](Node* target, glm::vec4 color) {
|
||||
apply_brush_color_plan(*this, color, false, false);
|
||||
};
|
||||
break;
|
||||
}
|
||||
case NodePanelFloating::kClass::ColorAdv:
|
||||
{
|
||||
floating_picker = f->m_container->add_child_ref<NodeColorPicker>();
|
||||
floating_picker->m_autohide = false;
|
||||
floating_picker->on_color_change = [this](Node* target, glm::vec3 color) {
|
||||
apply_brush_color_plan(*this, glm::vec4(color, 1.f), false, false);
|
||||
};
|
||||
break;
|
||||
}
|
||||
case NodePanelFloating::kClass::Layers:
|
||||
f->m_container->add_child(layers);
|
||||
layers->SetPositioning(YGPositionTypeRelative);
|
||||
layers->SetPosition(0, 0);
|
||||
layers->SetWidthP(100);
|
||||
layers->SetHeightP(100);
|
||||
layers->SetFlexShrink(0);
|
||||
break;
|
||||
case NodePanelFloating::kClass::Brush:
|
||||
f->m_container->add_child(stroke);
|
||||
stroke->SetPositioning(YGPositionTypeRelative);
|
||||
stroke->SetPosition(0, 0);
|
||||
stroke->SetWidthP(100);
|
||||
stroke->SetHeightP(100);
|
||||
break;
|
||||
case NodePanelFloating::kClass::Grids:
|
||||
f->m_container->add_child(grid);
|
||||
grid->SetPositioning(YGPositionTypeRelative);
|
||||
grid->SetPosition(0, 0);
|
||||
grid->SetWidthP(100);
|
||||
grid->SetHeightP(100);
|
||||
break;
|
||||
case NodePanelFloating::kClass::Generic:
|
||||
default:
|
||||
f->m_container->add_child<Node>();
|
||||
break;
|
||||
}
|
||||
f->m_class = cls;
|
||||
f->m_dock = drop_left;
|
||||
f->SetPositioning(YGPositionTypeRelative);
|
||||
f->SetPosition(0, 0);
|
||||
f->SetSize(size);
|
||||
}
|
||||
|
||||
for (auto const& l : d->get<Serializer::List>("drop-right")->items)
|
||||
{
|
||||
auto ld = std::static_pointer_cast<Serializer::Descriptor>(l);
|
||||
auto size = ld->value<Serializer::Vec2>("size");
|
||||
auto cls = static_cast<NodePanelFloating::kClass>(ld->value<Serializer::Integer>("class"));
|
||||
auto f = drop_right->add_child<NodePanelFloating>();
|
||||
std::string title = "Floating Panel";
|
||||
ld->value<Serializer::CString>("title", title);
|
||||
f->m_title->set_text(title.c_str());
|
||||
switch (cls)
|
||||
{
|
||||
case NodePanelFloating::kClass::Presets:
|
||||
{
|
||||
auto floating_presets = f->m_container->add_child<NodePanelBrushPreset>();
|
||||
floating_presets->SetHeightP(100);
|
||||
//floating_presets->find("toolbar")->destroy();
|
||||
floating_presets->on_brush_changed = [this](Node* target, std::shared_ptr<Brush>& b) {
|
||||
apply_brush_preset_plan(*this, b);
|
||||
};
|
||||
break;
|
||||
}
|
||||
case NodePanelFloating::kClass::Color:
|
||||
{
|
||||
auto floating_color = f->m_container->add_child<NodePanelColor>();
|
||||
floating_color->SetHeightP(100);
|
||||
pp::panopainter::destroy_legacy_node(*floating_color->find("title"));
|
||||
floating_color->on_color_changed = [this](Node* target, glm::vec4 color) {
|
||||
apply_brush_color_plan(*this, color, false, false);
|
||||
};
|
||||
break;
|
||||
}
|
||||
case NodePanelFloating::kClass::ColorAdv:
|
||||
{
|
||||
floating_picker = f->m_container->add_child_ref<NodeColorPicker>();
|
||||
floating_picker->m_autohide = false;
|
||||
floating_picker->on_color_change = [this](Node* target, glm::vec3 color) {
|
||||
apply_brush_color_plan(*this, glm::vec4(color, 1.f), false, false);
|
||||
};
|
||||
break;
|
||||
}
|
||||
case NodePanelFloating::kClass::Layers:
|
||||
f->m_container->add_child(layers);
|
||||
layers->SetPositioning(YGPositionTypeRelative);
|
||||
layers->SetPosition(0, 0);
|
||||
layers->SetWidthP(100);
|
||||
layers->SetHeightP(100);
|
||||
layers->SetFlexShrink(0);
|
||||
break;
|
||||
case NodePanelFloating::kClass::Brush:
|
||||
f->m_container->add_child(stroke);
|
||||
stroke->SetPositioning(YGPositionTypeRelative);
|
||||
stroke->SetPosition(0, 0);
|
||||
stroke->SetWidthP(100);
|
||||
stroke->SetHeightP(100);
|
||||
break;
|
||||
case NodePanelFloating::kClass::Grids:
|
||||
f->m_container->add_child(grid);
|
||||
grid->SetPositioning(YGPositionTypeRelative);
|
||||
grid->SetPosition(0, 0);
|
||||
grid->SetWidthP(100);
|
||||
grid->SetHeightP(100);
|
||||
break;
|
||||
case NodePanelFloating::kClass::Generic:
|
||||
default:
|
||||
f->m_container->add_child<Node>();
|
||||
break;
|
||||
}
|
||||
f->m_class = cls;
|
||||
f->m_dock = drop_right;
|
||||
f->SetPositioning(YGPositionTypeRelative);
|
||||
f->SetPosition(0, 0);
|
||||
f->SetSize(size);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user