Mercurial > minori
annotate src/sys/osx/dark_theme.mm @ 105:6d8da6e64d61
theme: add dark stylesheet, make it actually usable
win32: make the titlebar black where available
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Sun, 05 Nov 2023 03:54:26 -0500 |
parents | cde8f67a7c7d |
children | 9c4645100fec |
rev | line source |
---|---|
2 | 1 #include "sys/osx/dark_theme.h" |
2 #import <Cocoa/Cocoa.h> | |
3 | |
9 | 4 namespace osx { |
5 | |
105
6d8da6e64d61
theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents:
15
diff
changeset
|
6 /* I remember clang giving a hissy fit when I tried simplifying this to just |
6d8da6e64d61
theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents:
15
diff
changeset
|
7 a return; does it still do that? */ |
9 | 8 bool DarkThemeAvailable() { |
5 | 9 if (@available(macOS 10.14, *)) |
10 return true; | |
11 else | |
12 return false; | |
2 | 13 } |
14 | |
9 | 15 bool IsInDarkTheme() { |
16 if (@available(macOS 10.14, *)) { | |
15 | 17 auto appearance = [NSApp.effectiveAppearance |
18 bestMatchFromAppearancesWithNames:@[ NSAppearanceNameAqua, NSAppearanceNameDarkAqua ]]; | |
9 | 19 return [appearance isEqualToString:NSAppearanceNameDarkAqua]; |
20 } | |
21 return false; | |
2 | 22 } |
23 | |
9 | 24 void SetToDarkTheme() { |
25 // https://stackoverflow.com/questions/55925862/how-can-i-set-my-os-x-application-theme-in-code | |
26 if (@available(macOS 10.14, *)) { | |
15 | 27 [NSApp setAppearance:[NSAppearance appearanceNamed:NSAppearanceNameDarkAqua]]; |
9 | 28 } |
2 | 29 } |
30 | |
9 | 31 void SetToLightTheme() { |
32 // https://stackoverflow.com/questions/55925862/how-can-i-set-my-os-x-application-theme-in-code | |
105
6d8da6e64d61
theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents:
15
diff
changeset
|
33 if (@available(macOS 10.14, *)) { |
15 | 34 [NSApp setAppearance:[NSAppearance appearanceNamed:NSAppearanceNameAqua]]; |
9 | 35 } |
2 | 36 } |
37 | |
9 | 38 void SetToAutoTheme() { |
39 if (@available(macOS 10.14, *)) { | |
40 [NSApp setAppearance:nil]; | |
41 } | |
2 | 42 } |
9 | 43 |
44 } // namespace osx |