diff --git a/basis/cocoa/views/views-docs.factor b/basis/cocoa/views/views-docs.factor index 3b533f98c3..871326fcd4 100644 --- a/basis/cocoa/views/views-docs.factor +++ b/basis/cocoa/views/views-docs.factor @@ -1,13 +1,9 @@ -USING: help.syntax help.markup ; +USING: help.syntax help.markup ui.pixel-formats ; IN: cocoa.views -HELP: -{ $values { "attributes" "a sequence of attributes" } { "pixelfmt" "an " { $snippet "NSOpenGLPixelFormat" } } } -{ $description "Creates an " { $snippet "NSOpenGLPixelFormat" } " with some reasonable defaults." } ; - HELP: -{ $values { "class" "an subclass of " { $snippet "NSOpenGLView" } } { "dim" "a pair of real numbers" } { "view" "a new " { $snippet "NSOpenGLView" } } } -{ $description "Creates a new instance of the specified class, giving it a default pixel format and the given size." } ; +{ $values { "class" "an subclass of " { $snippet "NSOpenGLView" } } { "dim" "a pair of real numbers" } { "pixel-format" pixel-format } { "view" "a new " { $snippet "NSOpenGLView" } } } +{ $description "Creates a new instance of the specified class, giving it the specified pixel format and size." } ; HELP: view-dim { $values { "view" "an " { $snippet "NSView" } } { "dim" "a pair of real numbers" } } @@ -18,7 +14,6 @@ HELP: mouse-location { $description "Outputs the current mouse location." } ; ARTICLE: "cocoa-view-utils" "Cocoa view utilities" -{ $subsection } { $subsection } { $subsection view-dim } { $subsection mouse-location } ; diff --git a/basis/ui/backend/cocoa/cocoa.factor b/basis/ui/backend/cocoa/cocoa.factor index fbc713ac9a..8a91dfd94d 100755 --- a/basis/ui/backend/cocoa/cocoa.factor +++ b/basis/ui/backend/cocoa/cocoa.factor @@ -1,15 +1,15 @@ ! Copyright (C) 2006, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors math arrays assocs cocoa cocoa.application -command-line kernel memory namespaces cocoa.messages classes -cocoa.runtime cocoa.subclassing cocoa.pasteboard cocoa.types -cocoa.windows cocoa.classes cocoa.nibs sequences ui ui.private -ui.backend ui.clipboards ui.gadgets ui.gadgets.worlds -ui.backend.cocoa.views core-foundation core-foundation.run-loop -core-graphics.types threads math.rectangles fry libc -generalizations alien.c-types cocoa.views -combinators io.thread locals ui.pixel-formats -specialized-arrays.int literals core-graphics ; +USING: accessors alien.c-types arrays assocs classes cocoa +cocoa.application cocoa.classes cocoa.messages cocoa.nibs +cocoa.pasteboard cocoa.runtime cocoa.subclassing cocoa.types +cocoa.views cocoa.windows combinators command-line +core-foundation core-foundation.run-loop core-graphics +core-graphics.types destructors fry generalizations io.thread +kernel libc literals locals math math.rectangles memory +namespaces sequences specialized-arrays.int threads ui +ui.backend ui.backend.cocoa.views ui.clipboards ui.gadgets +ui.gadgets.worlds ui.pixel-formats ui.private words.symbol ; IN: ui.backend.cocoa TUPLE: handle ; @@ -56,12 +56,12 @@ M: symbol >NSOpenGLPFA M: pixel-format-attribute >NSOpenGLPFA dup class attribute>NSOpenGLPFA-map at [ swap value>> suffix ] - [ drop { } ] if ; + [ drop { } ] if* ; PRIVATE> M: cocoa-ui-backend (make-pixel-format) - [ >NSOpenGLPFA ] map concat >int-array + [ >NSOpenGLPFA ] map concat 0 suffix >int-array NSOpenGLPixelFormat -> alloc swap -> initWithAttributes: ; M: cocoa-ui-backend (free-pixel-format) @@ -70,7 +70,7 @@ M: cocoa-ui-backend (free-pixel-format) M: cocoa-ui-backend (pixel-format-attribute) attribute>NSOpenGLPFA-map at [ first 0 [ swap 0 -> getValues:forAttribute:forVirtualScreen: ] keep *int ] - [ f ] if* ; + [ drop f ] if* ; TUPLE: pasteboard handle ; @@ -122,7 +122,8 @@ M: cocoa-ui-backend fullscreen* ( world -- ? ) handle>> view>> -> isInFullScreenMode zero? not ; M:: cocoa-ui-backend (open-window) ( world -- ) - [ [ dim>> ] dip ] with-world-pixel-format :> view + world [ [ dim>> ] dip ] + with-world-pixel-format :> view view world world>NSRect :> window view -> release world view register-window @@ -160,7 +161,8 @@ M: cocoa-ui-backend raise-window* ( world -- ) [ :> pf NSOpenGLContext -> alloc pf handle>> f -> initWithFormat:shareContext: - dup world pf offscreen-buffer -> setOffScreen:width:height:rowbytes: + dup world pf offscreen-buffer + 4 npick [ -> setOffScreen:width:height:rowbytes: ] dip ] with-disposal ; M: cocoa-ui-backend (open-offscreen-buffer) ( world -- ) diff --git a/basis/ui/gadgets/worlds/worlds.factor b/basis/ui/gadgets/worlds/worlds.factor index d4162fa630..0328d453d4 100644 --- a/basis/ui/gadgets/worlds/worlds.factor +++ b/basis/ui/gadgets/worlds/worlds.factor @@ -153,6 +153,7 @@ M: world handle-gesture ( gesture gadget -- ? ) GENERIC: world-pixel-format-attributes ( world -- attributes ) M: world world-pixel-format-attributes + drop { windowed double-buffered T{ depth-bits { value 16 } } } ; : with-world-pixel-format ( world quot -- ) diff --git a/basis/ui/pixel-formats/pixel-formats.factor b/basis/ui/pixel-formats/pixel-formats.factor index 66de98ea1c..3c41926c21 100644 --- a/basis/ui/pixel-formats/pixel-formats.factor +++ b/basis/ui/pixel-formats/pixel-formats.factor @@ -1,4 +1,4 @@ -USING: destructors math ui.backend ; +USING: accessors destructors kernel math ui.backend ; IN: ui.pixel-formats SYMBOLS: @@ -45,10 +45,13 @@ HOOK: (make-pixel-format) ui-backend ( attributes -- pixel-format-handle ) HOOK: (free-pixel-format) ui-backend ( pixel-format-handle -- ) HOOK: (pixel-format-attribute) ui-backend ( pixel-format-handle attribute-name -- value ) +ERROR: invalid-pixel-format-attributes attributes ; + TUPLE: pixel-format { handle read-only } ; : ( attributes -- pixel-format ) - (make-pixel-format) pixel-format boa ; + dup (make-pixel-format) + [ nip pixel-format boa ] [ invalid-pixel-format-attributes ] if* ; M: pixel-format dispose [ [ (free-pixel-format) ] when* f ] change-handle drop ;