]> gitweb.factorcode.org Git - factor.git/commitdiff
basic notion of keyboard focus
authorSlava Pestov <slava@factorcode.org>
Fri, 11 Feb 2005 17:45:24 +0000 (17:45 +0000)
committerSlava Pestov <slava@factorcode.org>
Fri, 11 Feb 2005 17:45:24 +0000 (17:45 +0000)
13 files changed:
examples/gadget-test.factor
fonts/Vera.ttf [new file with mode: 0644]
fonts/VeraBI.ttf [new file with mode: 0644]
fonts/VeraBd.ttf [new file with mode: 0644]
fonts/VeraIt.ttf [new file with mode: 0644]
fonts/VeraSe.ttf [new file with mode: 0644]
fonts/VeraSeBd.ttf [new file with mode: 0644]
library/bootstrap/boot-stage2.factor
library/sdl/sdl-utils.factor
library/ui/gadgets.factor
library/ui/gestures.factor
library/ui/hand.factor
library/ui/world.factor

index 859a20e1a472b74c973dfa455b1fe8d03836f204..9b47faa4da8b84f8dd14cc06fe0284614b3da393 100644 (file)
@@ -36,10 +36,20 @@ USE: stdio
 USE: prettyprint
 USE: words
 
+: grab ( gadget hand -- )
+    [ swap screen-pos swap screen-pos - >rect ] 2keep
+    >r [ move-gadget ] keep r> add-gadget ;
+
+: release ( gadget world -- )
+    >r dup screen-pos >r
+    dup unparent
+    r> >rect pick move-gadget
+    r> add-gadget ;
+
 : moving-actions
     {{
-        [[ [ button-down 1 ] [ 0 0 pick move-gadget my-hand add-gadget ] ]]
-        [[ [ button-up 1 ] [ my-hand shape-x my-hand shape-y pick move-gadget world get add-gadget ] ]]
+            [[ [ button-down 1 ] [ my-hand grab ] ]]
+        [[ [ button-up 1 ] [ world get release ] ]]
     }} swap set-gadget-gestures ;
 
 : filled? "filled" get checkbox-selected? ;
@@ -65,12 +75,11 @@ USE: words
     "Filled?" <checkbox> dup "filled" set "shelf" get add-gadget
     "shelf" get "pile" get add-gadget
     "Welcome to Factor " version cat2 <label> "pile" get add-gadget
+    "Welcome to Factor " version cat2 <label> <field> "pile" get add-gadget
+    "Welcome to Factor " version cat2 <label> <field> "pile" get add-gadget
 
     "pile" get bevel-border dup "dialog" set dup  
- {{
-         [[ [ button-down 1 ] [ dup unparent 0 0 pick move-gadget my-hand add-gadget ] ]]
-         [[ [ button-up 1 ] [ my-hand shape-x my-hand shape-y pick move-gadget world get add-gadget ] ]]
-     }} swap set-gadget-gestures
+ moving-actions
   world get add-gadget ;
 
 : gadget-demo ( -- )
