From 58d8aacb74242d0c416b677c7d4a9baa9fcaca38 Mon Sep 17 00:00:00 2001 From: Sam Anklesaria Date: Wed, 22 Jul 2009 09:46:52 -0500 Subject: [PATCH] generalized image buttons --- extra/recipes/recipes.factor | 10 +++++----- extra/ui/frp/gadgets/gadgets-docs.factor | 6 +++++- extra/ui/frp/gadgets/gadgets.factor | 6 ++++-- extra/ui/frp/layout/layout-docs.factor | 8 ++++---- extra/ui/frp/signals/signals-docs.factor | 7 +++---- 5 files changed, 21 insertions(+), 16 deletions(-) diff --git a/extra/recipes/recipes.factor b/extra/recipes/recipes.factor index 71d2c41524..4ad9397504 100644 --- a/extra/recipes/recipes.factor +++ b/extra/recipes/recipes.factor @@ -31,11 +31,11 @@ STORED-TUPLE: recipe { title { VARCHAR 100 } } { votes INTEGER } { txt TEXT } { interface :> tbl "okay" BUTTON -> :> ok - IMAGE-BUTTON: submit [ store-tuple ] >>value TOOLBAR -> :> submit - IMAGE-BUTTON: love 1 >>value TOOLBAR -> - IMAGE-BUTTON: hate -1 >>value -> 2array :> votes - IMAGE-BUTTON: back -> [ -30 ] <$ - IMAGE-BUTTON: more -> [ 30 ] <$ 2array :> viewed + IMG-FRP-BTN: submit [ store-tuple ] >>value TOOLBAR -> :> submit + IMG-FRP-BTN: love 1 >>value TOOLBAR -> + IMG-FRP-BTN: hate -1 >>value -> 2array :> votes + IMG-FRP-BTN: back -> [ -30 ] <$ + IMG-FRP-BTN: more -> [ 30 ] <$ 2array :> viewed ->% 1 :> search submit ok [ [ drop ] ] <$ 2array [ drop ] >>value :> quot viewed 0 [ + ] search ok t "all" ALL -> diff --git a/extra/ui/frp/gadgets/gadgets-docs.factor b/extra/ui/frp/gadgets/gadgets-docs.factor index 0df9194746..ee0c764e60 100644 --- a/extra/ui/frp/gadgets/gadgets-docs.factor +++ b/extra/ui/frp/gadgets/gadgets-docs.factor @@ -58,10 +58,14 @@ HELP: { $values { "field" action-field } } { $description "Field that updates its model with its contents when the user hits the return key" } ; -HELP: IMAGE-BUTTON: +HELP: IMG-FRP-BTN: { $syntax "IMAGE-BUTTON: filename" } { $description "Creates a button using a tiff image named as specified found in the icons subdirectory of the vocabulary path" } ; +HELP: IMG-BTN: +{ $syntax "[ do-something ] IMAGE-BUTTON: filename" } +{ $description "Creates a button using a tiff image named as specified found in the icons subdirectory of the vocabulary path, calling the specified quotation on click" } ; + HELP: output-model { $values { "gadget" gadget } { "model" model } } { $description "Returns the model a gadget uses for output. Often the same as " { $link model>> } } ; \ No newline at end of file diff --git a/extra/ui/frp/gadgets/gadgets.factor b/extra/ui/frp/gadgets/gadgets.factor index a5a16676ef..db693e350c 100644 --- a/extra/ui/frp/gadgets/gadgets.factor +++ b/extra/ui/frp/gadgets/gadgets.factor @@ -52,8 +52,10 @@ M: frp-field model-changed 2dup frp-model>> = : ( -- field ) f dup [ set-control-value ] curry >>quot f >>model ; -SYNTAX: IMAGE-BUTTON: scan current-vocab name>> "vocab:" "/icons/" surround ".tiff" surround - [ ] curry over push-all ; +: image-prep ( -- image ) scan current-vocab name>> "vocab:" "/icons/" surround ".tiff" surround ; +SYNTAX: IMG-FRP-BTN: image-prep [ ] curry over push-all ; + +SYNTAX: IMG-BTN: image-prep [ swap