- optimize away dispatch\r
- layouts with gaps\r
- alignment of gadgets inside their bounding boxes needs thought\r
-- WordPreview calls markTokens() -> NPE\r
- faster completion\r
- ppc register decls\r
- rename f* words to stream-*\r
- slot compile problem\r
- sdl console crash\r
- x86 register decl\r
+- UI: don't roll over if mouse button is down\r
\r
+ compiler/ffi:\r
\r
] ifte ;
M: list prettyprint* ( indent list -- indent )
- [
- [
- \ [ swap \ ] prettyprint-sequence
- ] check-recursion
- ] [
- f unparse write
- ] ifte* ;
+ [
+ \ [ swap \ ] prettyprint-sequence
+ ] check-recursion ;
M: cons prettyprint* ( indent cons -- indent )
#! Here we turn the cons into a list of two elements.
SYMBOL: button-up
SYMBOL: button-down
+: hierarchy-gesture ( gadget ? gesture -- ? )
+ swap [
+ 2drop f
+ ] [
+ swap handle-gesture* drop t
+ ] ifte ;
+
: mouse-enter ( point gadget -- )
#! If the old point is inside the new gadget, do not fire an
#! enter gesture, since the mouse did not enter. Otherwise,
#! fire an enter gesture and go on to the parent.
[
[ shape-pos + ] keep
- 2dup inside? [
- drop f
- ] [
- [ mouse-enter ] swap handle-gesture* drop t
- ] ifte
+ 2dup inside? [ mouse-enter ] hierarchy-gesture
] each-parent drop ;
: mouse-leave ( point gadget -- )
#! fire a leave gesture and go on to the parent.
[
[ shape-pos + ] keep
- 2dup inside? [
- drop f
- ] [
- [ mouse-leave ] swap handle-gesture* drop t
- ] ifte
+ 2dup inside? [ mouse-leave ] hierarchy-gesture
+ ] each-parent drop ;
+
+: lose-focus ( old new -- )
+ #! If the old focus owner is a child of the new owner, do
+ #! not fire a focus lost gesture, since the focus was not
+ #! lost. Otherwise, fire a focus lost gesture and go to the
+ #! parent.
+ [
+ 2dup child? [ lose-focus ] hierarchy-gesture
+ ] each-parent drop ;
+
+: gain-focus ( old new -- )
+ #! If the old focus owner is a child of the new owner, do
+ #! not fire a focus gained gesture, since the focus was not
+ #! gained. Otherwise, fire a focus gained gesture and go on
+ #! to the parent.
+ [
+ 2dup child? [ gain-focus ] hierarchy-gesture
] each-parent drop ;
! The hand is a special gadget that holds mouse position and
! mouse button click state. The hand's parent is the world, but
! it is special in that the world does not list it as part of
-! its contents.
-TUPLE: hand click-pos clicked buttons gadget delegate ;
+! its contents. Some comments on the slots:
+! - hand-gadget is the gadget under the mouse position
+! - hand-clicked is the most recently clicked gadget
+! - hand-focus is the gadget holding keyboard focus
+TUPLE: hand click-pos clicked buttons gadget focus delegate ;
C: hand ( world -- hand )
0 0 0 0 <rectangle> <gadget>
dup r> fire-leave
dup fire-motion
r> swap fire-enter ;
+
+: request-focus ( gadget -- )
+ my-hand hand-focus swap
+ 2dup lose-focus
+ 2dup my-hand set-hand-focus
+ gain-focus ;