magic scrollers hide sliders when not needed
parent
a621e381e3
commit
df371bd8bb
|
@ -0,0 +1 @@
|
|||
Sam Anklesaria
|
|
@ -0,0 +1,21 @@
|
|||
! Copyright (C) 2009 Sam Anklesaria.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: arrays accessors kernel models threads calendar ;
|
||||
IN: models.conditional
|
||||
|
||||
TUPLE: conditional < model condition thread ;
|
||||
|
||||
M: conditional model-changed
|
||||
[
|
||||
[ dup
|
||||
[ condition>> call( -- ? ) ]
|
||||
[ thread>> self = not ] bi or
|
||||
[ [ value>> ] dip set-model f ]
|
||||
[ 2drop t ] if 100 milliseconds sleep
|
||||
] 2curry "models.conditional" spawn-server
|
||||
] keep (>>thread) ;
|
||||
|
||||
: <conditional> ( condition -- model )
|
||||
f conditional new-model swap >>condition ;
|
||||
|
||||
M: conditional model-activated [ model>> ] keep model-changed ;
|
|
@ -0,0 +1 @@
|
|||
Sam Anklesaria
|
|
@ -0,0 +1,21 @@
|
|||
! Copyright (C) 2009 Sam Anklesaria.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: accessors combinators kernel math models sequences
|
||||
ui.gadgets ui.gadgets.scrollers ui.gadgets.sliders ;
|
||||
IN: ui.gadgets.magic-scrollers
|
||||
|
||||
TUPLE: magic-slider < slider ;
|
||||
: <magic-slider> ( range orientation -- slider ) magic-slider new-slider ;
|
||||
: get-dim ( orientation dims -- dim )
|
||||
swap {
|
||||
{ horizontal [ first ] }
|
||||
{ vertical [ second ] }
|
||||
} case ;
|
||||
|
||||
! do this with pref-dim*, not draw-gadget
|
||||
M: magic-slider model-changed [ call-next-method ] 2keep swap value>>
|
||||
[ second ] [ fourth ] bi < [ show-gadget ] [ hide-gadget ] if ;
|
||||
|
||||
TUPLE: magic-scroller < scroller ;
|
||||
: <magic-scroller> ( gadget -- scroller ) magic-scroller new-scroller ;
|
||||
M: magic-scroller (build-children) <magic-slider> ;
|
Loading…
Reference in New Issue