]> gitweb.factorcode.org Git - factor.git/blob - extra/ui/offscreen/offscreen.factor
Split off some code from ui.backend.windows into windows.offscreen
[factor.git] / extra / ui / offscreen / offscreen.factor
1 ! (c) 2008 Joe Groff, see license for details
2 USING: accessors continuations images.bitmap kernel math
3 sequences ui.gadgets ui.gadgets.private ui.gadgets.worlds
4 ui.private ui ui.backend destructors ;
5 IN: ui.offscreen
6
7 TUPLE: offscreen-world < world ;
8
9 : <offscreen-world> ( gadget title status -- world )
10     offscreen-world new-world ;
11
12 M: offscreen-world graft*
13     (open-offscreen-buffer) ;
14
15 M: offscreen-world ungraft*
16     [ (ungraft-world) ]
17     [ handle>> (close-offscreen-buffer) ]
18     [ reset-world ] tri ;
19
20 : open-offscreen ( gadget -- world )
21     "" f <offscreen-world>
22     [ open-world-window dup relayout-1 ] keep
23     notify-queued ;
24
25 : close-offscreen ( world -- )
26     ungraft notify-queued ;
27
28 : offscreen-world>bitmap ( world -- bitmap )
29     offscreen-pixels bgra>bitmap ;
30
31 : do-offscreen ( gadget quot: ( offscreen-world -- ) -- )
32     [ open-offscreen ] dip
33     over [ slip ] [ close-offscreen ] [ ] cleanup ; inline
34
35 : gadget>bitmap ( gadget -- bitmap )
36     [ offscreen-world>bitmap ] do-offscreen ;