include/SDL_shape.h
author Sam Lantinga <slouken@libsdl.org>
Tue, 23 Apr 2019 07:59:31 -0700
changeset 12714 9b7633bd0aa0
parent 12503 806492103856
permissions -rw-r--r--
Use _Exit() when available
eligottlieb@4766
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@12503
     3
  Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
eligottlieb@4766
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
eligottlieb@4766
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
eligottlieb@4766
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
eligottlieb@4766
    20
*/
eligottlieb@4766
    21
slouken@10638
    22
#ifndef SDL_shape_h_
slouken@10638
    23
#define SDL_shape_h_
eligottlieb@4769
    24
eligottlieb@4769
    25
#include "SDL_stdinc.h"
eligottlieb@4769
    26
#include "SDL_pixels.h"
eligottlieb@4769
    27
#include "SDL_rect.h"
eligottlieb@4769
    28
#include "SDL_surface.h"
eligottlieb@4769
    29
#include "SDL_video.h"
eligottlieb@4769
    30
eligottlieb@4769
    31
#include "begin_code.h"
eligottlieb@4769
    32
/* Set up for C function definitions, even when using C++ */
eligottlieb@4769
    33
#ifdef __cplusplus
eligottlieb@4769
    34
extern "C" {
eligottlieb@4769
    35
#endif
eligottlieb@4766
    36
eligottlieb@4779
    37
/** \file SDL_shape.h
eligottlieb@4779
    38
 *
eligottlieb@4781
    39
 * Header file for the shaped window API.
eligottlieb@4779
    40
 */
eligottlieb@4779
    41
eligottlieb@4801
    42
#define SDL_NONSHAPEABLE_WINDOW -1
eligottlieb@4801
    43
#define SDL_INVALID_SHAPE_ARGUMENT -2
eligottlieb@4801
    44
#define SDL_WINDOW_LACKS_SHAPE -3
eligottlieb@4801
    45
eligottlieb@4766
    46
/**
eligottlieb@4781
    47
 *  \brief Create a window that can be shaped with the specified position, dimensions, and flags.
slouken@7191
    48
 *
eligottlieb@4766
    49
 *  \param title The title of the window, in UTF-8 encoding.
slouken@7191
    50
 *  \param x     The x position of the window, ::SDL_WINDOWPOS_CENTERED, or
eligottlieb@4766
    51
 *               ::SDL_WINDOWPOS_UNDEFINED.
slouken@7191
    52
 *  \param y     The y position of the window, ::SDL_WINDOWPOS_CENTERED, or
eligottlieb@4766
    53
 *               ::SDL_WINDOWPOS_UNDEFINED.
eligottlieb@4766
    54
 *  \param w     The width of the window.
eligottlieb@4766
    55
 *  \param h     The height of the window.
slouken@7191
    56
 *  \param flags The flags for the window, a mask of SDL_WINDOW_BORDERLESS with any of the following:
eligottlieb@4767
    57
 *               ::SDL_WINDOW_OPENGL,     ::SDL_WINDOW_INPUT_GRABBED,
philipp@7480
    58
 *               ::SDL_WINDOW_HIDDEN,     ::SDL_WINDOW_RESIZABLE,
eligottlieb@4766
    59
 *               ::SDL_WINDOW_MAXIMIZED,  ::SDL_WINDOW_MINIMIZED,
slouken@7191
    60
 *       ::SDL_WINDOW_BORDERLESS is always set, and ::SDL_WINDOW_FULLSCREEN is always unset.
slouken@7191
    61
 *
eligottlieb@4801
    62
 *  \return The window created, or NULL if window creation failed.
slouken@7191
    63
 *
eligottlieb@4766
    64
 *  \sa SDL_DestroyWindow()
eligottlieb@4766
    65
 */
eligottlieb@4768
    66
extern DECLSPEC SDL_Window * SDLCALL SDL_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags);
eligottlieb@4766
    67
eligottlieb@4778
    68
/**
slouken@7191
    69
 * \brief Return whether the given window is a shaped window.
eligottlieb@4778
    70
 *
eligottlieb@4778
    71
 * \param window The window to query for being shaped.
eligottlieb@4778
    72
 *
eligottlieb@4781
    73
 * \return SDL_TRUE if the window is a window that can be shaped, SDL_FALSE if the window is unshaped or NULL.
philipp@11167
    74
 *
eligottlieb@4778
    75
 * \sa SDL_CreateShapedWindow
eligottlieb@4778
    76
 */
eligottlieb@4781
    77
extern DECLSPEC SDL_bool SDLCALL SDL_IsShapedWindow(const SDL_Window *window);
eligottlieb@4778
    78
eligottlieb@4778
    79
/** \brief An enum denoting the specific type of contents present in an SDL_WindowShapeParams union. */
eligottlieb@4781
    80
