Implemented a possibility to set a custom toolbars icon size (related to #2247 and same others)
This commit is contained in:
parent
fb6ae5296e
commit
d845966cbb
@ -67,6 +67,12 @@ void AppConfig::set_defaults()
|
|||||||
if (get("remember_output_path").empty())
|
if (get("remember_output_path").empty())
|
||||||
set("remember_output_path", "1");
|
set("remember_output_path", "1");
|
||||||
|
|
||||||
|
if (get("use_custom_toolbar_size").empty())
|
||||||
|
set("use_custom_toolbar_size", "0");
|
||||||
|
|
||||||
|
if (get("custom_toolbar_size").empty())
|
||||||
|
set("custom_toolbar_size", "100");
|
||||||
|
|
||||||
// Remove legacy window positions/sizes
|
// Remove legacy window positions/sizes
|
||||||
erase("", "main_frame_maximized");
|
erase("", "main_frame_maximized");
|
||||||
erase("", "main_frame_pos");
|
erase("", "main_frame_pos");
|
||||||
|
@ -3418,9 +3418,6 @@ bool GLCanvas3D::_init_toolbar()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_SVG_ICONS
|
|
||||||
m_toolbar.set_icons_size(40);
|
|
||||||
#endif // ENABLE_SVG_ICONS
|
|
||||||
// m_toolbar.set_layout_type(GLToolbar::Layout::Vertical);
|
// m_toolbar.set_layout_type(GLToolbar::Layout::Vertical);
|
||||||
m_toolbar.set_layout_type(GLToolbar::Layout::Horizontal);
|
m_toolbar.set_layout_type(GLToolbar::Layout::Horizontal);
|
||||||
m_toolbar.set_layout_orientation(GLToolbar::Layout::Top);
|
m_toolbar.set_layout_orientation(GLToolbar::Layout::Top);
|
||||||
@ -4097,10 +4094,14 @@ void GLCanvas3D::_render_current_gizmo() const
|
|||||||
void GLCanvas3D::_render_gizmos_overlay() const
|
void GLCanvas3D::_render_gizmos_overlay() const
|
||||||
{
|
{
|
||||||
#if ENABLE_RETINA_GL
|
#if ENABLE_RETINA_GL
|
||||||
m_gizmos.set_overlay_scale(m_retina_helper->get_scale_factor());
|
// m_gizmos.set_overlay_scale(m_retina_helper->get_scale_factor());
|
||||||
|
const float scale = m_retina_helper->get_scale_factor()*wxGetApp().toolbar_icon_scale();
|
||||||
|
m_gizmos.set_overlay_scale(scale); //! #ys_FIXME_experiment
|
||||||
#else
|
#else
|
||||||
// m_gizmos.set_overlay_scale(m_canvas->GetContentScaleFactor());
|
// m_gizmos.set_overlay_scale(m_canvas->GetContentScaleFactor());
|
||||||
m_gizmos.set_overlay_scale(wxGetApp().em_unit()*0.1f);//! #ys_FIXME_experiment
|
// m_gizmos.set_overlay_scale(wxGetApp().em_unit()*0.1f);
|
||||||
|
const float size = int(GLGizmosManager::Default_Icons_Size*wxGetApp().toolbar_icon_scale());
|
||||||
|
m_gizmos.set_overlay_icon_size(size); //! #ys_FIXME_experiment
|
||||||
#endif /* __WXMSW__ */
|
#endif /* __WXMSW__ */
|
||||||
|
|
||||||
m_gizmos.render_overlay(*this, m_selection);
|
m_gizmos.render_overlay(*this, m_selection);
|
||||||
@ -4110,10 +4111,14 @@ void GLCanvas3D::_render_toolbar() const
|
|||||||
{
|
{
|
||||||
#if ENABLE_SVG_ICONS
|
#if ENABLE_SVG_ICONS
|
||||||
#if ENABLE_RETINA_GL
|
#if ENABLE_RETINA_GL
|
||||||
m_toolbar.set_scale(m_retina_helper->get_scale_factor());
|
// m_toolbar.set_scale(m_retina_helper->get_scale_factor());
|
||||||
|
const float scale = m_retina_helper->get_scale_factor() * wxGetApp().toolbar_icon_scale(true);
|
||||||
|
m_toolbar.set_scale(scale); //! #ys_FIXME_experiment
|
||||||
#else
|
#else
|
||||||
// m_toolbar.set_scale(m_canvas->GetContentScaleFactor());
|
// m_toolbar.set_scale(m_canvas->GetContentScaleFactor());
|
||||||
m_toolbar.set_scale(wxGetApp().em_unit()*0.1f);//! #ys_FIXME_experiment
|
// m_toolbar.set_scale(wxGetApp().em_unit()*0.1f);
|
||||||
|
const float size = int(GLToolbar::Default_Icons_Size * wxGetApp().toolbar_icon_scale(true));
|
||||||
|
m_toolbar.set_icons_size(size); //! #ys_FIXME_experiment
|
||||||
#endif // ENABLE_RETINA_GL
|
#endif // ENABLE_RETINA_GL
|
||||||
|
|
||||||
Size cnv_size = get_canvas_size();
|
Size cnv_size = get_canvas_size();
|
||||||
@ -4174,10 +4179,14 @@ void GLCanvas3D::_render_view_toolbar() const
|
|||||||
{
|
{
|
||||||
#if ENABLE_SVG_ICONS
|
#if ENABLE_SVG_ICONS
|
||||||
#if ENABLE_RETINA_GL
|
#if ENABLE_RETINA_GL
|
||||||
m_view_toolbar.set_scale(m_retina_helper->get_scale_factor());
|
// m_view_toolbar.set_scale(m_retina_helper->get_scale_factor());
|
||||||
|
const float scale = m_retina_helper->get_scale_factor() * wxGetApp().toolbar_icon_scale();
|
||||||
|
m_view_toolbar.set_scale(scale); //! #ys_FIXME_experiment
|
||||||
#else
|
#else
|
||||||
// m_view_toolbar.set_scale(m_canvas->GetContentScaleFactor());
|
// m_view_toolbar.set_scale(m_canvas->GetContentScaleFactor());
|
||||||
m_view_toolbar.set_scale(wxGetApp().em_unit()*0.1f); //! #ys_FIXME_experiment
|
// m_view_toolbar.set_scale(wxGetApp().em_unit()*0.1f);
|
||||||
|
const float size = int(GLGizmosManager::Default_Icons_Size * wxGetApp().toolbar_icon_scale());
|
||||||
|
m_view_toolbar.set_icons_size(size); //! #ys_FIXME_experiment
|
||||||
#endif // ENABLE_RETINA_GL
|
#endif // ENABLE_RETINA_GL
|
||||||
|
|
||||||
Size cnv_size = get_canvas_size();
|
Size cnv_size = get_canvas_size();
|
||||||
|
@ -123,7 +123,7 @@ BackgroundTexture::Metadata::Metadata()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_SVG_ICONS
|
#if ENABLE_SVG_ICONS
|
||||||
const float GLToolbar::Default_Icons_Size = 64.0f;
|
const float GLToolbar::Default_Icons_Size = 40.0f;
|
||||||
#endif // ENABLE_SVG_ICONS
|
#endif // ENABLE_SVG_ICONS
|
||||||
|
|
||||||
GLToolbar::Layout::Layout()
|
GLToolbar::Layout::Layout()
|
||||||
|
@ -390,6 +390,27 @@ void GUI_App::set_label_clr_sys(const wxColour& clr) {
|
|||||||
app_config->save();
|
app_config->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float GUI_App::toolbar_icon_scale(const bool is_limited/* = false*/) const
|
||||||
|
{
|
||||||
|
#ifdef __APPLE__
|
||||||
|
const float icon_sc = 1.0f; // for Retina display will be used its own scale
|
||||||
|
#else
|
||||||
|
const float icon_sc = m_em_unit*0.1f;
|
||||||
|
#endif // __APPLE__
|
||||||
|
|
||||||
|
const std::string& use_val = app_config->get("use_custom_toolbar_size");
|
||||||
|
const std::string& val = app_config->get("custom_toolbar_size");
|
||||||
|
|
||||||
|
if (val.empty() || use_val.empty() || use_val == "0")
|
||||||
|
return icon_sc;
|
||||||
|
|
||||||
|
int int_val = atoi(val.c_str());
|
||||||
|
if (is_limited && int_val < 50)
|
||||||
|
int_val = 50;
|
||||||
|
|
||||||
|
return 0.01f * int_val * icon_sc;
|
||||||
|
}
|
||||||
|
|
||||||
void GUI_App::recreate_GUI()
|
void GUI_App::recreate_GUI()
|
||||||
{
|
{
|
||||||
// Weird things happen as the Paint messages are floating around the windows being destructed.
|
// Weird things happen as the Paint messages are floating around the windows being destructed.
|
||||||
|
@ -115,6 +115,7 @@ public:
|
|||||||
const wxFont& normal_font() { return m_normal_font; }
|
const wxFont& normal_font() { return m_normal_font; }
|
||||||
size_t em_unit() const { return m_em_unit; }
|
size_t em_unit() const { return m_em_unit; }
|
||||||
void set_em_unit(const size_t em_unit) { m_em_unit = em_unit; }
|
void set_em_unit(const size_t em_unit) { m_em_unit = em_unit; }
|
||||||
|
float toolbar_icon_scale(const bool is_limited = false) const;
|
||||||
|
|
||||||
void recreate_GUI();
|
void recreate_GUI();
|
||||||
void system_info();
|
void system_info();
|
||||||
|
@ -18,8 +18,13 @@ void PreferencesDialog::build()
|
|||||||
auto app_config = get_app_config();
|
auto app_config = get_app_config();
|
||||||
m_optgroup = std::make_shared<ConfigOptionsGroup>(this, _(L("General")));
|
m_optgroup = std::make_shared<ConfigOptionsGroup>(this, _(L("General")));
|
||||||
m_optgroup->label_width = 40;
|
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";
|
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
|
// TODO
|
||||||
@ -109,6 +114,16 @@ void PreferencesDialog::build()
|
|||||||
m_optgroup->append_single_option_line(option);
|
m_optgroup->append_single_option_line(option);
|
||||||
#endif
|
#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);
|
auto sizer = new wxBoxSizer(wxVERTICAL);
|
||||||
sizer->Add(m_optgroup->sizer, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10);
|
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();
|
m_optgroup->msw_rescale();
|
||||||
|
|
||||||
|
msw_buttons_rescale(this, em_unit(), { wxID_OK, wxID_CANCEL });
|
||||||
|
|
||||||
|
layout();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreferencesDialog::layout()
|
||||||
|
{
|
||||||
const int em = em_unit();
|
const int em = em_unit();
|
||||||
|
|
||||||
msw_buttons_rescale(this, em, { wxID_OK, wxID_CANCEL });
|
SetMinSize(wxSize(47 * em, 28 * em));
|
||||||
|
|
||||||
const wxSize& size = wxSize(47 * em, 28 * em);
|
|
||||||
|
|
||||||
SetMinSize(size);
|
|
||||||
Fit();
|
Fit();
|
||||||
|
|
||||||
Refresh();
|
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
|
} // GUI
|
||||||
} // Slic3r
|
} // Slic3r
|
@ -16,6 +16,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;
|
||||||
public:
|
public:
|
||||||
PreferencesDialog(wxWindow* parent);
|
PreferencesDialog(wxWindow* parent);
|
||||||
~PreferencesDialog() {}
|
~PreferencesDialog() {}
|
||||||
@ -25,6 +26,8 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void on_dpi_changed(const wxRect &suggested_rect) override;
|
void on_dpi_changed(const wxRect &suggested_rect) override;
|
||||||
|
void layout();
|
||||||
|
void create_icon_size_slider();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // GUI
|
} // GUI
|
||||||
|
Loading…
Reference in New Issue
Block a user