include/SDL_shape.h
author Eli Gottlieb <eligottlieb@gmail.com>
Sat, 19 Jun 2010 23:10:57 -0400
changeset 4780 4f915a47b995
parent 4779 bb179250fcb3
child 4781 fc4c775b468a
permissions -rw-r--r--
Replaced the model of treating a window's shape as a render target with treating a window's shape as a surface passed into an SDL_SetWindowShape() function. I'll send this off to Andreas and Sam and start coding.
     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 shaped windows.
    43  */
    44 
    45 /**
    46  *  \brief Create a shaped window with the specified position, dimensions, and flags.
    47  *  
    48  *  \param title The title of the window, in UTF-8 encoding.
    49  *  \param x     The x position of the window, ::SDL_WINDOWPOS_CENTERED, or 
    50  *               ::SDL_WINDOWPOS_UNDEFINED.
    51  *  \param y     The y position of the window, ::SDL_WINDOWPOS_CENTERED, or 
    52  *               ::SDL_WINDOWPOS_UNDEFINED.
    53  *  \param w     The width of the window.
    54  *  \param h     The height of the window.
    55  *  \param flags The flags for the window, a mask of SDL_WINDOW_BORDERLESS with any of the following: 
    56  *               ::SDL_WINDOW_OPENGL,     ::SDL_WINDOW_INPUT_GRABBED,
    57  *               ::SDL_WINDOW_SHOWN,      ::SDL_WINDOW_RESIZABLE,
    58  *               ::SDL_WINDOW_MAXIMIZED,  ::SDL_WINDOW_MINIMIZED,
    59  *		 ::SDL_WINDOW_BORDERLESS is always set, and ::SDL_WINDOW_FULLSCREEN is always unset.
    60  *  
    61  *  \return The id of the window created, or zero if window creation failed.
    62  *  
    63  *  \sa SDL_DestroyWindow()
    64  */
    65 extern DECLSPEC SDL_Window * SDLCALL SDL_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags);
    66 
    67 /**
    68  * \brief Return whether the given window is a shaped window. 
    69  *
    70  * \param window The window to query for being shaped.
    71  *
    72  * \return SDL_TRUE if the window is a shaped window and SDL_FALSE otherwise.
    73  * \sa SDL_CreateShapedWindow
    74  */
    75 extern DECLSPEC SDL_bool SDLCALL SDL_WindowIsShaped(const SDL_Window *window);
    76 
    77 /** \brief An enum denoting the specific type of contents present in an SDL_WindowShapeParams union. */
    78 typedef enum {ShapeModeDefault, ShapeModeBinarizeAlpha} WindowShapeMode;
    79 /** \brief A union containing parameters for shaped windows. */
    80 typedef union {
    81 	/** \brief a cutoff alpha value for binarization of the window shape's alpha channel. */
    82 	Uint8 binarizationCutoff;
    83 } SDL_WindowShapeParams;
    84 
    85 /** \brief A struct that tags the SDL_WindowShapeParams union with an enum describing the type of its contents. */
    86 typedef struct SDL_WindowShapeMode {
    87 	/** \brief The mode of these window-shape parameters. */
    88 	WindowShapeMode mode;
    89 	/** \brief Window-shape parameters. */
    90 	SDL_WindowShapeParams parameters;
    91 } SDL_WindowShapeMode;
    92 
    93 /**
    94  * \brief Set the shape and parameters of a shaped window.
    95  *
    96  * \param window The shaped window whose parameters should be set.
    97  * \param shape A surface encoding the desired shape for the window as a bitmap mask.
    98  * \param parameters The parameters to set for the shaped window.
    99  *
   100  * \return 0 on success, -1 on invalid an invalid shape argument, or -2 if the SDL_Window* given does not reference
   101  *         a valid shaped window.
   102  *
   103  * \sa SDL_WindowShapeMode
   104  * \sa SDL_GetShapeParameters.
   105  */
   106 extern DECLSPEC int SDLCALL SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode parameters);
   107 
   108 /**
   109  * \brief Set the shape parameters of a shaped window.
   110  *
   111  * \param window The shaped window whose parameters should be retrieved.
   112  * \param shapeMode An empty shape-parameters structure to fill.
   113  *
   114  * \return 0 on success, -1 on a null shapeMode, or -2 if the SDL_Window given is not a shaped window.
   115  *
   116  * \sa SDL_WindowShapeMode
   117  * \sa SDL_SetShapeParameters
   118  */
   119 extern DECLSPEC int SDLCALL SDL_GetShapeParameters(SDL_Window *window,SDL_WindowShapeMode *shapeMode);
   120 
   121 /* Ends C function definitions when using C++ */
   122 #ifdef __cplusplus
   123 /* *INDENT-OFF* */
   124 }
   125 /* *INDENT-ON* */
   126 #endif
   127 #include "close_code.h"
   128 
   129 #endif /* _SDL_shape_h */