]> gitweb.factorcode.org Git - factor.git/commitdiff
ui.backend.cocoa.views: fix jittery resize.
authorJohn Benediktsson <mrjbq7@gmail.com>
Fri, 22 May 2020 15:23:20 +0000 (08:23 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Fri, 22 May 2020 15:23:20 +0000 (08:23 -0700)
This could still be improved since this current approach pauses Factor
execution when the window is being resized, and it could instead
maybe detect inLiveResize or something and be smoother.

basis/ui/backend/cocoa/views/views.factor

index 0d79bbe36c32ddb6e36e7f3480ab776a6fae9253..820b4831dd377d753b398b35e7375c4e72441169 100644 (file)
@@ -125,12 +125,6 @@ CONSTANT: key-codes
 : send-action$ ( view event gesture -- )
     [ drop window ] dip over [ send-action ] [ 2drop ] if ;
 
-: add-resize-observer ( observer object -- )
-    [
-        "updateFactorGadgetSize:"
-        "NSViewFrameDidChangeNotification" <NSString>
-    ] dip add-observer ;
-
 : string-or-nil? ( NSString -- ? )
     [ CF>string NSStringPboardType = ] [ t ] if* ;
 
@@ -299,6 +293,13 @@ PRIVATE>
         ] when
     ] ;
 
+    METHOD: void reshape [
+        self window :> window
+        window [
+            self view-dim window dim<<
+        ] when
+    ] ;
+
     ! TouchBar
     METHOD: void touchBarCommand0 [ 0 touchbar-invoke-command ] ;
     METHOD: void touchBarCommand1 [ 1 touchbar-invoke-command ] ;
@@ -324,7 +325,11 @@ PRIVATE>
     ] ;
 
     ! Rendering
-    METHOD: void drawRect: NSRect rect [ self window [ draw-world ] when* ] ;
+    METHOD: void drawRect: NSRect rect [
+        self window [
+            draw-world yield
+        ] when*
+    ] ;
 
     ! Events
     METHOD: char acceptsFirstMouse: id event [ 0 ] ;
@@ -632,18 +637,9 @@ PRIVATE>
     METHOD: void doCommandBySelector: SEL selector [ ] ;
 
     ! Initialization
-    METHOD: void updateFactorGadgetSize: id notification
-    [
-        self window :> window
-        window [
-            self view-dim window dim<< yield
-        ] when
-    ] ;
-
     METHOD: id initWithFrame: NSRect frame pixelFormat: id pixelFormat
     [
         self frame pixelFormat SUPER-> initWithFrame:pixelFormat:
-        dup dup add-resize-observer
     ] ;
 
     METHOD: char isOpaque [ 0 ] ;