]> gitweb.factorcode.org Git - factor.git/commitdiff
ui.backend.cocoa.views: add light/dark mode switching.
authorJohn Benediktsson <mrjbq7@gmail.com>
Fri, 31 Dec 2021 04:20:37 +0000 (20:20 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Fri, 31 Dec 2021 04:20:37 +0000 (20:20 -0800)
basis/ui/backend/cocoa/views/views.factor

index fb33261b3280118dcd27d83938a2b7b99df8bb6d..48d20387ad39ae3de0604df4719b86596691d193 100644 (file)
@@ -4,15 +4,14 @@ USING: accessors alien alien.c-types alien.data alien.strings
 arrays assocs classes cocoa cocoa.application cocoa.classes
 cocoa.pasteboard cocoa.runtime cocoa.subclassing cocoa.touchbar
 cocoa.types cocoa.views combinators core-foundation.strings
-core-graphics core-graphics.types core-text io.encodings.utf8
-kernel literals locals math math.order math.parser
-math.rectangles namespaces opengl sequences splitting threads
-ui.commands ui.gadgets ui.gadgets.private ui.gadgets.worlds
-ui.gestures ui.private words sorting math.vectors
-ui.baseline-alignment ui.gadgets.line-support
-ui.gadgets.editors ui.backend.cocoa.input-methods
-ui.backend.cocoa.input-methods.editors io.encodings.utf16n
-io.encodings.string classes.struct ;
+core-graphics core-graphics.types core-text io.encodings.string
+io.encodings.utf16n io.encodings.utf8 kernel literals math
+math.order math.parser 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 ui.theme
+ui.theme.switching words ;
 IN: ui.backend.cocoa.views
 
 SLOT: window
@@ -331,6 +330,17 @@ PRIVATE>
         ] when*
     ] ;
 
+    ! Light/Dark Mode
+
+    METHOD: void viewDidChangeEffectiveAppearance [
+        self -> effectiveAppearance -> name [
+            CF>string {
+                { "NSAppearanceNameAqua" [ light-theme ] }
+                { "NSAppearanceNameDarkAqua" [ dark-theme ] }
+            } case switch-theme
+        ] when*
+    ] ;
+
     ! Events
     METHOD: char acceptsFirstMouse: id event [ 0 ] ;