From 126a5186d8baa5b75fb0b911a9f6c1ada1cef97b Mon Sep 17 00:00:00 2001 From: slava Date: Fri, 26 May 2006 21:40:41 +0000 Subject: [PATCH] New gesture handling style --- TODO.FACTOR.txt | 1 - library/ui/apropos.factor | 23 +++++++++++------------ library/ui/buttons.factor | 33 ++++++++++++++++++++------------- library/ui/editors.factor | 35 +++++------------------------------ library/ui/gadgets.factor | 3 +-- library/ui/gestures.factor | 17 ++++------------- library/ui/panes.factor | 30 ++++++++++++++++-------------- library/ui/scrolling.factor | 11 ++++++----- library/ui/sliders.factor | 27 ++++++++++++++++----------- library/ui/tracks.factor | 14 +++++++------- 10 files changed, 86 insertions(+), 108 deletions(-) diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index 7dd88581dd..57d8f735d2 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -90,7 +90,6 @@ listener-gadget-scroller 4 slot ; - display lists - saving the image should save window configuration - variable width word wrap -- new gesture style + compiler/ffi: diff --git a/library/ui/apropos.factor b/library/ui/apropos.factor index 0a2d2af547..c5f0941620 100644 --- a/library/ui/apropos.factor +++ b/library/ui/apropos.factor @@ -5,21 +5,20 @@ kernel ; TUPLE: apropos-gadget scroller input ; -: apropos-pane ( gadget -- pane ) - [ apropos-gadget? ] find-parent +: apropos-gadget-pane ( apropos -- pane ) apropos-gadget-scroller scroller-gadget ; -: ( quot -- editor ) - "" [ - swap T{ key-down f f "RETURN" } set-action - ] keep ; - -: show-apropos ( editor -- ) - dup commit-editor-text - swap apropos-pane [ apropos ] with-pane ; - : ( -- gadget ) - [ show-apropos ] dup faint-boundary ; + "" dup faint-boundary ; + +: show-apropos ( apropos -- ) + dup apropos-gadget-input commit-editor-text + swap apropos-gadget-pane [ apropos ] with-pane ; + +M: apropos-gadget gadget-gestures + drop H{ + { T{ key-down f f "RETURN" } [ show-apropos ] } + } ; C: apropos-gadget ( -- ) { diff --git a/library/ui/buttons.factor b/library/ui/buttons.factor index a5b03dff3c..ab12d919c4 100644 --- a/library/ui/buttons.factor +++ b/library/ui/buttons.factor @@ -27,16 +27,17 @@ TUPLE: button rollover? pressed? quot ; : button-clicked ( button -- ) dup button-quot if-clicked ; -: button-gestures ( button quot -- ) - over set-button-quot - dup [ button-clicked ] T{ button-up } set-action - dup [ button-update ] T{ button-down } set-action - dup [ button-update ] T{ mouse-leave } set-action - [ button-update ] T{ mouse-enter } set-action ; +M: button gadget-gestures + drop H{ + { T{ button-up } [ button-clicked ] } + { T{ button-down } [ button-update ] } + { T{ mouse-leave } [ button-update ] } + { T{ mouse-enter } [ button-update ] } + } ; C: button ( gadget quot -- button ) rot over set-gadget-delegate - [ swap button-gestures ] keep ; + [ set-button-quot ] keep ; : ( gadget quot -- button )