typedef enum {
slouken@7191
    81
    /** \brief The default mode, a binarized alpha cutoff of 1. */
slouken@7191
    82
    ShapeModeDefault,
slouken@7191
    83
    /** \brief A binarized alpha cutoff with a given integer value. */
slouken@7191
    84
    ShapeModeBinarizeAlpha,
slouken@7191
    85
    /** \brief A binarized alpha cutoff with a given integer value, but with the opposite comparison. */
slouken@7191
    86
    ShapeModeReverseBinarizeAlpha,
slouken@7191
    87
    /** \brief A color key is applied. */
slouken@7191
    88
    ShapeModeColorKey
eligottlieb@4781
    89
} WindowShapeMode;
eligottlieb@4846
    90
eligottlieb@4846
    91
#define SDL_SHAPEMODEALPHA(mode) (mode == ShapeModeDefault || mode == ShapeModeBinarizeAlpha || mode == ShapeModeReverseBinarizeAlpha)
eligottlieb@4846
    92
eligottlieb@4778
    93
/** \brief A union containing parameters for shaped windows. */
eligottlieb@4778
    94
typedef union {
philipp@11167
    95
    /** \brief A cutoff alpha value for binarization of the window shape's alpha channel. */
slouken@7191
    96
    Uint8 binarizationCutoff;
slouken@7191
    97
    SDL_Color colorKey;
eligottlieb@4778
    98
} SDL_WindowShapeParams;
eligottlieb@4778
    99
eligottlieb@4778
   100
/** \brief A struct that tags the SDL_WindowShapeParams union with an enum describing the type of its contents. */
eligottlieb@4778
   101
typedef struct SDL_WindowShapeMode {
slouken@7191
   102
    /** \brief The mode of these window-shape parameters. */
slouken@7191
   103
    WindowShapeMode mode;
slouken@7191
   104
    /** \brief Window-shape parameters. */
slouken@7191
   105
    SDL_WindowShapeParams parameters;
eligottlieb@4778
   106
} SDL_WindowShapeMode;
eligottlieb@4778
   107
eligottlieb@4778
   108
/**
eligottlieb@4780
   109
 * \brief Set the shape and parameters of a shaped window.
eligottlieb@4778
   110
 *
eligottlieb@4778
   111
 * \param window The shaped window whose parameters should be set.
eligottlieb@4781
   112
 * \param shape A surface encoding the desired shape for the window.
egottlieb@4849
   113
 * \param shape_mode The parameters to set for the shaped window.
eligottlieb@4778
   114
 *
philipp@11167
   115
 * \return 0 on success, SDL_INVALID_SHAPE_ARGUMENT on an invalid shape argument, or SDL_NONSHAPEABLE_WINDOW
philipp@11167
   116
 *           if the SDL_Window given does not reference a valid shaped window.
eligottlieb@4778
   117
 *
eligottlieb@4778
   118
 * \sa SDL_WindowShapeMode
eligottlieb@4781
   119
 * \sa SDL_GetShapedWindowMode.
eligottlieb@4778
   120
 */
egottlieb@4849
   121
extern DECLSPEC int SDLCALL SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode);
eligottlieb@4778
   122
eligottlieb@4778
   123
/**
eligottlieb@4781
   124
 * \brief Get the shape parameters of a shaped window.
eligottlieb@4778
   125
 *
eligottlieb@4778
   126
 * \param window The shaped window whose parameters should be retrieved.
egottlieb@4849
   127
 * \param shape_mode An empty shape-mode structure to fill, or NULL to check whether the window has a shape.
eligottlieb@4778
   128
 *
egottlieb@4849
   129
 * \return 0 if the window has a shape and, provided shape_mode was not NULL, shape_mode has been filled with the mode
eligottlieb@4801
   130
 *           data, SDL_NONSHAPEABLE_WINDOW if the SDL_Window given is not a shaped window, or SDL_WINDOW_LACKS_SHAPE if
philipp@11167
   131
 *           the SDL_Window given is a shapeable window currently lacking a shape.
eligottlieb@4778
   132
 *
eligottlieb@4778
   133
 * \sa SDL_WindowShapeMode
eligottlieb@4781
   134
 * \sa SDL_SetWindowShape
eligottlieb@4778
   135
 */
egottlieb@4849
   136
extern DECLSPEC int SDLCALL SDL_GetShapedWindowMode(SDL_Window *window,SDL_WindowShapeMode *shape_mode);
eligottlieb@4778
   137
eligottlieb@4769
   138
/* Ends C function definitions when using C++ */
eligottlieb@4769
   139
#ifdef __cplusplus
eligottlieb@4769
   140
}
eligottlieb@4769
   141
#endif
eligottlieb@4769
   142
#include "close_code.h"
eligottlieb@4769
   143
slouken@10638
   144
#endif /* SDL_shape_h_ */