improve RTL workflow

This commit is contained in:
2019-05-20 19:31:05 +02:00
parent 1c822e5542
commit e5a3d803c9
3 changed files with 20 additions and 8 deletions

View File

@@ -88,6 +88,7 @@ public:
bool redraw = true;
bool animate = false;
bool ui_visible = true;
bool ui_rtl = false;
bool vr_active = false;
glm::mat4 vr_controller;
glm::vec3 vr_controller_pos;
@@ -210,6 +211,8 @@ public:
void ui_save();
void ui_restore();
void set_ui_rtl(bool rtl);
bool get_ui_rtl() const;
void cmd_convert(std::string pano_path, std::string out_path);
};

View File

@@ -931,9 +931,8 @@ void App::init_menu_tools()
if (auto rtl_btn = popup_exp->find<NodeButtonCustom>("tools-rtl"))
{
auto ui = main->find("central-row");
NodeCheckBox* cb = rtl_btn->find<NodeCheckBox>("tools-rtl-check");
cb->set_value(ui->GetRTL() == YGDirectionRTL, false);
cb->set_value(ui_rtl, false);
rtl_btn->on_click = [this, popup_exp, rtl_btn](Node* b)
{
@@ -943,8 +942,7 @@ void App::init_menu_tools()
rtl_btn->find<NodeCheckBox>("tools-rtl-check")->on_value_changed = [this, main](Node*, bool checked)
{
auto ui = main->find("central-row");
ui->SetRTL(checked ? YGDirectionRTL : YGDirectionLTR);
set_ui_rtl(checked);
};
}
@@ -1363,6 +1361,17 @@ void App::initLayout()
LOG("initializing layout completed");
}
void App::set_ui_rtl(bool rtl)
{
ui_rtl = rtl;
layout[main_id]->find("central-row")->SetRTL(rtl ? YGDirectionRTL : YGDirectionLTR);
}
bool App::get_ui_rtl() const
{
return ui_rtl;
}
void App::ui_save()
{
Serializer::Descriptor d;
@@ -1409,7 +1418,7 @@ void App::ui_save()
d.set("drop-right", list_drop_right);
Settings::set("ui", d);
Settings::set("ui-rtl", Serializer::Integer(layout[main_id]->find("central-row")->GetRTL()));
Settings::set("ui-rtl", Serializer::Boolean(ui_rtl));
#if _WIN32
extern void win32_save_window_state();
@@ -1422,7 +1431,7 @@ void App::ui_save()
void App::ui_restore()
{
if (Settings::has("ui-rtl"))
layout[main_id]->find("central-row")->SetRTL((YGDirection)Settings::value<Serializer::Integer>("ui-rtl"));
set_ui_rtl(Settings::value<Serializer::Integer>("ui-rtl"));
if (!Settings::has("ui"))
return;

View File

@@ -119,7 +119,7 @@ void NodePanelQuick::init_controls()
m_slider_size = find<NodeSliderV>("quick-size");
m_slider_size->on_value_changed = [this](Node* target, float value) {
float off = m_slider_flow->m_pos.x > App::I.width / 2.f ? -100.f : 100.f;
float off = App::I.ui_rtl ? -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]))
{
@@ -138,7 +138,7 @@ void NodePanelQuick::init_controls()
};
m_slider_flow = find<NodeSliderV>("quick-flow");
m_slider_flow->on_value_changed = [this](Node* target, float value) {
float off = m_slider_flow->m_pos.x > App::I.width / 2.f ? -100.f : 100.f;
float off = App::I.ui_rtl ? -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]))
{