Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 
 

145 строки
5.5 KiB

  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2018 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. * \brief Create a window that can be shaped with the specified position, dimensions, and flags.
  39. *
  40. * \param title The title of the window, in UTF-8 encoding.
  41. * \param x The x position of the window, ::SDL_WINDOWPOS_CENTERED, or
  42. * ::SDL_WINDOWPOS_UNDEFINED.
  43. * \param y The y position of the window, ::SDL_WINDOWPOS_CENTERED, or
  44. * ::SDL_WINDOWPOS_UNDEFINED.
  45. * \param w The width of the window.
  46. * \param h The height of the window.
  47. * \param flags The flags for the window, a mask of SDL_WINDOW_BORDERLESS with any of the following:
  48. * ::SDL_WINDOW_OPENGL, ::SDL_WINDOW_INPUT_GRABBED,
  49. * ::SDL_WINDOW_HIDDEN, ::SDL_WINDOW_RESIZABLE,
  50. * ::SDL_WINDOW_MAXIMIZED, ::SDL_WINDOW_MINIMIZED,
  51. * ::SDL_WINDOW_BORDERLESS is always set, and ::SDL_WINDOW_FULLSCREEN is always unset.
  52. *
  53. * \return The window created, or NULL if window creation failed.
  54. *
  55. * \sa SDL_DestroyWindow()
  56. */
  57. extern DECLSPEC SDL_Window * SDLCALL SDL_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags);
  58. /**
  59. * \brief Return whether the given window is a shaped window.
  60. *
  61. * \param window The window to query for being shaped.
  62. *
  63. * \return SDL_TRUE if the window is a window that can be shaped, SDL_FALSE if the window is unshaped or NULL.
  64. *
  65. * \sa SDL_CreateShapedWindow
  66. */
  67. extern DECLSPEC SDL_bool SDLCALL SDL_IsShapedWindow(const SDL_Window *window);
  68. /** \brief An enum denoting the specific type of contents present in an SDL_WindowShapeParams union. */
  69. typedef enum {
  70. /** \brief The default mode, a binarized alpha cutoff of 1. */
  71. ShapeModeDefault,
  72. /** \brief A binarized alpha cutoff with a given integer value. */
  73. ShapeModeBinarizeAlpha,
  74. /** \brief A binarized alpha cutoff with a given integer value, but with the opposite comparison. */
  75. ShapeModeReverseBinarizeAlpha,
  76. /** \brief A color key is applied. */
  77. ShapeModeColorKey
  78. } WindowShapeMode;
  79. #define SDL_SHAPEMODEALPHA(mode) (mode == ShapeModeDefault || mode == ShapeModeBinarizeAlpha || mode == ShapeModeReverseBinarizeAlpha)
  80. /** \brief A union containing parameters for shaped windows. */
  81. typedef union {
  82. /** \brief A cutoff alpha value for binarization of the window shape's alpha channel. */
  83. Uint8 binarizationCutoff;
  84. SDL_Color colorKey;
  85. } SDL_WindowShapeParams;
  86. /** \brief A struct that tags the SDL_WindowShapeParams union with an enum describing the type of its contents. */
  87. typedef struct SDL_WindowShapeMode {
  88. /** \brief The mode of these window-shape parameters. */
  89. WindowShapeMode mode;
  90. /** \brief Window-shape parameters. */
  91. SDL_WindowShapeParams parameters;
  92. } SDL_WindowShapeMode;
  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.
  98. * \param shape_mode The parameters to set for the shaped window.
  99. *
  100. * \return 0 on success, SDL_INVALID_SHAPE_ARGUMENT on an invalid shape argument, or SDL_NONSHAPEABLE_WINDOW
  101. * if the SDL_Window given does not reference a valid shaped window.
  102. *
  103. * \sa SDL_WindowShapeMode
  104. * \sa SDL_GetShapedWindowMode.
  105. */
  106. extern DECLSPEC int SDLCALL SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode);
  107. /**
  108. * \brief Get the shape parameters of a shaped window.
  109. *
  110. * \param window The shaped window whose parameters should be retrieved.
  111. * \param shape_mode An empty shape-mode structure to fill, or NULL to check whether the window has a shape.
  112. *
  113. * \return 0 if the window has a shape and, provided shape_mode was not NULL, shape_mode has been filled with the mode
  114. * data, SDL_NONSHAPEABLE_WINDOW if the SDL_Window given is not a shaped window, or SDL_WINDOW_LACKS_SHAPE if
  115. * the SDL_Window given is a shapeable window currently lacking a shape.
  116. *
  117. * \sa SDL_WindowShapeMode
  118. * \sa SDL_SetWindowShape
  119. */
  120. extern DECLSPEC int SDLCALL SDL_GetShapedWindowMode(SDL_Window *window,SDL_WindowShapeMode *shape_mode);
  121. /* Ends C function definitions when using C++ */
  122. #ifdef __cplusplus
  123. }
  124. #endif
  125. #include "close_code.h"
  126. #endif /* SDL_shape_h_ */