frp model activation changes
parent
e7cc0d02c6
commit
47edda1f66
|
@ -44,5 +44,5 @@ DEFER: (tree-insert)
|
|||
|
||||
: <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 ;
|
|
@ -33,12 +33,29 @@ M: table output-model dup multiple-selection?>>
|
|||
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>> ;
|
|
@ -1,5 +1,5 @@
|
|||
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
|
||||
|
@ -7,7 +7,7 @@ TUPLE: layout gadget width ; C: <layout> 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 ;
|
||||
|
@ -18,11 +18,9 @@ M: model -> dup , ;
|
|||
|
||||
: <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
|
|
@ -15,7 +15,7 @@ HELP: <fold>
|
|||
|
||||
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 } }
|
||||
|
|
|
@ -35,10 +35,10 @@ TUPLE: switch-model < multi-model original switcher on ;
|
|||
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
|
||||
|
@ -64,7 +64,7 @@ TUPLE: action < multi-model quot ;
|
|||
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 -- )
|
||||
|
@ -82,5 +82,5 @@ M: | model-activated dup model-changed ;
|
|||
TUPLE: & < | ;
|
||||
: <&> ( models -- product ) & <multi-model> ;
|
||||
M: & models-changed dependencies>> [ f swap (>>value) ] each ;
|
||||
|
||||
PRIVATE>
|
||||
FMAPS: $> <$ fmap FOR & | ;
|
Loading…
Reference in New Issue