]> gitweb.factorcode.org Git - factor.git/commitdiff
frp model activation changes
authorSam Anklesaria <sam@Tintin.local>
Sun, 31 May 2009 16:57:05 +0000 (11:57 -0500)
committerSam Anklesaria <sam@Tintin.local>
Sun, 31 May 2009 16:57:05 +0000 (11:57 -0500)
extra/file-trees/file-trees.factor
extra/ui/frp/gadgets/gadgets.factor
extra/ui/frp/layout/layout.factor
extra/ui/frp/signals/signals-docs.factor
extra/ui/frp/signals/signals.factor

index fa9411cfbf655053ef7befcbeb80257f95bdf604..0329021f573e62bb8b52d57b37a656ecca1cf52b 100644 (file)
@@ -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 ;
\ No newline at end of file
index 3568d4036d6916ee8c387dd91071d8a7dba86f4b..7df9a4e8c9d40509c52242434e96ff5b1bb503ea 100644 (file)
@@ -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>> ;
\ No newline at end of file
index 6e6689dce36186aba2a2872003fec0f5259ce1f4..b2d888470dafb8ff9ccf1daab99c5ec0c95d26d2 100644 (file)
@@ -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
\ No newline at end of file
index 2cc455c7ff62988ebdbd75d4bbe5e372b85e831b..e2b14234e1ebb0420e5df2123831db9ed7aa61fa 100644 (file)
@@ -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 } }
index 650acb37c80064ed4dd40b3d7dc697a8751f6fb7..145c25c0d6200881309cce2f88a3d094d0fbd6cf 100644 (file)
@@ -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 & | ;
\ No newline at end of file