From 43623d8fa574043eb560bf61ef7afac8c65829df Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 13 Feb 2009 01:44:19 -0600 Subject: [PATCH] Different apperance for sliders with no thumb --- basis/ui/gadgets/sliders/sliders.factor | 38 +++++++++++++++++++------ 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/basis/ui/gadgets/sliders/sliders.factor b/basis/ui/gadgets/sliders/sliders.factor index fc1ce96803..658a58e894 100644 --- a/basis/ui/gadgets/sliders/sliders.factor +++ b/basis/ui/gadgets/sliders/sliders.factor @@ -143,9 +143,12 @@ elevator H{ [ dim>> ] [ thumb-dim ] [ orientation>> ] tri [ n*v ] keep set-axis [ ceiling ] map >>dim drop ; +: slider-enabled? ( slider -- ? ) + visible-portion 1 = not ; + : layout-thumb ( slider -- ) [ thumb>> ] keep - [ visible-portion 1 = not >>visible? drop ] + [ slider-enabled? >>visible? drop ] [ layout-thumb-loc ] [ layout-thumb-dim ] 2tri ; @@ -158,7 +161,7 @@ M: elevator layout* : ( orientation left right -- pen ) [ horizontal = ] 2dip ? - [ f f ] [ theme-image f ] bi* ; + [ f f ] [ theme-image f f ] bi* ; TUPLE: slide-button < repeat-button ; @@ -185,19 +188,36 @@ M: slide-button pref-dim* dup interior>> pen-pref-dim ; "vertical-scroller-downarrow-clicked" ; +TUPLE: slider-pen enabled disabled ; + : ( orientation -- pen ) { { horizontal [ - "horizontal-scroller-left" - "horizontal-scroller-middle" - "horizontal-scroller-right" + "horizontal-scroller-left" theme-image + "horizontal-scroller-middle" theme-image + "horizontal-scroller-right" theme-image + "horizontal-scroller-right-disabled" theme-image ] } { vertical [ - "vertical-scroller-top" - "vertical-scroller-middle" - "vertical-scroller-bottom" + "vertical-scroller-top" theme-image + "vertical-scroller-middle" theme-image + "vertical-scroller-bottom" theme-image + "vertical-scroller-bottom-disabled" theme-image ] } - } case [ theme-image ] tri@ ; + } case + [ ] bi-curry@ 2bi \ slider-pen boa ; + +: slider-pen ( slider pen -- pen ) + [ slider-enabled? ] [ [ enabled>> ] [ disabled>> ] bi ] bi* ? ; + +M: slider-pen draw-interior + dupd slider-pen draw-interior ; + +M: slider-pen draw-boundary + dupd slider-pen draw-boundary ; + +M: slider-pen pen-pref-dim + enabled>> pen-pref-dim ; M: slider pref-dim* [ dup interior>> pen-pref-dim ] [ drop { 100 100 } ] [ orientation>> ] tri