Commit 57c8f6a4 authored by egottlieb's avatar egottlieb

Implemented shaped windows for Cocoa. Still need to see if they actually work.

parent 2d2a93ff
#define SDL_REVISION "hg-4526:d532a5a114cd"
...@@ -49,6 +49,23 @@ SDL_WindowShaper* Cocoa_CreateShaper(SDL_Window* window) { ...@@ -49,6 +49,23 @@ SDL_WindowShaper* Cocoa_CreateShaper(SDL_Window* window) {
return result; return result;
} }
typedef struct {
NSBezierPath* clipPath;
SDL_Window* window;
} SDL_PathConglomeration;
NSRect convert_rect(SDL_Rect rect,SDL_Window* window) {
NSRect nsrect = NSMakeRect(rect.x,window->h-(rect.y+rect.h),rect.w,rect.h);
return [[((SDL_WindowData*)window->driverdata)->nswindow contentView] convertRectFromBase:nsrect];
}
void ConglomerateShapeTree(SDL_ShapeTree* tree,SDL_PathConglomeration cong) {
if(tree->kind == OpaqueShape) {
NSRect rect = convert_rect(tree->data.shape,cong->window);
[cong->clipPath appendBezierPathWithRect:rect];
}
}
int Cocoa_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode) { int Cocoa_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode) {
SDL_ShapeData* data = (SDL_ShapeData*)shaper->driverdata; SDL_ShapeData* data = (SDL_ShapeData*)shaper->driverdata;
if(data->saved == SDL_TRUE) { if(data->saved == SDL_TRUE) {
...@@ -59,10 +76,17 @@ int Cocoa_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowS ...@@ -59,10 +76,17 @@ int Cocoa_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowS
[data->context saveGraphicsState]; [data->context saveGraphicsState];
data->saved = SDL_TRUE; data->saved = SDL_TRUE;
[[NSColor clearColor] set]; //[[NSColor clearColor] set];
NSRectFill([[((SDL_WindowData*)shaper->window->driverdata)->nswindow contentView] frame]); //NSRectFill([[((SDL_WindowData*)shaper->window->driverdata)->nswindow contentView] frame]);
/* TODO: It looks like Cocoa can set a clipping path based on a list of rectangles. That's what we get from the /* TODO: It looks like Cocoa can set a clipping path based on a list of rectangles. That's what we get from the
Windoze shape-calculation code: a list of rectangles. This will work... I think. */ Windoze shape-calculation code: a list of rectangles. This will work... I think. */
NSBezierPath* clipPath = [NSBezierPath bezierPath];
SDL_PathConglomeration cong = {clipPath,shaper->window};
SDL_TraverseShapeTree(data->shape,&ConglomerateShapeTree,cong);
[clipPath addClip];
} }
int Cocoa_ResizeWindowShape(SDL_Window *window) { int Cocoa_ResizeWindowShape(SDL_Window *window) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment