]> gitweb.factorcode.org Git - factor.git/commitdiff
comboboxes use frp
authorSam Anklesaria <sam@Tintin.local>
Tue, 28 Jul 2009 16:40:58 +0000 (11:40 -0500)
committerSam Anklesaria <sam@Tintin.local>
Tue, 28 Jul 2009 16:40:58 +0000 (11:40 -0500)
extra/ui/frp/gadgets/gadgets.factor
extra/ui/gadgets/comboboxes/comboboxes.factor

index a1287c736346d9a5a0a90f8071d86a7e31ab90ba..f39ca3accde6e1a6b8f82921130b37cda1181cc0 100644 (file)
@@ -19,9 +19,10 @@ M: frp-table row-columns quot>> [ call( a -- b ) ] [ drop f ] if* ;
 M: frp-table row-value val-quot>> [ call( a -- b ) ]  [ drop f ] if* ;
 M: frp-table row-color color-quot>> [ call( a -- b ) ]  [ drop f ] if* ;
 
-: <frp-table> ( model -- table ) f frp-table new-table dup >>renderer
+: new-frp-table ( model class -- table ) f swap new-table dup >>renderer
    V{ } clone <basic> >>selected-values V{ } clone <basic> >>selected-indices*
    f <basic> >>actions dup [ actions>> set-model ] curry >>action ;
+: <frp-table> ( model -- table ) frp-table new-frp-table ;
 : <frp-table*> ( -- table ) V{ } clone <model> <frp-table> ;
 : <frp-list> ( column-model -- table ) <frp-table> [ 1array ] >>quot ;
 : <frp-list*> ( -- table ) V{ } clone <model> <frp-list> ;
@@ -52,11 +53,10 @@ M: frp-field model-changed 2dup frp-model>> =
 : <frp-action-field> ( -- field ) f <action-field> dup [ set-control-value ] curry >>quot
     f <model> >>model ;
 
-: image-prep ( -- quot ) scan current-vocab name>> "vocab:" "/icons/" surround ".tiff" surround [ <image-name> ] [ load-image ] [ ] tri
-    [ \ cached-image "memoize" word-prop set-at ] 3curry ;
-SYNTAX: IMG-FRP-BTN: image-prep [ <frp-button> ] append over push-all ;
+: image-prep ( -- image ) scan current-vocab name>> "vocab:" "/icons/" surround ".tiff" surround <image-name> dup cached-image drop ;
+SYNTAX: IMG-FRP-BTN: image-prep [ <frp-button> ] curry over push-all ;
 
-SYNTAX: IMG-BTN: image-prep [ swap <button> ] append over push-all ;
+SYNTAX: IMG-BTN: image-prep [ swap <button> ] curry over push-all ;
 
 GENERIC: output-model ( gadget -- model )
 M: gadget output-model model>> ;
index 137150001cda9586045e2649c50199b964189cdf..eddd105e24794b8174a01e9cf8b6321479eced7e 100644 (file)
@@ -1,22 +1,21 @@
-USING: accessors arrays kernel math.rectangles models sequences
-ui.gadgets ui.gadgets.glass ui.gadgets.labels
-ui.gadgets.tables ui.gestures ;
+USING: accessors arrays kernel math.rectangles sequences
+ui.frp.gadgets ui.frp.signals ui.gadgets ui.gadgets.glass
+ui.gadgets.labels ui.gadgets.tables ui.gestures ;
 IN: ui.gadgets.comboboxes
 
-TUPLE: combo-table < table spawner ;
+TUPLE: combo-table < frp-table spawner ;
 
-M: combo-table handle-gesture [ call-next-method ] 2keep swap
+M: combo-table handle-gesture [ call-next-method drop ] 2keep swap
    T{ button-up } = [
       [ spawner>> ]
-      [ selected-value>> value>> [ swap set-control-value ] [ drop ] if* ]
-      [ hide-glass ] tri drop t
-   ] [ drop ] if ;
+      [ selected-row [ swap set-control-value ] [ 2drop ] if ]
+      [ hide-glass ] tri
+   ] [ drop ] if ;
 
 TUPLE: combobox < label-control table ;
 combobox H{
    { T{ button-down } [ dup table>> over >>spawner <zero-rect> show-glass ] }
 } set-gestures
 
-: <combobox> ( options -- combobox ) [ first [ combobox new-label ] keep <model> >>model ] keep
-   [ 1array ] map <model> trivial-renderer combo-table new-table
-   >>table ;
\ No newline at end of file
+: <combobox> ( options -- combobox ) [ first [ combobox new-label ] keep <basic> >>model ] keep
+    <basic> combo-table new-frp-table [ 1array ] >>quot >>table ;
\ No newline at end of file