diff options
author | YuSanka <yusanka@gmail.com> | 2019-05-22 14:51:02 +0300 |
---|---|---|
committer | YuSanka <yusanka@gmail.com> | 2019-05-22 14:51:02 +0300 |
commit | d845966cbbcadc80e4054019d0ff049b83557f49 (patch) | |
tree | 5889681ac339120896ab8a0ab200bba9a257cee1 /src/slic3r/GUI/Preferences.cpp | |
parent | fb6ae5296e45e8d4383807dbf1c1c8d49fa4236d (diff) |
Implemented a possibility to set a custom toolbars icon size (related to #2247 and same others)
Diffstat (limited to 'src/slic3r/GUI/Preferences.cpp')
-rw-r--r-- | src/slic3r/GUI/Preferences.cpp | 66 |
1 files changed, 61 insertions, 5 deletions
diff --git a/src/slic3r/GUI/Preferences.cpp b/src/slic3r/GUI/Preferences.cpp index a29ba5c91..82c3c39e2 100644 --- a/src/slic3r/GUI/Preferences.cpp +++ b/src/slic3r/GUI/Preferences.cpp @@ -18,8 +18,13 @@ void PreferencesDialog::build() auto app_config = get_app_config(); m_optgroup = std::make_shared<ConfigOptionsGroup>(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->m_on_change = [this](t_config_option_key opt_key, boost::any value) { m_values[opt_key] = boost::any_cast<bool>(value) ? "1" : "0"; + + if (opt_key == "use_custom_toolbar_size") { + m_icon_size_sizer->ShowItems(boost::any_cast<bool>(value)); + this->layout(); + } }; // TODO @@ -109,6 +114,16 @@ void PreferencesDialog::build() m_optgroup->append_single_option_line(option); #endif + 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); + + 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); @@ -145,17 +160,58 @@ void PreferencesDialog::on_dpi_changed(const wxRect &suggested_rect) { m_optgroup->msw_rescale(); - const int em = em_unit(); + msw_buttons_rescale(this, em_unit(), { wxID_OK, wxID_CANCEL }); - msw_buttons_rescale(this, em, { wxID_OK, wxID_CANCEL }); + layout(); +} - const wxSize& size = wxSize(47 * em, 28 * em); +void PreferencesDialog::layout() +{ + const int em = em_unit(); - SetMinSize(size); + SetMinSize(wxSize(47 * em, 28 * em)); Fit(); Refresh(); } +void PreferencesDialog::create_icon_size_slider() +{ + const auto app_config = get_app_config(); + + const int em = em_unit(); + + m_icon_size_sizer = new wxBoxSizer(wxHORIZONTAL); + + auto label = new wxStaticText(this, wxID_ANY, _(L("Icon size in a respect to the default size")) + " (%) :"); + label->SetFont(wxGetApp().normal_font()); + label->SetBackgroundStyle(wxBG_STYLE_PAINT); + + m_icon_size_sizer->Add(label, 0, wxALIGN_CENTER_VERTICAL| wxRIGHT | wxLEFT, em); + + const int def_val = atoi(app_config->get("custom_toolbar_size").c_str()); + + auto slider = new wxSlider(this, wxID_ANY, def_val, 25, 100, wxDefaultPosition, wxDefaultSize, + wxSL_LABELS | wxSL_AUTOTICKS); + + slider->SetFont(wxGetApp().normal_font()); + slider->SetBackgroundStyle(wxBG_STYLE_PAINT); + + slider->SetTickFreq(25); + slider->SetPageSize(25); + + slider->SetToolTip(_(L("Select toolbar icon size in respect to the default one."))); + + slider->Bind(wxEVT_SLIDER, ([this, slider](wxCommandEvent e) { + auto val = slider->GetValue(); + m_values["custom_toolbar_size"] = (boost::format("%d") % val).str(); + return; + }), slider->GetId()); + + m_icon_size_sizer->Add(slider, 1, wxEXPAND); + + m_optgroup->sizer->Add(m_icon_size_sizer, 0, wxEXPAND | wxALL, em); +} + } // GUI } // Slic3r
\ No newline at end of file |