On Wed, 10 Apr 2019 08:20:48 +0000 Stefan Csomor wrote:
SC> NSAppearance.current is the appearance that is active on the current
SC> thread, any UI element may set this as it wants to, for a window it may
SC> be a composited appearance (there are examples of a darkAqua appearance
SC> window within a aqua NSApp in the presentation) therefore when we want
SC> to resolve the NSColor to its rgb representation we must manually make
SC> sure this uses our NSApp.effectiveAppearance, without it at least on
SC> the early 10.14 betas things didn't always work properly, so we used
SC> the approach mentioned in
SC>
SC>
https://developer.apple.com/videos/play/wwdc2018/218
Sorry, I didn't have time to watch the video, so maybe I'm annoying you
with the questions already answered in it, but I'm still missing something
fundamental here: when is NSAppearance.current changed? Shouldn't it be
done by the window which wants to use the non-default appearance only while
it's repainting itself? And, if so, wouldn't it actually make sense for
wxSystemSettings::GetColour() to return the colour appropriate for this
window, rather than the global application value, _if_ it's called while
this window is being repainted?
SC> SC> In the emulated statusbar we use the value of the red channel of a
SC> SC> certain system color to determine whether we are really in dark mode
SC> SC>
SC> SC> wxColour bg = wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE);
SC> SC>
SC> SC> if ( bg.Red() < 128 )
SC> SC> {
SC> SC> // dark mode appearance
SC>
SC> This is more compatible with "is using dark theme" approach rather than
SC> "is using the system dark mode" approach. It could be a better idea or not,
SC> but I'm a bit surprised that you recommend doing it like this because
SC> everything I found during my (admittedly brief) web search seemed to
SC> recommend checking "AppleInterfaceStyle" value. Are the situations in which
SC> these 2 methods would yield different results?
SC>
SC> it depends whether you want to find out which name the appearance our
SC> app in use has or whether it renders the background darker.
Well, that's the question, isn't it... I was under impression that under
10.14 there were just 2 appearances: light and dark. And, of course, both
approaches work equally well for just 2 of them. But I also thought that
perhaps Apple might add some other appearance in a later version and then
we'd have to recognize it as well and IsSystemThemeDark() won't be enough
for doing it. Of course, I have absolutely no idea about how likely this
is...
SC> there have been appearance managers that allowed you to customize the
SC> appearance,
SC>
SC> If we need the name then actually I'd suggest using
SC>
SC> NSAppearanceName appearanceName = [[NSApp effectiveAppearance] name];
SC>
SC> which on my machine gives NSAppearanceNameDarkAqua or NSAppearanceNameAqua, and I don't think at the app level this is already is already composited, but if we must make sure and want to decide which of the 'standard' appearances it is we could use this recommended approach
SC>
SC> NSAppearanceName appearanceName = [[NSApp effectiveAppearance] bestMatchFromAppearancesWithNames :@[ NSAppearanceNameAqua, NSAppearanceNameDarkAqua];
SC>
SC> if ([appearanceName isEqualToString:NSAppearanceNameDarkAqua]) {
SC> // use dark color
I've seen several mentions of this approach not working on some early
10.14 versions, but if you think it's fine to use it now, let's do it like
this.
SC> SC> so this could be encapsulated in a system function, to me
SC> SC> wxSystemSettings first comes to mind
SC>
SC> OK, as both you and New Pagodi prefer this, let's go with it. I'm still
SC> not sure if it should be GetSystemThemeType(), as proposed by New Pagodi,
SC> or just IsSystemThemeDark() as you seem to be leaning to?
SC>
SC> it may be wise to encapsulate both, I think type should rather be a
SC> string than an enum - and for rendering the darkness my be more
SC> relevant than the precise appearance
I dislike string-typed APIs... If we want to do it like this, it would
have to be an object, with GetName() and IsDark() methods. Or would this be
going too far for not much gain? OTOH, it's not like creating a class costs
a lot neither.
So I'm probably going to end up doing it like this, with new wxSystemTheme
class.
Any last minute comments/suggestions/better name proposals?
Thanks!
VZ