! TrueType font rendering demo. ! ! To run this code, bootstrap Factor like so: ! ! ./f boot.image.le32 ! -libraries:sdl:name=libSDL.so ! -libraries:sdl-gfx:name=libSDL_gfx.so ! -libraries:sdl-ttf:name=libSDL_ttf.so ! ! (But all on one line) ! ! Then, start Factor as usual (./f factor.image) and enter this ! at the listener: ! ! "examples/text-demo.factor" run-file IN: text-demo USE: streams USE: sdl USE: sdl-event USE: sdl-gfx USE: sdl-video USE: sdl-ttf USE: namespaces USE: math USE: kernel USE: test USE: compiler USE: strings USE: alien USE: prettyprint USE: lists USE: gadgets USE: generic USE: stdio USE: prettyprint USE: words : grab ( gadget hand -- ) [ swap screen-pos swap screen-pos - >rect ] 2keep >r [ move-gadget ] keep r> add-gadget ; : release ( gadget world -- ) >r dup screen-pos >r dup unparent r> >rect pick move-gadget r> add-gadget ; : moving-actions {{ [[ [ button-down 1 ] [ my-hand grab ] ]] [[ [ button-up 1 ] [ world get release ] ]] }} swap set-gadget-gestures ; : filled? "filled" get checkbox-selected? ; : filled? [ ] [ ] ifte dup moving-actions ; : filled? [ ] [ ] ifte dup moving-actions ; : dup moving-actions ; : make-shapes ( -- ) f world get set-gadget-children 100 20 0 0 "pile" set 0 0 0 0 "shelf" set "Close" [ "dialog" get world get remove-gadget ]