diff --git a/fonts/Vera.ttf b/fonts/Vera.ttf
new file mode 100644 (file)
index 0000000..58cd6b5
Binary files /dev/null and b/fonts/Vera.ttf differ
diff --git a/fonts/VeraBI.ttf b/fonts/VeraBI.ttf
new file mode 100644 (file)
index 0000000..b55eee3
Binary files /dev/null and b/fonts/VeraBI.ttf differ
diff --git a/fonts/VeraBd.ttf b/fonts/VeraBd.ttf
new file mode 100644 (file)
index 0000000..51d6111
Binary files /dev/null and b/fonts/VeraBd.ttf differ
diff --git a/fonts/VeraIt.ttf b/fonts/VeraIt.ttf
new file mode 100644 (file)
index 0000000..cc23c9e
Binary files /dev/null and b/fonts/VeraIt.ttf differ
diff --git a/fonts/VeraSe.ttf b/fonts/VeraSe.ttf
new file mode 100644 (file)
index 0000000..4b4ecc6
Binary files /dev/null and b/fonts/VeraSe.ttf differ
diff --git a/fonts/VeraSeBd.ttf b/fonts/VeraSeBd.ttf
new file mode 100644 (file)
index 0000000..672bf76
Binary files /dev/null and b/fonts/VeraSeBd.ttf differ
index 33df1d16fc3058cc038de1290c88db4bc21d745c..cf1f2a061be832038ac9065778d48dfe207da537 100644 (file)
@@ -162,6 +162,7 @@ cpu "x86" = [
         "/library/ui/world.factor"\r
         "/library/ui/labels.factor"\r
         "/library/ui/buttons.factor"\r
+        "/library/ui/fields.factor"\r
         "/library/ui/events.factor"\r
     ] [\r
         dup print\r
index 49c003bc2f6141c04907b840802dc2b6ba96f404..84b777278037c23f33ae0dcca75a18c761f0d444 100644 (file)
@@ -129,6 +129,8 @@ SYMBOL: logical-fonts
 global [
     {{
         [[ "Monospaced" "/fonts/VeraMono.ttf" ]]
+        [[ "Serif" "/fonts/VeraSe.ttf" ]]
+        [[ "Sans Serif" "/fonts/Vera.ttf" ]]
     }} logical-fonts set
 ] bind
 
index 4aeb29e489bb589d36fbb8fee93d94c9f4fa7ad4..1683af160e282a66f12cf0bd923373e2889ccc59 100644 (file)
@@ -59,13 +59,13 @@ C: gadget ( shape -- gadget )
 : each-parent ( gadget quot -- )
     #! Apply quotation to each parent of the gadget in turn,
     #! stopping when the quotation returns f.
-    [ call ] 2keep rot [
-        >r gadget-parent dup [
-            r> each-parent
+    over [
+        [ call ] 2keep rot [
+            >r gadget-parent r> each-parent
         ] [
-            r> 2drop
+            2drop
         ] ifte
-    ] [
+    ] [ 
         2drop
     ] ifte ; inline
 
index 76d4daadaf4e6404135bbaa2700f2b5af62ea6b0..e4afe052e329d4a600afb2404e8b2a89acf9fbcd 100644 (file)
@@ -52,7 +52,7 @@ SYMBOL: button-down
         2dup inside? [ mouse-leave ] hierarchy-gesture
     ] each-parent drop ;
 
-: lose-focus ( old new -- )
+: lose-focus ( new old -- )
     #! 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
index f1d609df225abe3460d979ae2680ec79a6f9310a..e627c1ba86a72314c10e651669176ddcd09d0869 100644 (file)
@@ -86,7 +86,7 @@ C: hand ( world -- hand )
     r> swap fire-enter ;
 
 : request-focus ( gadget -- )
-    my-hand hand-focus swap
+    my-hand hand-focus
     2dup lose-focus
-    2dup my-hand set-hand-focus
+    swap dup my-hand set-hand-focus
     gain-focus ;
index 4eb5f90844a2bbc25b92f1585276f8da3e74eadb..9339c3b07c28554658311e780b5329a19fe6bcb7 100644 (file)
@@ -68,13 +68,13 @@ DEFER: handle-event
 
 global [
     <world> world set
-    640 480 world get resize-gadget
+    1024 768 world get resize-gadget
     {{
-        [[ background [ 216 216 216 ] ]]
-        [[ foreground [ 0 0 0 ] ]]
-        [[ bevel-1    [ 240 240 240 ] ]]
-        [[ bevel-2    [ 192 192 192 ] ]]
+        [[ background [ 255 255 255 ] ]]
+        [[ foreground [ 0 0 102 ] ]]
+        [[ bevel-1    [ 224 224 255 ] ]]
+        [[ bevel-2    [ 192 192 216 ] ]]
         [[ bevel-up?  t ]]
-        [[ font       [[ "Monospaced" 12 ]] ]]
+        [[ font       [[ "Sans Serif" 14 ]] ]]
     }} world get set-gadget-paint
 ] bind