Stubbed out the new get/set parameter functions, added the start of the enum, union, and struct for those parameters themselves, and added doxygen comments throughout the SDL_shape.h header.
authorEli Gottlieb <eligottlieb@gmail.com>
Thu, 10 Jun 2010 17:37:19 -0400
changeset 47789838d3525a1b
parent 4777 6e03d73054d7
child 4779 bb179250fcb3
Stubbed out the new get/set parameter functions, added the start of the enum, union, and struct for those parameters themselves, and added doxygen comments throughout the SDL_shape.h header.
include/SDL_shape.h
src/video/SDL_shape.c
     1.1 --- a/include/SDL_shape.h	Sat Jun 05 15:12:27 2010 -0400
     1.2 +++ b/include/SDL_shape.h	Thu Jun 10 17:37:19 2010 -0400
     1.3 @@ -59,9 +59,77 @@
     1.4   */
     1.5  extern DECLSPEC SDL_Window * SDLCALL SDL_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags);
     1.6  
     1.7 +/**
     1.8 + * \brief Return whether the given window is a shaped window. 
     1.9 + *
    1.10 + * \param window The window to query for being shaped.
    1.11 + *
    1.12 + * \return SDL_TRUE if the window is a shaped window and SDL_FALSE otherwise.
    1.13 + * \sa SDL_CreateShapedWindow
    1.14 + */
    1.15  extern DECLSPEC SDL_bool SDLCALL SDL_WindowIsShaped(const SDL_Window *window);
    1.16 +
    1.17 +/**
    1.18 + * \brief Select the shape of a given window as a rendering target.
    1.19 + *
    1.20 + * \param window The window whose shape should become the current rendering target.
    1.21 + *
    1.22 + * \return 0 on success, -1 if something other than a valid shaped window is passed into \c window.
    1.23 + *
    1.24 + * The shape of the window given in \c window is selected as the new render target, and in the default mode (see
    1.25 + * SDL_WindowShapeParams) the alpha channel of that render target determines which pixels of the window are part of its
    1.26 + * visible shape and which are not according to a cutoff value.  All normal SDL rendering functions can be used on it,
    1.27 + * and its own specific parameters can be examined and set with SDL_GetShapeParameters() and SDL_SetShapeParameters().
    1.28 + * The final shape will be computed and the actual appearance of the window changed only upon a call to
    1.29 + * SDL_RenderPresent().
    1.30 + *
    1.31 + * \sa SDL_GetShapeParameters
    1.32 + * \sa SDL_SetShapeParameters
    1.33 + * \sa SDL_RenderPresent
    1.34 + */
    1.35  extern DECLSPEC int SDLCALL SDL_SelectShapeRenderer(const SDL_Window *window);
    1.36  
    1.37 +/** \brief An enum denoting the specific type of contents present in an SDL_WindowShapeParams union. */
    1.38 +typedef enum {ShapeModeDefault, ShapeModeBinarizeAlpha} WindowShapeMode;
    1.39 +/** \brief A union containing parameters for shaped windows. */
    1.40 +typedef union {
    1.41 +	/** \brief a cutoff alpha value for binarization of the window shape's alpha channel. */
    1.42 +	Uint8 binarizationCutoff;
    1.43 +} SDL_WindowShapeParams;
    1.44 +
    1.45 +/** \brief A struct that tags the SDL_WindowShapeParams union with an enum describing the type of its contents. */
    1.46 +typedef struct SDL_WindowShapeMode {
    1.47 +	WindowShapeMode mode;
    1.48 +	SDL_WindowShapeParams parameters;
    1.49 +} SDL_WindowShapeMode;
    1.50 +
    1.51 +/**
    1.52 + * \brief Set the shape parameters of a shaped window.
    1.53 + *
    1.54 + * \param window The shaped window whose parameters should be set.
    1.55 + * \param shapeMode The parameters to set for the shaped window.
    1.56 + *
    1.57 + * \return 0 on success, -1 on invalid parameters in the shapeMode argument, or -2 if the SDL_Window given is not a
    1.58 + *         shaped window.
    1.59 + *
    1.60 + * \sa SDL_WindowShapeMode
    1.61 + * \sa SDL_GetShapeParameters
    1.62 + */
    1.63 +extern DECLSPEC int SDLCALL SDL_SetShapeParameters(SDL_Window *window,SDL_WindowShapeMode shapeMode);
    1.64 +
    1.65 +/**
    1.66 + * \brief Set the shape parameters of a shaped window.
    1.67 + *
    1.68 + * \param window The shaped window whose parameters should be retrieved.
    1.69 + * \param shapeMode An empty shape-parameters structure to fill.
    1.70 + *
    1.71 + * \return 0 on success, -1 on a null shapeMode, or -2 if the SDL_Window given is not a shaped window.
    1.72 + *
    1.73 + * \sa SDL_WindowShapeMode
    1.74 + * \sa SDL_SetShapeParameters
    1.75 + */
    1.76 +extern DECLSPEC int SDLCALL SDL_GetShapeParameters(SDL_Window *window,SDL_WindowShapeMode *shapeMode);
    1.77 +
    1.78  /* Ends C function definitions when using C++ */
    1.79  #ifdef __cplusplus
    1.80  /* *INDENT-OFF* */
     2.1 --- a/src/video/SDL_shape.c	Sat Jun 05 15:12:27 2010 -0400
     2.2 +++ b/src/video/SDL_shape.c	Thu Jun 10 17:37:19 2010 -0400
     2.3 @@ -37,3 +37,17 @@
     2.4  int SDL_SelectShapeRenderer(const SDL_Window *window) {
     2.5  	return -1;
     2.6  }
     2.7 +
     2.8 +int SDL_SetShapeParameters(SDL_Window *window,SDL_WindowShapeMode shapeMode) {
     2.9 +	if(window == NULL || !SDL_WindowIsShaped(window))
    2.10 +		return -2;
    2.11 +	return -3;
    2.12 +}
    2.13 +
    2.14 +int SDL_GetShapeParameters(SDL_Window *window,SDL_WindowShapeMode *shapeMode) {
    2.15 +	if(shapeMode == NULL)
    2.16 +		return -1;
    2.17 +	if(window == NULL || !SDL_WindowIsShaped(window))
    2.18 +		return -2;
    2.19 +	return -3;
    2.20 +}