From 96d29b7dbaf1fa0cf69160fe76f607651198b3d5 Mon Sep 17 00:00:00 2001 From: Sam Anklesaria <sam@Tintin.local> Date: Sun, 24 May 2009 15:35:03 -0500 Subject: [PATCH] illusion models activated automatically --- basis/models/illusion/illusion.factor | 2 +- extra/ui/frp/gadgets/gadgets.factor | 6 ++++-- extra/ui/frp/signals/signals.factor | 1 + extra/ui/gadgets/alerts/alerts.factor | 4 ++-- extra/ui/gadgets/comboboxes/comboboxes.factor | 6 +++--- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/basis/models/illusion/illusion.factor b/basis/models/illusion/illusion.factor index 6cab6e6371..f41a4a2444 100644 --- a/basis/models/illusion/illusion.factor +++ b/basis/models/illusion/illusion.factor @@ -5,7 +5,7 @@ TUPLE: illusion < arrow ; : <illusion> ( model quot -- illusion ) illusion new V{ } clone >>connections V{ } clone >>dependencies 0 >>ref - swap >>quot over >>model [ add-dependency ] keep ; + swap >>quot over >>model [ add-dependency ] keep dup activate-model ; : backtalk ( value object -- ) [ quot>> [undo] call( a -- b ) ] [ model>> ] bi set-model ; diff --git a/extra/ui/frp/gadgets/gadgets.factor b/extra/ui/frp/gadgets/gadgets.factor index 02bc8f45cb..08c7b44002 100644 --- a/extra/ui/frp/gadgets/gadgets.factor +++ b/extra/ui/frp/gadgets/gadgets.factor @@ -4,10 +4,12 @@ ui.gadgets.editors ui.gadgets.tables ; IN: ui.frp.gadgets TUPLE: frp-button < button hook ; -: <frp-button> ( text -- button ) [ +: <frp-button> ( gadget -- button ) [ [ dup hook>> [ call( button -- ) ] [ drop ] if* ] keep t swap set-control-value - ] frp-button new-button border-button-theme f <basic> >>model ; + ] frp-button new-button f <basic> >>model ; + +: <frp-bevel-button> ( text -- button ) <frp-button> border-button-theme ; TUPLE: frp-table < table { quot initial: [ ] } { val-quot initial: [ ] } color-quot column-titles column-alignment ; M: frp-table column-titles column-titles>> ; diff --git a/extra/ui/frp/signals/signals.factor b/extra/ui/frp/signals/signals.factor index 184dd05365..c7c9736111 100644 --- a/extra/ui/frp/signals/signals.factor +++ b/extra/ui/frp/signals/signals.factor @@ -38,6 +38,7 @@ M: switch-model (model-changed) 2dup switcher>> = : <switch> ( signal1 signal2 -- signal' ) [ 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> ; TUPLE: mapped-model < multi-model model quot ; : new-mapped-model ( model quot class -- const-model ) [ over 1array ] dip diff --git a/extra/ui/gadgets/alerts/alerts.factor b/extra/ui/gadgets/alerts/alerts.factor index 265c0fdc74..e948c92d43 100644 --- a/extra/ui/gadgets/alerts/alerts.factor +++ b/extra/ui/gadgets/alerts/alerts.factor @@ -10,7 +10,7 @@ IN: ui.gadgets.alerts :: ask-user* ( model string -- model' ) [ [let | lbl [ string <label> T{ font { name "sans-serif" } { size 14 } } >>font dup , ] fldm [ <frp-field> ->% 1 ] - btn [ "okay" <frp-button> model >>model ] | + btn [ "okay" <frp-bevel-button> model >>model ] | btn -> [ fldm swap <updates> ] [ [ drop lbl close-window ] $> , ] bi ] ] <vbox> { 161 86 } >>pref-dim "" open-window ; @@ -20,7 +20,7 @@ IN: ui.gadgets.alerts MACRO: ask-buttons ( buttons -- quot ) dup length [ [ swap [ 22 wrap-lines <label> T{ font { name "sans-serif" } { size 18 } } >>font , - [ [ <frp-button> [ close-window ] >>hook -> ] map ] <hbox> , ] <vbox> + [ [ <frp-bevel-button> [ close-window ] >>hook -> ] map ] <hbox> , ] <vbox> { 200 110 } >>pref-dim "" open-window ] dip firstn ] 2curry ; \ No newline at end of file diff --git a/extra/ui/gadgets/comboboxes/comboboxes.factor b/extra/ui/gadgets/comboboxes/comboboxes.factor index a937b73d35..137150001c 100644 --- a/extra/ui/gadgets/comboboxes/comboboxes.factor +++ b/extra/ui/gadgets/comboboxes/comboboxes.factor @@ -1,6 +1,6 @@ USING: accessors arrays kernel math.rectangles models sequences -ui.frp ui.gadgets ui.gadgets.glass ui.gadgets.labels -ui.gadgets.tables ui.gestures colors.constants fonts ; +ui.gadgets ui.gadgets.glass ui.gadgets.labels +ui.gadgets.tables ui.gestures ; IN: ui.gadgets.comboboxes TUPLE: combo-table < table spawner ; @@ -19,4 +19,4 @@ combobox H{ : <combobox> ( options -- combobox ) [ first [ combobox new-label ] keep <model> >>model ] keep [ 1array ] map <model> trivial-renderer combo-table new-table - >>table dup font>> COLOR: gray >>background 12 >>size >>font ; \ No newline at end of file + >>table ; \ No newline at end of file