From 5091d878254c80a85a7287383d64168ccbf64bee Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Thu, 14 Jun 2018 20:09:37 +0200 Subject: [PATCH] Support Dark Mode for Status Bar see #18146 --- include/wx/osx/statusbr.h | 2 ++ src/osx/carbon/statbrma.cpp | 51 +++++++++++++++++++++++++++++-------- 2 files changed, 43 insertions(+), 10 deletions(-) diff --git a/include/wx/osx/statusbr.h b/include/wx/osx/statusbr.h index e8ff1d312e..a331cd2ec6 100644 --- a/include/wx/osx/statusbr.h +++ b/include/wx/osx/statusbr.h @@ -35,6 +35,8 @@ protected: virtual void DrawField(wxDC& dc, int i, int textHeight) wxOVERRIDE; virtual void DoUpdateStatusText(int number = 0) wxOVERRIDE; + virtual void InitColours(); + private: wxColour m_textActive, m_textInactive, m_bgActiveFrom, m_bgActiveTo, diff --git a/src/osx/carbon/statbrma.cpp b/src/osx/carbon/statbrma.cpp index 76dc302dd4..01fe6abdd4 100644 --- a/src/osx/carbon/statbrma.cpp +++ b/src/osx/carbon/statbrma.cpp @@ -67,6 +67,13 @@ bool wxStatusBarMac::Create(wxWindow *parent, wxWindowID id, // normal system font is too tall for fitting into the standard height SetWindowVariant( wxWINDOW_VARIANT_SMALL ); + InitColours(); + + return true; +} + +void wxStatusBarMac::InitColours() +{ #if MAC_OS_X_VERSION_MIN_REQUIRED < 101000 if ( !wxPlatformInfo::Get().CheckOSVersion(10, 10) ) { @@ -82,17 +89,41 @@ bool wxStatusBarMac::Create(wxWindow *parent, wxWindowID id, else #endif // MAC_OS_X_VERSION_MIN_REQUIRED < 101000 { - // 10.10 Yosemite and newer: - m_textActive = wxColour(0x40, 0x40, 0x40); - m_textInactive = wxColour(0x4B, 0x4B, 0x4B); - m_bgActiveFrom = wxColour(0xE9, 0xE7, 0xEA); - m_bgActiveTo = wxColour(0xCD, 0xCB, 0xCE); - m_borderActive = wxColour(0xBA, 0xB8, 0xBB); - m_borderInactive = wxColour(0xC3, 0xC3, 0xC3); - SetBackgroundColour(wxColour(0xF4, 0xF4, 0xF4)); // inactive bg + if (!wxPlatformInfo::Get().CheckOSVersion(10, 14)) + { + // 10.10 Yosemite to 10.13 : + m_textActive = wxColour(0x40, 0x40, 0x40); + m_textInactive = wxColour(0x4B, 0x4B, 0x4B); + m_bgActiveFrom = wxColour(0xE9, 0xE7, 0xEA); + m_bgActiveTo = wxColour(0xCD, 0xCB, 0xCE); + m_borderActive = wxColour(0xBA, 0xB8, 0xBB); + m_borderInactive = wxColour(0xC3, 0xC3, 0xC3); + SetBackgroundColour(wxColour(0xF4, 0xF4, 0xF4)); // inactive bg + } + else + { + wxColour bg = wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE); + m_textActive = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT); + m_textInactive = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT); + + if ( bg.Red() < 128 ) + { + // dark mode appearance + m_bgActiveFrom = wxColour(0x32, 0x32, 0x34); + m_bgActiveTo = wxColour(0x29, 0x29, 0x2A); + m_borderActive = wxColour(0x00, 0x00, 0x00); + m_borderInactive = wxColour(0x00, 0x00, 0x00); + } + else + { + m_bgActiveFrom = wxColour(0xE9, 0xE7, 0xEA); + m_bgActiveTo = wxColour(0xCD, 0xCB, 0xCE); + m_borderActive = wxColour(0xBA, 0xB8, 0xBB); + m_borderInactive = wxColour(0xC3, 0xC3, 0xC3); + } + SetBackgroundColour(bg); // inactive bg + } } - - return true; } void wxStatusBarMac::DrawFieldText(wxDC& dc, const wxRect& rect, int i, int textHeight)