ui.backend.cocoa.views: fix jittery resize.

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.
master
John Benediktsson 2020-05-22 08:23:20 -07:00
parent 61102548f4
commit e2fa0a6392
1 changed files with 12 additions and 16 deletions

View File

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