]> gitweb.factorcode.org Git - factor.git/blob - extra/ui/offscreen/offscreen.factor
Merge branch 'master' of git://repo.or.cz/factor/jcg
[factor.git] / extra / ui / offscreen / offscreen.factor
1 USING: accessors continuations graphics.bitmap kernel math
2 sequences ui.gadgets ui.gadgets.worlds ui ui.backend ;
3 IN: ui.offscreen
4
5 TUPLE: offscreen-world < world ;
6
7 : <offscreen-world> ( gadget title status -- world )
8     offscreen-world new-world ;
9
10 M: offscreen-world graft*
11     (open-offscreen-buffer) ;
12
13 M: offscreen-world ungraft*
14     [ (ungraft-world) ]
15     [ handle>> (close-offscreen-buffer) ]
16     [ reset-world ] tri ;
17
18 : open-offscreen ( gadget -- world )
19     "" f <offscreen-world> [ open-world-window ] keep
20     notify-queued ;
21
22 : close-offscreen ( world -- )
23     ungraft notify-queued ;
24
25 : offscreen-world>bitmap ( world -- bitmap )
26     [ handle>> offscreen-pixels ] [ dim>> first2 neg ] bi
27     bgra>bitmap ;
28
29 : do-offscreen ( gadget quot: ( offscreen-world -- ) -- )
30     [ open-offscreen ] dip
31     over [ slip ] [ close-offscreen ] [ ] cleanup ;