Merge branch 'master' of https://github.com/prusa3d/PrusaSlicer into et_experiments

This commit is contained in:
Enrico Turri 2019-05-24 08:22:53 +02:00
commit 302ac3a849
15 changed files with 231 additions and 36 deletions

Binary file not shown.

View File

@ -0,0 +1,12 @@
NotoSans-Regular.ttf
--------------------
Name: Noto Sans Regular. Version 2.000;GOOG;noto-source:20170915:90ef993387c0; ttfautohint (v1.7)
It was designed by Monotype Design Team Manufacturer: Monotype Imaging Inc.
© Copyright 2015 Google Inc. All Rights Reserved.
License: This Font Software is licensed under the SIL Open Font License, Version 1.1. This Font Software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the SIL Open Font License for the specific language, permissions and limitations governing your use of this Font Software.
Supported languages: Afrikaans Albanian Azerbaijani Belarusian Bosnian Bulgarian Catalan Croatian Czech Danish Dutch English Estonian Finnish French German Greek Hungarian Icelandic Italian Latvian Lithuanian Macedonian Maltese Norwegian Ossetic Polish Portugese Romanian Russian Serbian Slovak Slovenian Spanisch Swedish Turkish Ukrainian Uzbek Vietnamese Zulu
NotoSansCJK-Regular.ttc
-----------------------
Noto Sans CJK and Noto Serif CJK comprehensively cover Simplified Chinese, Traditional Chinese, Japanese, and Korean in a unified font family. This includes the full coverage of CJK Ideographs with variation support for 4 regions, Kangxi radicals, Japanese Kana, Korean Hangul, and other CJK symbols and letters in the Basic Multilingual Plane of Unicode. It also provides limited coverage of CJK Ideographs in Plane 2 of Unicode as necessary to support standards from China and Japan.
https://www.google.com/get/noto/help/cjk/

View File

@ -425,7 +425,10 @@ SLAPrint::ApplyStatus SLAPrint::apply(const Model &model, const DynamicPrintConf
print_object->set_trafo(sla_trafo(*this, model_object), model_object.instances.front()->is_left_handed()); print_object->set_trafo(sla_trafo(*this, model_object), model_object.instances.front()->is_left_handed());
print_object->set_instances(std::move(new_instances)); print_object->set_instances(std::move(new_instances));
print_object->config_apply(config, true);
SLAPrintObjectConfig new_config = m_default_object_config;
normalize_and_apply_config(new_config, model_object.config);
print_object->config_apply(new_config, true);
print_objects_new.emplace_back(print_object); print_objects_new.emplace_back(print_object);
new_objects = true; new_objects = true;
} }

View File

@ -12,8 +12,8 @@ PRODUCTVERSION @SLIC3R_RC_VERSION@
VALUE "ProductName", "@SLIC3R_APP_NAME@" VALUE "ProductName", "@SLIC3R_APP_NAME@"
VALUE "ProductVersion", "@SLIC3R_BUILD_ID@" VALUE "ProductVersion", "@SLIC3R_BUILD_ID@"
VALUE "InternalName", "@SLIC3R_APP_NAME@" VALUE "InternalName", "@SLIC3R_APP_NAME@"
VALUE "LegalCopyright", "Copyright \251 2011-2019 Alessandro Ranelucci, \251 2016-2019 Prusa Research" VALUE "LegalCopyright", "Copyright \251 2016-2019 Prusa Research, \251 2011-2018 Alessandro Ranelucci"
VALUE "OriginalFilename", "slic3r.exe" VALUE "OriginalFilename", "prusa-slicer.exe"
} }
} }
BLOCK "VarFileInfo" BLOCK "VarFileInfo"

View File

@ -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");

View File

@ -1266,6 +1266,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
} }
@ -3443,9 +3445,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);
@ -4122,10 +4121,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);
@ -4135,10 +4138,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();
@ -4199,10 +4206,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();

View File

@ -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()

View File

@ -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.

View File

@ -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();

View File

@ -355,8 +355,8 @@ DynamicPrintConfig& ObjectList::get_item_config(const wxDataViewItem& item) cons
const int vol_idx = type & itVolume ? m_objects_model->GetVolumeIdByItem(item) : -1; const int vol_idx = type & itVolume ? m_objects_model->GetVolumeIdByItem(item) : -1;
assert(obj_idx >= 0 || ((type & itVolume) && vol_idx >=0)); assert(obj_idx >= 0 || ((type & itVolume) && vol_idx >=0));
return type & itObject|itInstance ? (*m_objects)[obj_idx]->config : return type & itVolume ?(*m_objects)[obj_idx]->volumes[vol_idx]->config :
(*m_objects)[obj_idx]->volumes[vol_idx]->config; (*m_objects)[obj_idx]->config;
} }
wxDataViewColumn* ObjectList::create_objects_list_extruder_column(int extruders_count) wxDataViewColumn* ObjectList::create_objects_list_extruder_column(int extruders_count)

View File

