From effad844e2f38bddba2a81524dd8cae6572207d4 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Tue, 6 Apr 2021 22:20:24 +0200 Subject: [PATCH] MSW specific: Fixed update of the UI after system color change. Note: the wxEVT_SYS_COLOUR_CHANGED event works only for high contrast settings under MSW. + ConfigSnapshotDialog: Fixed UI colors for dark mode on all platforms --- src/slic3r/GUI/ConfigSnapshotDialog.cpp | 24 +++++++++++++++++------- src/slic3r/GUI/MainFrame.cpp | 5 +++++ src/slic3r/GUI/Plater.cpp | 6 ++++++ src/slic3r/GUI/Preferences.cpp | 3 +++ src/slic3r/GUI/Tab.cpp | 4 +++- src/slic3r/GUI/wxExtensions.cpp | 6 ++++++ 6 files changed, 40 insertions(+), 8 deletions(-) diff --git a/src/slic3r/GUI/ConfigSnapshotDialog.cpp b/src/slic3r/GUI/ConfigSnapshotDialog.cpp index 9f996d378b..6a02e67534 100644 --- a/src/slic3r/GUI/ConfigSnapshotDialog.cpp +++ b/src/slic3r/GUI/ConfigSnapshotDialog.cpp @@ -29,11 +29,20 @@ static wxString format_reason(const Config::Snapshot::Reason reason) } } -static wxString generate_html_row(const Config::Snapshot &snapshot, bool row_even, bool snapshot_active) +static std::string get_color(wxColour colour) { + wxString clr_str = wxString::Format(wxT("#%02X%02X%02X"), colour.Red(), colour.Green(), colour.Blue()); + return clr_str.ToStdString(); +}; + + +static wxString generate_html_row(const Config::Snapshot &snapshot, bool row_even, bool snapshot_active, bool dark_mode) +{ // Start by declaring a row with an alternating background color. wxString text = ""; text += ""; @@ -92,14 +101,15 @@ static wxString generate_html_row(const Config::Snapshot &snapshot, bool row_eve static wxString generate_html_page(const Config::SnapshotDB &snapshot_db, const wxString &on_snapshot) { + bool dark_mode = wxGetApp().dark_mode(); wxString text = "" - "" - ""; + "" + ""; text += ""; for (size_t i_row = 0; i_row < snapshot_db.snapshots().size(); ++ i_row) { const Config::Snapshot &snapshot = snapshot_db.snapshots()[snapshot_db.snapshots().size() - i_row - 1]; - text += generate_html_row(snapshot, i_row & 1, snapshot.id == on_snapshot); + text += generate_html_row(snapshot, i_row & 1, snapshot.id == on_snapshot, dark_mode); } text += "
" @@ -115,8 +125,8 @@ ConfigSnapshotDialog::ConfigSnapshotDialog(const Config::SnapshotDB &snapshot_db wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX) { this->SetFont(wxGetApp().normal_font()); - this->SetBackgroundColour(*wxWHITE); - + this->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); + wxBoxSizer* vsizer = new wxBoxSizer(wxVERTICAL); this->SetSizer(vsizer); diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 35b1c16d82..5c390b66f6 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -522,6 +522,8 @@ void MainFrame::init_tabpanel() #ifndef __WXOSX__ // Don't call SetFont under OSX to avoid name cutting in ObjectList m_tabpanel->SetFont(Slic3r::GUI::wxGetApp().normal_font()); #endif + if (wxSystemSettings::GetAppearance().IsDark()) + m_tabpanel->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); m_tabpanel->Hide(); m_settings_dialog.set_tabpanel(m_tabpanel); @@ -838,6 +840,9 @@ void MainFrame::on_sys_color_changed() // update label colors in respect to the system mode wxGetApp().init_label_colours(); +#ifdef __WXMSW__ + m_tabpanel->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); +#endif // update Plater wxGetApp().plater()->sys_color_changed(); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index b4b025cd2e..a640d6e280 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -964,6 +964,10 @@ void Sidebar::msw_rescale() void Sidebar::sys_color_changed() { +#ifdef __WXMSW__ + SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); +#endif + for (PlaterPresetComboBox* combo : std::vector{ p->combo_print, p->combo_sla_print, p->combo_sla_material, @@ -972,6 +976,8 @@ void Sidebar::sys_color_changed() for (PlaterPresetComboBox* combo : p->combos_filament) combo->msw_rescale(); + p->frequently_changed_parameters->msw_rescale(); + p->object_list->msw_rescale(); p->object_list->sys_color_changed(); p->object_manipulation->sys_color_changed(); p->object_layers->sys_color_changed(); diff --git a/src/slic3r/GUI/Preferences.cpp b/src/slic3r/GUI/Preferences.cpp index 67381cf220..38a31bf76b 100644 --- a/src/slic3r/GUI/Preferences.cpp +++ b/src/slic3r/GUI/Preferences.cpp @@ -51,6 +51,9 @@ void PreferencesDialog::build() auto app_config = get_app_config(); wxNotebook* tabs = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP | wxTAB_TRAVERSAL | wxNB_NOPAGETHEME); +#ifdef __WXMSW__ + tabs->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); +#endif // Add "General" tab m_optgroup_general = create_options_tab(_L("General"), tabs); diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 933ae1a4db..cfd36e6878 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -1002,7 +1002,9 @@ void Tab::sys_color_changed() for (ScalableBitmap& bmp : m_scaled_icons_list) m_icons->Add(bmp.bmp()); m_treectrl->AssignImageList(m_icons); - +#ifdef __WXMSW__ + m_treectrl->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); +#endif // Colors for ui "decoration" update_label_colours(); diff --git a/src/slic3r/GUI/wxExtensions.cpp b/src/slic3r/GUI/wxExtensions.cpp index 28c3ba40b9..c8b0dfd31d 100644 --- a/src/slic3r/GUI/wxExtensions.cpp +++ b/src/slic3r/GUI/wxExtensions.cpp @@ -590,6 +590,9 @@ void LockButton::msw_rescale() void LockButton::update_button_bitmaps() { +#ifdef __WXMSW__ + SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); +#endif SetBitmap(m_is_pushed ? m_bmp_lock_closed.bmp() : m_bmp_lock_open.bmp()); SetBitmapHover(m_is_pushed ? m_bmp_lock_closed_f.bmp() : m_bmp_lock_open_f.bmp()); @@ -885,6 +888,9 @@ void ScalableButton::UseDefaultBitmapDisabled() void ScalableButton::msw_rescale() { +#ifdef __WXMSW__ + SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); +#endif SetBitmap(create_scaled_bitmap(m_current_icon_name, m_parent, m_px_cnt)); if (!m_disabled_icon_name.empty()) SetBitmapDisabled(create_scaled_bitmap(m_disabled_icon_name, m_parent, m_px_cnt));