Fix of an icon size slider under OSX and GTK

This commit is contained in:
YuSanka 2019-05-22 17:08:02 +02:00
parent ccdd68f157
commit a1e09c3db3
3 changed files with 37 additions and 12 deletions

View File

@ -1252,6 +1252,8 @@ GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, Bed3D& bed, Camera& camera, GLToolbar
m_timer.SetOwner(m_canvas); m_timer.SetOwner(m_canvas);
#if ENABLE_RETINA_GL #if ENABLE_RETINA_GL
m_retina_helper.reset(new RetinaHelper(canvas)); 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 #endif
} }

View File

@ -10,6 +10,9 @@ PreferencesDialog::PreferencesDialog(wxWindow* parent) :
DPIDialog(parent, wxID_ANY, _(L("Preferences")), wxDefaultPosition, DPIDialog(parent, wxID_ANY, _(L("Preferences")), wxDefaultPosition,
wxDefaultSize, wxDEFAULT_DIALOG_STYLE) wxDefaultSize, wxDEFAULT_DIALOG_STYLE)
{ {
#ifdef __WXOSX__
isOSX = true;
#endif
build(); build();
} }
@ -183,32 +186,51 @@ void PreferencesDialog::create_icon_size_slider()
m_icon_size_sizer = new wxBoxSizer(wxHORIZONTAL); m_icon_size_sizer = new wxBoxSizer(wxHORIZONTAL);
auto label = new wxStaticText(this, wxID_ANY, _(L("Icon size in a respect to the default size")) + " (%) :"); wxWindow* parent = m_optgroup->ctrl_parent();
label->SetFont(wxGetApp().normal_font());
label->SetBackgroundStyle(wxBG_STYLE_PAINT);
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()); 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, long style = wxSL_HORIZONTAL;
wxSL_LABELS | wxSL_AUTOTICKS); if (!isOSX)
style |= wxSL_LABELS | wxSL_AUTOTICKS;
slider->SetFont(wxGetApp().normal_font()); auto slider = new wxSlider(parent, wxID_ANY, def_val, 25, 100,
slider->SetBackgroundStyle(wxBG_STYLE_PAINT); wxDefaultPosition, wxDefaultSize, style);
slider->SetTickFreq(25); slider->SetTickFreq(25);
slider->SetPageSize(25); slider->SetPageSize(25);
slider->SetToolTip(_(L("Select toolbar icon size in respect to the default one."))); 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(); auto val = slider->GetValue();
m_values["custom_toolbar_size"] = (boost::format("%d") % val).str(); m_values["custom_toolbar_size"] = (boost::format("%d") % val).str();
return;
if (val_label)
val_label->SetLabelText(wxString::Format("%d", val));
}), slider->GetId()); }), slider->GetId());
m_icon_size_sizer->Add(slider, 1, wxEXPAND); for (wxWindow* win : std::vector<wxWindow*>{ 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); m_optgroup->sizer->Add(m_icon_size_sizer, 0, wxEXPAND | wxALL, em);
} }

View File

@ -17,6 +17,7 @@ class PreferencesDialog : public DPIDialog
std::map<std::string, std::string> m_values; std::map<std::string, std::string> m_values;
std::shared_ptr<ConfigOptionsGroup> m_optgroup; std::shared_ptr<ConfigOptionsGroup> m_optgroup;
wxSizer* m_icon_size_sizer; wxSizer* m_icon_size_sizer;
bool isOSX {false};
public: public:
PreferencesDialog(wxWindow* parent); PreferencesDialog(wxWindow* parent);
~PreferencesDialog() {} ~PreferencesDialog() {}