1 ! Copyright (C) 2005, 2008 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.packs accessors math.geometry.rect ;
5 IN: ui.gadgets.incremental
7 TUPLE: incremental < pack cursor ;
9 : <incremental> ( -- incremental )
10 incremental new-gadget
14 M: incremental pref-dim*
16 dup call-next-method >>cursor
19 : next-cursor ( gadget incremental -- cursor )
21 [ rect-dim ] [ cursor>> ] bi*
23 ] keep orientation>> set-axis ;
25 : update-cursor ( gadget incremental -- )
26 tuck next-cursor >>cursor drop ;
28 : incremental-loc ( gadget incremental -- )
29 [ cursor>> ] [ orientation>> ] bi v*
32 : prefer-incremental ( gadget -- ) USE: slots.private
33 dup forget-pref-dim dup pref-dim >>dim drop ;
35 M: incremental dim-changed drop ;
37 : add-incremental ( gadget incremental -- )
39 2dup swap (add-gadget) drop
41 over prefer-incremental
45 dup prefer-incremental
46 parent>> [ invalidate* ] when*
49 : clear-incremental ( incremental -- )
54 parent>> [ relayout ] when* ;