Update AUI art colours after system colours change
Move code initializing colours and colour-dependent bitmaps from ctor to UpdateColoursFromSystem(), which means that now this is done not only once, when creating the object, but also later if the system colours change (e.g. due to turning on or off the dark mode).
This commit is contained in:
		
				
					committed by
					
						 Vadim Zeitlin
						Vadim Zeitlin
					
				
			
			
				
	
			
			
			
						parent
						
							88928e712a
						
					
				
				
					commit
					e12a9b11e4
				
			| @@ -139,18 +139,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 +163,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) | ||||
|   | ||||
| @@ -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, wxSystemSettings::GetColour(wxSYS_COLOUR_CAPTIONTEXT))) | ||||
|     , m_disabledCloseBmp(wxAuiBitmapFromBits(close_bits, 16, 16, wxSystemSettings::GetColour(wxSYS_COLOUR_INACTIVECAPTION))) | ||||
|     , m_activeLeftBmp(wxAuiBitmapFromBits(left_bits, 16, 16, wxSystemSettings::GetColour(wxSYS_COLOUR_CAPTIONTEXT))) | ||||
|     , m_disabledLeftBmp(wxAuiBitmapFromBits(left_bits, 16, 16, wxSystemSettings::GetColour(wxSYS_COLOUR_INACTIVECAPTION))) | ||||
|     , m_activeRightBmp(wxAuiBitmapFromBits(right_bits, 16, 16, wxSystemSettings::GetColour(wxSYS_COLOUR_CAPTIONTEXT))) | ||||
|     , m_disabledRightBmp(wxAuiBitmapFromBits(right_bits, 16, 16, wxSystemSettings::GetColour(wxSYS_COLOUR_INACTIVECAPTION))) | ||||
|     , m_activeWindowListBmp(wxAuiBitmapFromBits(list_bits, 16, 16, wxSystemSettings::GetColour(wxSYS_COLOUR_CAPTIONTEXT))) | ||||
|     , m_disabledWindowListBmp(wxAuiBitmapFromBits(list_bits, 16, 16, wxSystemSettings::GetColour(wxSYS_COLOUR_INACTIVECAPTION))) | ||||
| { | ||||
|     m_selectedFont.SetWeight(wxFONTWEIGHT_BOLD); | ||||
|     m_measuringFont = m_selectedFont; | ||||
| @@ -223,6 +215,15 @@ void wxAuiGenericTabArt::UpdateColoursFromSystem() | ||||
|     m_borderPen = wxPen(borderColour); | ||||
|     m_baseColourPen = wxPen(m_baseColour); | ||||
|     m_baseColourBrush = wxBrush(m_baseColour); | ||||
|  | ||||
|     m_activeCloseBmp = wxAuiBitmapFromBits(close_bits, 16, 16, wxSystemSettings::GetColour(wxSYS_COLOUR_CAPTIONTEXT)); | ||||
|     m_disabledCloseBmp = wxAuiBitmapFromBits(close_bits, 16, 16, wxSystemSettings::GetColour(wxSYS_COLOUR_INACTIVECAPTION)); | ||||
|     m_activeLeftBmp = wxAuiBitmapFromBits(left_bits, 16, 16, wxSystemSettings::GetColour(wxSYS_COLOUR_CAPTIONTEXT)); | ||||
|     m_disabledLeftBmp = wxAuiBitmapFromBits(left_bits, 16, 16, wxSystemSettings::GetColour(wxSYS_COLOUR_INACTIVECAPTION)); | ||||
|     m_activeRightBmp = wxAuiBitmapFromBits(right_bits, 16, 16, wxSystemSettings::GetColour(wxSYS_COLOUR_CAPTIONTEXT)); | ||||
|     m_disabledRightBmp = wxAuiBitmapFromBits(right_bits, 16, 16, wxSystemSettings::GetColour(wxSYS_COLOUR_INACTIVECAPTION)); | ||||
|     m_activeWindowListBmp = wxAuiBitmapFromBits(list_bits, 16, 16, wxSystemSettings::GetColour(wxSYS_COLOUR_CAPTIONTEXT)); | ||||
|     m_disabledWindowListBmp = wxAuiBitmapFromBits(list_bits, 16, 16, wxSystemSettings::GetColour(wxSYS_COLOUR_INACTIVECAPTION)); | ||||
| } | ||||
|  | ||||
| wxAuiTabArt* wxAuiGenericTabArt::Clone() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user