factor/unmaintained/ui/offscreen/offscreen.factor

46 lines
1.3 KiB
Factor
Raw Normal View History

! (c) 2008 Joe Groff, see license for details
2009-04-03 13:54:34 -04:00
USING: accessors alien.c-types continuations images kernel math
sequences ui.gadgets ui.gadgets.private ui.gadgets.worlds
2009-04-03 13:54:34 -04:00
ui.private ui ui.backend destructors locals ;
IN: ui.offscreen
TUPLE: offscreen-world < world ;
M: offscreen-world world-pixel-format-attributes
{ offscreen T{ depth-bits { value 16 } } } ;
: <offscreen-world> ( gadget title status -- world )
offscreen-world new-world ;
M: offscreen-world graft*
(open-offscreen-buffer) ;
M: offscreen-world ungraft*
[ (ungraft-world) ]
[ handle>> (close-offscreen-buffer) ]
[ reset-world ] tri ;
: open-offscreen ( gadget -- world )
2008-12-11 19:50:37 -05:00
"" f <offscreen-world>
2009-04-03 13:54:34 -04:00
[ open-world-window ] [ relayout-1 ] [ ] tri
notify-queued ;
: close-offscreen ( world -- )
ungraft notify-queued ;
2009-04-03 13:54:34 -04:00
:: bgrx>bitmap ( alien w h -- image )
<image>
{ w h } >>dim
alien w h * 4 * memory>byte-array >>bitmap
BGRX >>component-order ;
: offscreen-world>bitmap ( world -- image )
offscreen-pixels bgrx>bitmap ;
: do-offscreen ( gadget quot: ( offscreen-world -- ) -- )
[ open-offscreen ] dip
2008-12-10 09:49:50 -05:00
over [ slip ] [ close-offscreen ] [ ] cleanup ; inline
2009-04-03 13:54:34 -04:00
: gadget>bitmap ( gadget -- image )
2008-12-10 09:49:50 -05:00
[ offscreen-world>bitmap ] do-offscreen ;