1 ! Copyright (C) 2007, 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: arrays hashtables help.markup help.stylesheet io
4 io.styles kernel math models namespaces sequences ui ui.gadgets
5 ui.gadgets.books ui.gadgets.panes ui.gestures ui.render
6 parser accessors colors ;
26 { page-color T{ rgba f 0.4 0.4 0.4 0.3 } }
33 { foreground T{ rgba f 0.1 0.1 0.4 1 } }
37 H{ { wrap-margin 1000 } }
40 H{ { table-gap { 10 20 } } }
45 : $title ( string -- )
46 [ H{ { font "sans-serif" } { font-size 48 } } format ] ($block) ;
52 T{ rgba f 0.25 0.25 0.25 1.0 }
53 T{ rgba f 1.0 1.0 1.0 0.0 }
54 } <gradient> >>interior
60 : page-theme ( gadget -- )
61 { T{ rgba f 0.8 0.8 1.0 1.0 } T{ rgba f 0.8 1.0 1.0 1.0 } } <gradient>
64 : <page> ( list -- gadget )
67 [ print-element ] with-default-style
72 : $slide ( element -- )
77 TUPLE: slides < book ;
79 : <slides> ( slides -- gadget )
80 [ <page> ] map 0 <model> slides new-book ;
82 : change-page ( book n -- )
83 over control-value + over children>> length rem
84 swap model>> set-model ;
86 : next-page ( book -- ) 1 change-page ;
88 : prev-page ( book -- ) -1 change-page ;
90 : (strip-tease) ( data n -- data )
91 [ first3 ] dip head 3array ;
93 : strip-tease ( data -- seq )
99 parse-definition strip-tease [ parsed ] each ; parsing
102 { T{ key-down f f "DOWN" } [ next-page ] }
103 { T{ key-down f f "UP" } [ prev-page ] }
106 : slides-window ( slides -- )
107 [ <slides> "Slides" open-window ] with-ui ;