1 USING: accessors continuations graphics.bitmap kernel math
2 sequences ui.gadgets ui.gadgets.worlds ui ui.backend ;
5 TUPLE: offscreen-world < world ;
7 : <offscreen-world> ( gadget title status -- world )
8 offscreen-world new-world ;
10 M: offscreen-world graft*
11 (open-offscreen-buffer) ;
13 M: offscreen-world ungraft*
15 [ handle>> (close-offscreen-buffer) ]
18 : open-offscreen ( gadget -- world )
19 "" f <offscreen-world> [ open-world-window ] keep
22 : close-offscreen ( world -- )
23 ungraft notify-queued ;
25 : offscreen-world>bitmap ( world -- bitmap )
26 [ handle>> offscreen-pixels ] [ dim>> first2 neg ] bi
29 : do-offscreen ( gadget quot: ( offscreen-world -- ) -- )
30 [ open-offscreen ] dip
31 over [ slip ] [ close-offscreen ] [ ] cleanup ;