: <dir-table> ( tree-model -- table )
<frp-list*> [ node>> 1array ] >>quot
- [ selected-value>> [ file? not ] <filter> <switch> ]
+ [ selected-value>> [ file? not ] <filter> swap <switch> ]
[ swap >>model ] bi ;
\ No newline at end of file
M: model-field output-model field-model>> ;
M: scroller output-model viewport>> children>> first output-model ;
+TUPLE: frp-field < field frp-model ;
+
+M: model-field graft*
+ [ [ field-model>> value>> ] [ editor>> ] bi set-editor-string ]
+ [ dup editor>> model>> add-connection ]
+ bi ;
+
+! frp-fields observe the underlying editor, relaying the string to the
+! frp-model. Also, however, they relay the frp-model to the document and
+! relayout
+
+! Frp boxes should unactivate all models attatched to them
+
+! Table gadgets should have slots for their illusions, not requireing manual activation
+! and allowing deactivation an superior memory management
+
: <frp-field> ( -- field ) "" <model> <model-field> ;
-: <frp-field*> ( model -- field ) "" <model> swap <switch> <model-field> ;
+: <frp-field*> ( model -- field ) "" <model> <switch> <model-field> ;
: <frp-editor> ( model -- gadget )
model-field [ <multiline-editor> ] dip new-border dup gadget-child >>editor
field-theme swap >>field-model { 1 0 } >>align ;
-: <frp-editor*> ( model -- editor ) "" <model> swap <switch> <frp-editor> ;
+: <frp-editor*> ( model -- editor ) "" <model> <switch> <frp-editor> ;
+: after-empty ( model quot -- model' ) fmap "" <model> <switch> ; inline
IN: accessors
M: frp-button text>> children>> first text>> ;
\ No newline at end of file
USING: accessors fry kernel lexer math.parser models
-sequences ui.frp.signals ui.gadgets.tracks ui.gadgets
+sequences ui.gadgets.tracks ui.gadgets models.product
ui.frp.gadgets ui.gadgets.books ;
QUALIFIED: make
IN: ui.frp.layout
GENERIC: , ( uiitem -- )
M: gadget , f <layout> make:, ;
-M: model , activate-model ;
+M: model , make:, ;
SYNTAX: ,% scan string>number [ <layout> make:, ] curry over push-all ;
SYNTAX: ->% scan string>number '[ [ _ <layout> make:, ] [ output-model ] bi ] over push-all ;
: <spacer> ( -- ) <gadget> 1 <layout> make:, ;
: <box> ( gadgets type -- track )
- [ { } make:make ] dip <track> swap [ [ gadget>> ] [ width>> ] bi track-add ] each ; inline
-: <box*> ( gadgets type -- track ) [ <box> ] [ [ model>> ] map <|> ] bi >>model ; inline
+ [ { } make:make dup [ layout? ] filter ] dip <track> swap [ [ gadget>> ] [ width>> ] bi track-add ] each
+ swap [ model? ] filter [ <product> >>model ] unless-empty ; inline
: <hbox> ( gadgets -- track ) horizontal <box> ; inline
-: <hbox*> ( gadgets -- track ) horizontal <box*> ; inline
: <vbox> ( gadgets -- track ) vertical <box> ; inline
-: <vbox*> ( gadgets -- track ) vertical <box*> ; inline
: <frp-book> ( gadgets -- book ) { } make:make [ gadget>> ] map f <book> ; inline
\ No newline at end of file
HELP: <switch>
{ $values { "signal1" model } { "signal2" model } { "signal'" model } }
-{ $description "Creates a signal that starts with the behavior of signal1 and switches to the behavior of signal2 on its update" } ;
+{ $description "Creates a signal that starts with the behavior of signal2 and switches to the behavior of signal1 on its update" } ;
HELP: <mapped>
{ $values { "model" model } { "quot" "applied to model's value on updates" } { "signal" model } }
M: switch-model (model-changed) 2dup switcher>> =
[ [ value>> ] [ t >>on ] bi* set-model ]
[ dup on>> [ 2drop ] [ [ value>> ] dip set-model ] if ] if ;
-: <switch> ( signal1 signal2 -- signal' ) [ 2array switch-model <multi-model> ] 2keep
+: <switch> ( signal1 signal2 -- signal' ) swap [ 2array switch-model <multi-model> ] 2keep
[ >>original ] [ >>switcher ] bi* ;
M: switch-model model-activated [ original>> ] keep model-changed ;
-: >behavior ( event -- behavior ) t <model> swap <switch> ;
+: >behavior ( event -- behavior ) t <model> <switch> ;
TUPLE: mapped-model < multi-model model quot ;
: new-mapped-model ( model quot class -- mapped-model ) [ over 1array ] dip
M: action (model-changed) [ [ value>> ] [ quot>> ] bi* call( a -- b ) ] keep value>>
[ swap add-connection ] 2keep model-changed ;
: <action> ( model quot -- action-signal ) [ 1array action <multi-model> ] dip >>quot dup f <action-value> >>value value>> ;
-
+<PRIVATE
TUPLE: | < multi-model ;
: <|> ( models -- product ) | <multi-model> ;
GENERIC: models-changed ( product -- )
TUPLE: & < | ;
: <&> ( models -- product ) & <multi-model> ;
M: & models-changed dependencies>> [ f swap (>>value) ] each ;
-
+PRIVATE>
FMAPS: $> <$ fmap FOR & | ;
\ No newline at end of file