]> gitweb.factorcode.org Git - factor.git/blob - extra/ui/frp/gadgets/gadgets.factor
modulization of ui.frp
[factor.git] / extra / ui / frp / gadgets / gadgets.factor
1 USING: accessors arrays kernel models ui.frp.signals ui.gadgets
2 ui.gadgets.buttons ui.gadgets.buttons.private
3 ui.gadgets.editors ui.gadgets.tables ;
4 IN: ui.frp.gadgets
5
6 TUPLE: frp-button < button hook ;
7 : <frp-button> ( text -- button ) [
8       [ dup hook>> [ call( button -- ) ] [ drop ] if* ] keep
9       t swap set-control-value
10    ] frp-button new-button border-button-theme f <basic> >>model ;
11
12 TUPLE: frp-table < table { quot initial: [ ] } { val-quot initial: [ ] } color-quot column-titles column-alignment ;
13 M: frp-table column-titles column-titles>> ;
14 M: frp-table column-alignment column-alignment>> ;
15 M: frp-table row-columns quot>> [ call( a -- b ) ] [ drop f ] if* ;
16 M: frp-table row-value val-quot>> [ call( a -- b ) ]  [ drop f ] if* ;
17 M: frp-table row-color color-quot>> [ call( a -- b ) ]  [ drop f ] if* ;
18
19 : <frp-table> ( model -- table ) f frp-table new-table dup >>renderer
20    V{ } clone <basic> >>selected-values V{ } clone <basic> >>selected-indices* ;
21 : <frp-table*> ( -- table ) V{ } clone <model> <frp-table> ;
22 : <frp-list> ( model -- table ) <frp-table> [ 1array ] >>quot ;
23 : <frp-list*> ( -- table ) V{ } clone <model> <frp-list> ;
24 : indexed ( table -- table ) f >>val-quot ;
25
26 : <frp-field> ( -- field ) "" <model> <model-field> ;