From 0f0c9a0726cc7a6cb1e180df5d1e730a73ea6489 Mon Sep 17 00:00:00 2001 From: YuSanka <yusanka@gmail.com> Date: Thu, 3 Sep 2020 10:44:54 +0200 Subject: [PATCH 1/8] OSX specific: UnsavedChangesDialog: Fixed strange ellipsis for items in DataViewCtrl --- src/slic3r/GUI/UnsavedChangesDialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/slic3r/GUI/UnsavedChangesDialog.cpp b/src/slic3r/GUI/UnsavedChangesDialog.cpp index f30e719ce..5a0d23a20 100644 --- a/src/slic3r/GUI/UnsavedChangesDialog.cpp +++ b/src/slic3r/GUI/UnsavedChangesDialog.cpp @@ -531,7 +531,7 @@ void UnsavedChangesDialog::build(Preset::Type type, PresetCollection* dependent_ wxColour bgr_clr = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); SetBackgroundColour(bgr_clr); -#if ENABLE_WX_3_1_3_DPI_CHANGED_EVENT +#if ENABLE_WX_3_1_3_DPI_CHANGED_EVENT && 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 From c49221c6217b787785807284bb6a7164395abe62 Mon Sep 17 00:00:00 2001 From: YuSanka <yusanka@gmail.com> Date: Thu, 3 Sep 2020 15:40:14 +0200 Subject: [PATCH 2/8] Fix of Settings scaling when they are placed in non-modal Dialog --- src/slic3r/GUI/GUI_Utils.hpp | 9 ++++++++- src/slic3r/GUI/MainFrame.cpp | 10 +++++++++- src/slic3r/GUI/PresetComboBoxes.cpp | 2 +- src/slic3r/GUI/Tab.cpp | 2 +- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/slic3r/GUI/GUI_Utils.hpp b/src/slic3r/GUI/GUI_Utils.hpp index 96b24524c..749a556b8 100644 --- a/src/slic3r/GUI/GUI_Utils.hpp +++ b/src/slic3r/GUI/GUI_Utils.hpp @@ -218,7 +218,7 @@ private: void rescale(const wxRect &suggested_rect) { this->Freeze(); - +/* #if wxVERSION_EQUAL_OR_GREATER_THAN(3,1,3) if (m_force_rescale) { #endif // wxVERSION_EQUAL_OR_GREATER_THAN @@ -230,6 +230,13 @@ private: m_force_rescale = false; } #endif // wxVERSION_EQUAL_OR_GREATER_THAN +*/ +#if !wxVERSION_EQUAL_OR_GREATER_THAN(3,1,3) + // rescale fonts of all controls + scale_controls_fonts(this, m_new_font_point_size); + // rescale current window font + scale_win_font(this, m_new_font_point_size); +#endif // wxVERSION_EQUAL_OR_GREATER_THAN // set normal application font as a current window font m_normal_font = this->GetFont(); diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index bab5d7502..191e6c455 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -787,9 +787,10 @@ void MainFrame::on_dpi_changed(const wxRect& suggested_rect) this->SetSize(sz); this->Maximize(is_maximized); - +/* if (m_layout == ESettingsLayout::Dlg) rescale_dialog_after_dpi_change(*this, m_settings_dialog, ERescaleTarget::SettingsDialog); + */ } void MainFrame::on_sys_color_changed() @@ -1988,7 +1989,14 @@ SettingsDialog::SettingsDialog(MainFrame* mainframe) wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMINIMIZE_BOX | wxMAXIMIZE_BOX, "settings_dialog"), m_main_frame(mainframe) { +#if ENABLE_WX_3_1_3_DPI_CHANGED_EVENT && 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)); +#else this->SetFont(wxGetApp().normal_font()); +#endif // ENABLE_WX_3_1_3_DPI_CHANGED_EVENT this->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); diff --git a/src/slic3r/GUI/PresetComboBoxes.cpp b/src/slic3r/GUI/PresetComboBoxes.cpp index 7300a2887..8bc939387 100644 --- a/src/slic3r/GUI/PresetComboBoxes.cpp +++ b/src/slic3r/GUI/PresetComboBoxes.cpp @@ -1194,7 +1194,7 @@ SavePresetDialog::~SavePresetDialog() void SavePresetDialog::build(std::vector<Preset::Type> types, std::string suffix) { SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); -#if ENABLE_WX_3_1_3_DPI_CHANGED_EVENT +#if ENABLE_WX_3_1_3_DPI_CHANGED_EVENT && 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 diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index b95227dad..29c9e3302 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -102,7 +102,7 @@ Tab::Tab(wxNotebook* parent, const wxString& title, Preset::Type type) : wxGetApp().tabs_list.push_back(this); - m_em_unit = wxGetApp().em_unit(); + m_em_unit = em_unit(m_parent); //wxGetApp().em_unit(); m_config_manipulation = get_config_manipulation(); From ba87a4fd9a607fd0ed7f60241a25884ff0d6d61b Mon Sep 17 00:00:00 2001 From: YuSanka <yusanka@gmail.com> Date: Fri, 4 Sep 2020 10:08:54 +0200 Subject: [PATCH 3/8] Fixed rescale of the MainFrame/SettingsDialog after switching between settings layouts on the 2 monitors with different DPI --- src/slic3r/GUI/GUI_Utils.hpp | 1 + src/slic3r/GUI/MainFrame.cpp | 40 +++++++++++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/GUI_Utils.hpp b/src/slic3r/GUI/GUI_Utils.hpp index 749a556b8..6a93d4156 100644 --- a/src/slic3r/GUI/GUI_Utils.hpp +++ b/src/slic3r/GUI/GUI_Utils.hpp @@ -231,6 +231,7 @@ private: } #endif // wxVERSION_EQUAL_OR_GREATER_THAN */ + m_force_rescale = false; #if !wxVERSION_EQUAL_OR_GREATER_THAN(3,1,3) // rescale fonts of all controls scale_controls_fonts(this, m_new_font_point_size); diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 191e6c455..ac6f541e7 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -310,8 +310,10 @@ void MainFrame::update_layout() m_plater_page = nullptr; } + /* if (m_layout == ESettingsLayout::Dlg) rescale_dialog_after_dpi_change(*this, m_settings_dialog, ERescaleTarget::Mainframe); + */ clean_sizer(m_main_sizer); clean_sizer(m_settings_dialog.GetSizer()); @@ -347,6 +349,14 @@ void MainFrame::update_layout() if (m_layout != ESettingsLayout::Unknown) restore_to_creation(); + enum class State { + noUpdate, + fromDlg, + toDlg + }; + State update_scaling_state = m_layout == ESettingsLayout::Dlg ? State::fromDlg : + layout == ESettingsLayout::Dlg ? State::toDlg : State::noUpdate; + m_layout = layout; // From the very beginning the Print settings should be selected @@ -384,7 +394,7 @@ void MainFrame::update_layout() m_tabpanel->Reparent(&m_settings_dialog); m_settings_dialog.GetSizer()->Add(m_tabpanel, 1, wxEXPAND); - rescale_dialog_after_dpi_change(*this, m_settings_dialog, ERescaleTarget::SettingsDialog); +// rescale_dialog_after_dpi_change(*this, m_settings_dialog, ERescaleTarget::SettingsDialog); m_tabpanel->Show(); m_plater->Show(); @@ -400,6 +410,34 @@ void MainFrame::update_layout() #endif // ENABLE_GCODE_VIEWER } + if (update_scaling_state != State::noUpdate) + { + int mainframe_dpi = get_dpi_for_window(this); + int dialog_dpi = get_dpi_for_window(&m_settings_dialog); + if (mainframe_dpi != dialog_dpi) { + wxSize oldDPI = update_scaling_state == State::fromDlg ? wxSize(dialog_dpi, dialog_dpi) : wxSize(mainframe_dpi, mainframe_dpi); + wxSize newDPI = update_scaling_state == State::toDlg ? wxSize(dialog_dpi, dialog_dpi) : wxSize(mainframe_dpi, mainframe_dpi); + + if (update_scaling_state == State::fromDlg) + this->enable_force_rescale(); + else + (&m_settings_dialog)->enable_force_rescale(); + + wxWindow* win { nullptr }; + if (update_scaling_state == State::fromDlg) + win = this; + else + win = &m_settings_dialog; + +#if wxVERSION_EQUAL_OR_GREATER_THAN(3,1,3) + m_tabpanel->MSWUpdateOnDPIChange(oldDPI, newDPI); + win->GetEventHandler()->AddPendingEvent(wxDPIChangedEvent(oldDPI, newDPI)); +#else + win->GetEventHandler()->AddPendingEvent(DpiChangedEvent(EVT_DPI_CHANGED_SLICER, newDPI, win->GetRect())); +#endif // wxVERSION_EQUAL_OR_GREATER_THAN + } + } + //#ifdef __APPLE__ // // Using SetMinSize() on Mac messes up the window position in some cases // // cf. https://groups.google.com/forum/#!topic/wx-users/yUKPBBfXWO0 From 436e12e99f9d516896f156176d99b6a8a3ad246e Mon Sep 17 00:00:00 2001 From: Lukas Matena <lukasmatena@seznam.cz> Date: Fri, 4 Sep 2020 12:46:34 +0200 Subject: [PATCH 4/8] Seam gizmo: fixed action names in undo/redo stack --- src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.cpp | 7 ++++ src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.hpp | 1 + src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp | 37 ++++++++++++++++---- src/slic3r/GUI/Gizmos/GLGizmoPainterBase.hpp | 5 +++ src/slic3r/GUI/Gizmos/GLGizmoSeam.cpp | 7 ++++ src/slic3r/GUI/Gizmos/GLGizmoSeam.hpp | 1 + 6 files changed, 51 insertions(+), 7 deletions(-) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.cpp b/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.cpp index af1517637..6b3456b60 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.cpp @@ -285,5 +285,12 @@ void GLGizmoFdmSupports::update_from_model_object() } + +PainterGizmoType GLGizmoFdmSupports::get_painter_type() const +{ + return PainterGizmoType::FDM_SUPPORTS; +} + + } // namespace GUI } // namespace Slic3r diff --git a/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.hpp b/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.hpp index 913133617..0c39992f0 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.hpp @@ -27,6 +27,7 @@ private: void on_opening() override {} void on_shutdown() override; + PainterGizmoType get_painter_type() const override; void select_facets_by_angle(float threshold, bool block); float m_angle_threshold_deg = 45.f; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp b/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp index 1809b417c..ed98bf71d 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp @@ -28,13 +28,19 @@ GLGizmoPainterBase::GLGizmoPainterBase(GLCanvas3D& parent, const std::string& ic void GLGizmoPainterBase::activate_internal_undo_redo_stack(bool activate) { if (activate && ! m_internal_stack_active) { - Plater::TakeSnapshot(wxGetApp().plater(), _L("FDM gizmo turned on")); + wxString str = get_painter_type() == PainterGizmoType::FDM_SUPPORTS + ? _L("Supports gizmo turned on") + : _L("Seam gizmo turned on"); + Plater::TakeSnapshot(wxGetApp().plater(), str); wxGetApp().plater()->enter_gizmos_stack(); m_internal_stack_active = true; } if (! activate && m_internal_stack_active) { + wxString str = get_painter_type() == PainterGizmoType::SEAM + ? _L("Seam gizmo turned off") + : _L("Supports gizmo turned off"); wxGetApp().plater()->leave_gizmos_stack(); - Plater::TakeSnapshot(wxGetApp().plater(), _L("FDM gizmo turned off")); + Plater::TakeSnapshot(wxGetApp().plater(), str); m_internal_stack_active = false; } } @@ -356,11 +362,28 @@ bool GLGizmoPainterBase::gizmo_event(SLAGizmoEventType action, const Vec2d& mous if ((action == SLAGizmoEventType::LeftUp || action == SLAGizmoEventType::RightUp) && m_button_down != Button::None) { // Take snapshot and update ModelVolume data. - wxString action_name = shift_down - ? _L("Remove selection") - : (m_button_down == Button::Left - ? _L("Add supports") - : _L("Block supports")); + wxString action_name; + if (get_painter_type() == PainterGizmoType::FDM_SUPPORTS) { + if (shift_down) + action_name = _L("Remove selection"); + else { + if (m_button_down == Button::Left) + action_name = _L("Add supports"); + else + action_name = _L("Block supports"); + } + } + if (get_painter_type() == PainterGizmoType::SEAM) { + if (shift_down) + action_name = _L("Remove selection"); + else { + if (m_button_down == Button::Left) + action_name = _L("Enforce seam"); + else + action_name = _L("Block seam"); + } + } + activate_internal_undo_redo_stack(true); Plater::TakeSnapshot(wxGetApp().plater(), action_name); update_model_object(); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.hpp b/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.hpp index da9b37895..b3e2b65f1 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.hpp @@ -22,6 +22,10 @@ namespace GUI { enum class SLAGizmoEventType : unsigned char; class ClippingPlane; +enum class PainterGizmoType { + FDM_SUPPORTS, + SEAM +}; class TriangleSelectorGUI : public TriangleSelector { @@ -103,6 +107,7 @@ protected: virtual void on_opening() = 0; virtual void on_shutdown() = 0; + virtual PainterGizmoType get_painter_type() const = 0; bool on_is_activable() const override; bool on_is_selectable() const override; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSeam.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSeam.cpp index 3c7d180a7..d0edfba13 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSeam.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSeam.cpp @@ -204,5 +204,12 @@ void GLGizmoSeam::update_from_model_object() } +PainterGizmoType GLGizmoSeam::get_painter_type() const +{ + return PainterGizmoType::SEAM; +} + + + } // namespace GUI } // namespace Slic3r diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSeam.hpp b/src/slic3r/GUI/Gizmos/GLGizmoSeam.hpp index 469ec9180..c3eb98c80 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSeam.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSeam.hpp @@ -16,6 +16,7 @@ public: protected: void on_render_input_window(float x, float y, float bottom_limit) override; std::string on_get_name() const override; + PainterGizmoType get_painter_type() const override; private: bool on_init() override; From c8133b91b74774ce9ec015986d744991d93a3219 Mon Sep 17 00:00:00 2001 From: YuSanka <yusanka@gmail.com> Date: Fri, 4 Sep 2020 13:00:33 +0200 Subject: [PATCH 5/8] Code cleaning. + Use default DPIfont for wxHtmlWindows --- src/slic3r/GUI/AboutDialog.cpp | 4 +-- src/slic3r/GUI/ConfigSnapshotDialog.cpp | 4 +-- src/slic3r/GUI/GUI_Utils.hpp | 14 +--------- src/slic3r/GUI/MainFrame.cpp | 35 ------------------------- src/slic3r/GUI/SysInfoDialog.cpp | 4 +-- 5 files changed, 7 insertions(+), 54 deletions(-) diff --git a/src/slic3r/GUI/AboutDialog.cpp b/src/slic3r/GUI/AboutDialog.cpp index 92f8d1fdb..f95b8d93b 100644 --- a/src/slic3r/GUI/AboutDialog.cpp +++ b/src/slic3r/GUI/AboutDialog.cpp @@ -52,7 +52,7 @@ CopyrightsDialog::CopyrightsDialog() m_html = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition, wxSize(40 * em_unit(), 20 * em_unit()), wxHW_SCROLLBAR_AUTO); - wxFont font = GetFont(); + wxFont font = get_default_font_for_dpi(get_dpi_for_window(this));// GetFont(); const int fs = font.GetPointSize(); const int fs2 = static_cast<int>(1.2f*fs); int size[] = { fs, fs, fs, fs, fs2, fs2, fs2 }; @@ -249,7 +249,7 @@ AboutDialog::AboutDialog() m_html = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO/*NEVER*/); { m_html->SetMinSize(wxSize(-1, 16 * wxGetApp().em_unit())); - wxFont font = GetFont(); + wxFont font = get_default_font_for_dpi(get_dpi_for_window(this));// GetFont(); const auto text_clr = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); auto text_clr_str = wxString::Format(wxT("#%02X%02X%02X"), text_clr.Red(), text_clr.Green(), text_clr.Blue()); auto bgr_clr_str = wxString::Format(wxT("#%02X%02X%02X"), bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue()); diff --git a/src/slic3r/GUI/ConfigSnapshotDialog.cpp b/src/slic3r/GUI/ConfigSnapshotDialog.cpp index 6a44b96dc..4855bea81 100644 --- a/src/slic3r/GUI/ConfigSnapshotDialog.cpp +++ b/src/slic3r/GUI/ConfigSnapshotDialog.cpp @@ -114,7 +114,7 @@ ConfigSnapshotDialog::ConfigSnapshotDialog(const Config::SnapshotDB &snapshot_db // text html = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO); { - wxFont font = wxGetApp().normal_font();//wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); + wxFont font = get_default_font_for_dpi(get_dpi_for_window(this));// wxGetApp().normal_font();//wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); #ifdef __WXMSW__ const int fs = font.GetPointSize(); const int fs1 = static_cast<int>(0.8f*fs); @@ -140,7 +140,7 @@ ConfigSnapshotDialog::ConfigSnapshotDialog(const Config::SnapshotDB &snapshot_db void ConfigSnapshotDialog::on_dpi_changed(const wxRect &suggested_rect) { - wxFont font = GetFont(); + wxFont font = get_default_font_for_dpi(get_dpi_for_window(this));// GetFont(); const int fs = font.GetPointSize(); const int fs1 = static_cast<int>(0.8f*fs); const int fs2 = static_cast<int>(1.1f*fs); diff --git a/src/slic3r/GUI/GUI_Utils.hpp b/src/slic3r/GUI/GUI_Utils.hpp index 6a93d4156..f29e0cd84 100644 --- a/src/slic3r/GUI/GUI_Utils.hpp +++ b/src/slic3r/GUI/GUI_Utils.hpp @@ -218,19 +218,7 @@ private: void rescale(const wxRect &suggested_rect) { this->Freeze(); -/* -#if wxVERSION_EQUAL_OR_GREATER_THAN(3,1,3) - if (m_force_rescale) { -#endif // wxVERSION_EQUAL_OR_GREATER_THAN - // rescale fonts of all controls - scale_controls_fonts(this, m_new_font_point_size); - // rescale current window font - scale_win_font(this, m_new_font_point_size); -#if wxVERSION_EQUAL_OR_GREATER_THAN(3,1,3) - m_force_rescale = false; - } -#endif // wxVERSION_EQUAL_OR_GREATER_THAN -*/ + m_force_rescale = false; #if !wxVERSION_EQUAL_OR_GREATER_THAN(3,1,3) // rescale fonts of all controls diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index ac6f541e7..b342ebc72 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -55,29 +55,6 @@ enum class ERescaleTarget SettingsDialog }; -static void rescale_dialog_after_dpi_change(MainFrame& mainframe, SettingsDialog& dialog, ERescaleTarget target) -{ - int mainframe_dpi = get_dpi_for_window(&mainframe); - int dialog_dpi = get_dpi_for_window(&dialog); - if (mainframe_dpi != dialog_dpi) { - if (target == ERescaleTarget::SettingsDialog) { - dialog.enable_force_rescale(); -#if wxVERSION_EQUAL_OR_GREATER_THAN(3,1,3) - dialog.GetEventHandler()->AddPendingEvent(wxDPIChangedEvent(wxSize(mainframe_dpi, mainframe_dpi), wxSize(dialog_dpi, dialog_dpi))); -#else - dialog.GetEventHandler()->AddPendingEvent(DpiChangedEvent(EVT_DPI_CHANGED_SLICER, dialog_dpi, dialog.GetRect())); -#endif // wxVERSION_EQUAL_OR_GREATER_THAN - } else { -#if wxVERSION_EQUAL_OR_GREATER_THAN(3,1,3) - mainframe.GetEventHandler()->AddPendingEvent(wxDPIChangedEvent(wxSize(dialog_dpi, dialog_dpi), wxSize(mainframe_dpi, mainframe_dpi))); -#else - mainframe.enable_force_rescale(); - mainframe.GetEventHandler()->AddPendingEvent(DpiChangedEvent(EVT_DPI_CHANGED_SLICER, mainframe_dpi, mainframe.GetRect())); -#endif // wxVERSION_EQUAL_OR_GREATER_THAN - } - } -} - MainFrame::MainFrame() : DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, "mainframe"), m_printhost_queue_dlg(new PrintHostQueueDialog(this)) @@ -310,11 +287,6 @@ void MainFrame::update_layout() m_plater_page = nullptr; } - /* - if (m_layout == ESettingsLayout::Dlg) - rescale_dialog_after_dpi_change(*this, m_settings_dialog, ERescaleTarget::Mainframe); - */ - clean_sizer(m_main_sizer); clean_sizer(m_settings_dialog.GetSizer()); @@ -393,9 +365,6 @@ void MainFrame::update_layout() m_main_sizer->Add(m_plater, 1, wxEXPAND); m_tabpanel->Reparent(&m_settings_dialog); m_settings_dialog.GetSizer()->Add(m_tabpanel, 1, wxEXPAND); - -// rescale_dialog_after_dpi_change(*this, m_settings_dialog, ERescaleTarget::SettingsDialog); - m_tabpanel->Show(); m_plater->Show(); break; @@ -825,10 +794,6 @@ void MainFrame::on_dpi_changed(const wxRect& suggested_rect) this->SetSize(sz); this->Maximize(is_maximized); -/* - if (m_layout == ESettingsLayout::Dlg) - rescale_dialog_after_dpi_change(*this, m_settings_dialog, ERescaleTarget::SettingsDialog); - */ } void MainFrame::on_sys_color_changed() diff --git a/src/slic3r/GUI/SysInfoDialog.cpp b/src/slic3r/GUI/SysInfoDialog.cpp index 3bd0fcf9f..7a41aca1c 100644 --- a/src/slic3r/GUI/SysInfoDialog.cpp +++ b/src/slic3r/GUI/SysInfoDialog.cpp @@ -109,7 +109,7 @@ SysInfoDialog::SysInfoDialog() } // main_info_text - wxFont font = wxGetApp().normal_font(); + wxFont font = get_default_font_for_dpi(get_dpi_for_window(this));// wxGetApp().normal_font(); const auto text_clr = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); auto text_clr_str = wxString::Format(wxT("#%02X%02X%02X"), text_clr.Red(), text_clr.Green(), text_clr.Blue()); auto bgr_clr_str = wxString::Format(wxT("#%02X%02X%02X"), bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue()); @@ -175,7 +175,7 @@ void SysInfoDialog::on_dpi_changed(const wxRect &suggested_rect) m_logo_bmp.msw_rescale(); m_logo->SetBitmap(m_logo_bmp.bmp()); - wxFont font = GetFont(); + wxFont font = get_default_font_for_dpi(get_dpi_for_window(this));// GetFont(); const int fs = font.GetPointSize() - 1; int font_size[] = { static_cast<int>(fs*1.5), static_cast<int>(fs*1.4), static_cast<int>(fs*1.3), fs, fs, fs, fs }; From 486c07702c35d43bc49e2afaf53e7baa7b30845a Mon Sep 17 00:00:00 2001 From: YuSanka <yusanka@gmail.com> Date: Fri, 4 Sep 2020 13:42:44 +0200 Subject: [PATCH 6/8] Added SplashScreen --- src/slic3r/GUI/GUI_App.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index d444017f4..7b4c275c1 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -30,6 +30,7 @@ #include <wx/dialog.h> #include <wx/textctrl.h> +#include <wx/splash.h> #include "libslic3r/Utils.hpp" #include "libslic3r/Model.hpp" @@ -436,6 +437,10 @@ bool GUI_App::on_init_inner() // Let the libslic3r know the callback, which will translate messages on demand. Slic3r::I18N::set_translate_callback(libslic3r_translate_callback); + wxBitmap bitmap = create_scaled_bitmap("wrench", nullptr, 400); + wxSplashScreen* scrn = new wxSplashScreen(bitmap, wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_TIMEOUT, 2500, NULL, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFRAME_NO_TASKBAR | wxSIMPLE_BORDER | wxSTAY_ON_TOP); + wxYield(); + // application frame if (wxImage::FindHandler(wxBITMAP_TYPE_PNG) == nullptr) wxImage::AddHandler(new wxPNGHandler()); From 9d786b5f889f4d126ce33d85c0d6a61b87aad21b Mon Sep 17 00:00:00 2001 From: YuSanka <yusanka@gmail.com> Date: Fri, 4 Sep 2020 16:21:36 +0200 Subject: [PATCH 7/8] Fixed non-MSW builds --- src/slic3r/GUI/MainFrame.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index b342ebc72..f6fd939e2 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -321,6 +321,7 @@ void MainFrame::update_layout() if (m_layout != ESettingsLayout::Unknown) restore_to_creation(); +#ifdef __WXMSW__ enum class State { noUpdate, fromDlg, @@ -328,6 +329,7 @@ void MainFrame::update_layout() }; State update_scaling_state = m_layout == ESettingsLayout::Dlg ? State::fromDlg : layout == ESettingsLayout::Dlg ? State::toDlg : State::noUpdate; +#endif //__WXMSW__ m_layout = layout; @@ -379,6 +381,7 @@ void MainFrame::update_layout() #endif // ENABLE_GCODE_VIEWER } +#ifdef __WXMSW__ if (update_scaling_state != State::noUpdate) { int mainframe_dpi = get_dpi_for_window(this); @@ -406,6 +409,7 @@ void MainFrame::update_layout() #endif // wxVERSION_EQUAL_OR_GREATER_THAN } } +#endif //__WXMSW__ //#ifdef __APPLE__ // // Using SetMinSize() on Mac messes up the window position in some cases From 902de849c0d3dcb7ff153268c0e0c028180000f9 Mon Sep 17 00:00:00 2001 From: YuSanka <yusanka@gmail.com> Date: Fri, 4 Sep 2020 20:25:27 +0200 Subject: [PATCH 8/8] Implemented class SplashScreen for using of text --- resources/icons/prusa_slicer_logo.svg | 5 +++ src/slic3r/GUI/GUI_App.cpp | 50 ++++++++++++++++++++++++--- 2 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 resources/icons/prusa_slicer_logo.svg diff --git a/resources/icons/prusa_slicer_logo.svg b/resources/icons/prusa_slicer_logo.svg new file mode 100644 index 000000000..927c3e70b --- /dev/null +++ b/resources/icons/prusa_slicer_logo.svg @@ -0,0 +1,5 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="800" height="800" viewBox="0 0 800 800"> + <circle cx="400" cy="400" r="400" fill="#fff"/> + <path d="M599.3,186.8c-93.9-93.9-246.1-93.9-340,0s-93.9,246.1,0,340Z" transform="translate(0 0)" fill="#363636"/> + <path d="M202.7,612.5c93.9,93.9,246.1,93.9,340,0s93.9-246.1,0-340" transform="translate(0 0)" fill="#ed6b21"/> +</svg> diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 7b4c275c1..08219ed86 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -77,6 +77,46 @@ namespace GUI { class MainFrame; +class SplashScreen : public wxSplashScreen +{ +public: + SplashScreen(const wxBitmap& bitmap, long splashStyle, int milliseconds, wxWindow* parent) + : wxSplashScreen(bitmap, splashStyle, milliseconds, parent, wxID_ANY) + { + wxASSERT(bitmap.IsOk()); + m_main_bitmap = bitmap; + } + + void SetText(const wxString& text) + { + SetBmp(m_main_bitmap); + if (!text.empty()) { + wxBitmap bitmap(m_main_bitmap); + wxMemoryDC memDC; + + memDC.SelectObject(bitmap); + + memDC.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).Bold()); + memDC.SetTextForeground(wxColour(237, 107, 33)); + memDC.DrawText(text, 120, 120); + + memDC.SelectObject(wxNullBitmap); + SetBmp(bitmap); + } + wxYield(); + } + + void SetBmp(wxBitmap& bmp) + { + m_window->SetBitmap(bmp); + m_window->Refresh(); + m_window->Update(); + } + +private: + wxBitmap m_main_bitmap; +}; + wxString file_wildcards(FileType file_type, const std::string &custom_extension) { static const std::string defaults[FT_SIZE] = { @@ -390,6 +430,10 @@ bool GUI_App::on_init_inner() app_config->set("version", SLIC3R_VERSION); app_config->save(); + + wxBitmap bitmap = create_scaled_bitmap("prusa_slicer_logo", nullptr, 400); + SplashScreen* scrn = new SplashScreen(bitmap, wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_TIMEOUT, 4000, nullptr); + scrn->SetText(_L("Loading configuration...")); preset_bundle = new PresetBundle(); @@ -437,13 +481,11 @@ bool GUI_App::on_init_inner() // Let the libslic3r know the callback, which will translate messages on demand. Slic3r::I18N::set_translate_callback(libslic3r_translate_callback); - wxBitmap bitmap = create_scaled_bitmap("wrench", nullptr, 400); - wxSplashScreen* scrn = new wxSplashScreen(bitmap, wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_TIMEOUT, 2500, NULL, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFRAME_NO_TASKBAR | wxSIMPLE_BORDER | wxSTAY_ON_TOP); - wxYield(); - // application frame if (wxImage::FindHandler(wxBITMAP_TYPE_PNG) == nullptr) wxImage::AddHandler(new wxPNGHandler()); + scrn->SetText(_L("Creating settings tabs...")); + mainframe = new MainFrame(); // hide settings tabs after first Layout mainframe->select_tab(0);