🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

155 lines
5.8 KiB

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