@ -28,6 +28,7 @@ namespace GUI {
ImGuiWrapper::ImGuiWrapper() ImGuiWrapper::ImGuiWrapper()
: m_glyph_ranges(nullptr) : m_glyph_ranges(nullptr)
, m_font_cjk(false)
, m_font_size(18.0) , m_font_size(18.0)
, m_font_texture(0) , m_font_texture(0)
, m_style_scaling(1.0) , m_style_scaling(1.0)
@ -68,16 +69,52 @@ void ImGuiWrapper::set_language(const std::string &language)
0x0100, 0x017F, // Latin Extended-A 0x0100, 0x017F, // Latin Extended-A
0, 0,
}; };
static const ImWchar ranges_turkish[] = {
0x0020, 0x01FF, // Basic Latin + Latin Supplement
0x0100, 0x017F, // Latin Extended-A
0x0180, 0x01FF, // Turkish
0,
};
static const ImWchar ranges_vietnamese[] =
{
0x0020, 0x00FF, // Basic Latin
0x0102, 0x0103,
0x0110, 0x0111,
0x0128, 0x0129,
0x0168, 0x0169,
0x01A0, 0x01A1,
0x01AF, 0x01B0,
0x1EA0, 0x1EF9,
0,
};
m_font_cjk = false;
if (lang == "cs" || lang == "pl") { if (lang == "cs" || lang == "pl") {
ranges = ranges_latin2; ranges = ranges_latin2;
} else if (lang == "ru" || lang == "uk") { } else if (lang == "ru" || lang == "uk") {
ranges = ImGui::GetIO().Fonts->GetGlyphRangesCyrillic(); ranges = ImGui::GetIO().Fonts->GetGlyphRangesCyrillic(); // Default + about 400 Cyrillic characters
} else if (lang == "tr") {
ranges = ranges_turkish;
} else if (lang == "vi") {
ranges = ranges_vietnamese;
} else if (lang == "jp") { } else if (lang == "jp") {
ranges = ImGui::GetIO().Fonts->GetGlyphRangesJapanese(); ranges = ImGui::GetIO().Fonts->GetGlyphRangesJapanese(); // Default + Hiragana, Katakana, Half-Width, Selection of 1946 Ideographs
m_font_cjk = true;
} else if (lang == "ko") { } else if (lang == "ko") {
ranges = ImGui::GetIO().Fonts->GetGlyphRangesKorean(); ranges = ImGui::GetIO().Fonts->GetGlyphRangesKorean(); // Default + Korean characters
m_font_cjk = true;
} else if (lang == "zh") { } else if (lang == "zh") {
ranges = ImGui::GetIO().Fonts->GetGlyphRangesChineseSimplifiedCommon(); ranges = (language == "zh_TW") ?
// Traditional Chinese
// Default + Half-Width + Japanese Hiragana/Katakana + full set of about 21000 CJK Unified Ideographs
ImGui::GetIO().Fonts->GetGlyphRangesChineseFull() :
// Simplified Chinese
// Default + Half-Width + Japanese Hiragana/Katakana + set of 2500 CJK Unified Ideographs for common simplified Chinese
ImGui::GetIO().Fonts->GetGlyphRangesChineseSimplifiedCommon();
m_font_cjk = true;
} else if (lang == "th") {
ranges = ImGui::GetIO().Fonts->GetGlyphRangesThai(); // Default + Thai characters
} else {
ranges = ImGui::GetIO().Fonts->GetGlyphRangesDefault(); // Basic Latin, Extended Latin
} }
if (ranges != m_glyph_ranges) { if (ranges != m_glyph_ranges) {
@ -352,7 +389,9 @@ void ImGuiWrapper::init_font()
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
io.Fonts->Clear(); io.Fonts->Clear();
ImFont* font = io.Fonts->AddFontFromFileTTF((Slic3r::resources_dir() + "/fonts/NotoSans-Regular.ttf").c_str(), m_font_size, nullptr, m_glyph_ranges); //FIXME replace with io.Fonts->AddFontFromMemoryTTF(buf_decompressed_data, (int)buf_decompressed_size, m_font_size, nullptr, m_glyph_ranges);
//https://github.com/ocornut/imgui/issues/220
ImFont* font = io.Fonts->AddFontFromFileTTF((Slic3r::resources_dir() + "/fonts/" + (m_font_cjk ? "NotoSansCJK-Regular.ttc" : "NotoSans-Regular.ttf")).c_str(), m_font_size, nullptr, m_glyph_ranges);
if (font == nullptr) { if (font == nullptr) {
font = io.Fonts->AddFontDefault(); font = io.Fonts->AddFontDefault();
if (font == nullptr) { if (font == nullptr) {

View File

@ -19,6 +19,8 @@ namespace GUI {
class ImGuiWrapper class ImGuiWrapper
{ {
const ImWchar *m_glyph_ranges; const ImWchar *m_glyph_ranges;
// Chinese, Japanese, Korean
bool m_font_cjk;
float m_font_size; float m_font_size;
unsigned m_font_texture; unsigned m_font_texture;
float m_style_scaling; float m_style_scaling;

View File

@ -259,29 +259,45 @@ wxBitmapComboBox(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(15 *
if (preset_type == Slic3r::Preset::TYPE_FILAMENT) if (preset_type == Slic3r::Preset::TYPE_FILAMENT)
{ {
Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &event) { Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &event) {
if (extruder_idx < 0 || event.GetLogicalPosition(wxClientDC(this)).x > 24) { int shifl_Left = 0;
float scale = m_em_unit*0.1f;
#if defined(wxBITMAPCOMBOBOX_OWNERDRAWN_BASED)
shifl_Left = int(scale * 4 + 0.5f); // IMAGE_SPACING_RIGHT = 4 for wxBitmapComboBox -> Space left of image
#endif
int icon_right_pos = int(scale * (24+4) + 0.5);
int mouse_pos = event.GetLogicalPosition(wxClientDC(this)).x;
// if (extruder_idx < 0 || event.GetLogicalPosition(wxClientDC(this)).x > 24) {
if ( extruder_idx < 0 || mouse_pos < shifl_Left || mouse_pos > icon_right_pos ) {
// Let the combo box process the mouse click. // Let the combo box process the mouse click.
event.Skip(); event.Skip();
return; return;
} }
// Swallow the mouse click and open the color picker. // Swallow the mouse click and open the color picker.
// get current color
DynamicPrintConfig* cfg = wxGetApp().get_tab(Preset::TYPE_PRINTER)->get_config();
auto colors = static_cast<ConfigOptionStrings*>(cfg->option("extruder_colour")->clone());
wxColour clr(colors->values[extruder_idx]);
if (!clr.IsOk())
clr = wxTransparentColour;
auto data = new wxColourData(); auto data = new wxColourData();
data->SetChooseFull(1); data->SetChooseFull(1);
auto dialog = new wxColourDialog(/* wxGetApp().mainframe */this, data); data->SetColour(clr);
dialog->CenterOnParent();
if (dialog->ShowModal() == wxID_OK) {
DynamicPrintConfig cfg = *wxGetApp().get_tab(Preset::TYPE_PRINTER)->get_config();
//FIXME this is too expensive to call full_config to get just the extruder color! auto dialog = new wxColourDialog(this, data);
auto colors = static_cast<ConfigOptionStrings*>(wxGetApp().preset_bundle->full_config().option("extruder_colour")->clone()); dialog->CenterOnParent();
if (dialog->ShowModal() == wxID_OK)
{
colors->values[extruder_idx] = dialog->GetColourData().GetColour().GetAsString(wxC2S_HTML_SYNTAX); colors->values[extruder_idx] = dialog->GetColourData().GetColour().GetAsString(wxC2S_HTML_SYNTAX);
cfg.set_key_value("extruder_colour", colors); DynamicPrintConfig cfg_new = *cfg;
cfg_new.set_key_value("extruder_colour", colors);
wxGetApp().get_tab(Preset::TYPE_PRINTER)->load_config(cfg); wxGetApp().get_tab(Preset::TYPE_PRINTER)->load_config(cfg_new);
wxGetApp().preset_bundle->update_platter_filament_ui(extruder_idx, this); wxGetApp().preset_bundle->update_platter_filament_ui(extruder_idx, this);
wxGetApp().plater()->on_config_change(cfg); wxGetApp().plater()->on_config_change(cfg_new);
} }
dialog->Destroy(); dialog->Destroy();
}); });

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();
} }
@ -18,8 +21,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 +117,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 +163,79 @@ 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);
wxWindow* parent = m_optgroup->ctrl_parent();
if (isOSX)
// For correct rendering of the slider and value label under OSX
// we should use system default background
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());
long style = wxSL_HORIZONTAL;
if (!isOSX)
style |= wxSL_LABELS | wxSL_AUTOTICKS;
auto slider = new wxSlider(parent, wxID_ANY, def_val, 30, 100,
wxDefaultPosition, wxDefaultSize, style);
slider->SetTickFreq(10);
slider->SetPageSize(10);
slider->SetToolTip(_(L("Select toolbar icon size in respect to the default one.")));
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();
if (val_label)
val_label->SetLabelText(wxString::Format("%d", val));
}), slider->GetId());
for (wxWindow* win : std::vector<wxWindow*>{ slider, label, val_label }) {
if (!win) continue;
win->SetFont(wxGetApp().normal_font());
if (isOSX) continue; // under OSX we use wxBG_STYLE_ERASE
win->SetBackgroundStyle(wxBG_STYLE_PAINT);
}
m_optgroup->sizer->Add(m_icon_size_sizer, 0, wxEXPAND | wxALL, em);
}
} // GUI } // GUI
} // Slic3r } // Slic3r

View File

@ -16,6 +16,8 @@ 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;
bool isOSX {false};
public: public:
PreferencesDialog(wxWindow* parent); PreferencesDialog(wxWindow* parent);
~PreferencesDialog() {} ~PreferencesDialog() {}
@ -25,6 +27,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