comparison src/sys/osx/dark_theme.mm @ 15:cde8f67a7c7d

*: update, megacommit :)
author Paper <mrpapersonic@gmail.com>
date Tue, 19 Sep 2023 22:36:08 -0400
parents 5c0397762b53
children 6d8da6e64d61
comparison
equal deleted inserted replaced
14:a29c9402faf0 15:cde8f67a7c7d
10 return false; 10 return false;
11 } 11 }
12 12
13 bool IsInDarkTheme() { 13 bool IsInDarkTheme() {
14 if (@available(macOS 10.14, *)) { 14 if (@available(macOS 10.14, *)) {
15 auto appearance = 15 auto appearance = [NSApp.effectiveAppearance
16 [NSApp.effectiveAppearance bestMatchFromAppearancesWithNames:@[ 16 bestMatchFromAppearancesWithNames:@[ NSAppearanceNameAqua, NSAppearanceNameDarkAqua ]];
17 NSAppearanceNameAqua, NSAppearanceNameDarkAqua
18 ]];
19 return [appearance isEqualToString:NSAppearanceNameDarkAqua]; 17 return [appearance isEqualToString:NSAppearanceNameDarkAqua];
20 } 18 }
21 return false; 19 return false;
22 } 20 }
23 21
24 void SetToDarkTheme() { 22 void SetToDarkTheme() {
25 // https://stackoverflow.com/questions/55925862/how-can-i-set-my-os-x-application-theme-in-code 23 // https://stackoverflow.com/questions/55925862/how-can-i-set-my-os-x-application-theme-in-code
26 if (@available(macOS 10.14, *)) { 24 if (@available(macOS 10.14, *)) {
27 [NSApp setAppearance:[NSAppearance 25 [NSApp setAppearance:[NSAppearance appearanceNamed:NSAppearanceNameDarkAqua]];
28 appearanceNamed:NSAppearanceNameDarkAqua]];
29 } 26 }
30 } 27 }
31 28
32 void SetToLightTheme() { 29 void SetToLightTheme() {
33 // https://stackoverflow.com/questions/55925862/how-can-i-set-my-os-x-application-theme-in-code 30 // https://stackoverflow.com/questions/55925862/how-can-i-set-my-os-x-application-theme-in-code
34 if (__builtin_available(macOS 10.14, *)) { 31 if (__builtin_available(macOS 10.14, *)) {
35 [NSApp 32 [NSApp setAppearance:[NSAppearance appearanceNamed:NSAppearanceNameAqua]];
36 setAppearance:[NSAppearance appearanceNamed:NSAppearanceNameAqua]];
37 } 33 }
38 } 34 }
39 35
40 void SetToAutoTheme() { 36 void SetToAutoTheme() {
41 if (@available(macOS 10.14, *)) { 37 if (@available(macOS 10.14, *)) {