From 71dfb3b41426c3a6564d0dd6ed5715f2168fe1b8 Mon Sep 17 00:00:00 2001 From: "Zane U. Ji" Date: Sat, 12 Apr 2014 20:18:47 +0800 Subject: [PATCH] Fix invisible captions in high contrast mode Don't use black text on dark background. Closes #16186. --- docs/changes.txt | 1 + include/wx/aui/tabart.h | 2 ++ src/aui/dockart.cpp | 23 +++++++++-------------- src/aui/tabart.cpp | 21 ++++++++++++++++++--- 4 files changed, 30 insertions(+), 17 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index fb0b4773d3..16cc8b9961 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -141,6 +141,7 @@ All (GUI): - Fix a crash when using animated GIFs in wxHtmlListBox. - Use platform-specific stock icons for wxEditableListBox buttons. - Add support for the events from multimedia keys (Jens Göpfert). +- Improve wxAUI appearance in high contrast themes (Zane U. Ji). wxGTK: diff --git a/include/wx/aui/tabart.h b/include/wx/aui/tabart.h index 47efe359e3..11d919384b 100644 --- a/include/wx/aui/tabart.h +++ b/include/wx/aui/tabart.h @@ -289,6 +289,8 @@ protected: wxFont m_normalFont; wxFont m_selectedFont; wxFont m_measuringFont; + wxColour m_normalTextColour; + wxColour m_selectedTextColour; wxPen m_normalBkPen; wxPen m_selectedBkPen; wxBrush m_normalBkBrush; diff --git a/src/aui/dockart.cpp b/src/aui/dockart.cpp index b1c77b1ae6..b9a50a8c14 100644 --- a/src/aui/dockart.cpp +++ b/src/aui/dockart.cpp @@ -172,26 +172,21 @@ wxAuiDefaultDockArt::wxAuiDefaultDockArt() } m_baseColour = baseColour; - wxColor darker1Colour = baseColour.ChangeLightness(85); - wxColor darker2Colour = baseColour.ChangeLightness(75); - wxColor darker3Colour = baseColour.ChangeLightness(60); - //wxColor darker4Colour = baseColour.ChangeLightness(50); - wxColor darker5Colour = baseColour.ChangeLightness(40); - m_activeCaptionColour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT); - m_activeCaptionGradientColour = wxAuiLightContrastColour(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT)); - m_activeCaptionTextColour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT); - m_inactiveCaptionColour = darker1Colour; - m_inactiveCaptionGradientColour = baseColour.ChangeLightness(97); - m_inactiveCaptionTextColour = *wxBLACK; + m_activeCaptionColour = wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION); + m_activeCaptionGradientColour = wxSystemSettings::GetColour(wxSYS_COLOUR_GRADIENTACTIVECAPTION); + m_activeCaptionTextColour = wxSystemSettings::GetColour(wxSYS_COLOUR_CAPTIONTEXT); + m_inactiveCaptionColour = wxSystemSettings::GetColour(wxSYS_COLOUR_INACTIVECAPTION); + m_inactiveCaptionGradientColour = wxSystemSettings::GetColour(wxSYS_COLOUR_GRADIENTINACTIVECAPTION); + m_inactiveCaptionTextColour = wxSystemSettings::GetColour(wxSYS_COLOUR_INACTIVECAPTIONTEXT); m_sashBrush = wxBrush(baseColour); m_backgroundBrush = wxBrush(baseColour); m_gripperBrush = wxBrush(baseColour); - m_borderPen = wxPen(darker2Colour); - m_gripperPen1 = wxPen(darker5Colour); - m_gripperPen2 = wxPen(darker3Colour); + m_borderPen = wxPen(baseColour.ChangeLightness(75)); + m_gripperPen1 = wxPen(baseColour.ChangeLightness(40)); + m_gripperPen2 = wxPen(baseColour.ChangeLightness(60)); m_gripperPen3 = *wxWHITE_PEN; #ifdef __WXMAC__ diff --git a/src/aui/tabart.cpp b/src/aui/tabart.cpp index dec0f1b1da..b064591143 100644 --- a/src/aui/tabart.cpp +++ b/src/aui/tabart.cpp @@ -74,6 +74,11 @@ wxBitmap wxAuiBitmapFromBits(const unsigned char bits[], int w, int h, wxString wxAuiChopText(wxDC& dc, const wxString& text, int max_size); +inline bool IsDarkColour(const wxColour& c) +{ + return (c.Red() + c.Green() + c.Blue()) * c.Alpha() * 2 < 3 * 255 * 255; +} + static void DrawButtons(wxDC& dc, const wxRect& _rect, const wxBitmap& bmp, @@ -416,6 +421,7 @@ void wxAuiGenericTabArt::DrawTab(wxDC& dc, int drawn_tab_height = border_points[0].y - border_points[1].y; + wxColour text_colour; if (page.active) { // draw active tab @@ -431,6 +437,8 @@ void wxAuiGenericTabArt::DrawTab(wxDC& dc, dc.SetBrush(*wxWHITE_BRUSH); dc.DrawRectangle(r.x+2, r.y+1, r.width-3, r.height-4); + text_colour = *wxBLACK; + // these two points help the rounded corners appear more antialiased dc.SetPen(wxPen(m_activeColour)); dc.DrawPoint(r.x+2, r.y+1); @@ -464,9 +472,11 @@ void wxAuiGenericTabArt::DrawTab(wxDC& dc, r.height--; // -- draw top gradient fill for glossy look - wxColor top_color = m_baseColour; - wxColor bottom_color = top_color.ChangeLightness(160); - dc.GradientFillLinear(r, bottom_color, top_color, wxNORTH); + wxColor top_color = m_baseColour.ChangeLightness(160); + wxColor bottom_color = m_baseColour; + dc.GradientFillLinear(r, top_color, bottom_color, wxSOUTH); + + text_colour = IsDarkColour(bottom_color) ? *wxWHITE : *wxBLACK; r.y += r.height; r.y--; @@ -532,6 +542,7 @@ void wxAuiGenericTabArt::DrawTab(wxDC& dc, tab_width - (text_offset-tab_x) - close_button_width); // draw tab text + dc.SetTextForeground(text_colour); dc.DrawText(draw_text, text_offset, drawn_tab_yoff + (drawn_tab_height)/2 - (texty/2) - 1); @@ -863,6 +874,9 @@ wxAuiSimpleTabArt::wxAuiSimpleTabArt() wxColour normaltabColour = baseColour; wxColour selectedtabColour = *wxWHITE; + m_normalTextColour = IsDarkColour(baseColour) ? *wxWHITE : *wxBLACK; + m_selectedTextColour = *wxBLACK; + m_bkBrush = wxBrush(backgroundColour); m_normalBkBrush = wxBrush(normaltabColour); m_normalBkPen = wxPen(normaltabColour); @@ -1084,6 +1098,7 @@ void wxAuiSimpleTabArt::DrawTab(wxDC& dc, tab_width - (text_offset-tab_x) - close_button_width); // draw tab text + dc.SetTextForeground(page.active ? m_selectedTextColour : m_normalTextColour); dc.DrawText(draw_text, text_offset, (tab_y + tab_height)/2 - (texty/2) + 1);