Merge branch 'aui-dark-mode'
Fixes for AUI in dark mode, especially, but not only, under macOS. See https://github.com/wxWidgets/wxWidgets/pull/1955 Closes #18812.
This commit is contained in:
commit
c073995352
@ -69,11 +69,7 @@ wxBitmap wxAuiBitmapFromBits(const unsigned char bits[], int w, int h,
|
||||
static wxColor GetBaseColor()
|
||||
{
|
||||
|
||||
#if defined( __WXMAC__ ) && wxOSX_USE_COCOA_OR_CARBON
|
||||
wxColor baseColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
|
||||
#else
|
||||
wxColor baseColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
|
||||
#endif
|
||||
|
||||
// the baseColour is too pale to use as our base colour,
|
||||
// so darken it a bit --
|
||||
@ -120,13 +116,6 @@ private:
|
||||
};
|
||||
|
||||
|
||||
|
||||
static const unsigned char
|
||||
DISABLED_TEXT_GREY_HUE = wxColour::AlphaBlend(0, 255, 0.4);
|
||||
const wxColour DISABLED_TEXT_COLOR(DISABLED_TEXT_GREY_HUE,
|
||||
DISABLED_TEXT_GREY_HUE,
|
||||
DISABLED_TEXT_GREY_HUE);
|
||||
|
||||
wxAuiGenericToolBarArt::wxAuiGenericToolBarArt()
|
||||
{
|
||||
UpdateColoursFromSystem();
|
||||
@ -139,18 +128,6 @@ wxAuiGenericToolBarArt::wxAuiGenericToolBarArt()
|
||||
m_overflowSize = wxWindow::FromDIP(16, NULL);
|
||||
m_dropdownSize = wxWindow::FromDIP(10, NULL);
|
||||
|
||||
// TODO: Provide x1.5 and x2.0 versions or migrate to SVG.
|
||||
static const unsigned char buttonDropdownBits[] = { 0xe0, 0xf1, 0xfb };
|
||||
static const unsigned char overflowBits[] = { 0x80, 0xff, 0x80, 0xc1, 0xe3, 0xf7 };
|
||||
|
||||
m_buttonDropDownBmp = wxAuiBitmapFromBits(buttonDropdownBits, 5, 3,
|
||||
wxSystemSettings::GetColour(wxSYS_COLOUR_CAPTIONTEXT));
|
||||
m_disabledButtonDropDownBmp = wxAuiBitmapFromBits(
|
||||
buttonDropdownBits, 5, 3,
|
||||
wxColor(128,128,128));
|
||||
m_overflowBmp = wxAuiBitmapFromBits(overflowBits, 7, 6,
|
||||
wxSystemSettings::GetColour(wxSYS_COLOUR_CAPTIONTEXT));
|
||||
m_disabledOverflowBmp = wxAuiBitmapFromBits(overflowBits, 7, 6, wxColor(128,128,128));
|
||||
|
||||
m_font = *wxNORMAL_FONT;
|
||||
}
|
||||
@ -175,6 +152,21 @@ void wxAuiGenericToolBarArt::UpdateColoursFromSystem()
|
||||
m_gripperPen1 = wxPen(darker5Colour, pen_width);
|
||||
m_gripperPen2 = wxPen(darker3Colour, pen_width);
|
||||
m_gripperPen3 = wxPen(*wxStockGDI::GetColour(wxStockGDI::COLOUR_WHITE), pen_width);
|
||||
|
||||
// Note: update the bitmaps here as they depend on the system colours too.
|
||||
|
||||
// TODO: Provide x1.5 and x2.0 versions or migrate to SVG.
|
||||
static const unsigned char buttonDropdownBits[] = { 0xe0, 0xf1, 0xfb };
|
||||
static const unsigned char overflowBits[] = { 0x80, 0xff, 0x80, 0xc1, 0xe3, 0xf7 };
|
||||
|
||||
m_buttonDropDownBmp = wxAuiBitmapFromBits(buttonDropdownBits, 5, 3,
|
||||
wxSystemSettings::GetColour(wxSYS_COLOUR_CAPTIONTEXT));
|
||||
m_disabledButtonDropDownBmp = wxAuiBitmapFromBits(
|
||||
buttonDropdownBits, 5, 3,
|
||||
wxColor(128,128,128));
|
||||
m_overflowBmp = wxAuiBitmapFromBits(overflowBits, 7, 6,
|
||||
wxSystemSettings::GetColour(wxSYS_COLOUR_CAPTIONTEXT));
|
||||
m_disabledOverflowBmp = wxAuiBitmapFromBits(overflowBits, 7, 6, wxColor(128,128,128));
|
||||
}
|
||||
|
||||
void wxAuiGenericToolBarArt::SetFlags(unsigned int flags)
|
||||
@ -249,11 +241,7 @@ void wxAuiGenericToolBarArt::DrawLabel(
|
||||
const wxRect& rect)
|
||||
{
|
||||
dc.SetFont(m_font);
|
||||
#ifdef __WXMAC__
|
||||
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_CAPTIONTEXT));
|
||||
#else
|
||||
dc.SetTextForeground(*wxBLACK);
|
||||
#endif
|
||||
|
||||
// we only care about the text height here since the text
|
||||
// will get cropped based on the width of the item
|
||||
@ -366,11 +354,7 @@ void wxAuiGenericToolBarArt::DrawButton(
|
||||
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_CAPTIONTEXT));
|
||||
if (item.GetState() & wxAUI_BUTTON_STATE_DISABLED)
|
||||
{
|
||||
#ifdef __WXMAC__
|
||||
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_INACTIVECAPTIONTEXT));
|
||||
#else
|
||||
dc.SetTextForeground(DISABLED_TEXT_COLOR);
|
||||
#endif
|
||||
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT));
|
||||
}
|
||||
|
||||
if ( (m_flags & wxAUI_TB_TEXT) && !item.GetLabel().empty() )
|
||||
@ -500,11 +484,7 @@ void wxAuiGenericToolBarArt::DrawDropDownButton(
|
||||
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_CAPTIONTEXT));
|
||||
if (item.GetState() & wxAUI_BUTTON_STATE_DISABLED)
|
||||
{
|
||||
#ifdef __WXMAC__
|
||||
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_INACTIVECAPTIONTEXT));
|
||||
#else
|
||||
dc.SetTextForeground(DISABLED_TEXT_COLOR);
|
||||
#endif
|
||||
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT));
|
||||
}
|
||||
|
||||
if ( (m_flags & wxAUI_TB_TEXT) && !item.GetLabel().empty() )
|
||||
@ -544,11 +524,7 @@ void wxAuiGenericToolBarArt::DrawControlLabel(
|
||||
return;
|
||||
|
||||
// set the label's text color
|
||||
#ifdef __WXMAC__
|
||||
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_CAPTIONTEXT));
|
||||
#else
|
||||
dc.SetTextForeground(*wxBLACK);
|
||||
#endif
|
||||
|
||||
textX = rect.x + (rect.width/2) - (textWidth/2) + 1;
|
||||
textY = rect.y + rect.height - textHeight - 1;
|
||||
|
@ -95,9 +95,38 @@ wxBitmap wxAuiBitmapFromBits(const unsigned char bits[], int w, int h,
|
||||
const wxColour& color)
|
||||
{
|
||||
wxImage img = wxBitmap((const char*)bits, w, h).ConvertToImage();
|
||||
if (color.Alpha() == wxALPHA_OPAQUE)
|
||||
{
|
||||
img.Replace(0,0,0,123,123,123);
|
||||
img.Replace(255,255,255,color.Red(),color.Green(),color.Blue());
|
||||
img.SetMaskColour(123,123,123);
|
||||
}
|
||||
else
|
||||
{
|
||||
img.InitAlpha();
|
||||
const int newr = color.Red();
|
||||
const int newg = color.Green();
|
||||
const int newb = color.Blue();
|
||||
const int newa = color.Alpha();
|
||||
for (int x = 0; x < w; x++)
|
||||
{
|
||||
for (int y = 0; y < h; y++)
|
||||
{
|
||||
int r = img.GetRed(x, y);
|
||||
int g = img.GetGreen(x, y);
|
||||
int b = img.GetBlue(x, y);
|
||||
if (r == 0 && g == 0 && b == 0)
|
||||
{
|
||||
img.SetAlpha(x, y, wxALPHA_TRANSPARENT);
|
||||
}
|
||||
else
|
||||
{
|
||||
img.SetRGB(x, y, newr, newg, newb);
|
||||
img.SetAlpha(x, y, newa);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return wxBitmap(img);
|
||||
}
|
||||
|
||||
@ -268,40 +297,29 @@ wxAuiDefaultDockArt::InitBitmaps ()
|
||||
0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
|
||||
|
||||
#ifdef __WXMAC__
|
||||
m_inactiveCloseBitmap = wxAuiBitmapFromBits(close_bits, 16, 16, *wxWHITE);
|
||||
m_activeCloseBitmap = wxAuiBitmapFromBits(close_bits, 16, 16, *wxWHITE );
|
||||
const wxColour inactive = wxSystemSettings::GetColour(wxSYS_COLOUR_INACTIVECAPTION);
|
||||
const wxColour active = wxSystemSettings::GetColour(wxSYS_COLOUR_CAPTIONTEXT);
|
||||
#else
|
||||
m_inactiveCloseBitmap = wxAuiBitmapFromBits(close_bits, 16, 16, m_inactiveCaptionTextColour);
|
||||
m_activeCloseBitmap = wxAuiBitmapFromBits(close_bits, 16, 16, m_activeCaptionTextColour);
|
||||
const wxColor inactive = m_inactiveCaptionTextColour;
|
||||
const wxColor active = m_activeCaptionTextColour;
|
||||
#endif
|
||||
|
||||
#ifdef __WXMAC__
|
||||
m_inactiveMaximizeBitmap = wxAuiBitmapFromBits(maximize_bits, 16, 16, *wxWHITE);
|
||||
m_activeMaximizeBitmap = wxAuiBitmapFromBits(maximize_bits, 16, 16, *wxWHITE );
|
||||
#else
|
||||
m_inactiveMaximizeBitmap = wxAuiBitmapFromBits(maximize_bits, 16, 16, m_inactiveCaptionTextColour);
|
||||
m_activeMaximizeBitmap = wxAuiBitmapFromBits(maximize_bits, 16, 16, m_activeCaptionTextColour);
|
||||
#endif
|
||||
m_inactiveCloseBitmap = wxAuiBitmapFromBits(close_bits, 16, 16, inactive);
|
||||
m_activeCloseBitmap = wxAuiBitmapFromBits(close_bits, 16, 16, active);
|
||||
|
||||
#ifdef __WXMAC__
|
||||
m_inactiveRestoreBitmap = wxAuiBitmapFromBits(restore_bits, 16, 16, *wxWHITE);
|
||||
m_activeRestoreBitmap = wxAuiBitmapFromBits(restore_bits, 16, 16, *wxWHITE );
|
||||
#else
|
||||
m_inactiveRestoreBitmap = wxAuiBitmapFromBits(restore_bits, 16, 16, m_inactiveCaptionTextColour);
|
||||
m_activeRestoreBitmap = wxAuiBitmapFromBits(restore_bits, 16, 16, m_activeCaptionTextColour);
|
||||
#endif
|
||||
m_inactiveMaximizeBitmap = wxAuiBitmapFromBits(maximize_bits, 16, 16, inactive);
|
||||
m_activeMaximizeBitmap = wxAuiBitmapFromBits(maximize_bits, 16, 16, active);
|
||||
|
||||
m_inactivePinBitmap = wxAuiBitmapFromBits(pin_bits, 16, 16, m_inactiveCaptionTextColour);
|
||||
m_activePinBitmap = wxAuiBitmapFromBits(pin_bits, 16, 16, m_activeCaptionTextColour);
|
||||
m_inactiveRestoreBitmap = wxAuiBitmapFromBits(restore_bits, 16, 16, inactive);
|
||||
m_activeRestoreBitmap = wxAuiBitmapFromBits(restore_bits, 16, 16, active);
|
||||
|
||||
m_inactivePinBitmap = wxAuiBitmapFromBits(pin_bits, 16, 16, inactive);
|
||||
m_activePinBitmap = wxAuiBitmapFromBits(pin_bits, 16, 16, active);
|
||||
}
|
||||
|
||||
void wxAuiDefaultDockArt::UpdateColoursFromSystem()
|
||||
{
|
||||
#if defined( __WXMAC__ ) && wxOSX_USE_COCOA_OR_CARBON
|
||||
wxColor baseColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
|
||||
#else
|
||||
wxColor baseColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
|
||||
#endif
|
||||
|
||||
// the baseColour is too pale to use as our base colour,
|
||||
// so darken it a bit --
|
||||
|
@ -176,14 +176,6 @@ static const unsigned char list_bits[] = {
|
||||
wxAuiGenericTabArt::wxAuiGenericTabArt()
|
||||
: m_normalFont(*wxNORMAL_FONT)
|
||||
, m_selectedFont(m_normalFont)
|
||||
, m_activeCloseBmp(wxAuiBitmapFromBits(close_bits, 16, 16, *wxBLACK))
|
||||
, m_disabledCloseBmp(wxAuiBitmapFromBits(close_bits, 16, 16, wxColour(128,128,128)))
|
||||
, m_activeLeftBmp(wxAuiBitmapFromBits(left_bits, 16, 16, *wxBLACK))
|
||||
, m_disabledLeftBmp(wxAuiBitmapFromBits(left_bits, 16, 16, wxColour(128,128,128)))
|
||||
, m_activeRightBmp(wxAuiBitmapFromBits(right_bits, 16, 16, *wxBLACK))
|
||||
, m_disabledRightBmp(wxAuiBitmapFromBits(right_bits, 16, 16, wxColour(128,128,128)))
|
||||
, m_activeWindowListBmp(wxAuiBitmapFromBits(list_bits, 16, 16, *wxBLACK))
|
||||
, m_disabledWindowListBmp(wxAuiBitmapFromBits(list_bits, 16, 16, wxColour(128,128,128)))
|
||||
{
|
||||
m_selectedFont.SetWeight(wxFONTWEIGHT_BOLD);
|
||||
m_measuringFont = m_selectedFont;
|
||||
@ -201,11 +193,7 @@ wxAuiGenericTabArt::~wxAuiGenericTabArt()
|
||||
|
||||
void wxAuiGenericTabArt::UpdateColoursFromSystem()
|
||||
{
|
||||
#if defined( __WXMAC__ ) && wxOSX_USE_COCOA_OR_CARBON
|
||||
wxColor baseColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
|
||||
#else
|
||||
wxColor baseColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
|
||||
#endif
|
||||
|
||||
// the baseColour is too pale to use as our base colour,
|
||||
// so darken it a bit --
|
||||
@ -223,6 +211,17 @@ void wxAuiGenericTabArt::UpdateColoursFromSystem()
|
||||
m_borderPen = wxPen(borderColour);
|
||||
m_baseColourPen = wxPen(m_baseColour);
|
||||
m_baseColourBrush = wxBrush(m_baseColour);
|
||||
|
||||
const int disabledLightness = wxSystemSettings::GetAppearance().IsUsingDarkBackground() ? 130 : 70;
|
||||
|
||||
m_activeCloseBmp = wxAuiBitmapFromBits(close_bits, 16, 16, wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
|
||||
m_disabledCloseBmp = wxAuiBitmapFromBits(close_bits, 16, 16, wxSystemSettings::GetColour(wxSYS_COLOUR_INACTIVECAPTIONTEXT).ChangeLightness(disabledLightness));
|
||||
m_activeLeftBmp = wxAuiBitmapFromBits(left_bits, 16, 16, wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
|
||||
m_disabledLeftBmp = wxAuiBitmapFromBits(left_bits, 16, 16, wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT));
|
||||
m_activeRightBmp = wxAuiBitmapFromBits(right_bits, 16, 16, wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
|
||||
m_disabledRightBmp = wxAuiBitmapFromBits(right_bits, 16, 16, wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT));
|
||||
m_activeWindowListBmp = wxAuiBitmapFromBits(list_bits, 16, 16, wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
|
||||
m_disabledWindowListBmp = wxAuiBitmapFromBits(list_bits, 16, 16, wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT));
|
||||
}
|
||||
|
||||
wxAuiTabArt* wxAuiGenericTabArt::Clone()
|
||||
@ -280,9 +279,19 @@ void wxAuiGenericTabArt::DrawBackground(wxDC& dc,
|
||||
wxWindow* WXUNUSED(wnd),
|
||||
const wxRect& rect)
|
||||
{
|
||||
// draw background
|
||||
int topLightness = 90;
|
||||
int bottomLightness = 170;
|
||||
// draw background using arbitrary hard-coded, but at least adapted to dark
|
||||
// mode, gradient
|
||||
int topLightness, bottomLightness;
|
||||
if (wxSystemSettings::GetAppearance().IsUsingDarkBackground())
|
||||
{
|
||||
topLightness = 110;
|
||||
bottomLightness = 90;
|
||||
}
|
||||
else
|
||||
{
|
||||
topLightness = 90;
|
||||
bottomLightness = 170;
|
||||
}
|
||||
|
||||
wxColor top_color = m_baseColour.ChangeLightness(topLightness);
|
||||
wxColor bottom_color = m_baseColour.ChangeLightness(bottomLightness);
|
||||
@ -436,9 +445,8 @@ void wxAuiGenericTabArt::DrawTab(wxDC& dc,
|
||||
int drawn_tab_yoff = border_points[1].y;
|
||||
int drawn_tab_height = border_points[0].y - border_points[1].y;
|
||||
|
||||
bool isdark = (m_baseColour.Red() < 75)
|
||||
&& (m_baseColour.Green() < 75)
|
||||
&& (m_baseColour.Blue() < 75);
|
||||
bool isdark = wxSystemSettings::GetAppearance().IsUsingDarkBackground();
|
||||
|
||||
wxColor back_color = m_baseColour;
|
||||
if (page.active)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user