comparison src/video/cocoa/SDL_cocoashape.m @ 4860:8f1994e8d886

Create all shaped windows at -1000,-1000 and save the real coordinates.
author egottlieb
date Tue, 17 Aug 2010 01:11:11 -0400
parents 91f4d4d5c395
children a2cf0174e5ab
comparison
equal deleted inserted replaced
4859:91f4d4d5c395 4860:8f1994e8d886
49 } 49 }
50 50
51 typedef struct { 51 typedef struct {
52 NSView* view; 52 NSView* view;
53 NSBezierPath* path; 53 NSBezierPath* path;
54 SDL_Window* window;
54 } SDL_CocoaClosure; 55 } SDL_CocoaClosure;
55 56
56 void 57 void
57 ConvertRects(SDL_ShapeTree* tree,void* closure) { 58 ConvertRects(SDL_ShapeTree* tree,void* closure) {
58 SDL_CocoaClosure* data = (SDL_CocoaClosure*)closure; 59 SDL_CocoaClosure* data = (SDL_CocoaClosure*)closure;
59 if(tree->kind == OpaqueShape) { 60 if(tree->kind == OpaqueShape) {
60 NSRect rect = NSMakeRect(tree->data.shape.x,tree->data.shape.y,tree->data.shape.w,tree->data.shape.h); 61 NSRect rect = NSMakeRect(tree->data.shape.x,data->window->h - tree->data.shape.y,tree->data.shape.w,tree->data.shape.h);
61 [data->path appendBezierPathWithRect:[data->view convertRect:rect toView:nil]]; 62 [data->path appendBezierPathWithRect:[data->view convertRect:rect toView:nil]];
62 } 63 }
63 } 64 }
64 65
65 int 66 int
73 data->saved = SDL_FALSE; 74 data->saved = SDL_FALSE;
74 } 75 }
75 76
76 //[data->context saveGraphicsState]; 77 //[data->context saveGraphicsState];
77 //data->saved = SDL_TRUE; 78 //data->saved = SDL_TRUE;
79 [NSGraphicsContext setCurrentContext:data->context];
78 80
79 [[NSColor clearColor] set]; 81 [[NSColor clearColor] set];
80 NSRectFill([[windata->nswindow contentView] frame]); 82 NSRectFill([[windata->nswindow contentView] frame]);
81 /* TODO: It looks like Cocoa can set a clipping path based on a list of rectangles. That's what we get from the
82 Windoze shape-calculation code: a list of rectangles. This will work... I think. */
83 data->shape = SDL_CalculateShapeTree(*shape_mode,shape); 83 data->shape = SDL_CalculateShapeTree(*shape_mode,shape);
84 84
85 pool = [[NSAutoreleasePool alloc] init]; 85 pool = [[NSAutoreleasePool alloc] init];
86 closure.view = [windata->nswindow contentView]; 86 closure.view = [windata->nswindow contentView];
87 closure.path = [[NSBezierPath bezierPath] autorelease]; 87 closure.path = [[NSBezierPath bezierPath] autorelease];
88 closure.window = shaper->window;
88 SDL_TraverseShapeTree(data->shape,&ConvertRects,&closure); 89 SDL_TraverseShapeTree(data->shape,&ConvertRects,&closure);
89 [NSGraphicsContext setCurrentContext:data->context]; 90 [closure.path addClip];
90 [closure.path setClip];
91 [pool drain];
92 } 91 }
93 92
94 int 93 int
95 Cocoa_ResizeWindowShape(SDL_Window *window) { 94 Cocoa_ResizeWindowShape(SDL_Window *window) {
96 SDL_ShapeData* data = window->shaper->driverdata; 95 SDL_ShapeData* data = window->shaper->driverdata;