1 ! Copyright (C) 2005, 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: io kernel math namespaces math.vectors ui.gadgets
4 ui.gadgets.private ui.gadgets.packs accessors
5 math.rectangles combinators ;
6 IN: ui.gadgets.incremental
8 TUPLE: incremental < pack cursor ;
10 : <incremental> ( -- incremental )
12 vertical >>orientation
15 M: incremental pref-dim*
17 dup call-next-method >>cursor
20 : next-cursor ( gadget incremental -- cursor )
22 [ dim>> ] [ cursor>> ] bi*
24 ] keep orientation>> set-axis ;
26 : update-cursor ( gadget incremental -- )
27 [ nip ] [ next-cursor ] 2bi >>cursor drop ;
29 : incremental-loc ( gadget incremental -- )
30 [ cursor>> ] [ orientation>> ] bi v*
33 : prefer-incremental ( gadget -- )
34 dup forget-pref-dim dup pref-dim >>dim drop ;
36 M: incremental dim-changed drop ;
38 : add-incremental ( gadget incremental -- )
43 [ drop prefer-incremental ]
47 [ nip prefer-incremental ]
48 [ nip parent>> [ invalidate* ] when* ]
52 : clear-incremental ( incremental -- )
56 [ { 0 0 } >>cursor parent>> [ relayout ] when* ]