factor/extra/ui/gadgets/books/books.factor

29 lines
691 B
Factor
Raw Normal View History

2007-09-20 18:09:08 -04:00
! Copyright (C) 2006, 2007 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
2007-11-13 18:51:10 -05:00
USING: kernel sequences models ui.gadgets ;
2007-09-20 18:09:08 -04:00
IN: ui.gadgets.books
TUPLE: book ;
: hide-all ( book -- ) gadget-children [ hide-gadget ] each ;
: current-page ( book -- gadget )
[ control-value ] keep nth-gadget ;
M: book model-changed
nip
2007-09-20 18:09:08 -04:00
dup hide-all
dup current-page show-gadget
relayout ;
: <book> ( pages model -- book )
<gadget> book construct-control [ add-gadgets ] keep ;
2007-09-20 18:09:08 -04:00
M: book pref-dim* gadget-children pref-dims max-dim ;
M: book layout*
dup rect-dim swap gadget-children
2008-01-09 17:36:30 -05:00
[ set-layout-dim ] with each ;
2007-09-20 18:09:08 -04:00
M: book focusable-child* current-page ;