Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'intern/ghost/intern/GHOST_WindowCocoa.mm')
-rw-r--r--intern/ghost/intern/GHOST_WindowCocoa.mm59
1 files changed, 47 insertions, 12 deletions
diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm b/intern/ghost/intern/GHOST_WindowCocoa.mm
index 8d28c9d5b17..937dffe9fba 100644
--- a/intern/ghost/intern/GHOST_WindowCocoa.mm
+++ b/intern/ghost/intern/GHOST_WindowCocoa.mm
@@ -241,10 +241,19 @@ extern "C" {
//We need to subclass it in order to give Cocoa the feeling key events are trapped
@interface CocoaOpenGLView : NSOpenGLView
{
+ GHOST_SystemCocoa *systemCocoa;
+ GHOST_WindowCocoa *associatedWindow;
}
+- (void)setSystemAndWindowCocoa:(GHOST_SystemCocoa *)sysCocoa windowCocoa:(GHOST_WindowCocoa *)winCocoa;
@end
@implementation CocoaOpenGLView
+- (void)setSystemAndWindowCocoa:(GHOST_SystemCocoa *)sysCocoa windowCocoa:(GHOST_WindowCocoa *)winCocoa
+{
+ systemCocoa = sysCocoa;
+ associatedWindow = winCocoa;
+}
+
- (BOOL)acceptsFirstResponder
{
return YES;
@@ -294,6 +303,7 @@ extern "C" {
else
{
[super drawRect:rect];
+ systemCocoa->handleWindowEvent(GHOST_kEventWindowUpdate, associatedWindow);
}
}
@@ -308,14 +318,14 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(
GHOST_SystemCocoa *systemCocoa,
const STR_String& title,
GHOST_TInt32 left,
- GHOST_TInt32 top,
+ GHOST_TInt32 bottom,
GHOST_TUns32 width,
GHOST_TUns32 height,
GHOST_TWindowState state,
GHOST_TDrawingContextType type,
const bool stereoVisual, const GHOST_TUns16 numOfAASamples
) :
- GHOST_Window(title, left, top, width, height, state, GHOST_kDrawingContextTypeNone, stereoVisual, numOfAASamples),
+ GHOST_Window(width, height, state, GHOST_kDrawingContextTypeNone, stereoVisual, numOfAASamples),
m_customCursor(0)
{
NSOpenGLPixelFormatAttribute pixelFormatAttrsWindow[40];
@@ -327,13 +337,12 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
//Creates the window
NSRect rect;
NSSize minSize;
rect.origin.x = left;
- rect.origin.y = top;
+ rect.origin.y = bottom;
rect.size.width = width;
rect.size.height = height;
@@ -425,6 +434,8 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(
//Creates the OpenGL View inside the window
m_openGLView = [[CocoaOpenGLView alloc] initWithFrame:rect
pixelFormat:pixelFormat];
+
+ [m_openGLView setSystemAndWindowCocoa:systemCocoa windowCocoa:this];
[pixelFormat release];
@@ -461,9 +472,13 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(
GHOST_WindowCocoa::~GHOST_WindowCocoa()
{
- if (m_customCursor) delete m_customCursor;
-
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+ if (m_customCursor) {
+ [m_customCursor release];
+ m_customCursor = nil;
+ }
+
[m_openGLView release];
if (m_window) {
@@ -688,7 +703,30 @@ GHOST_TWindowState GHOST_WindowCocoa::getState() const
void GHOST_WindowCocoa::screenToClient(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const
{
GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::screenToClient(): window invalid")
-
+
+ screenToClientIntern(inX, inY, outX, outY);
+
+ /* switch y to match ghost convention */
+ GHOST_Rect cBnds;
+ getClientBounds(cBnds);
+ outY = (cBnds.getHeight() - 1) - outY;
+}
+
+
+void GHOST_WindowCocoa::clientToScreen(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const
+{
+ GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::clientToScreen(): window invalid")
+
+ /* switch y to match ghost convention */
+ GHOST_Rect cBnds;
+ getClientBounds(cBnds);
+ inY = (cBnds.getHeight() - 1) - inY;
+
+ clientToScreenIntern(inX, inY, outX, outY);
+}
+
+void GHOST_WindowCocoa::screenToClientIntern(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const
+{
NSPoint screenCoord;
NSPoint baseCoord;
@@ -701,11 +739,8 @@ void GHOST_WindowCocoa::screenToClient(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST
outY = baseCoord.y;
}
-
-void GHOST_WindowCocoa::clientToScreen(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const
+void GHOST_WindowCocoa::clientToScreenIntern(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const
{
- GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::clientToScreen(): window invalid")
-
NSPoint screenCoord;
NSPoint baseCoord;
@@ -1207,7 +1242,7 @@ GHOST_TSuccess GHOST_WindowCocoa::setWindowCursorGrab(GHOST_TGrabCursorMode mode
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
m_systemCocoa->getCursorPosition(x_old,y_old);
- screenToClient(x_old, y_old, m_cursorGrabInitPos[0], m_cursorGrabInitPos[1]);
+ screenToClientIntern(x_old, y_old, m_cursorGrabInitPos[0], m_cursorGrabInitPos[1]);
//Warp position is stored in client (window base) coordinates
setCursorGrabAccum(0, 0);