1 ! Copyright (C) 2006, 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors kernel sequences models ui.gadgets
4 math.geometry.rect fry ;
9 : hide-all ( book -- ) children>> [ hide-gadget ] each ;
11 : current-page ( book -- gadget ) [ control-value ] keep nth-gadget ;
13 M: book model-changed ( model book -- )
16 dup current-page show-gadget
19 : new-book ( pages model class -- book )
22 swap add-gadgets ; inline
24 : <book> ( pages model -- book ) book new-book ;
26 M: book pref-dim* ( book -- dim ) children>> pref-dims max-dim ;
28 M: book layout* ( book -- )
29 [ children>> ] [ dim>> ] bi '[ _ >>dim drop ] each ;
31 M: book focusable-child* ( book -- child/t ) current-page ;