]> gitweb.factorcode.org Git - factor.git/commitdiff
ui.backend.cocoa: support automatic changing of themes
authorJohn Benediktsson <mrjbq7@gmail.com>
Sat, 5 Mar 2022 15:02:15 +0000 (07:02 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Sat, 5 Mar 2022 15:02:15 +0000 (07:02 -0800)
basis/ui/backend/cocoa/cocoa.factor
basis/ui/backend/cocoa/views/views.factor

index 25518a17965dc86236185105999adf34633cbff2..c99241a651209935ef5e318b0e48211b5fcb955f 100644 (file)
@@ -7,7 +7,8 @@ combinators core-foundation.run-loop core-foundation.strings
 core-graphics core-graphics.types io.thread kernel literals math
 math.bitwise math.rectangles namespaces sequences threads ui
 ui.backend ui.backend.cocoa.views ui.clipboards
-ui.gadgets.worlds ui.pixel-formats ui.private ;
+ui.gadgets.worlds ui.pixel-formats ui.private ui.theme
+ui.theme.switching ;
 IN: ui.backend.cocoa
 
 TUPLE: window-handle view window ;
@@ -206,11 +207,11 @@ M: cocoa-ui-backend system-alert
 : install-app-delegate ( -- )
     NSApp FactorApplicationDelegate install-delegate ;
 
-: current-theme ( -- )
-    NSAppearance -> currentAppearance -> name [
-        CF>string "NSAppearanceNameDarkAqua" =
-        dark-theme light-theme ? switch-theme-if-default
-    ] when* ;
+: current-theme ( -- )
+    NSAppearance -> currentAppearance -> name [
+        CF>string "NSAppearanceNameDarkAqua" =
+        dark-theme light-theme ? switch-theme-if-default
+    ] when* ;
 
 SYMBOL: cocoa-startup-hook
 
@@ -222,7 +223,7 @@ M: cocoa-ui-backend (with-ui)
     "UI" assert.app [
         init-clipboard
         cocoa-startup-hook get call( -- )
-        current-theme
+        current-theme
         start-ui
         stop-io-thread
         init-thread-timer
index be51f635b72c4b39b07c3376a57e491899b14bf6..f101f87abc6f638ed0d183d4a9187b742b94e790 100644 (file)
@@ -12,7 +12,7 @@ math.rectangles math.vectors namespaces opengl sequences
 splitting threads ui.backend.cocoa.input-methods ui.commands
 ui.gadgets ui.gadgets.editors ui.gadgets.line-support
 ui.gadgets.private ui.gadgets.worlds ui.gestures ui.private
-words ;
+ui.theme ui.theme.switching words ;
 
 IN: ui.backend.cocoa.views
 
@@ -325,12 +325,12 @@ PRIVATE>
 
     ! Light/Dark Mode
 
-    METHOD: void viewDidChangeEffectiveAppearance [
-        self -> effectiveAppearance -> name [
-            CF>string "NSAppearanceNameDarkAqua" =
-            dark-theme light-theme ? switch-theme-if-default
-        ] when*
-    ] ;
+    METHOD: void viewDidChangeEffectiveAppearance [
+        self -> effectiveAppearance -> name [
+            CF>string "NSAppearanceNameDarkAqua" =
+            dark-theme light-theme ? switch-theme-if-default
+        ] when*
+    ] ;
 
     ! Events
     METHOD: char acceptsFirstMouse: id event [ 0 ] ;