From a1e09c3db3104a9e01ebe69d11e67a6bc13beb4a Mon Sep 17 00:00:00 2001 From: YuSanka Date: Wed, 22 May 2019 17:08:02 +0200 Subject: [PATCH] Fix of an icon size slider under OSX and GTK --- src/slic3r/GUI/GLCanvas3D.cpp | 2 ++ src/slic3r/GUI/Preferences.cpp | 46 +++++++++++++++++++++++++--------- src/slic3r/GUI/Preferences.hpp | 1 + 3 files changed, 37 insertions(+), 12 deletions(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 8bdf6de15..161cdea0c 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -1252,6 +1252,8 @@ GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, Bed3D& bed, Camera& camera, GLToolbar m_timer.SetOwner(m_canvas); #if ENABLE_RETINA_GL m_retina_helper.reset(new RetinaHelper(canvas)); + // set default view_toolbar icons size equal to GLGizmosManager::Default_Icons_Size + m_view_toolbar.set_icons_size(GLGizmosManager::Default_Icons_Size); #endif } diff --git a/src/slic3r/GUI/Preferences.cpp b/src/slic3r/GUI/Preferences.cpp index 82c3c39e2..bbd2585d1 100644 --- a/src/slic3r/GUI/Preferences.cpp +++ b/src/slic3r/GUI/Preferences.cpp @@ -10,6 +10,9 @@ PreferencesDialog::PreferencesDialog(wxWindow* parent) : DPIDialog(parent, wxID_ANY, _(L("Preferences")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE) { +#ifdef __WXOSX__ + isOSX = true; +#endif build(); } @@ -183,32 +186,51 @@ void PreferencesDialog::create_icon_size_slider() 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); + wxWindow* parent = m_optgroup->ctrl_parent(); - m_icon_size_sizer->Add(label, 0, wxALIGN_CENTER_VERTICAL| wxRIGHT | wxLEFT, em); + if (isOSX) + parent->SetBackgroundStyle(wxBG_STYLE_ERASE); + + auto label = new wxStaticText(parent, wxID_ANY, _(L("Icon size in a respect to the default size")) + " (%) :"); + + m_icon_size_sizer->Add(label, 0, wxALIGN_CENTER_VERTICAL| wxRIGHT | (isOSX ? 0 : 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); + long style = wxSL_HORIZONTAL; + if (!isOSX) + style |= wxSL_LABELS | wxSL_AUTOTICKS; - slider->SetFont(wxGetApp().normal_font()); - slider->SetBackgroundStyle(wxBG_STYLE_PAINT); + auto slider = new wxSlider(parent, wxID_ANY, def_val, 25, 100, + wxDefaultPosition, wxDefaultSize, style); 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) { + m_icon_size_sizer->Add(slider, 1, wxEXPAND); + + wxStaticText* val_label{ nullptr }; + if (isOSX) { + val_label = new wxStaticText(parent, wxID_ANY, wxString::Format("%d", def_val)); + m_icon_size_sizer->Add(val_label, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, em); + } + + slider->Bind(wxEVT_SLIDER, ([this, slider, val_label](wxCommandEvent e) { auto val = slider->GetValue(); m_values["custom_toolbar_size"] = (boost::format("%d") % val).str(); - return; + + if (val_label) + val_label->SetLabelText(wxString::Format("%d", val)); }), slider->GetId()); - m_icon_size_sizer->Add(slider, 1, wxEXPAND); + for (wxWindow* win : std::vector{ slider, label, val_label }) { + if (!win) continue; + win->SetFont(wxGetApp().normal_font()); + + if (isOSX) continue; + win->SetBackgroundStyle(wxBG_STYLE_PAINT); + } m_optgroup->sizer->Add(m_icon_size_sizer, 0, wxEXPAND | wxALL, em); } diff --git a/src/slic3r/GUI/Preferences.hpp b/src/slic3r/GUI/Preferences.hpp index 43a353482..9fffe6a7f 100644 --- a/src/slic3r/GUI/Preferences.hpp +++ b/src/slic3r/GUI/Preferences.hpp @@ -17,6 +17,7 @@ class PreferencesDialog : public DPIDialog std::map m_values; std::shared_ptr m_optgroup; wxSizer* m_icon_size_sizer; + bool isOSX {false}; public: PreferencesDialog(wxWindow* parent); ~PreferencesDialog() {}