USING: accessors math arrays assocs cocoa cocoa.application
command-line kernel memory namespaces cocoa.messages
cocoa.runtime cocoa.subclassing cocoa.pasteboard cocoa.types
- cocoa.windows cocoa.classes cocoa.application cocoa.nibs
- sequences system ui ui.backend ui.clipboards ui.gadgets
- ui.gadgets.worlds ui.cocoa.views core-foundation threads
- math.geometry.rect fry ;
-cocoa.windows cocoa.classes cocoa.application sequences system
++cocoa.windows cocoa.classes sequences system
+ ui ui.backend ui.clipboards ui.gadgets ui.gadgets.worlds
+ ui.cocoa.views core-foundation threads math.geometry.rect fry
+ libc generalizations alien.c-types cocoa.views combinators ;
IN: ui.cocoa
- TUPLE: handle view window ;
+ TUPLE: handle ;
+ TUPLE: window-handle < handle view window ;
+ TUPLE: offscreen-handle < handle context buffer ;
- C: <handle> handle
+ C: <window-handle> window-handle
+ C: <offscreen-handle> offscreen-handle
SINGLETON: cocoa-ui-backend
--- /dev/null
-
+ 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 )
+ [ handle>> offscreen-pixels ] [ dim>> first2 neg ] bi
+ bgra>bitmap ;
++
+ : do-offscreen ( gadget quot: ( offscreen-world -- ) -- )
+ [ open-offscreen ] dip
+ over [ slip ] [ close-offscreen ] [ ] cleanup ;