Update Cocoa for latest changes

slava 2006-03-23 22:46:35 +00:00
parent 9125357466
commit 6893186be4
4 changed files with 27 additions and 17 deletions

View File

@ -30,8 +30,7 @@
- make the launchpad a palette - make the launchpad a palette
- expired aliens in view hash - expired aliens in view hash
- don't multiplex in the event loop if there is no pending i/o - don't multiplex in the event loop if there is no pending i/o
- hand is broken by design - fix mouse-overs...
- maybe eliminate mouse-overs...?
- speed up ideas: - speed up ideas:
- only do clipping for certain gadgets - only do clipping for certain gadgets
- use glRect - use glRect

View File

@ -33,6 +33,9 @@ H{ } clone views set-global
#! Cocoa -> Factor UI button mapping #! Cocoa -> Factor UI button mapping
[buttonNumber] H{ { 0 1 } { 2 2 } { 1 3 } } hash ; [buttonNumber] H{ { 0 1 } { 2 2 } { 1 3 } } hash ;
: button&loc ( view event -- button# loc )
dup button -rot mouse-location ;
: modifiers : modifiers
{ {
{ "SHIFT" HEX: 10000 } { "SHIFT" HEX: 10000 }
@ -67,7 +70,14 @@ H{ } clone views set-global
>r view world-focus r> dup event>gesture pick handle-gesture >r view world-focus r> dup event>gesture pick handle-gesture
[ [characters] CF>string swap user-input ] [ 2drop ] if ; [ [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" { "NSOpenGLView" "FactorView" {
{ "drawRect:" "void" { "id" "SEL" "NSRect" } { "drawRect:" "void" { "id" "SEL" "NSRect" }
@ -91,31 +101,31 @@ H{ } clone views set-global
} }
{ "mouseDown:" "void" { "id" "SEL" "id" } { "mouseDown:" "void" { "id" "SEL" "id" }
[ nip button... send-button-down ] [ nip send-button-down$ ]
} }
{ "mouseUp:" "void" { "id" "SEL" "id" } { "mouseUp:" "void" { "id" "SEL" "id" }
[ nip button... send-button-up ] [ nip send-button-up$ ]
} }
{ "rightMouseDown:" "void" { "id" "SEL" "id" } { "rightMouseDown:" "void" { "id" "SEL" "id" }
[ nip button... send-button-down ] [ nip send-button-down$ ]
} }
{ "rightMouseUp:" "void" { "id" "SEL" "id" } { "rightMouseUp:" "void" { "id" "SEL" "id" }
[ nip button... send-button-up ] [ nip send-button-up$ ]
} }
{ "otherMouseDown:" "void" { "id" "SEL" "id" } { "otherMouseDown:" "void" { "id" "SEL" "id" }
[ nip button... send-button-down ] [ nip send-button-down$ ]
} }
{ "otherMouseUp:" "void" { "id" "SEL" "id" } { "otherMouseUp:" "void" { "id" "SEL" "id" }
[ nip button... send-button-up ] [ nip send-button-up$ ]
} }
{ "scrollWheel:" "void" { "id" "SEL" "id" } { "scrollWheel:" "void" { "id" "SEL" "id" }
[ nip [deltaY] 0 > >r view r> send-scroll-wheel ] [ nip send-wheel$ ]
} }
{ "keyDown:" "void" { "id" "SEL" "id" } { "keyDown:" "void" { "id" "SEL" "id" }
@ -181,6 +191,7 @@ IN: shells
] unless ] unless
[ [
[ [
init-ui
launchpad-window launchpad-window
listener-window listener-window
finish-launching finish-launching

View File

@ -20,6 +20,12 @@ SYMBOL: hand-click-loc
SYMBOL: hand-buttons SYMBOL: hand-buttons
V{ } clone hand-buttons set-global 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 ( -- ) : drag-gesture ( -- )
#! Send a gesture like [ drag 2 ]; if nobody handles it, #! Send a gesture like [ drag 2 ]; if nobody handles it,
#! send [ drag ]. #! send [ drag ].
@ -86,12 +92,6 @@ V{ } clone hand-buttons set-global
pick-up hand-gadget set-global pick-up hand-gadget set-global
under-hand r> hand-gestures update-help ; 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 -- ) : update-clicked ( loc world -- )
move-hand move-hand
hand-gadget get-global hand-clicked set-global hand-gadget get-global hand-clicked set-global

View File

@ -2,7 +2,7 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
IN: gadgets IN: gadgets
USING: errors freetype gadgets-layouts generic hashtables kernel 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) ! The world gadget is the top level gadget that all (visible)
! gadgets are contained in. ! gadgets are contained in.