]> gitweb.factorcode.org Git - factor.git/commitdiff
Add the <field> gadget to boids
authorwayo.cavazos <wayo.cavazos@gmail.com>
Sat, 15 Jul 2006 11:29:39 +0000 (11:29 +0000)
committerwayo.cavazos <wayo.cavazos@gmail.com>
Sat, 15 Jul 2006 11:29:39 +0000 (11:29 +0000)
contrib/boids.factor

index 2ceef57fa20af9a5130c2b3b6e78e30f7c20c244..b4c827617a7342dc906be4f433123c5e7f09a4c9 100644 (file)
@@ -8,7 +8,7 @@
 ! results, increase the size of the window (larger than 400x400 is
 ! good). Then press the "Reset" button to start the demo over.
 
-REQUIRES: slate ;
+REQUIRES: math slate vars ;
 
 USING: generic threads namespaces math kernel sequences arrays gadgets
        math-contrib slate vars ;
@@ -321,6 +321,25 @@ run-boids ;
 USING: gadgets-frames gadgets-labels gadgets-theme gadgets-grids
        gadgets-editors gadgets-buttons ;
 
+! USING: kernel arrays gadgets  gadgets-labels gadgets-editors vars ;
+
+TUPLE: field label editor quot ;
+
+VAR: field
+
+C: field ( label-text editor-text quot -- <field> )
+[ field ]
+[ field> set-field-quot
+  <editor> field> set-field-editor
+  <label> field> set-field-label
+  field> field-label field> field-editor 2array make-shelf
+  field> set-gadget-delegate
+  field> ]
+let ;
+
+M: field gadget-gestures
+drop H{ { T{ key-down f f "RETURN" } [ dup field-quot call ] } } ;
+
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
 : [bind] ( ns quot -- quot ) \ bind 3array >quotation ;