annotate src/sys/osx/dark_theme.mm @ 201:8f6f8dd2eb23

dep/animia: finish kvm backend dep/animia: cmake: don't use kvm on unsupported systems, use private and public includes properly cmake: why are we defining target include directories twice?
author paper@DavesDouble.local
date Sun, 19 Nov 2023 19:13:28 -0500
parents 6d8da6e64d61
children 9c4645100fec
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
1 #include "sys/osx/dark_theme.h"
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
2 #import <Cocoa/Cocoa.h>
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
3
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
4 namespace osx {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
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
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
8 bool DarkThemeAvailable() {
5
51ae25154b70 Fix OS X support code
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
9 if (@available(macOS 10.14, *))
51ae25154b70 Fix OS X support code
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
10 return true;
51ae25154b70 Fix OS X support code
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
11 else
51ae25154b70 Fix OS X support code
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
12 return false;
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
13 }
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
14
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
15 bool IsInDarkTheme() {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
16 if (@available(macOS 10.14, *)) {
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
17 auto appearance = [NSApp.effectiveAppearance
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
18 bestMatchFromAppearancesWithNames:@[ NSAppearanceNameAqua, NSAppearanceNameDarkAqua ]];
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
19 return [appearance isEqualToString:NSAppearanceNameDarkAqua];
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
20 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
21 return false;
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
22 }
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
23
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
24 void SetToDarkTheme() {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
25 // https://stackoverflow.com/questions/55925862/how-can-i-set-my-os-x-application-theme-in-code
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
26 if (@available(macOS 10.14, *)) {
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
27 [NSApp setAppearance:[NSAppearance appearanceNamed:NSAppearanceNameDarkAqua]];
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
28 }
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
29 }
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
30
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
31 void SetToLightTheme() {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
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
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
34 [NSApp setAppearance:[NSAppearance appearanceNamed:NSAppearanceNameAqua]];
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
35 }
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
36 }
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
37
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
38 void SetToAutoTheme() {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
39 if (@available(macOS 10.14, *)) {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
40 [NSApp setAppearance:nil];
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
41 }
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
42 }
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
43
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
44 } // namespace osx