diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index ba43830184..06b03e2769 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -30,8 +30,7 @@ - make the launchpad a palette - expired aliens in view hash - don't multiplex in the event loop if there is no pending i/o -- hand is broken by design - - maybe eliminate mouse-overs...? +- fix mouse-overs... - speed up ideas: - only do clipping for certain gadgets - use glRect diff --git a/library/cocoa/ui.factor b/library/cocoa/ui.factor index ffea40712f..876857f178 100644 --- a/library/cocoa/ui.factor +++ b/library/cocoa/ui.factor @@ -33,6 +33,9 @@ H{ } clone views set-global #! Cocoa -> Factor UI button mapping [buttonNumber] H{ { 0 1 } { 2 2 } { 1 3 } } hash ; +: button&loc ( view event -- button# loc ) + dup button -rot mouse-location ; + : modifiers { { "SHIFT" HEX: 10000 } @@ -67,7 +70,14 @@ H{ } clone views set-global >r view world-focus r> dup event>gesture pick handle-gesture [ [characters] CF>string swap user-input ] [ 2drop ] if ; -: button... button >r view r> ; +: send-button-down$ ( view event -- ) + over >r button&loc r> view send-button-down ; + +: send-button-up$ ( view event -- ) + over >r button&loc r> view send-button-up ; + +: send-wheel$ ( view event -- ) + [ [deltaY] 0 > ] 2keep mouse-location rot view send-wheel ; "NSOpenGLView" "FactorView" { { "drawRect:" "void" { "id" "SEL" "NSRect" } @@ -91,31 +101,31 @@ H{ } clone views set-global } { "mouseDown:" "void" { "id" "SEL" "id" } - [ nip button... send-button-down ] + [ nip send-button-down$ ] } { "mouseUp:" "void" { "id" "SEL" "id" } - [ nip button... send-button-up ] + [ nip send-button-up$ ] } { "rightMouseDown:" "void" { "id" "SEL" "id" } - [ nip button... send-button-down ] + [ nip send-button-down$ ] } { "rightMouseUp:" "void" { "id" "SEL" "id" } - [ nip button... send-button-up ] + [ nip send-button-up$ ] } { "otherMouseDown:" "void" { "id" "SEL" "id" } - [ nip button... send-button-down ] + [ nip send-button-down$ ] } { "otherMouseUp:" "void" { "id" "SEL" "id" } - [ nip button... send-button-up ] + [ nip send-button-up$ ] } { "scrollWheel:" "void" { "id" "SEL" "id" } - [ nip [deltaY] 0 > >r view r> send-scroll-wheel ] + [ nip send-wheel$ ] } { "keyDown:" "void" { "id" "SEL" "id" } @@ -181,6 +191,7 @@ IN: shells ] unless [ [ + init-ui launchpad-window listener-window finish-launching diff --git a/library/ui/hand.factor b/library/ui/hand.factor index 4502e0c234..84472743cd 100644 --- a/library/ui/hand.factor +++ b/library/ui/hand.factor @@ -20,6 +20,12 @@ SYMBOL: hand-click-loc SYMBOL: hand-buttons V{ } clone hand-buttons set-global +: button-gesture ( buttons gesture -- ) + #! Send a gesture like [ button-down 2 ]; if nobody + #! handles it, send [ button-down ]. + swap hand-clicked get-global 3dup >r add r> handle-gesture + [ nip handle-gesture drop ] [ 3drop ] if ; + : drag-gesture ( -- ) #! Send a gesture like [ drag 2 ]; if nobody handles it, #! send [ drag ]. @@ -86,12 +92,6 @@ V{ } clone hand-buttons set-global pick-up hand-gadget set-global under-hand r> hand-gestures update-help ; -: button-gesture ( buttons gesture -- ) - #! Send a gesture like [ button-down 2 ]; if nobody - #! handles it, send [ button-down ]. - swap hand-clicked get-global 3dup >r add r> handle-gesture - [ nip handle-gesture drop ] [ 3drop ] if ; - : update-clicked ( loc world -- ) move-hand hand-gadget get-global hand-clicked set-global diff --git a/library/ui/world.factor b/library/ui/world.factor index 4a523fa7cf..9c89d6ee58 100644 --- a/library/ui/world.factor +++ b/library/ui/world.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. IN: gadgets USING: errors freetype gadgets-layouts generic hashtables kernel -namespaces opengl sequences ; +math namespaces opengl sequences ; ! The world gadget is the top level gadget that all (visible) ! gadgets are contained in.