diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 1d4a53fd9..e03df09bb 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -1322,7 +1322,7 @@ bool GUI_App::on_init_inner() if (!delayed_error_load_presets.empty()) show_error(nullptr, delayed_error_load_presets); - mainframe = new MainFrame(); + mainframe = new MainFrame(app_config->has("font_size") ? atoi(app_config->get("font_size").c_str()) : -1); // hide settings tabs after first Layout if (is_editor()) mainframe->select_tab(size_t(0)); @@ -1810,7 +1810,7 @@ void GUI_App::recreate_GUI(const wxString& msg_name) dlg.Update(10, _L("Recreating") + dots); MainFrame *old_main_frame = mainframe; - mainframe = new MainFrame(); + mainframe = new MainFrame(app_config->has("font_size") ? atoi(app_config->get("font_size").c_str()) : -1); if (is_editor()) // hide settings tabs after first Layout mainframe->select_tab(size_t(0)); diff --git a/src/slic3r/GUI/GUI_Utils.hpp b/src/slic3r/GUI/GUI_Utils.hpp index 55ca43248..624e7e1a3 100644 --- a/src/slic3r/GUI/GUI_Utils.hpp +++ b/src/slic3r/GUI/GUI_Utils.hpp @@ -82,7 +82,7 @@ template class DPIAware : public P { public: DPIAware(wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &pos=wxDefaultPosition, - const wxSize &size=wxDefaultSize, long style=wxDEFAULT_FRAME_STYLE, const wxString &name=wxFrameNameStr) + const wxSize &size=wxDefaultSize, long style=wxDEFAULT_FRAME_STYLE, const wxString &name= wxFrameNameStr, const int font_point_size = -1) : P(parent, id, title, pos, size, style, name) { int dpi = get_dpi_for_window(this); @@ -90,6 +90,9 @@ public: m_prev_scale_factor = m_scale_factor; m_normal_font = get_default_font_for_dpi(this, dpi); + if (font_point_size > 0) + m_normal_font.SetPointSize(font_point_size); + /* Because of default window font is a primary display font, * We should set correct font for window before getting em_unit value. */ diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 0c7805db8..4c9e8332a 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -122,8 +122,8 @@ static wxIcon main_frame_icon(GUI_App::EAppMode app_mode) #endif // _WIN32 } -MainFrame::MainFrame() : -DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, "mainframe"), +MainFrame::MainFrame(const int font_point_size) : +DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, "mainframe", font_point_size), m_printhost_queue_dlg(new PrintHostQueueDialog(this)) , m_recent_projects(9) , m_settings_dialog(this) @@ -1540,6 +1540,7 @@ void MainFrame::init_menubar_as_editor() // assign menubar to frame after appending items, otherwise special items // will not be handled correctly m_menubar = new wxMenuBar(); + m_menubar->SetFont(this->normal_font()); m_menubar->Append(fileMenu, _L("&File")); if (editMenu) m_menubar->Append(editMenu, _L("&Edit")); m_menubar->Append(windowMenu, _L("&Window")); @@ -2237,7 +2238,7 @@ std::string MainFrame::get_dir_name(const wxString &full_name) const // ---------------------------------------------------------------------------- SettingsDialog::SettingsDialog(MainFrame* mainframe) -:DPIFrame(NULL, wxID_ANY, wxString(SLIC3R_APP_NAME) + " - " + _L("Settings"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, "settings_dialog"), +:DPIFrame(NULL, wxID_ANY, wxString(SLIC3R_APP_NAME) + " - " + _L("Settings"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, "settings_dialog", mainframe->normal_font().GetPointSize()), //: DPIDialog(mainframe, wxID_ANY, wxString(SLIC3R_APP_NAME) + " - " + _L("Settings"), wxDefaultPosition, wxDefaultSize, // wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMINIMIZE_BOX | wxMAXIMIZE_BOX, "settings_dialog"), m_main_frame(mainframe) diff --git a/src/slic3r/GUI/MainFrame.hpp b/src/slic3r/GUI/MainFrame.hpp index 78ec13f64..c9fa601e1 100644 --- a/src/slic3r/GUI/MainFrame.hpp +++ b/src/slic3r/GUI/MainFrame.hpp @@ -139,7 +139,7 @@ protected: virtual void on_sys_color_changed() override; public: - MainFrame(); + MainFrame(const int font_point_size); ~MainFrame() = default; void update_layout(); diff --git a/src/slic3r/GUI/MsgDialog.cpp b/src/slic3r/GUI/MsgDialog.cpp index 43e13841c..cce159903 100644 --- a/src/slic3r/GUI/MsgDialog.cpp +++ b/src/slic3r/GUI/MsgDialog.cpp @@ -136,7 +136,7 @@ static void add_msg_content(wxWindow* parent, wxBoxSizer* content_sizer, wxStrin msg_lines++; } - wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); + wxFont font = wxGetApp().normal_font();//wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); wxFont monospace = wxGetApp().code_font(); wxColour text_clr = wxGetApp().get_label_clr_default(); wxColour bgr_clr = parent->GetBackgroundColour(); diff --git a/src/slic3r/GUI/Preferences.cpp b/src/slic3r/GUI/Preferences.cpp index 492e3fc37..69b6fb5fe 100644 --- a/src/slic3r/GUI/Preferences.cpp +++ b/src/slic3r/GUI/Preferences.cpp @@ -4,6 +4,7 @@ #include "Plater.hpp" #include "MsgDialog.hpp" #include "I18N.hpp" +#include "format.hpp" #include "libslic3r/AppConfig.hpp" #include #include "Notebook.hpp" @@ -549,6 +550,7 @@ void PreferencesDialog::build() create_settings_mode_widget(); create_settings_text_color_widget(); create_settings_mode_color_widget(); +// create_settings_font_widget(); m_optgroup_other = create_options_tab(_L("Other"), tabs); m_optgroup_other->m_on_change = [this](t_config_option_key opt_key, boost::any value) { @@ -580,6 +582,7 @@ void PreferencesDialog::build() activate_options_tab(m_optgroup_other); create_downloader_path_sizer(); + create_settings_font_widget(); #if ENABLE_ENVIRONMENT_MAP // Add "Render" tab @@ -694,7 +697,7 @@ void PreferencesDialog::accept(wxEvent&) bool update_filament_sidebar = (m_values.find("no_templates") != m_values.end()); - std::vector options_to_recreate_GUI = { "no_defaults", "tabs_as_menu", "sys_menu_enabled" }; + std::vector options_to_recreate_GUI = { "no_defaults", "tabs_as_menu", "sys_menu_enabled", "font_size" }; for (const std::string& option : options_to_recreate_GUI) { if (m_values.find(option) != m_values.end()) { @@ -943,7 +946,6 @@ void PreferencesDialog::create_icon_size_slider() void PreferencesDialog::create_settings_mode_widget() { wxWindow* parent = m_optgroup_gui->parent(); - wxGetApp().UpdateDarkUI(parent); wxString title = L("Layout Options"); wxStaticBox* stb = new wxStaticBox(parent, wxID_ANY, _(title)); @@ -1045,6 +1047,74 @@ void PreferencesDialog::create_settings_mode_color_widget() append_preferences_option_to_searcher(m_optgroup_gui, opt_key, title); } +void PreferencesDialog::create_settings_font_widget() +{ + wxWindow* parent = m_optgroup_other->parent(); + wxGetApp().UpdateDarkUI(parent); + + const wxString title = L("Application font size"); + wxStaticBox* stb = new wxStaticBox(parent, wxID_ANY, _(title)); + if (!wxOSX) stb->SetBackgroundStyle(wxBG_STYLE_PAINT); + + const std::string opt_key = "font_size"; + m_blinkers[opt_key] = new BlinkingBitmap(parent); + + wxSizer* stb_sizer = new wxStaticBoxSizer(stb, wxHORIZONTAL); + + wxStaticText* font_example = new wxStaticText(parent, wxID_ANY, "Application text"); + int val = wxGetApp().normal_font().GetPointSize(); + wxSpinCtrl* size_sc = new wxSpinCtrl(parent, wxID_ANY, format_wxstr("%1%", val), wxDefaultPosition, wxSize(15*em_unit(), -1), wxTE_PROCESS_ENTER | wxSP_ARROW_KEYS +#ifdef _WIN32 + | wxBORDER_SIMPLE +#endif + , 8, 20); + wxGetApp().UpdateDarkUI(size_sc); + + auto apply_font = [this, font_example, opt_key](const int val, const wxFont& font) { + font_example->SetFont(font); + m_values[opt_key] = format("%1%", val); + refresh_og(m_optgroup_other); + }; + + auto change_value = [size_sc, apply_font](wxCommandEvent& evt) { + const int val = size_sc->GetValue(); + wxFont font = wxGetApp().normal_font(); + font.SetPointSize(val); + + apply_font(val, font); + }; + size_sc->Bind(wxEVT_SPINCTRL, change_value); + size_sc->Bind(wxEVT_TEXT_ENTER, change_value); + + auto revert_btn = new ScalableButton(parent, wxID_ANY, "undo"); + revert_btn->SetToolTip(_L("Revert font to default")); + revert_btn->Bind(wxEVT_BUTTON, [size_sc, apply_font](wxEvent& event) { + wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); + const int val = font.GetPointSize(); + size_sc->SetValue(val); + apply_font(val, font); + }); + parent->Bind(wxEVT_UPDATE_UI, [size_sc](wxUpdateUIEvent& evt) { + const int def_size = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).GetPointSize(); + evt.Enable(def_size != size_sc->GetValue()); + }, revert_btn->GetId()); + + stb_sizer->Add(new wxStaticText(parent, wxID_ANY, _L("Font size") + ":"), 0, wxALIGN_CENTER_VERTICAL | wxLEFT, em_unit()); + stb_sizer->Add(size_sc, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT | wxLEFT, em_unit()); + stb_sizer->Add(revert_btn, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, em_unit()); + wxBoxSizer* font_sizer = new wxBoxSizer(wxVERTICAL); + font_sizer->Add(font_example, 1, wxALIGN_CENTER_HORIZONTAL); + stb_sizer->Add(font_sizer, 1, wxALIGN_CENTER_VERTICAL); + + auto sizer = new wxBoxSizer(wxHORIZONTAL); + sizer->Add(m_blinkers[opt_key], 0, wxRIGHT, 2); + sizer->Add(stb_sizer, 1, wxALIGN_CENTER_VERTICAL); + + m_optgroup_other->sizer->Add(sizer, 1, wxEXPAND | wxTOP, em_unit()); + + append_preferences_option_to_searcer(m_optgroup_other, opt_key, title); +} + void PreferencesDialog::create_downloader_path_sizer() { wxWindow* parent = m_optgroup_other->parent(); diff --git a/src/slic3r/GUI/Preferences.hpp b/src/slic3r/GUI/Preferences.hpp index 4ae93f6f9..765447f89 100644 --- a/src/slic3r/GUI/Preferences.hpp +++ b/src/slic3r/GUI/Preferences.hpp @@ -91,10 +91,12 @@ protected: void layout(); void clear_cache(); void refresh_og(std::shared_ptr og); + void refresh_og(ConfigOptionsGroup* og); void create_icon_size_slider(); void create_settings_mode_widget(); void create_settings_text_color_widget(); void create_settings_mode_color_widget(); + void create_settings_font_widget(); void create_downloader_path_sizer(); void init_highlighter(const t_config_option_key& opt_key); std::vector optgroups(); diff --git a/src/slic3r/GUI/SavePresetDialog.cpp b/src/slic3r/GUI/SavePresetDialog.cpp index 09ae10207..a561a754e 100644 --- a/src/slic3r/GUI/SavePresetDialog.cpp +++ b/src/slic3r/GUI/SavePresetDialog.cpp @@ -311,11 +311,13 @@ SavePresetDialog::~SavePresetDialog() void SavePresetDialog::build(std::vector types, std::string suffix, bool template_filament) { + this->SetFont(wxGetApp().normal_font()); + #if defined(__WXMSW__) // ys_FIXME! temporary workaround for correct font scaling // Because of from wxWidgets 3.1.3 auto rescaling is implemented for the Fonts, // From the very beginning set dialog font to the wxSYS_DEFAULT_GUI_FONT - this->SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); +// this->SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); #else SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); #endif // __WXMSW__ diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 3fb7bf605..d31f48913 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -265,6 +265,7 @@ void Tab::create_preset_tab() // tree m_treectrl = new wxTreeCtrl(panel, wxID_ANY, wxDefaultPosition, wxSize(20 * m_em_unit, -1), wxTR_NO_BUTTONS | wxTR_HIDE_ROOT | wxTR_SINGLE | wxTR_NO_LINES | wxBORDER_SUNKEN | wxWANTS_CHARS); + m_treectrl->SetFont(wxGetApp().normal_font()); m_left_sizer->Add(m_treectrl, 1, wxEXPAND); // Index of the last icon inserted into m_treectrl m_icon_count = -1; diff --git a/src/slic3r/GUI/UnsavedChangesDialog.cpp b/src/slic3r/GUI/UnsavedChangesDialog.cpp index ad702c1b3..5220b2115 100644 --- a/src/slic3r/GUI/UnsavedChangesDialog.cpp +++ b/src/slic3r/GUI/UnsavedChangesDialog.cpp @@ -837,7 +837,8 @@ void UnsavedChangesDialog::build(Preset::Type type, PresetCollection* dependent_ // ys_FIXME! temporary workaround for correct font scaling // Because of from wxWidgets 3.1.3 auto rescaling is implemented for the Fonts, // From the very beginning set dialog font to the wxSYS_DEFAULT_GUI_FONT - this->SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); +// this->SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); + this->SetFont(wxGetApp().normal_font()); #endif // __WXMSW__ int border = 10; @@ -850,7 +851,8 @@ void UnsavedChangesDialog::build(Preset::Type type, PresetCollection* dependent_ add_new_value_column = false; m_action_line = new wxStaticText(this, wxID_ANY, ""); - m_action_line->SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).Bold()); +// m_action_line->SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).Bold()); + m_action_line->SetFont(wxGetApp().bold_font()); m_tree = new DiffViewCtrl(this, wxSize(em * (add_new_value_column ? 80 : 60), em * 30)); m_tree->AppendToggleColumn_(L"\u2714" , DiffModel::colToggle, wxLinux ? 9 : 6); @@ -910,7 +912,8 @@ void UnsavedChangesDialog::build(Preset::Type type, PresetCollection* dependent_ cancel_btn->Bind(wxEVT_BUTTON, [this](wxEvent&) { this->EndModal(wxID_CANCEL); }); m_info_line = new wxStaticText(this, wxID_ANY, ""); - m_info_line->SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).Bold()); +// m_info_line->SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).Bold()); + m_info_line->SetFont(wxGetApp().bold_font()); m_info_line->Hide(); if (!m_app_config_key.empty()) { @@ -1362,6 +1365,7 @@ FullCompareDialog::FullCompareDialog(const wxString& option_name, const wxString : wxDialog(nullptr, wxID_ANY, option_name, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) { wxGetApp().UpdateDarkUI(this); + this->SetFont(wxGetApp().normal_font()); int border = 10; bool has_new_value_column = !new_value_header.IsEmpty(); @@ -1528,7 +1532,8 @@ void DiffPresetDialog::create_show_all_presets_chb() void DiffPresetDialog::create_info_lines() { - const wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).Bold(); +// const wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).Bold(); + const wxFont font = GetFont().Bold(); m_top_info_line = new wxStaticText(this, wxID_ANY, _L("Select presets to compare")); m_top_info_line->SetFont(font); @@ -1668,7 +1673,8 @@ DiffPresetDialog::DiffPresetDialog(MainFrame* mainframe) // ys_FIXME! temporary workaround for correct font scaling // Because of from wxWidgets 3.1.3 auto rescaling is implemented for the Fonts, // From the very beginning set dialog font to the wxSYS_DEFAULT_GUI_FONT - this->SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); +// this->SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); + this->SetFont(mainframe->normal_font()); #endif // __WXMSW__ // Init bundles