Mercurial > minori
comparison src/sys/osx/dark_theme.mm @ 5:51ae25154b70
Fix OS X support code
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Sat, 12 Aug 2023 13:10:34 -0400 |
parents | 23d0d9319a00 |
children | 5c0397762b53 |
comparison
equal
deleted
inserted
replaced
4:5af270662505 | 5:51ae25154b70 |
---|---|
1 #include "sys/osx/dark_theme.h" | 1 #include "sys/osx/dark_theme.h" |
2 #import <Cocoa/Cocoa.h> | 2 #import <Cocoa/Cocoa.h> |
3 | 3 |
4 bool osx::DarkThemeAvailable() | 4 bool osx::DarkThemeAvailable() |
5 { | 5 { |
6 return (__builtin_available(macOS 10.14, *)) ? true : false; | 6 if (@available(macOS 10.14, *)) |
7 return true; | |
8 else | |
9 return false; | |
7 } | 10 } |
8 | 11 |
9 bool osx::IsInDarkTheme() | 12 bool osx::IsInDarkTheme() |
10 { | 13 { |
11 if (__builtin_available(macOS 10.14, *)) | 14 if (@available(macOS 10.14, *)) |
12 { | 15 { |
13 auto appearance = [NSApp.effectiveAppearance bestMatchFromAppearancesWithNames: | 16 auto appearance = [NSApp.effectiveAppearance bestMatchFromAppearancesWithNames: |
14 @[ NSAppearanceNameAqua, NSAppearanceNameDarkAqua ]]; | 17 @[ NSAppearanceNameAqua, NSAppearanceNameDarkAqua ]]; |
15 return [appearance isEqualToString:NSAppearanceNameDarkAqua]; | 18 return [appearance isEqualToString:NSAppearanceNameDarkAqua]; |
16 } | 19 } |
18 } | 21 } |
19 | 22 |
20 void osx::SetToDarkTheme() | 23 void osx::SetToDarkTheme() |
21 { | 24 { |
22 // https://stackoverflow.com/questions/55925862/how-can-i-set-my-os-x-application-theme-in-code | 25 // https://stackoverflow.com/questions/55925862/how-can-i-set-my-os-x-application-theme-in-code |
23 if (__builtin_available(macOS 10.14, *)) | 26 if (@available(macOS 10.14, *)) |
24 { | 27 { |
25 [NSApp setAppearance:[NSAppearance appearanceNamed:NSAppearanceNameDarkAqua]]; | 28 [NSApp setAppearance:[NSAppearance appearanceNamed:NSAppearanceNameDarkAqua]]; |
26 } | 29 } |
27 } | 30 } |
28 | 31 |
35 } | 38 } |
36 } | 39 } |
37 | 40 |
38 void osx::SetToAutoTheme() | 41 void osx::SetToAutoTheme() |
39 { | 42 { |
40 if (__builtin_available(macOS 10.14, *)) | 43 if (@available(macOS 10.14, *)) |
41 { | 44 { |
42 [NSApp setAppearance:nil]; | 45 [NSApp setAppearance:nil]; |
43 } | 46 } |
44 } | 47 } |