Move offscreen-world widget and support words into ui.offscreen vocab
parent
c861ed9e2c
commit
98c0daae2a
|
@ -27,6 +27,8 @@ GENERIC: select-gl-context ( handle -- )
|
||||||
|
|
||||||
GENERIC: flush-gl-context ( handle -- )
|
GENERIC: flush-gl-context ( handle -- )
|
||||||
|
|
||||||
|
GENERIC: offscreen-pixels ( handle -- alien )
|
||||||
|
|
||||||
HOOK: beep ui-backend ( -- )
|
HOOK: beep ui-backend ( -- )
|
||||||
|
|
||||||
: with-gl-context ( handle quot -- )
|
: with-gl-context ( handle quot -- )
|
||||||
|
|
|
@ -16,10 +16,6 @@ TUPLE: offscreen-handle < handle context buffer ;
|
||||||
C: <window-handle> window-handle
|
C: <window-handle> window-handle
|
||||||
C: <offscreen-handle> offscreen-handle
|
C: <offscreen-handle> offscreen-handle
|
||||||
|
|
||||||
! XXX gross!
|
|
||||||
M: offscreen-handle window>> drop f ;
|
|
||||||
M: offscreen-handle view>> drop f ;
|
|
||||||
|
|
||||||
SINGLETON: cocoa-ui-backend
|
SINGLETON: cocoa-ui-backend
|
||||||
|
|
||||||
M: cocoa-ui-backend do-events ( -- )
|
M: cocoa-ui-backend do-events ( -- )
|
||||||
|
@ -117,15 +113,18 @@ M: cocoa-ui-backend (close-offscreen-buffer) ( handle -- )
|
||||||
[ context>> -> release ]
|
[ context>> -> release ]
|
||||||
[ buffer>> free ] bi ;
|
[ buffer>> free ] bi ;
|
||||||
|
|
||||||
GENERIC: gl-context ( handle -- context )
|
GENERIC: (gl-context) ( handle -- context )
|
||||||
M: window-handle gl-context view>> -> openGLContext ;
|
M: window-handle (gl-context) view>> -> openGLContext ;
|
||||||
M: offscreen-handle gl-context context>> ;
|
M: offscreen-handle (gl-context) context>> ;
|
||||||
|
|
||||||
M: handle select-gl-context ( handle -- )
|
M: handle select-gl-context ( handle -- )
|
||||||
gl-context -> makeCurrentContext ;
|
(gl-context) -> makeCurrentContext ;
|
||||||
|
|
||||||
M: handle flush-gl-context ( handle -- )
|
M: handle flush-gl-context ( handle -- )
|
||||||
gl-context -> flushBuffer ;
|
(gl-context) -> flushBuffer ;
|
||||||
|
|
||||||
|
M: offscreen-handle offscreen-pixels ( handle -- alien )
|
||||||
|
buffer>> ;
|
||||||
|
|
||||||
M: cocoa-ui-backend beep ( -- )
|
M: cocoa-ui-backend beep ( -- )
|
||||||
NSBeep ;
|
NSBeep ;
|
||||||
|
|
|
@ -81,14 +81,6 @@ M: world ungraft*
|
||||||
[ handle>> (close-window) ]
|
[ handle>> (close-window) ]
|
||||||
[ reset-world ] tri ;
|
[ reset-world ] tri ;
|
||||||
|
|
||||||
M: offscreen-world graft*
|
|
||||||
(open-offscreen-buffer) ;
|
|
||||||
|
|
||||||
M: offscreen-world ungraft*
|
|
||||||
[ (ungraft-world) ]
|
|
||||||
[ handle>> (close-offscreen-buffer) ]
|
|
||||||
[ reset-world ] tri ;
|
|
||||||
|
|
||||||
: find-window ( quot -- world )
|
: find-window ( quot -- world )
|
||||||
windows get values
|
windows get values
|
||||||
[ gadget-child swap call ] with find-last nip ; inline
|
[ gadget-child swap call ] with find-last nip ; inline
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
USING: accessors 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 ;
|
||||||
|
|
||||||
|
: offscreen-world>bitmap ( world -- bitmap )
|
||||||
|
[ handle>> offscreen-pixels ] [ dim>> first2 neg ] bi
|
||||||
|
bgra>bitmap ;
|
||||||
|
|
Loading…
Reference in New Issue