wxWidgets / wxWidgets

Cross-Platform C++ GUI Library
https://www.wxwidgets.org/
6.05k stars 1.76k forks source link

Provide a way to overwrite system color settings for wxAui tab and dock arts #18614

Open wxtrac opened 4 years ago

wxtrac commented 4 years ago

Issue migrated from trac ticket # 18614

component: GUI-all | priority: low

2019-12-05 21:16:50: paulclinger (Paul K) created the issue


As discussed in #18601, some of the color settings in wxAui are retrieved from system colors (for example, font colors), but are not configurable programmatically. Having a way to re-configure system colors would be beneficial in several ways: provides application-based theming support, allows customization of colors that are not currently configurable, and makes wxwidgets applications better "skinnable".

One way to implement this would be to add SetColour to wxSystemSettings and store its results in a table, which would be checked by GetColour before retrieving system-specific values (the default value would be NULL/not-assigned, so it would be fully backward compatible). This also provides a way to customize some of the colors without having a need to set all of them.

wxtrac commented 4 years ago

2019-12-07 15:11:36: @vadz changed priority from normal to low

2019-12-07 15:11:36: @vadz changed status from new to confirmed

2019-12-07 15:11:36: @vadz changed component from wxAui to GUI-all

2019-12-07 15:11:36: @vadz commented

We could indeed add some OverrideColour() (I think it's more clear than innocuously-looking Set) to wxSystemSettings and always "override" GetColour() method in it to return any replacement colours if set.

This doesn't look difficult to do except for some possible problems due to the existing of GetColour() in wxUniv, but in the worst case we could just not support colour overrides in it, it's supposed to have its themes instead anyhow.

wxtrac commented 4 years ago

2019-12-17 06:23:11: paulclinger (Paul K) commented


Vadim, I'm not sure what's going on with system colors on macOS, but I get dark colors reported and yet white background shown. For example, this is what I get for wxSYS_COLOUR_CAPTIONTEXT when dark mode is enabled:

  > wx.wxSystemSettings.GetColour(wx.wxSYS_COLOUR_CAPTIONTEXT):GetAsString()
  rgba(0,0,0,0.847)

I realize that since I compile with 10.9+ SDK, I don't get support for the dark mode, but shouln't the colors still be shown dark, as they seem to be reported correctly. Does anyone get dark background in wxAui components on macOS based on system colors (when not set manually)?

wxtrac commented 4 years ago

2019-12-28 00:09:52: @vadz commented


Sorry for the lack of reply, but I just don't know if it's worthwhile to look into what happens when using old SDK under 10.14+. We know that things won't work correctly for the dark mode support in this case, so does it really matter how exactly do they fail? I really think you should switch to 10.14 SDK (note that it doesn't prevent you from targeting macOS 10.9+).

wxtrac commented 4 years ago

2019-12-29 06:20:55: paulclinger (Paul K) commented


@vadz, I figured out why it hasn't been working for me and what exactly happens here. I did compile wxwidgets with 10.15, but it was still not working, until I realized that the SDK is checked based on the executable and not the library. In fact, it works even when the library is built with 10.9, as long as the executable itself is built with 10.14+.

The switching between Dark and Normal mode also works in real time (so that's nice), but unfortunately there are some areas where the colors don't change for obvious reasons. For example, wxSTC needs manual handling to switch the colors.

Is there any event I can handle when the Dark mode is switched in the OS?

wxtrac commented 4 years ago

2019-12-29 07:10:45: paulclinger (Paul K) commented


Is there any event I can handle when the Dark mode is switched in the OS?

Never mind; found SYS_COLOUR_CHANGED event.

wxtrac commented 4 years ago

2019-12-29 23:34:50: paulclinger (Paul K) commented


Vadim, one question related to the dark mode: is it possible to make the app not use the dark mode even when it's compiled with 10.14+ sdk (or running on Linux/Win10)? Right now it will switch as soon as the mode is switched in the OS or if it's launched when the Dark mode is selected, but what if I want my app to stay white? I know I can not call Skip on the event, but it doesn't produce the desirable result, as the toolbar, the menu and the status bar still switch colors (and there are some inconsistencies in wxAui handling of this).

I suspect the answer is "no", but wanted to check in case I missed something.

wxtrac commented 4 years ago

2019-12-30 00:27:32: @imciner2 commented


There is a way to opt out (either programatically or through the Info.plist file). See here: https://developer.apple.com/documentation/appkit/nsappearancecustomization/choosing_a_specific_appearance_for_your_macos_app

We could add a global opt-out setting in the wxApp class (similar to the opt-out for automatic tabbing).