mirror of
https://github.com/wxWidgets/wxWidgets.git
synced 2026-09-28 15:50:17 +08:00
Support switching to wxMSW dark mode in wxAuiToolBar
On Windows, enable dark mode switching for wxAuiToolBar by updating m_themed upon system colour change. Closes #26648.
This commit is contained in:
committed by
Vadim Zeitlin
parent
c5b9d2850e
commit
25d7cfefea
@@ -79,6 +79,8 @@ public:
|
||||
virtual int ShowDropDown(wxWindow* wnd,
|
||||
const wxAuiToolBarItemArray& items) override;
|
||||
|
||||
virtual void UpdateColoursFromSystem() override;
|
||||
|
||||
private:
|
||||
bool m_themed;
|
||||
wxSize m_buttonSize;
|
||||
|
||||
+11
-6
@@ -26,11 +26,8 @@
|
||||
|
||||
wxAuiMSWToolBarArt::wxAuiMSWToolBarArt()
|
||||
{
|
||||
// Theme colours don't work in dark theme, so don't use them in this case.
|
||||
if ( wxUxThemeIsActive() && !wxMSWDarkMode::IsActive() )
|
||||
if ( wxUxThemeIsActive() )
|
||||
{
|
||||
m_themed = true;
|
||||
|
||||
// Determine sizes from theme
|
||||
wxWindow* window = static_cast<wxApp*>(wxApp::GetInstance())->GetTopWindow();
|
||||
wxUxThemeHandle hTheme(window, L"Rebar");
|
||||
@@ -51,8 +48,8 @@ wxAuiMSWToolBarArt::wxAuiMSWToolBarArt()
|
||||
|
||||
m_buttonSize = hThemeToolbar.GetTrueSize(TP_BUTTON);
|
||||
}
|
||||
else
|
||||
m_themed = false;
|
||||
|
||||
UpdateColoursFromSystem();
|
||||
}
|
||||
|
||||
wxAuiToolBarArt* wxAuiMSWToolBarArt::Clone()
|
||||
@@ -432,4 +429,12 @@ int wxAuiMSWToolBarArt::ShowDropDown(wxWindow* wnd,
|
||||
return wxAuiGenericToolBarArt::ShowDropDown(wnd, items);
|
||||
}
|
||||
|
||||
void wxAuiMSWToolBarArt::UpdateColoursFromSystem()
|
||||
{
|
||||
wxAuiGenericToolBarArt::UpdateColoursFromSystem();
|
||||
|
||||
// Theme colours do not work in dark mode.
|
||||
m_themed = wxUxThemeIsActive() && !wxMSWDarkMode::IsActive();
|
||||
}
|
||||
|
||||
#endif // wxUSE_AUI
|
||||
|
||||
Reference in New Issue
Block a user