Mercurial > sdl-ios-xcode
comparison include/SDL_shape.h @ 4862:7b1d35d98294
Merged Eli's Google Summer of Code work from SDL-gsoc2010-shaped_windows
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 22 Aug 2010 13:45:56 -0700 |
parents | 0b918c186938 |
children |
comparison
equal
deleted
inserted
replaced
4764:102675835e08 | 4862:7b1d35d98294 |
---|---|
1 /* | |
2 SDL - Simple DirectMedia Layer | |
3 Copyright (C) 2010 Eli Gottlieb | |
4 | |
5 This library is free software; you can redistribute it and/or | |
6 modify it under the terms of the GNU Lesser General Public | |
7 License as published by the Free Software Foundation; either | |
8 version 2.1 of the License, or (at your option) any later version. | |
9 | |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 Lesser General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU Lesser General Public | |
16 License along with this library; if not, write to the Free Software | |
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
18 | |
19 Eli Gottlieb | |
20 eligottlieb@gmail.com | |
21 */ | |
22 | |
23 #ifndef _SDL_shape_h | |
24 #define _SDL_shape_h | |
25 | |
26 #include "SDL_stdinc.h" | |
27 #include "SDL_pixels.h" | |
28 #include "SDL_rect.h" | |
29 #include "SDL_surface.h" | |
30 #include "SDL_video.h" | |
31 | |
32 #include "begin_code.h" | |
33 /* Set up for C function definitions, even when using C++ */ | |
34 #ifdef __cplusplus | |
35 /* *INDENT-OFF* */ | |
36 extern "C" { | |
37 /* *INDENT-ON* */ | |
38 #endif | |
39 | |
40 /** \file SDL_shape.h | |
41 * | |
42 * Header file for the shaped window API. | |
43 */ | |
44 | |
45 #define SDL_NONSHAPEABLE_WINDOW -1 | |
46 #define SDL_INVALID_SHAPE_ARGUMENT -2 | |
47 #define SDL_WINDOW_LACKS_SHAPE -3 | |
48 | |
49 /** | |
50 * \brief Create a window that can be shaped with the specified position, dimensions, and flags. | |
51 * | |
52 * \param title The title of the window, in UTF-8 encoding. | |
53 * \param x The x position of the window, ::SDL_WINDOWPOS_CENTERED, or | |
54 * ::SDL_WINDOWPOS_UNDEFINED. | |
55 * \param y The y position of the window, ::SDL_WINDOWPOS_CENTERED, or | |
56 * ::SDL_WINDOWPOS_UNDEFINED. | |
57 * \param w The width of the window. | |
58 * \param h The height of the window. | |
59 * \param flags The flags for the window, a mask of SDL_WINDOW_BORDERLESS with any of the following: | |
60 * ::SDL_WINDOW_OPENGL, ::SDL_WINDOW_INPUT_GRABBED, | |
61 * ::SDL_WINDOW_SHOWN, ::SDL_WINDOW_RESIZABLE, | |
62 * ::SDL_WINDOW_MAXIMIZED, ::SDL_WINDOW_MINIMIZED, | |
63 * ::SDL_WINDOW_BORDERLESS is always set, and ::SDL_WINDOW_FULLSCREEN is always unset. | |
64 * | |
65 * \return The window created, or NULL if window creation failed. | |
66 * | |
67 * \sa SDL_DestroyWindow() | |
68 */ | |
69 extern DECLSPEC SDL_Window * SDLCALL SDL_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags); | |
70 | |
71 /** | |
72 * \brief Return whether the given window is a shaped window. | |
73 * | |
74 * \param window The window to query for being shaped. | |
75 * | |
76 * \return SDL_TRUE if the window is a window that can be shaped, SDL_FALSE if the window is unshaped or NULL. | |
77 * \sa SDL_CreateShapedWindow | |
78 */ | |
79 extern DECLSPEC SDL_bool SDLCALL SDL_IsShapedWindow(const SDL_Window *window); | |
80 | |
81 /** \brief An enum denoting the specific type of contents present in an SDL_WindowShapeParams union. */ | |
82 typedef enum { | |
83 /** \brief The default mode, a binarized alpha cutoff of 1. */ | |
84 ShapeModeDefault, | |
85 /** \brief A binarized alpha cutoff with a given integer value. */ | |
86 ShapeModeBinarizeAlpha, | |
87 /** \brief A binarized alpha cutoff with a given integer value, but with the opposite comparison. */ | |
88 ShapeModeReverseBinarizeAlpha, | |
89 /** \brief A color key is applied. */ | |
90 ShapeModeColorKey | |
91 } WindowShapeMode; | |
92 | |
93 #define SDL_SHAPEMODEALPHA(mode) (mode == ShapeModeDefault || mode == ShapeModeBinarizeAlpha || mode == ShapeModeReverseBinarizeAlpha) | |
94 | |
95 /** \brief A union containing parameters for shaped windows. */ | |
96 typedef union { | |
97 /** \brief a cutoff alpha value for binarization of the window shape's alpha channel. */ | |
98 Uint8 binarizationCutoff; | |
99 SDL_Color colorKey; | |
100 } SDL_WindowShapeParams; | |
101 | |
102 /** \brief A struct that tags the SDL_WindowShapeParams union with an enum describing the type of its contents. */ | |
103 typedef struct SDL_WindowShapeMode { | |
104 /** \brief The mode of these window-shape parameters. */ | |
105 WindowShapeMode mode; | |
106 /** \brief Window-shape parameters. */ | |
107 SDL_WindowShapeParams parameters; | |
108 } SDL_WindowShapeMode; | |
109 | |
110 /** | |
111 * \brief Set the shape and parameters of a shaped window. | |
112 * | |
113 * \param window The shaped window whose parameters should be set. | |
114 * \param shape A surface encoding the desired shape for the window. | |
115 * \param shape_mode The parameters to set for the shaped window. | |
116 * | |
117 * \return 0 on success, SDL_INVALID_SHAPE_ARGUMENT on invalid an invalid shape argument, or SDL_NONSHAPEABLE_WINDOW | |
118 * if the SDL_Window* given does not reference a valid shaped window. | |
119 * | |
120 * \sa SDL_WindowShapeMode | |
121 * \sa SDL_GetShapedWindowMode. | |
122 */ | |
123 extern DECLSPEC int SDLCALL SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode); | |
124 | |
125 /** | |
126 * \brief Get the shape parameters of a shaped window. | |
127 * | |
128 * \param window The shaped window whose parameters should be retrieved. | |
129 * \param shape_mode An empty shape-mode structure to fill, or NULL to check whether the window has a shape. | |
130 * | |
131 * \return 0 if the window has a shape and, provided shape_mode was not NULL, shape_mode has been filled with the mode | |
132 * data, SDL_NONSHAPEABLE_WINDOW if the SDL_Window given is not a shaped window, or SDL_WINDOW_LACKS_SHAPE if | |
133 * the SDL_Window* given is a shapeable window currently lacking a shape. | |
134 * | |
135 * \sa SDL_WindowShapeMode | |
136 * \sa SDL_SetWindowShape | |
137 */ | |
138 extern DECLSPEC int SDLCALL SDL_GetShapedWindowMode(SDL_Window *window,SDL_WindowShapeMode *shape_mode); | |
139 | |
140 /* Ends C function definitions when using C++ */ | |
141 #ifdef __cplusplus | |
142 /* *INDENT-OFF* */ | |
143 } | |
144 /* *INDENT-ON* */ | |
145 #endif | |
146 #include "close_code.h" | |
147 | |
148 #endif /* _SDL_shape_h */ |