comparison src/video/cocoa/SDL_cocoashape.m @ 4838:1f9915666afd

Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
author Eli Gottlieb <eligottlieb@gmail.com>
date Mon, 09 Aug 2010 15:37:20 -0400
parents d79939f20c45
children 05d172e92b52
comparison
equal deleted inserted replaced
4826:d532a5a114cd 4838:1f9915666afd
22 22
23 #include "SDL_cocoavideo.h" 23 #include "SDL_cocoavideo.h"
24 #include "SDL_shape.h" 24 #include "SDL_shape.h"
25 #include "SDL_cocoashape.h" 25 #include "SDL_cocoashape.h"
26 26
27 SDL_WindowShaper* Cocoa_CreateShaper(SDL_Window* window) { 27 SDL_WindowShaper*
28 SDL_WindowData* data = (SDL_WindowData*)window->driverdata; 28 Cocoa_CreateShaper(SDL_Window* window) {
29 [data->nswindow setAlpha:1.0]; 29 SDL_WindowData* data = (SDL_WindowData*)window->driverdata;
30 [data->nswindow setOpaque:YES]; 30 [data->nswindow setAlpha:1.0];
31 [data->nswindow setStyleMask:NSBorderlessWindowMask]; 31 [data->nswindow setOpaque:YES];
32 SDL_Shaper* result = result = malloc(sizeof(SDL_WindowShaper)); 32 [data->nswindow setStyleMask:NSBorderlessWindowMask];
33 result->window = window; 33 SDL_Shaper* result = result = malloc(sizeof(SDL_WindowShaper));
34 result->mode.mode = ShapeModeDefault; 34 result->window = window;
35 result->mode.parameters.binarizationCutoff = 1; 35 result->mode.mode = ShapeModeDefault;
36 result->usershownflag = 0; 36 result->mode.parameters.binarizationCutoff = 1;
37 window->shaper = result; 37 result->usershownflag = 0;
38 38 window->shaper = result;
39 SDL_ShapeData* data = malloc(sizeof(SDL_ShapeData)); 39
40 result->driverdata = data; 40 SDL_ShapeData* data = malloc(sizeof(SDL_ShapeData));
41 data->context = [data->nswindow graphicsContext]; 41 result->driverdata = data;
42 data->saved = SDL_False; 42 data->context = [data->nswindow graphicsContext];
43 data->rects = NULL; 43 data->saved = SDL_False;
44 data->count = 0; 44 data->rects = NULL;
45 45 data->count = 0;
46 int resized_properly = Cocoa_ResizeWindowShape(window); 46
47 assert(resized_properly == 0); 47 int resized_properly = Cocoa_ResizeWindowShape(window);
48 return result; 48 assert(resized_properly == 0);
49 return result;
49 } 50 }
50 51
51 int Cocoa_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode) { 52 int
52 SDL_WindowData* data = (SDL_WindowData*)shaper->window->driverdata; 53 Cocoa_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode) {
53 if(data->saved == SDL_True) { 54 SDL_WindowData* data = (SDL_WindowData*)shaper->window->driverdata;
54 [data->context restoreGraphicsState]; 55 if(data->saved == SDL_True) {
55 data->saved = SDL_False; 56 [data->context restoreGraphicsState];
56 } 57 data->saved = SDL_False;
57 58 }
58 [data->context saveGraphicsState]; 59
59 data->saved = SDL_True; 60 [data->context saveGraphicsState];
60 61 data->saved = SDL_True;
61 [[NSColor clearColor] set]; 62
62 NSRectFill([[data->nswindow contentView] frame]); 63 [[NSColor clearColor] set];
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 NSRectFill([[data->nswindow contentView] frame]);
65 /* 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. */ 66 Windoze shape-calculation code: a list of rectangles. This will work... I think. */
65 } 67 }
66 68
67 int Cocoa_ResizeWindowShape(SDL_Window *window) { 69 int
68 SDL_ShapeData* data = window->shaper->driverdata; 70 Cocoa_ResizeWindowShape(SDL_Window *window) {
69 assert(data != NULL); 71 SDL_ShapeData* data = window->shaper->driverdata;
70 return 0; 72 assert(data != NULL);
73 return 0;
71 } 74 }