comboboxes use frp

db4
Sam Anklesaria 2009-07-28 11:40:58 -05:00
parent 16e44372e3
commit 7a5309f075
2 changed files with 15 additions and 16 deletions

View 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-value val-quot>> [ call( a -- b ) ] [ drop f ] if* ;
M: frp-table row-color color-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* V{ } clone <basic> >>selected-values V{ } clone <basic> >>selected-indices*
f <basic> >>actions dup [ actions>> set-model ] curry >>action ; 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-table*> ( -- table ) V{ } clone <model> <frp-table> ;
: <frp-list> ( column-model -- table ) <frp-table> [ 1array ] >>quot ; : <frp-list> ( column-model -- table ) <frp-table> [ 1array ] >>quot ;
: <frp-list*> ( -- table ) V{ } clone <model> <frp-list> ; : <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 : <frp-action-field> ( -- field ) f <action-field> dup [ set-control-value ] curry >>quot
f <model> >>model ; f <model> >>model ;
: image-prep ( -- quot ) scan current-vocab name>> "vocab:" "/icons/" surround ".tiff" surround [ <image-name> ] [ load-image ] [ ] tri : image-prep ( -- image ) scan current-vocab name>> "vocab:" "/icons/" surround ".tiff" surround <image-name> dup cached-image drop ;
[ \ cached-image "memoize" word-prop set-at ] 3curry ; SYNTAX: IMG-FRP-BTN: image-prep [ <frp-button> ] curry over push-all ;
SYNTAX: IMG-FRP-BTN: image-prep [ <frp-button> ] append 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 ) GENERIC: output-model ( gadget -- model )
M: gadget output-model model>> ; M: gadget output-model model>> ;

View File

@ -1,22 +1,21 @@
USING: accessors arrays kernel math.rectangles models sequences USING: accessors arrays kernel math.rectangles sequences
ui.gadgets ui.gadgets.glass ui.gadgets.labels ui.frp.gadgets ui.frp.signals ui.gadgets ui.gadgets.glass
ui.gadgets.tables ui.gestures ; ui.gadgets.labels ui.gadgets.tables ui.gestures ;
IN: ui.gadgets.comboboxes 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 } = [ T{ button-up } = [
[ spawner>> ] [ spawner>> ]
[ selected-value>> value>> [ swap set-control-value ] [ drop ] if* ] [ selected-row [ swap set-control-value ] [ 2drop ] if ]
[ hide-glass ] tri drop t [ hide-glass ] tri
] [ drop ] if ; ] [ drop ] if t ;
TUPLE: combobox < label-control table ; TUPLE: combobox < label-control table ;
combobox H{ combobox H{
{ T{ button-down } [ dup table>> over >>spawner <zero-rect> show-glass ] } { T{ button-down } [ dup table>> over >>spawner <zero-rect> show-glass ] }
} set-gestures } set-gestures
: <combobox> ( options -- combobox ) [ first [ combobox new-label ] keep <model> >>model ] keep : <combobox> ( options -- combobox ) [ first [ combobox new-label ] keep <basic> >>model ] keep
[ 1array ] map <model> trivial-renderer combo-table new-table <basic> combo-table new-frp-table [ 1array ] >>quot >>table ;
>>table ;