Mercurial > minori
view src/sys/osx/dark_theme.mm @ 2:23d0d9319a00
Update
Also converted everything to LF from CRLF
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Sat, 12 Aug 2023 03:16:26 -0400 |
parents | 1ae666fdf9e2 |
children | 51ae25154b70 |
line wrap: on
line source
#include "sys/osx/dark_theme.h" #import <Cocoa/Cocoa.h> bool osx::DarkThemeAvailable() { return (__builtin_available(macOS 10.14, *)) ? true : false; } bool osx::IsInDarkTheme() { if (__builtin_available(macOS 10.14, *)) { auto appearance = [NSApp.effectiveAppearance bestMatchFromAppearancesWithNames: @[ NSAppearanceNameAqua, NSAppearanceNameDarkAqua ]]; return [appearance isEqualToString:NSAppearanceNameDarkAqua]; } return false; } void osx::SetToDarkTheme() { // https://stackoverflow.com/questions/55925862/how-can-i-set-my-os-x-application-theme-in-code if (__builtin_available(macOS 10.14, *)) { [NSApp setAppearance:[NSAppearance appearanceNamed:NSAppearanceNameDarkAqua]]; } } void osx::SetToLightTheme() { // https://stackoverflow.com/questions/55925862/how-can-i-set-my-os-x-application-theme-in-code if (__builtin_available(macOS 10.14, *)) { [NSApp setAppearance:[NSAppearance appearanceNamed:NSAppearanceNameAqua]]; } } void osx::SetToAutoTheme() { if (__builtin_available(macOS 10.14, *)) { [NSApp setAppearance:nil]; } }