comparison src/video/cocoa/SDL_cocoashape.m @ 4811:d79939f20c45

Working on Cocoa implementation.
author Eli Gottlieb <eligottlieb@gmail.com>
date Mon, 26 Jul 2010 21:48:53 -0400
parents 7a602fd2121f
children 5660aac926e9 1f9915666afd
comparison
equal deleted inserted replaced
4810:7a602fd2121f 4811:d79939f20c45
18 18
19 Eli Gottlieb 19 Eli Gottlieb
20 eligottlieb@gmail.com 20 eligottlieb@gmail.com
21 */ 21 */
22 22
23 #include "SDL_cocoavideo.h"
23 #include "SDL_shape.h" 24 #include "SDL_shape.h"
24 #include "SDL_cocoashape.h" 25 #include "SDL_cocoashape.h"
25 26
26 SDL_WindowShaper* Cocoa_CreateShaper(SDL_Window* window) { 27 SDL_WindowShaper* Cocoa_CreateShaper(SDL_Window* window) {
27 SDL_WindowData* data = (SDL_WindowData*)window->driverdata; 28 SDL_WindowData* data = (SDL_WindowData*)window->driverdata;
28 [data->nswindow setAlpha:1.0]; 29 [data->nswindow setAlpha:1.0];
29 [data->nswindow setOpaque:YES]; 30 [data->nswindow setOpaque:YES];
31 [data->nswindow setStyleMask:NSBorderlessWindowMask];
30 SDL_Shaper* result = result = malloc(sizeof(SDL_WindowShaper)); 32 SDL_Shaper* result = result = malloc(sizeof(SDL_WindowShaper));
31 result->window = window; 33 result->window = window;
32 result->mode.mode = ShapeModeDefault; 34 result->mode.mode = ShapeModeDefault;
33 result->mode.parameters.binarizationCutoff = 1; 35 result->mode.parameters.binarizationCutoff = 1;
34 result->usershownflag = 0; 36 result->usershownflag = 0;
35 window->shaper = result; 37 window->shaper = result;
38
39 SDL_ShapeData* data = malloc(sizeof(SDL_ShapeData));
40 result->driverdata = data;
41 data->context = [data->nswindow graphicsContext];
42 data->saved = SDL_False;
43 data->rects = NULL;
44 data->count = 0;
45
36 int resized_properly = Cocoa_ResizeWindowShape(window); 46 int resized_properly = Cocoa_ResizeWindowShape(window);
37 assert(resized_properly == 0); 47 assert(resized_properly == 0);
38 return result; 48 return result;
39 } 49 }
40 50
41 extern int Cocoa_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode); 51 int Cocoa_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode) {
42 extern int Cocoa_ResizeWindowShape(SDL_Window *window); 52 SDL_WindowData* data = (SDL_WindowData*)shaper->window->driverdata;
53 if(data->saved == SDL_True) {
54 [data->context restoreGraphicsState];
55 data->saved = SDL_False;
56 }
57
58 [data->context saveGraphicsState];
59 data->saved = SDL_True;
60
61 [[NSColor clearColor] set];
62 NSRectFill([[data->nswindow contentView] frame]);
63 /* TODO: It looks like Cocoa can set a clipping path based on a list of rectangles. That's what we get from the
64 Windoze shape-calculation code: a list of rectangles. This will work... I think. */
65 }
66
67 int Cocoa_ResizeWindowShape(SDL_Window *window) {
68 SDL_ShapeData* data = window->shaper->driverdata;
69 assert(data != NULL);
70 return 0;
71 }