From 89166accbe19c3599fb7c7102bc7d60a973213ed Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Thu, 16 Jan 2020 11:08:19 +0100 Subject: [PATCH] Modified layout of preferences dialog --- src/slic3r/GUI/Preferences.cpp | 82 ++++++++++++++++++++-------------- src/slic3r/GUI/Preferences.hpp | 6 ++- 2 files changed, 53 insertions(+), 35 deletions(-) diff --git a/src/slic3r/GUI/Preferences.cpp b/src/slic3r/GUI/Preferences.cpp index d0686677d..4fd63fe0e 100644 --- a/src/slic3r/GUI/Preferences.cpp +++ b/src/slic3r/GUI/Preferences.cpp @@ -19,16 +19,11 @@ PreferencesDialog::PreferencesDialog(wxWindow* parent) : void PreferencesDialog::build() { auto app_config = get_app_config(); - m_optgroup = std::make_shared(this, _(L("General"))); - m_optgroup->label_width = 40; - m_optgroup->m_on_change = [this](t_config_option_key opt_key, boost::any value) { + m_optgroup_general = std::make_shared(this, _(L("General"))); + m_optgroup_general->label_width = 40; + m_optgroup_general->m_on_change = [this](t_config_option_key opt_key, boost::any value) { m_values[opt_key] = boost::any_cast(value) ? "1" : "0"; - - if (opt_key == "use_custom_toolbar_size") { - m_icon_size_sizer->ShowItems(boost::any_cast(value)); - this->layout(); - } - }; + }; // TODO // $optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new( @@ -47,7 +42,7 @@ void PreferencesDialog::build() "instead of the one containing the input files."); def.set_default_value(new ConfigOptionBool{ app_config->has("remember_output_path") ? app_config->get("remember_output_path") == "1" : true }); Option option(def, "remember_output_path"); - m_optgroup->append_single_option_line(option); + m_optgroup_general->append_single_option_line(option); def.label = L("Auto-center parts"); def.type = coBool; @@ -55,7 +50,7 @@ void PreferencesDialog::build() "around the print bed center."); def.set_default_value(new ConfigOptionBool{ app_config->get("autocenter") == "1" }); option = Option (def,"autocenter"); - m_optgroup->append_single_option_line(option); + m_optgroup_general->append_single_option_line(option); def.label = L("Background processing"); def.type = coBool; @@ -63,7 +58,7 @@ void PreferencesDialog::build() "as they\'re loaded in order to save time when exporting G-code."); def.set_default_value(new ConfigOptionBool{ app_config->get("background_processing") == "1" }); option = Option (def,"background_processing"); - m_optgroup->append_single_option_line(option); + m_optgroup_general->append_single_option_line(option); // Please keep in sync with ConfigWizard def.label = L("Check for application updates"); @@ -71,7 +66,7 @@ void PreferencesDialog::build() def.tooltip = L("If enabled, PrusaSlicer will check for the new versions of itself online. When a new version becomes available a notification is displayed at the next application startup (never during program usage). This is only a notification mechanisms, no automatic installation is done."); def.set_default_value(new ConfigOptionBool(app_config->get("version_check") == "1")); option = Option (def, "version_check"); - m_optgroup->append_single_option_line(option); + m_optgroup_general->append_single_option_line(option); #if ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF // Please keep in sync with ConfigWizard @@ -80,7 +75,7 @@ void PreferencesDialog::build() def.tooltip = L("If enabled, allows the Reload from disk command to automatically find and load the files when invoked."); def.set_default_value(new ConfigOptionBool(app_config->get("export_sources_full_pathnames") == "1")); option = Option(def, "export_sources_full_pathnames"); - m_optgroup->append_single_option_line(option); + m_optgroup_general->append_single_option_line(option); #endif // ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF // Please keep in sync with ConfigWizard @@ -89,7 +84,7 @@ void PreferencesDialog::build() def.tooltip = L("If enabled, Slic3r downloads updates of built-in system presets in the background. These updates are downloaded into a separate temporary location. When a new preset version becomes available it is offered at application startup."); def.set_default_value(new ConfigOptionBool(app_config->get("preset_update") == "1")); option = Option (def, "preset_update"); - m_optgroup->append_single_option_line(option); + m_optgroup_general->append_single_option_line(option); def.label = L("Suppress \" - default - \" presets"); def.type = coBool; @@ -97,7 +92,7 @@ void PreferencesDialog::build() "selections once there are any other valid presets available."); def.set_default_value(new ConfigOptionBool{ app_config->get("no_defaults") == "1" }); option = Option (def,"no_defaults"); - m_optgroup->append_single_option_line(option); + m_optgroup_general->append_single_option_line(option); def.label = L("Show incompatible print and filament presets"); def.type = coBool; @@ -105,7 +100,7 @@ void PreferencesDialog::build() "even if they are marked as incompatible with the active printer"); def.set_default_value(new ConfigOptionBool{ app_config->get("show_incompatible_presets") == "1" }); option = Option (def,"show_incompatible_presets"); - m_optgroup->append_single_option_line(option); + m_optgroup_general->append_single_option_line(option); #if __APPLE__ def.label = L("Use Retina resolution for the 3D scene"); @@ -114,15 +109,21 @@ void PreferencesDialog::build() "If you are experiencing 3D performance problems, disabling this option may help."); def.set_default_value(new ConfigOptionBool{ app_config->get("use_retina_opengl") == "1" }); option = Option (def, "use_retina_opengl"); - m_optgroup->append_single_option_line(option); + m_optgroup_general->append_single_option_line(option); #endif - def.label = L("Use perspective camera"); - def.type = coBool; - def.tooltip = L("If enabled, use perspective camera. If not enabled, use orthographic camera."); - def.set_default_value(new ConfigOptionBool{ app_config->get("use_perspective_camera") == "1" }); - option = Option(def, "use_perspective_camera"); - m_optgroup->append_single_option_line(option); + m_optgroup_camera = std::make_shared(this, _(L("Camera"))); + m_optgroup_camera->label_width = 40; + m_optgroup_camera->m_on_change = [this](t_config_option_key opt_key, boost::any value) { + m_values[opt_key] = boost::any_cast(value) ? "1" : "0"; + }; + + def.label = L("Use perspective camera"); + def.type = coBool; + def.tooltip = L("If enabled, use perspective camera. If not enabled, use orthographic camera."); + def.set_default_value(new ConfigOptionBool{ app_config->get("use_perspective_camera") == "1" }); + option = Option(def, "use_perspective_camera"); + m_optgroup_camera->append_single_option_line(option); #if ENABLE_6DOF_CAMERA def.label = L("Use free camera"); @@ -130,21 +131,33 @@ void PreferencesDialog::build() def.tooltip = L("If enabled, use free camera. If not enabled, use constrained camera."); def.set_default_value(new ConfigOptionBool(app_config->get("use_free_camera") == "1")); option = Option(def, "use_free_camera"); - m_optgroup->append_single_option_line(option); + m_optgroup_camera->append_single_option_line(option); #endif // ENABLE_6DOF_CAMERA + m_optgroup_gui = std::make_shared(this, _(L("GUI"))); + m_optgroup_gui->label_width = 40; + m_optgroup_gui->m_on_change = [this](t_config_option_key opt_key, boost::any value) { + m_values[opt_key] = boost::any_cast(value) ? "1" : "0"; + if (opt_key == "use_custom_toolbar_size") { + m_icon_size_sizer->ShowItems(boost::any_cast(value)); + this->layout(); + } + }; + def.label = L("Use custom size for toolbar icons"); def.type = coBool; def.tooltip = L("If enabled, you can change size of toolbar icons manually."); def.set_default_value(new ConfigOptionBool{ app_config->get("use_custom_toolbar_size") == "1" }); - option = Option (def,"use_custom_toolbar_size"); - m_optgroup->append_single_option_line(option); + option = Option(def, "use_custom_toolbar_size"); + m_optgroup_gui->append_single_option_line(option); - create_icon_size_slider(); - m_icon_size_sizer->ShowItems(app_config->get("use_custom_toolbar_size") == "1"); + create_icon_size_slider(); + m_icon_size_sizer->ShowItems(app_config->get("use_custom_toolbar_size") == "1"); auto sizer = new wxBoxSizer(wxVERTICAL); - sizer->Add(m_optgroup->sizer, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10); + sizer->Add(m_optgroup_general->sizer, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10); + sizer->Add(m_optgroup_camera->sizer, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10); + sizer->Add(m_optgroup_gui->sizer, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10); SetFont(wxGetApp().normal_font()); @@ -176,7 +189,9 @@ void PreferencesDialog::accept() void PreferencesDialog::on_dpi_changed(const wxRect &suggested_rect) { - m_optgroup->msw_rescale(); + m_optgroup_general->msw_rescale(); + m_optgroup_camera->msw_rescale(); + m_optgroup_gui->msw_rescale(); msw_buttons_rescale(this, em_unit(), { wxID_OK, wxID_CANCEL }); @@ -201,7 +216,7 @@ void PreferencesDialog::create_icon_size_slider() m_icon_size_sizer = new wxBoxSizer(wxHORIZONTAL); - wxWindow* parent = m_optgroup->ctrl_parent(); + wxWindow* parent = m_optgroup_gui->ctrl_parent(); if (isOSX) // For correct rendering of the slider and value label under OSX @@ -249,8 +264,9 @@ void PreferencesDialog::create_icon_size_slider() win->SetBackgroundStyle(wxBG_STYLE_PAINT); } - m_optgroup->sizer->Add(m_icon_size_sizer, 0, wxEXPAND | wxALL, em); + m_optgroup_gui->sizer->Add(m_icon_size_sizer, 0, wxEXPAND | wxALL, em); } + } // GUI } // Slic3r \ No newline at end of file diff --git a/src/slic3r/GUI/Preferences.hpp b/src/slic3r/GUI/Preferences.hpp index 9fffe6a7f..35bf2b8c5 100644 --- a/src/slic3r/GUI/Preferences.hpp +++ b/src/slic3r/GUI/Preferences.hpp @@ -15,8 +15,10 @@ class ConfigOptionsGroup; class PreferencesDialog : public DPIDialog { std::map m_values; - std::shared_ptr m_optgroup; - wxSizer* m_icon_size_sizer; + std::shared_ptr m_optgroup_general; + std::shared_ptr m_optgroup_camera; + std::shared_ptr m_optgroup_gui; + wxSizer* m_icon_size_sizer; bool isOSX {false}; public: PreferencesDialog(wxWindow* parent);