annotate src/sys/osx/dark_theme.mm @ 18:28d8f4c0ae12

*nix: add missing header file for stat
author Paper <mrpapersonic@gmail.com>
date Tue, 19 Sep 2023 23:02:39 -0400
parents cde8f67a7c7d
children 6d8da6e64d61
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
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
6 bool DarkThemeAvailable() {
5
51ae25154b70 Fix OS X support code
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
7 if (@available(macOS 10.14, *))
51ae25154b70 Fix OS X support code
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
8 return true;
51ae25154b70 Fix OS X support code
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
9 else
51ae25154b70 Fix OS X support code
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
10 return false;
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
11 }
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
12
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
13 bool IsInDarkTheme() {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
14 if (@available(macOS 10.14, *)) {
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
15 auto appearance = [NSApp.effectiveAppearance
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
16 bestMatchFromAppearancesWithNames:@[ NSAppearanceNameAqua, NSAppearanceNameDarkAqua ]];
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
17 return [appearance isEqualToString:NSAppearanceNameDarkAqua];
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
18 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
19 return false;
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
20 }
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
21
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
22 void SetToDarkTheme() {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
23 // 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
24 if (@available(macOS 10.14, *)) {
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
25 [NSApp setAppearance:[NSAppearance appearanceNamed:NSAppearanceNameDarkAqua]];
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
26 }
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
27 }
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
28
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
29 void SetToLightTheme() {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
30 // 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
31 if (__builtin_available(macOS 10.14, *)) {
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
32 [NSApp setAppearance:[NSAppearance appearanceNamed:NSAppearanceNameAqua]];
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
33 }
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
34 }
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
35
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
36 void SetToAutoTheme() {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
37 if (@available(macOS 10.14, *)) {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
38 [NSApp setAppearance:nil];
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
39 }
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
40 }
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
41
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
42 } // namespace osx