From fea655f668bd95185e6e3afe97c674ba59b2eccc Mon Sep 17 00:00:00 2001 From: YuSanka Date: Tue, 17 Oct 2023 14:17:12 +0200 Subject: [PATCH] Set max font size in respect to the display size. + non-MSW specific: Suppress colored border for focused control. + Fixed layout of the PointCtrl + WipeTowerDialog: use SpinInput control instead of wxSpinCtrl --- src/slic3r/GUI/Field.cpp | 9 ++++---- src/slic3r/GUI/Preferences.cpp | 13 ++++++++++- src/slic3r/GUI/Widgets/StaticBox.cpp | 6 +++++ src/slic3r/GUI/WipeTowerDialog.cpp | 34 +++++++++++++++------------- src/slic3r/GUI/WipeTowerDialog.hpp | 11 +++++---- 5 files changed, 47 insertions(+), 26 deletions(-) diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp index 9a8c0287c3..bf3aab1861 100644 --- a/src/slic3r/GUI/Field.cpp +++ b/src/slic3r/GUI/Field.cpp @@ -1528,8 +1528,9 @@ void PointCtrl::BUILD() y_textctrl->SetFont(Slic3r::GUI::wxGetApp().normal_font()); if (!wxOSX) y_textctrl->SetBackgroundStyle(wxBG_STYLE_PAINT); - auto static_text_x = new wxStaticText(m_parent, wxID_ANY, "x : "); - auto static_text_y = new wxStaticText(m_parent, wxID_ANY, " y : "); + wxSize label_sz = wxSize(int(field_size.x / 2), field_size.y); + auto static_text_x = new wxStaticText(m_parent, wxID_ANY, "x : ", wxDefaultPosition, label_sz, wxALIGN_RIGHT); + auto static_text_y = new wxStaticText(m_parent, wxID_ANY, "y : ", wxDefaultPosition, label_sz, wxALIGN_RIGHT); static_text_x->SetFont(Slic3r::GUI::wxGetApp().normal_font()); static_text_x->SetBackgroundStyle(wxBG_STYLE_PAINT); static_text_y->SetFont(Slic3r::GUI::wxGetApp().normal_font()); @@ -1540,9 +1541,9 @@ void PointCtrl::BUILD() wxGetApp().UpdateDarkUI(static_text_x, false, true); wxGetApp().UpdateDarkUI(static_text_y, false, true); - temp->Add(static_text_x, 0, wxALIGN_CENTER_VERTICAL, 0); + temp->Add(static_text_x); temp->Add(x_textctrl); - temp->Add(static_text_y, 0, wxALIGN_CENTER_VERTICAL, 0); + temp->Add(static_text_y); temp->Add(y_textctrl); x_textctrl->Bind(wxEVT_TEXT_ENTER, ([this](wxCommandEvent e) { propagate_value(x_textctrl); }), x_textctrl->GetId()); diff --git a/src/slic3r/GUI/Preferences.cpp b/src/slic3r/GUI/Preferences.cpp index f63b5e8ca5..e1fa4b07f6 100644 --- a/src/slic3r/GUI/Preferences.cpp +++ b/src/slic3r/GUI/Preferences.cpp @@ -1094,6 +1094,17 @@ void PreferencesDialog::create_settings_mode_color_widget() append_preferences_option_to_searcher(m_optgroup_gui, opt_key, title); } +static int get_max_font_pt_size() +{ + const unsigned disp_count = wxDisplay::GetCount(); + for (int i = 0; i < disp_count; i++) { + const wxRect display_rect = wxDisplay(i).GetGeometry(); + if (display_rect.width >= 2560 && display_rect.height >= 1440) + return 20; + } + return 15; +} + void PreferencesDialog::create_settings_font_widget() { wxWindow* parent = m_optgroup_other->parent(); @@ -1114,7 +1125,7 @@ void PreferencesDialog::create_settings_font_widget() #ifdef _WIN32 | wxBORDER_SIMPLE #endif - , 8, 20); + , 8, get_max_font_pt_size()); wxGetApp().UpdateDarkUI(size_sc); auto apply_font = [this, font_example, opt_key, stb_sizer](const int val, const wxFont& font) { diff --git a/src/slic3r/GUI/Widgets/StaticBox.cpp b/src/slic3r/GUI/Widgets/StaticBox.cpp index 29d5ff69e3..f2dd175f39 100644 --- a/src/slic3r/GUI/Widgets/StaticBox.cpp +++ b/src/slic3r/GUI/Widgets/StaticBox.cpp @@ -23,8 +23,14 @@ StaticBox::StaticBox() , radius(8) { border_color = StateColor(std::make_pair(clr_border_disabled, (int) StateColor::Disabled), +#ifndef __WXMSW__ + std::make_pair(clr_border_nornal, (int) StateColor::Focused), +#endif std::make_pair(clr_border_hovered, (int) StateColor::Hovered), std::make_pair(clr_border_nornal, (int) StateColor::Normal)); +#ifndef __WXMSW__ + border_color.setTakeFocusedAsHovered(false); +#endif } StaticBox::StaticBox(wxWindow* parent, diff --git a/src/slic3r/GUI/WipeTowerDialog.cpp b/src/slic3r/GUI/WipeTowerDialog.cpp index 51d77d7c9c..061245d52d 100644 --- a/src/slic3r/GUI/WipeTowerDialog.cpp +++ b/src/slic3r/GUI/WipeTowerDialog.cpp @@ -15,17 +15,20 @@ #include -int scale(const int val) { return val * Slic3r::GUI::wxGetApp().em_unit(); } +using namespace Slic3r::GUI; + +int scale(const int val) { return val * wxGetApp().em_unit(); } int ITEM_WIDTH() { return scale(6); } static void update_ui(wxWindow* window) { - Slic3r::GUI::wxGetApp().UpdateDarkUI(window); + wxGetApp().UpdateDarkUI(window); } RammingDialog::RammingDialog(wxWindow* parent,const std::string& parameters) : wxDialog(parent, wxID_ANY, _(L("Ramming customization")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE/* | wxRESIZE_BORDER*/) { + SetFont(wxGetApp().normal_font()); update_ui(this); m_panel_ramming = new RammingPanel(this,parameters); @@ -43,8 +46,8 @@ RammingDialog::RammingDialog(wxWindow* parent,const std::string& parameters) auto main_sizer = new wxBoxSizer(wxVERTICAL); main_sizer->Add(m_panel_ramming, 1, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, 5); auto buttons = CreateStdDialogButtonSizer(wxOK | wxCANCEL); - Slic3r::GUI::wxGetApp().SetWindowVariantForButton(buttons->GetAffirmativeButton()); - Slic3r::GUI::wxGetApp().SetWindowVariantForButton(buttons->GetCancelButton()); + wxGetApp().SetWindowVariantForButton(buttons->GetAffirmativeButton()); + wxGetApp().SetWindowVariantForButton(buttons->GetCancelButton()); main_sizer->Add(buttons, 0, wxALIGN_CENTER_HORIZONTAL | wxTOP | wxBOTTOM, 10); SetSizer(main_sizer); main_sizer->SetSizeHints(this); @@ -59,8 +62,7 @@ RammingDialog::RammingDialog(wxWindow* parent,const std::string& parameters) EndModal(wxID_OK); },wxID_OK); this->Show(); -// wxMessageDialog dlg(this, _(L("Ramming denotes the rapid extrusion just before a tool change in a single-extruder MM printer. Its purpose is to " - Slic3r::GUI::MessageDialog dlg(this, _(L("Ramming denotes the rapid extrusion just before a tool change in a single-extruder MM printer. Its purpose is to " + MessageDialog dlg(this, _(L("Ramming denotes the rapid extrusion just before a tool change in a single-extruder MM printer. Its purpose is to " "properly shape the end of the unloaded filament so it does not prevent insertion of the new filament and can itself " "be reinserted later. This phase is important and different materials can require different extrusion speeds to get " "the good shape. For this reason, the extrusion rates during ramming are adjustable.\n\nThis is an expert-level " @@ -108,9 +110,9 @@ RammingPanel::RammingPanel(wxWindow* parent, const std::string& parameters) sizer_chart->Add(m_chart, 0, wxALL, 5); m_widget_time = new wxSpinCtrlDouble(this,wxID_ANY,wxEmptyString,wxDefaultPosition,wxSize(ITEM_WIDTH(), -1),style,0.,5.0,3.,0.5); - m_widget_volume = new wxSpinCtrl(this,wxID_ANY,wxEmptyString,wxDefaultPosition,wxSize(ITEM_WIDTH(), -1),style,0,10000,0); - m_widget_ramming_line_width_multiplicator = new wxSpinCtrl(this,wxID_ANY,wxEmptyString,wxDefaultPosition,wxSize(ITEM_WIDTH(), -1),style,10,200,100); - m_widget_ramming_step_multiplicator = new wxSpinCtrl(this,wxID_ANY,wxEmptyString,wxDefaultPosition,wxSize(ITEM_WIDTH(), -1),style,10,200,100); + m_widget_volume = new ::SpinInput(this,"",wxEmptyString,wxDefaultPosition,wxSize(ITEM_WIDTH(), -1),style,0,10000,0); + m_widget_ramming_line_width_multiplicator = new ::SpinInput(this,"",wxEmptyString,wxDefaultPosition,wxSize(ITEM_WIDTH(), -1),style,10,200,100); + m_widget_ramming_step_multiplicator = new ::SpinInput(this,"",wxEmptyString,wxDefaultPosition,wxSize(ITEM_WIDTH(), -1),style,10,200,100); #ifdef _WIN32 update_ui(m_widget_time->GetText()); @@ -181,10 +183,11 @@ std::string RammingPanel::get_parameters() WipingDialog::WipingDialog(wxWindow* parent, const std::vector& matrix, const std::vector& extruders, const std::vector& extruder_colours) : wxDialog(parent, wxID_ANY, _(L("Wipe tower - Purging volume adjustment")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE/* | wxRESIZE_BORDER*/) { + SetFont(wxGetApp().normal_font()); update_ui(this); auto widget_button = new wxButton(this,wxID_ANY,"-",wxPoint(0,0),wxDefaultSize); update_ui(widget_button); - Slic3r::GUI::wxGetApp().SetWindowVariantForButton(widget_button); + wxGetApp().SetWindowVariantForButton(widget_button); m_panel_wiping = new WipingPanel(this,matrix,extruders, extruder_colours, widget_button); auto main_sizer = new wxBoxSizer(wxVERTICAL); @@ -196,8 +199,8 @@ WipingDialog::WipingDialog(wxWindow* parent, const std::vector& matrix, c main_sizer->Add(m_panel_wiping, 0, wxEXPAND | wxALL, 5); main_sizer->Add(widget_button, 0, wxALIGN_CENTER_HORIZONTAL | wxCENTER | wxBOTTOM, 5); auto buttons = CreateStdDialogButtonSizer(wxOK | wxCANCEL); - Slic3r::GUI::wxGetApp().SetWindowVariantForButton(buttons->GetAffirmativeButton()); - Slic3r::GUI::wxGetApp().SetWindowVariantForButton(buttons->GetCancelButton()); + wxGetApp().SetWindowVariantForButton(buttons->GetAffirmativeButton()); + wxGetApp().SetWindowVariantForButton(buttons->GetCancelButton()); main_sizer->Add(buttons, 0, wxALIGN_CENTER_HORIZONTAL | wxBOTTOM, 10); SetSizer(main_sizer); main_sizer->SetSizeHints(this); @@ -321,9 +324,9 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector& matrix, con gridsizer_simple->Add(new wxStaticText(m_page_simple, wxID_ANY, wxString(_(L("unloaded")))), 0, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL); gridsizer_simple->Add(new wxStaticText(m_page_simple,wxID_ANY,wxString(_(L("loaded")))), 0, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL); - auto add_spin_ctrl = [this](std::vector& vec, float initial) + auto add_spin_ctrl = [this](std::vector<::SpinInput*>& vec, float initial) { - wxSpinCtrl* spin_ctrl = new wxSpinCtrl(m_page_simple, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(ITEM_WIDTH(), -1), style | wxALIGN_RIGHT, 0, 300, (int)initial); + ::SpinInput* spin_ctrl = new ::SpinInput(m_page_simple, "", wxEmptyString, wxDefaultPosition, wxSize(ITEM_WIDTH(), -1), style | wxALIGN_RIGHT, 0, 300, (int)initial); update_ui(spin_ctrl); vec.push_back(spin_ctrl); @@ -451,8 +454,7 @@ bool WipingPanel::advanced_matches_simple() { // Switches the dialog from simple to advanced mode and vice versa void WipingPanel::toggle_advanced(bool user_action) { if (m_advanced && !advanced_matches_simple() && user_action) { -// if (wxMessageDialog(this,wxString(_(L("Switching to simple settings will discard changes done in the advanced mode!\n\nDo you want to proceed?"))), - if (Slic3r::GUI::MessageDialog(this, _L("Switching to simple settings will discard changes done in the advanced mode!\n\nDo you want to proceed?"), + if (MessageDialog(this, _L("Switching to simple settings will discard changes done in the advanced mode!\n\nDo you want to proceed?"), _L("Warning"),wxYES_NO|wxICON_EXCLAMATION).ShowModal() != wxID_YES) return; } diff --git a/src/slic3r/GUI/WipeTowerDialog.hpp b/src/slic3r/GUI/WipeTowerDialog.hpp index 7181a4fdf1..f64d1363a5 100644 --- a/src/slic3r/GUI/WipeTowerDialog.hpp +++ b/src/slic3r/GUI/WipeTowerDialog.hpp @@ -12,6 +12,7 @@ #include #include "RammingChart.hpp" +#include "Widgets/SpinInput.hpp" class RammingPanel : public wxPanel { @@ -22,9 +23,9 @@ public: private: Chart* m_chart = nullptr; - wxSpinCtrl* m_widget_volume = nullptr; - wxSpinCtrl* m_widget_ramming_line_width_multiplicator = nullptr; - wxSpinCtrl* m_widget_ramming_step_multiplicator = nullptr; + ::SpinInput* m_widget_volume = nullptr; + ::SpinInput* m_widget_ramming_line_width_multiplicator = nullptr; + ::SpinInput* m_widget_ramming_step_multiplicator = nullptr; wxSpinCtrlDouble* m_widget_time = nullptr; int m_ramming_step_multiplicator; int m_ramming_line_width_multiplicator; @@ -60,8 +61,8 @@ private: void fill_in_matrix(); bool advanced_matches_simple(); - std::vector m_old; - std::vector m_new; + std::vector<::SpinInput*> m_old; + std::vector<::SpinInput*> m_new; std::vector> edit_boxes; std::vector m_colours; unsigned int m_number_of_extruders = 0;