factor/extra/ui/offscreen/offscreen.factor

34 lines
911 B
Factor
Raw Normal View History

USING: accessors continuations graphics.bitmap kernel math
sequences ui.gadgets ui.gadgets.worlds ui ui.backend ;
IN: ui.offscreen
TUPLE: offscreen-world < world ;
: <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 )
"" f <offscreen-world> [ open-world-window ] keep
notify-queued ;
: close-offscreen ( world -- )
ungraft notify-queued ;
: offscreen-world>bitmap ( world -- bitmap )
2008-12-10 09:49:50 -05:00
offscreen-pixels bgra>bitmap ;
: do-offscreen ( gadget quot: ( offscreen-world -- ) -- )
[ open-offscreen ] dip
2008-12-10 09:49:50 -05:00
over [ slip ] [ close-offscreen ] [ ] cleanup ; inline
: gadget>bitmap ( gadget -- bitmap )
[ offscreen-world>bitmap ] do-offscreen ;