From 96474ab059f894e996919178c49d0c058d7d9745 Mon Sep 17 00:00:00 2001 From: Sam Anklesaria Date: Tue, 28 Apr 2009 20:37:25 -0500 Subject: [PATCH] frp-table additions --- extra/ui/frp/frp-docs.factor | 2 +- extra/ui/frp/frp.factor | 41 ++++++++++---------- extra/ui/frp/frp.factor copy | 73 ------------------------------------ 3 files changed, 23 insertions(+), 93 deletions(-) delete mode 100644 extra/ui/frp/frp.factor copy diff --git a/extra/ui/frp/frp-docs.factor b/extra/ui/frp/frp-docs.factor index ac3306a54a..a6f625cc59 100644 --- a/extra/ui/frp/frp-docs.factor +++ b/extra/ui/frp/frp-docs.factor @@ -15,7 +15,7 @@ HELP: { $description "Creates an vertical track containing the gadgets listed in the quotation" } ; ! Gadgets -HELP: +HELP: { $description "Creates an button whose model updates on clicks" } ; HELP: diff --git a/extra/ui/frp/frp.factor b/extra/ui/frp/frp.factor index 6e9a03cd86..38e4f77084 100644 --- a/extra/ui/frp/frp.factor +++ b/extra/ui/frp/frp.factor @@ -1,9 +1,26 @@ -USING: accessors arrays fry kernel models models.product -monads sequences ui.gadgets ui.gadgets.buttons ui.gadgets.tracks -ui.gadgets.tables ; +USING: accessors arrays colors fonts fry kernel models +models.product monads sequences ui.gadgets ui.gadgets.buttons +ui.gadgets.editors ui.gadgets.line-support ui.gadgets.tables +ui.gadgets.tracks ui.render ; QUALIFIED: make IN: ui.frp +! Gadgets +: ( text -- button ) [ t swap set-control-value ] f >>model ; +TUPLE: frp-table < table quot val-quot color-quot column-titles column-alignment ; +M: frp-table column-titles column-titles>> ; +M: frp-table column-alignment column-alignment>> ; +M: frp-table row-columns quot>> call( a -- b ) ; +M: frp-table row-value val-quot>> call( a -- b ) ; +M: frp-table row-color color-quot>> call( a -- b ) ; + +: ( model quot -- table ) + frp-table new-line-gadget dup >>renderer swap >>quot swap >>model + f >>selected-value sans-serif-font >>font + focus-border-color >>focus-border-color + transparent >>column-line-color ; +: ( -- field ) f ; + ! Layout utilities GENERIC: output-model ( gadget -- model ) @@ -17,6 +34,7 @@ M: model , activate-model ; GENERIC: -> ( object -- model ) M: gadget -> dup make:, output-model ; M: model -> dup , ; +M: table -> dup , selected-value>> ; : ( models type -- track ) [ { } make:make ] dip swap dup [ model>> ] map @@ -24,18 +42,6 @@ M: model -> dup , ; : ( models -- track ) horizontal ; inline : ( models -- track ) vertical ; inline -! Gadgets -: ( text -- button ) [ t swap set-control-value ] f >>model ; -TUPLE: frp-table < table quot column-titles column-alignment ; -M: frp-table column-titles column-titles>> ; -M: frp-table column-alignment column-alignment>> ; -M: frp-table row-columns quot>> call( a -- b ) ; -: ( model quot -- table ) - frp-table new-line-gadget dup >>renderer swap >>quot swap >>model - f >>selected-value sans-serif-font >>font - focus-border-color >>focus-border-color - transparent >>column-line-color ; - ! Model utilities TUPLE: multi-model < model ; ! M: multi-model model-activated dup model-changed ; @@ -80,7 +86,4 @@ INSTANCE: gadget-monad monad INSTANCE: gadget monad M: gadget monad-of drop gadget-monad ; M: gadget-monad return drop swap >>model ; -M: gadget >>= model>> '[ _ swap call( x -- y ) ] ; - -! ! list (model = Columns), listContent (model = contents) - +M: gadget >>= model>> '[ _ swap call( x -- y ) ] ; \ No newline at end of file diff --git a/extra/ui/frp/frp.factor copy b/extra/ui/frp/frp.factor copy deleted file mode 100644 index 3ebb33e2d6..0000000000 --- a/extra/ui/frp/frp.factor copy +++ /dev/null @@ -1,73 +0,0 @@ -USING: accessors arrays fry kernel models models.product -monads sequences ui.gadgets ui.gadgets.buttons ui.gadgets.tracks ; -QUALIFIED: make -IN: ui.frp - -! Layout utilities - -GENERIC: , ( object -- ) -M: gadget , make:, ; -M: model , activate-model ; - -GENERIC: -> ( object -- model ) -M: gadget -> dup make:, model>> ; -M: model -> dup , ; - -: ( models type -- track ) - [ { } make:make ] dip swap dup [ model>> ] map - [ [ f track-add ] each ] dip >>model ; inline -: ( models -- track ) horizontal ; inline -: ( models -- track ) vertical ; inline - -! Gadgets -: ( text -- button ) [ t swap set-control-value ]