New Layouts: There 3 mode of a layout of the settings tabpanel :

1. Old mode, as it was always.
2. New mode, when Settings Tabs are hidden on the Plater. Use "cog" icon for the switching to the settings tabs
3. Dlg mode, when Settings Tabs are extracted to the Settings dialog. Use "cog" icon for Show or Focus the Settings Dialog

The "Collapse sidebar" toolbar appearance is set in the Preferences.
This commit is contained in:
YuSanka 2020-05-04 22:30:38 +02:00
parent 5679438e64
commit 10d530a57e
9 changed files with 241 additions and 101 deletions
src/slic3r/GUI

View file

@ -117,6 +117,13 @@ void PreferencesDialog::build()
m_optgroup_general->append_single_option_line(option);
#endif
def.label = L("Show the button for the collapse sidebar");
def.type = coBool;
def.tooltip = L("If enabled, the button for the collapse sidebar will be appeared in top right corner of the 3D Scene");
def.set_default_value(new ConfigOptionBool{ app_config->get("show_collapse_button") == "1" });
option = Option(def, "show_collapse_button");
m_optgroup_general->append_single_option_line(option);
m_optgroup_camera = std::make_shared<ConfigOptionsGroup>(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) {
@ -157,6 +164,8 @@ void PreferencesDialog::build()
create_icon_size_slider();
m_icon_size_sizer->ShowItems(app_config->get("use_custom_toolbar_size") == "1");
create_settings_mode_widget();
auto sizer = new wxBoxSizer(wxVERTICAL);
sizer->Add(m_optgroup_general->sizer, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10);
sizer->Add(m_optgroup_camera->sizer, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10);
@ -167,7 +176,7 @@ void PreferencesDialog::build()
auto buttons = CreateStdDialogButtonSizer(wxOK | wxCANCEL);
wxButton* btn = static_cast<wxButton*>(FindWindowById(wxID_OK, this));
btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { accept(); });
sizer->Add(buttons, 0, wxALIGN_CENTER_HORIZONTAL | wxBOTTOM, 10);
sizer->Add(buttons, 0, wxALIGN_CENTER_HORIZONTAL | wxBOTTOM, 5);
SetSizer(sizer);
sizer->SetSizeHints(this);
@ -179,8 +188,33 @@ void PreferencesDialog::accept()
warning_catcher(this, wxString::Format(_(L("You need to restart %s to make the changes effective.")), SLIC3R_APP_NAME));
}
auto app_config = get_app_config();
for (std::map<std::string, std::string>::iterator it = m_values.begin(); it != m_values.end(); ++it) {
bool settings_layout_changed = m_values.find("old_settings_layout_mode") != m_values.end() ||
m_values.find("new_settings_layout_mode") != m_values.end() ||
m_values.find("dlg_settings_layout_mode") != m_values.end();
bool canceled = false;
if (settings_layout_changed) {
// the dialog needs to be destroyed before the call to recreate_gui()
// or sometimes the application crashes into wxDialogBase() destructor
// so we put it into an inner scope
wxMessageDialog dialog(nullptr,
_L("Switching the settings layout mode will trigger application restart.\n"
"You will lose content of the plater.") + "\n\n" +
_L("Do you want to proceed?"),
wxString(SLIC3R_APP_NAME) + " - " + _L("Switching the settings layout mode"),
wxICON_QUESTION | wxOK | wxCANCEL);
if (dialog.ShowModal() == wxID_CANCEL)
canceled = true;
}
auto app_config = get_app_config();
for (std::map<std::string, std::string>::iterator it = m_values.begin(); it != m_values.end(); ++it)
{
if (canceled && (it->first == "old_settings_layout_mode" ||
it->first == "new_settings_layout_mode" ||
it->first == "dlg_settings_layout_mode" ))
continue;
app_config->set(it->first, it->second);
}
@ -188,8 +222,12 @@ void PreferencesDialog::accept()
EndModal(wxID_OK);
// Nothify the UI to update itself from the ini file.
wxGetApp().update_ui_from_settings();
if (settings_layout_changed && !canceled)
// recreate application, if settings layout was changed
wxGetApp().recreate_GUI();
else
// Nothify the UI to update itself from the ini file.
wxGetApp().update_ui_from_settings();
}
void PreferencesDialog::on_dpi_changed(const wxRect &suggested_rect)
@ -272,6 +310,38 @@ void PreferencesDialog::create_icon_size_slider()
m_optgroup_gui->sizer->Add(m_icon_size_sizer, 0, wxEXPAND | wxALL, em);
}
void PreferencesDialog::create_settings_mode_widget()
{
wxString choices[] = { _L("Old regular layout with tab bar"),
_L("New layout without the tab bar on the platter"),
_L("Settings will be shown in non-modal dialog") };
auto app_config = get_app_config();
int selection = app_config->get("old_settings_layout_mode") == "1" ? 0 :
app_config->get("new_settings_layout_mode") == "1" ? 1 :
app_config->get("dlg_settings_layout_mode") == "1" ? 2 : 0;
wxWindow* parent = m_optgroup_gui->ctrl_parent();
wxRadioBox* box = new wxRadioBox(parent, wxID_ANY, _L("Settings layout mode"), wxDefaultPosition, wxDefaultSize, WXSIZEOF(choices), choices,
3, wxRA_SPECIFY_ROWS);
box->SetButtonFont(wxGetApp().normal_font());
box->SetSelection(selection);
box->Bind(wxEVT_RADIOBOX, [this](wxCommandEvent& e) {
int selection = e.GetSelection();
m_values["old_settings_layout_mode"] = boost::any_cast<bool>(selection == 0) ? "1" : "0";
m_values["new_settings_layout_mode"] = boost::any_cast<bool>(selection == 1) ? "1" : "0";
m_values["dlg_settings_layout_mode"] = boost::any_cast<bool>(selection == 2) ? "1" : "0";
});
auto sizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add(box, 1, wxALIGN_CENTER_VERTICAL);
m_optgroup_gui->sizer->Add(sizer, 0, wxEXPAND | wxALL, em_unit());
}
} // GUI
} // Slic3r