Add dark mode support for the wxGauge control. The background and bar color values were taken from observing a progress bar using the DarkMode_DarkTheme. I did not try to actually use DarkMode_DarkTheme in this implementation because it was too complicated. I did not use colors from WinUI 3 because the control there has a very different overall look, and very different colors.
See #26767.
https://github.com/wxWidgets/wxWidgets/pull/26796
(2 files)
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()
@vadz commented on this pull request.
Thanks, this looks good, but I strongly dislike hardcoding colours like this, this is bound to create problems in some configurations. Ideal would be to derive them from system colours (which can already be customized by the application) but if not, I think we need to extend wxDarkModeSettings.
If you prefer, we can merge this and make this change in another PR but I think we really need to do it.
> + ::SendMessage(m_hWnd, PBM_SETBKCOLOR, 0, 0x131313); + ::SendMessage(m_hWnd, PBM_SETBARCOLOR, 0, 0x5fcb6c);
I think we need to make this configurable via wxDarkModeSettings, by adding dedicated functions to it for progress bar colours if none of the system colours can be used. Hardcoding colours here is definitely going to create problems for someone...
> @@ -94,6 +96,43 @@ wxGauge::~wxGauge()
{
}
+void wxGauge::MSWSetDarkOrLightMode(SetMode setmode)
+{
+ wxGaugeBase::MSWSetDarkOrLightMode(setmode);
+
+ // Get window styles, for the border style.
+ auto style = ::GetWindowLong(m_hWnd, GWL_STYLE);
+ auto exStyle = ::GetWindowLong(m_hWnd, GWL_EXSTYLE);
+
+ if ( wxMSWDarkMode::IsActive() )
+ {
+ // Disable visual styles so colour messages take effect.
+ ::SetWindowTheme(m_hWnd, L"", L"");
Do we restore the theme when switching back to "light" later? I'm not sure where/how: is this done by the base class version of this function for all windows?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()
@stevecor pushed 1 commit.
—
View it on GitHub or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()
Thanks, this looks good, but I strongly dislike hardcoding colours like this, this is bound to create problems in some
For all the Windows dark mode hard-coded colors I think we should add a new function into darkmode.cpp similar to wxDarkModeSettings::GetColour(). I will look into that for a separate PR.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()
@stevecor commented on this pull request.
> @@ -94,6 +96,43 @@ wxGauge::~wxGauge()
{
}
+void wxGauge::MSWSetDarkOrLightMode(SetMode setmode)
+{
+ wxGaugeBase::MSWSetDarkOrLightMode(setmode);
+
+ // Get window styles, for the border style.
+ auto style = ::GetWindowLong(m_hWnd, GWL_STYLE);
+ auto exStyle = ::GetWindowLong(m_hWnd, GWL_EXSTYLE);
+
+ if ( wxMSWDarkMode::IsActive() )
+ {
+ // Disable visual styles so colour messages take effect.
+ ::SetWindowTheme(m_hWnd, L"", L"");
Do we restore the theme when switching back to "light" later? I'm not sure where/how: is this done by the base class version of this function for all windows?
No, there is no attempt to restore the theme. The only effect the theme has is the colors. So if we set the colors, there is no point setting a theme.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()
@vadz commented on this pull request.
> @@ -94,6 +96,43 @@ wxGauge::~wxGauge()
{
}
+void wxGauge::MSWSetDarkOrLightMode(SetMode setmode)
+{
+ wxGaugeBase::MSWSetDarkOrLightMode(setmode);
+
+ // Get window styles, for the border style.
+ auto style = ::GetWindowLong(m_hWnd, GWL_STYLE);
+ auto exStyle = ::GetWindowLong(m_hWnd, GWL_EXSTYLE);
+
+ if ( wxMSWDarkMode::IsActive() )
+ {
+ // Disable visual styles so colour messages take effect.
+ ::SetWindowTheme(m_hWnd, L"", L"");
Sorry, I don't understand. In the light mode we don't want to use the custom colours, but we do want to have a themable control.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()
@stevecor pushed 1 commit.
—
View it on GitHub or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()
@stevecor commented on this pull request.
> @@ -94,6 +96,43 @@ wxGauge::~wxGauge()
{
}
+void wxGauge::MSWSetDarkOrLightMode(SetMode setmode)
+{
+ wxGaugeBase::MSWSetDarkOrLightMode(setmode);
+
+ // Get window styles, for the border style.
+ auto style = ::GetWindowLong(m_hWnd, GWL_STYLE);
+ auto exStyle = ::GetWindowLong(m_hWnd, GWL_EXSTYLE);
+
+ if ( wxMSWDarkMode::IsActive() )
+ {
+ // Disable visual styles so colour messages take effect.
+ ::SetWindowTheme(m_hWnd, L"", L"");
My mistake: yes the theme is restored by the base class upon switching to light mode.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()
Thanks!
After testing this, I see that we lose the animation effect of the native control in dark mode, but I guess this is unavoidable.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()