Initial Video, Render, and Properties implementations.
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -5,36 +5,457 @@
|
||||
*/
|
||||
#include <SDL3/SDL.h>
|
||||
#include <hdk/grid/SharedPtrWrapper.hpp>
|
||||
#include <hdk/sdl/Properties.hpp>
|
||||
/** Windows are the primary interface for rendering and interacting with the user in SDL */
|
||||
namespace hdk::sdl {
|
||||
class Window : public hdk::grid::SharedPtrWrapper<SDL_Window> {
|
||||
public:
|
||||
/** Inherit constructors from SharedPtrWrapper */
|
||||
using hdk::grid::SharedPtrWrapper<SDL_Window>::SharedPtrWrapper;
|
||||
/**
|
||||
* https://wiki.libsdl.org/SDL3/SDL_CreateWindow
|
||||
* https://wiki.libsdl.org/SDL3/SDL_DestroyWindowSurface
|
||||
*
|
||||
* @param title The title of the window, in UTF-8 encoding. If the title contains UTF-8 characters, you should use SDL_CreateWindowUTF8() instead.
|
||||
* @param w The width of the window in pixels.
|
||||
* @param h The height of the window in pixels.
|
||||
* @param flags 0, or one or more SDL_WindowFlags OR'd together.
|
||||
* @return A Window instance that manages the created SDL_Window. If window creation fails, the returned Window will evaluate to false (i.e., it will be null).
|
||||
*/
|
||||
static Window Create(const char* title, int w, int h, SDL_WindowFlags flags)
|
||||
{
|
||||
class Renderer;
|
||||
class Window : public hdk::grid::SharedPtrWrapper<SDL_Window> {
|
||||
public:
|
||||
friend class Renderer;
|
||||
friend std::pair<Window, Renderer> CreateWindowAndRenderer(const char* title, int width, int height, SDL_WindowFlags window_flags);
|
||||
/** Inherit constructors from SharedPtrWrapper */
|
||||
using hdk::grid::SharedPtrWrapper<SDL_Window>::SharedPtrWrapper;
|
||||
/**
|
||||
* https://wiki.libsdl.org/SDL3/SDL_CreateWindow
|
||||
* https://wiki.libsdl.org/SDL3/SDL_DestroyWindowSurface
|
||||
*
|
||||
* @param title The title of the window
|
||||
* @param w The width of the window in pixels.
|
||||
* @param h The height of the window in pixels.
|
||||
* @param flags 0, or one or more SDL_WindowFlags OR'd together.
|
||||
* @return A Window instance that manages the created SDL_Window. If window creation fails, the returned Window
|
||||
* will evaluate to false (i.e., it will be null).
|
||||
*/
|
||||
static Window Create(const char* title, int w, int h, SDL_WindowFlags flags) {
|
||||
return Window(get_or_cache(SDL_CreateWindow(title, w, h, flags), SDL_DestroyWindow));
|
||||
}
|
||||
/**
|
||||
* https://wiki.libsdl.org/SDL3/SDL_GetWindowFromID
|
||||
* @brief Get window for WindowID
|
||||
* @param id The ID of the window.
|
||||
* @return A Window instance that wraps the SDL_Window. If no window with the given ID exists, the returned Window will evaluate to false (i.e., it will be null).
|
||||
*/
|
||||
static Window GetFromID(SDL_WindowID id)
|
||||
{
|
||||
/** Because it is possible windows were created by other means, we use get_or_view to wrap the SDL_Window without taking ownership */
|
||||
}
|
||||
/** @see SDL_CreateWindowWithProperties
|
||||
* https://wiki.libsdl.org/SDL3/SDL_CreateWindowWithProperties
|
||||
* @brief Create a window with properties.
|
||||
* @param propertiesID The ID of the properties set to use for the window.
|
||||
* @return Window The created window. If the creation fails, returns an invalid window.
|
||||
*/
|
||||
static Window CreateWithProperties(
|
||||
SDL_PropertiesID propertiesID) {
|
||||
return Window(
|
||||
get_or_cache(SDL_CreateWindowWithProperties(propertiesID), SDL_DestroyWindow));
|
||||
}
|
||||
/**
|
||||
* https://wiki.libsdl.org/SDL3/SDL_GetWindowFromID
|
||||
* @brief Get window for WindowID
|
||||
* @param id The ID of the window.
|
||||
* @return A Window instance that wraps the SDL_Window. If no window with the given ID exists, the returned Window
|
||||
* will evaluate to false (i.e., it will be null).
|
||||
*/
|
||||
static Window GetFromID(SDL_WindowID id) {
|
||||
/** Because it is possible windows were created by other means, we use get_or_view to wrap the SDL_Window
|
||||
* without taking ownership */
|
||||
return Window(get_or_view(SDL_GetWindowFromID(id)));
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
/**
|
||||
* https://wiki.libsdl.org/SDL3/SDL_GetGrabbedWindow
|
||||
* @brief Get the currently grabbed window, if any.
|
||||
* @return A Window instance that wraps the currently grabbed SDL_Window. If no window is
|
||||
*/
|
||||
static Window GetGrabbed() {
|
||||
/** Because it is possible windows were created by other means, we use get_or_view to wrap the SDL_Window
|
||||
* without taking ownership */
|
||||
return Window(get_or_view(SDL_GetGrabbedWindow()));
|
||||
}
|
||||
|
||||
public: // Instance Properties
|
||||
/**
|
||||
* https://wiki.libsdl.org/SDL3/SDL_GetWindowAspectRatio
|
||||
* @brief Get the aspect ratio of the window.
|
||||
* @param min_aspect_ratio A pointer to a float that will be filled with the minimum aspect ratio of the window.
|
||||
* @param max_aspect_ratio A pointer to a float that will be filled with the
|
||||
* @return bool True if the aspect ratio was successfully retrieved, false otherwise.
|
||||
*/
|
||||
bool GetAspectRatio(float* min_aspect_ratio, float* max_aspect_ratio) const {
|
||||
return SDL_GetWindowAspectRatio(*this, min_aspect_ratio, max_aspect_ratio);
|
||||
}
|
||||
/** https://wiki.libsdl.org/SDL3/SDL_GetWindowBordersSize
|
||||
* @brief Get the size of the window borders.
|
||||
* @param top A pointer to an int that will be filled with the size of the top border of the window.
|
||||
* @param left A pointer to an int that will be filled with the size of the left border of the window.
|
||||
* @param bottom A pointer to an int that will be filled with the size of the bottom border of the window.
|
||||
* @param right A pointer to an int that will be filled with the size of the right border of the window.
|
||||
* @return bool True if the border sizes were successfully retrieved, false otherwise.
|
||||
*/
|
||||
bool GetBordersSize(int* top, int* left, int* bottom, int* right) const {
|
||||
return SDL_GetWindowBordersSize(*this, top, left, bottom, right);
|
||||
}
|
||||
/** https://wiki.libsdl.org/SDL3/SDL_GetWindowDisplayScale
|
||||
* @brief Get the display scale of the window.
|
||||
* @return float The display scale of the window. If the window is invalid, returns 0.0f.
|
||||
*/
|
||||
float GetDisplayScale() const { return SDL_GetWindowDisplayScale(*this); }
|
||||
/** https://wiki.libsdl.org/SDL3/SDL_GetWindowFlags
|
||||
* @brief Get the flags of the window.
|
||||
* @return SDL_WindowFlags The flags of the window. If the window is invalid, returns 0.
|
||||
*/
|
||||
SDL_WindowFlags GetFlags() const { return SDL_GetWindowFlags(*this); }
|
||||
/** https://wiki.libsdl.org/SDL3/SDL_GetWindowFullscreenMode
|
||||
* @brief Get the fullscreen mode of the window.
|
||||
* @return const SDL_DisplayMode* A pointer to an SDL_DisplayMode structure that will be filled with the
|
||||
* fullscreen mode of the window. If the window is not in fullscreen mode or is invalid, returns nullptr.
|
||||
*/
|
||||
const SDL_DisplayMode* GetFullscreenMode() const { return SDL_GetWindowFullscreenMode(*this); }
|
||||
/** https://wiki.libsdl.org/SDL3/SDL_GetWindowID
|
||||
* @brief Get the ID of the window.
|
||||
* @return SDL_WindowID The ID of the window. If the window is invalid, returns 0.
|
||||
*/
|
||||
SDL_WindowID GetID() const { return SDL_GetWindowID(*this); }
|
||||
/** https://wiki.libsdl.org/SDL3/SDL_GetWindowKeyboardGrab
|
||||
* @brief Get the keyboard grab state of the window.
|
||||
* @return SDL_bool True if the window has grabbed the keyboard, false otherwise.
|
||||
*/
|
||||
bool GetKeyboardGrab() const { return SDL_GetWindowKeyboardGrab(*this); }
|
||||
/** https://wiki.libsdl.org/SDL3/SDL_SetWindowKeyboardGrab
|
||||
* @brief Set the keyboard grab state of the window.
|
||||
* @param grabbed True to grab the keyboard, false to release it.
|
||||
* @return bool True if the keyboard grab state was successfully set, false otherwise.
|
||||
*/
|
||||
bool SetKeyboardGrab(bool grabbed) const { return SDL_SetWindowKeyboardGrab(*this, grabbed); }
|
||||
/** https://wiki.libsdl.org/SDL3/SDL_GetWindowMouseGrab
|
||||
* @brief Get the mouse grab state of the window.
|
||||
* @return SDL_bool True if the window has grabbed the mouse, false otherwise.
|
||||
*/
|
||||
bool GetMouseGrab() const { return SDL_GetWindowMouseGrab(*this); }
|
||||
/** https://wiki.libsdl.org/SDL3/SDL_SetWindowMouseGrab
|
||||
* @brief Set the mouse grab state of the window.
|
||||
* @param grabbed True to grab the mouse, false to release it.
|
||||
* @return bool True if the mouse grab state was successfully set, false otherwise.
|
||||
*/
|
||||
bool SetMouseGrab(bool grabbed) const { return SDL_SetWindowMouseGrab(*this, grabbed); }
|
||||
/** SDL_GetWindowMouseRect
|
||||
* https://wiki.libsdl.org/SDL3/SDL_GetWindowMouseRect
|
||||
* @brief Get the mouse rectangle of the window.
|
||||
* @return const SDL_Rect* A pointer to an SDL_Rect structure that will be filled with the mouse rectangle of the
|
||||
* window. If the window is invalid, returns nullptr.
|
||||
*/
|
||||
const SDL_Rect* GetMouseRect() const { return SDL_GetWindowMouseRect(*this); }
|
||||
/** @see SDL_SetWindowMouseRect
|
||||
* https://wiki.libsdl.org/SDL3/SDL_SetWindowMouseRect
|
||||
* @brief Set the mouse rectangle of the window.
|
||||
* @param rect A pointer to an SDL_Rect structure that defines the mouse rectangle of the window.
|
||||
* @return bool True if the mouse rectangle was successfully set, false otherwise.
|
||||
*/
|
||||
bool SetMouseRect(const SDL_Rect* rect) const { return SDL_SetWindowMouseRect(*this, rect); }
|
||||
/** https://wiki.libsdl.org/SDL3/SDL_GetWindowMaximumSize
|
||||
* @brief Get the maximum size of the window.
|
||||
* @param w A pointer to an int that will be filled with the maximum width of the window.
|
||||
* @param h A pointer to an int that will be filled with the maximum height of the window.
|
||||
* @return bool True if the maximum size was successfully retrieved, false otherwise.
|
||||
*/
|
||||
bool GetMaximumSize(int* w, int* h) const { return SDL_GetWindowMaximumSize(*this, w, h); }
|
||||
/** https://wiki.libsdl.org/SDL3/SDL_SetWindowMaximumSize
|
||||
* @brief Set the maximum size of the window.
|
||||
* @param w The maximum width of the window in pixels.
|
||||
* @param h The maximum height of the window in pixels.
|
||||
* @return bool True if the maximum size was successfully set, false otherwise.
|
||||
*/
|
||||
bool SetMaximumSize(int w, int h) const { return SDL_SetWindowMaximumSize(*this, w, h); }
|
||||
/** https://wiki.libsdl.org/SDL3/SDL_GetWindowMinimumSize
|
||||
* @brief Get the minimum size of the window.
|
||||
* @param w A pointer to an int that will be filled with the minimum width of the window.
|
||||
* @param h A pointer to an int that will be filled with the minimum height of the window.
|
||||
* @return bool True if the minimum size was successfully retrieved, false otherwise.
|
||||
*/
|
||||
bool GetMinimumSize(int* w, int* h) const { return SDL_GetWindowMinimumSize(*this, w, h); }
|
||||
/** https://wiki.libsdl.org/SDL3/SDL_SetWindowMinimumSize
|
||||
* @brief Set the minimum size of the window.
|
||||
* @param w The minimum width of the window in pixels.
|
||||
* @param h The minimum height of the window in pixels.
|
||||
* @return bool True if the minimum size was successfully set, false otherwise.
|
||||
*/
|
||||
bool SetMinimumSize(int w, int h) const { return SDL_SetWindowMinimumSize(*this, w, h); }
|
||||
/** https://wiki.libsdl.org/SDL3/SDL_SetWindowSize
|
||||
* @brief Set the size of the window.
|
||||
* @param w The width of the window in pixels.
|
||||
* @param h The height of the window in pixels.
|
||||
* @return bool True if the size was successfully set, false otherwise.
|
||||
*/
|
||||
bool SetSize(int w, int h) const { return SDL_SetWindowSize(*this, w, h); }
|
||||
/** https://wiki.libsdl.org/SDL3/SDL_GetWindowSize
|
||||
* @brief Get the size of the window.
|
||||
* @param w A pointer to an int that will be filled with the width of the window.
|
||||
* @param h A pointer to an int that will be filled with the height of the window.
|
||||
* @return bool True if the size was successfully retrieved, false otherwise.
|
||||
*/
|
||||
bool GetSize(int* w, int* h) const { return SDL_GetWindowSize(*this, w, h); }
|
||||
/** https://wiki.libsdl.org/SDL3/SDL_GetWindowSafeArea
|
||||
* @brief Get the safe area of the window.
|
||||
* @param rect A pointer to an SDL_Rect structure that will be filled with the safe area of the window. If the
|
||||
* window is invalid, the rect will be set to {0, 0, 0, 0}.
|
||||
* @return bool True if the safe area was successfully retrieved, false otherwise.
|
||||
*/
|
||||
bool GetSafeArea(SDL_Rect* rect) const { return SDL_GetWindowSafeArea(*this, rect); }
|
||||
/** @see SDL_GetWindowOpacity
|
||||
* https://wiki.libsdl.org/SDL3/SDL_GetWindowOpacity
|
||||
* @brief Get the opacity of the window.
|
||||
* @return float The opacity of the window. If the window is invalid, returns 0.0f.
|
||||
*/
|
||||
float GetOpacity() const { return SDL_GetWindowOpacity(*this); }
|
||||
/** @see SDL_SetWindowOpacity
|
||||
* https://wiki.libsdl.org/SDL3/SDL_SetWindowOpacity
|
||||
* @brief Set the opacity of the window.
|
||||
* @param opacity The opacity of the window, between 0.0f and 1.0f. If the window is invalid, this function will
|
||||
* return false.
|
||||
* @return bool True if the opacity was successfully set, false otherwise.
|
||||
*/
|
||||
bool SetOpacity(float opacity) const { return SDL_SetWindowOpacity(*this, opacity); }
|
||||
/** @see SDL_GetWindowParent
|
||||
* https://wiki.libsdl.org/SDL3/SDL_GetWindowParent
|
||||
* @brief Get the parent of the window.
|
||||
* @return Window The parent of the window. If the window has no parent or is invalid, returns a Window that
|
||||
* evaluates to false (i.e., it will be null).
|
||||
*/
|
||||
Window GetParent() const {
|
||||
/** Because it is possible windows were created by other means, we use get_or_view to wrap the SDL_Window
|
||||
* without taking ownership */
|
||||
return Window(get_or_view(SDL_GetWindowParent(*this)));
|
||||
}
|
||||
/** @see SDL_SetWindowParent
|
||||
* https://wiki.libsdl.org/SDL3/SDL_SetWindowParent
|
||||
* @brief Set the parent of the window.
|
||||
* @param parent The parent window. If the window is invalid, this function will return false.
|
||||
* @return bool True if the parent was successfully set, false otherwise.
|
||||
*/
|
||||
bool SetParent(SDL_Window* parent) const { return SDL_SetWindowParent(*this, parent); }
|
||||
/** @see SDL_GetWindowPixelDensity
|
||||
* https://wiki.libsdl.org/SDL3/SDL_GetWindowPixelDensity
|
||||
* @brief Get the pixel density of the window.
|
||||
* @return float The pixel density of the window. If the window is invalid, returns 0.0f.
|
||||
*/
|
||||
float GetPixelDensity() const { return SDL_GetWindowPixelDensity(*this); }
|
||||
/** @see SDL_GetWindowSurfaceVSync
|
||||
* https://wiki.libsdl.org/SDL3/SDL_GetWindowSurfaceVSync
|
||||
* @brief Get current vertical refresh sync interval.
|
||||
* @param vsync pointer to existing int to be filled with the current vertical refresh sync interval. If the
|
||||
* window is invalid, this function will return false and vsync will be set to 0.
|
||||
* @return bool True if the vertical refresh sync interval was successfully retrieved, false otherwise.
|
||||
*/
|
||||
bool GetSurfaceVSync(int* vsync) const { return SDL_GetWindowSurfaceVSync(*this, vsync); }
|
||||
/** @see SDL_SetWindowSurfaceVSync
|
||||
* https://wiki.libsdl.org/SDL3/SDL_SetWindowSurfaceVSync
|
||||
* @brief Set vertical refresh sync interval.
|
||||
* @param vsync The vertical refresh sync interval. If the window is invalid, this function will return false.
|
||||
* @return bool True if the vertical refresh sync interval was successfully set, false otherwise.
|
||||
*/
|
||||
bool SetSurfaceVSync(int vsync) const { return SDL_SetWindowSurfaceVSync(*this, vsync); }
|
||||
/** @see SDL_GetWindowPixelFormat
|
||||
* https://wiki.libsdl.org/SDL3/SDL_GetWindowPixelFormat
|
||||
* @brief Get the pixel format of the window.
|
||||
* @return Uint32 The pixel format of the window. If the window is invalid, returns 0.
|
||||
*/
|
||||
SDL_PixelFormat GetPixelFormat() const { return SDL_GetWindowPixelFormat(*this); }
|
||||
/** @see SDL_GetWindowPosition
|
||||
* https://wiki.libsdl.org/SDL3/SDL_GetWindowPosition
|
||||
* @brief Get the position of the window.
|
||||
* @param x Pointer to an int to be filled with the x position of the window. If the window is invalid, this
|
||||
* function will return false and x will be set to 0.
|
||||
* @param y Pointer to an int to be filled with the y position of the window. If the window is invalid, this
|
||||
* function will return false and y will be set to 0.
|
||||
* @return bool True if the position was successfully retrieved, false otherwise.
|
||||
*/
|
||||
bool GetPosition(int* x, int* y) const { return SDL_GetWindowPosition(*this, x, y); }
|
||||
/** @see SDL_SetWindowPosition
|
||||
* https://wiki.libsdl.org/SDL3/SDL_SetWindowPosition
|
||||
* @brief Set the position of the window.
|
||||
* @param x The x position of the window in pixels. If the window is invalid, this function will return false.
|
||||
* @param y The y position of the window in pixels. If the window is invalid, this function will return false.
|
||||
* @return bool True if the position was successfully set, false otherwise.
|
||||
*/
|
||||
bool SetPosition(int x, int y) const { return SDL_SetWindowPosition(*this, x, y); }
|
||||
/** @see SDL_GetWindowProgressState
|
||||
* @see SDL_ProgressState
|
||||
* https://wiki.libsdl.org/SDL3/SDL_GetWindowProgressState
|
||||
* @brief Get the progress state of the window.
|
||||
* @return The progress state of the window. If the window is invalid, returns 0.
|
||||
*/
|
||||
SDL_ProgressState GetProgressState() const { return SDL_GetWindowProgressState(*this); }
|
||||
/** @see SDL_SetWindowProgressState
|
||||
* @see SDL_ProgressState
|
||||
* https://wiki.libsdl.org/SDL3/SDL_SetWindowProgressState
|
||||
* @brief Set the progress state of the window.
|
||||
* @param state The progress state of the window. If the window is invalid, this function will return false.
|
||||
* @return bool True if the progress state was successfully set, false otherwise.
|
||||
*/
|
||||
bool SetProgressState(SDL_ProgressState state) const { return SDL_SetWindowProgressState(*this, state); }
|
||||
|
||||
/** @see SDL_GetWindowProgressValue
|
||||
* https://wiki.libsdl.org/SDL3/SDL_GetWindowProgressValue
|
||||
* @brief Get the progress value of the window.
|
||||
* @return float The progress value of the window, between 0.0f and 1.0f. If the window is invalid, returns 0.0f.
|
||||
*/
|
||||
float GetProgressValue() const { return SDL_GetWindowProgressValue(*this); }
|
||||
/** @see SDL_SetWindowProgressValue
|
||||
* https://wiki.libsdl.org/SDL3/SDL_SetWindowProgressValue
|
||||
* @brief Set the progress value of the window.
|
||||
* @param value The progress value of the window, between 0.0f and 1.0f. If the window is invalid, this function
|
||||
* will return false.
|
||||
* @return bool True if the progress value was successfully set, false otherwise.
|
||||
*/
|
||||
bool SetProgressValue(float value) const { return SDL_SetWindowProgressValue(*this, value); }
|
||||
/** @see SDL_GetWindowProperties
|
||||
* https://wiki.libsdl.org/SDL3/SDL_GetWindowProperties
|
||||
* @brief Get the properties set of the window.
|
||||
* @return Properties The properties set of the window. If the window is invalid, returns an empty properties set.
|
||||
*/
|
||||
Properties GetProperties() const { return Properties(SDL_GetWindowProperties(*this)); }
|
||||
/** @see SDL_GetRenderer
|
||||
* https://wiki.libsdl.org/SDL3/SDL_GetRenderer
|
||||
* @brief Get the renderer associated with the window.
|
||||
* @return Renderer The renderer associated with the window. If the window is invalid, returns nullptr.
|
||||
*/
|
||||
Renderer GetRenderer() const;
|
||||
/** @see SDL_GetWindowTitle
|
||||
* https://wiki.libsdl.org/SDL3/SDL_GetWindowTitle
|
||||
* @brief Get the title of the window.
|
||||
* @return const char* The title of the window. If the window is invalid, returns an empty string.
|
||||
*/
|
||||
const char* GetTitle() const { return SDL_GetWindowTitle(*this); }
|
||||
/** @see SDL_SetWindowTitle
|
||||
* https://wiki.libsdl.org/SDL3/SDL_SetWindowTitle
|
||||
* @brief Set the title of the window.
|
||||
* @param title The title of the window. If the window is invalid, this function will return false.
|
||||
* @return bool True if the title was successfully set, false otherwise.
|
||||
*/
|
||||
bool SetTitle(const char* title) const { return SDL_SetWindowTitle(*this, title); }
|
||||
/** @see SDL_SetWindowAlwaysOnTop
|
||||
* https://wiki.libsdl.org/SDL3/SDL_SetWindowAlwaysOnTop
|
||||
* @brief Set the window to be always on top.
|
||||
* @param alwaysOnTop True to make the window always on top, false otherwise.
|
||||
* @return bool True if the operation was successful, false otherwise.
|
||||
*/
|
||||
bool SetAlwaysOnTop(bool alwaysOnTop) const { return SDL_SetWindowAlwaysOnTop(*this, alwaysOnTop); }
|
||||
/** @see SDL_SetWindowIcon
|
||||
* https://wiki.libsdl.org/SDL3/SDL_SetWindowIcon
|
||||
* @brief Set the icon of the window.
|
||||
* @param icon The surface to use as the window's icon. If the window is invalid, this function will return false.
|
||||
* @return bool True if the icon was successfully set, false otherwise.
|
||||
*/
|
||||
bool SetIcon(SDL_Surface* icon) const { return SDL_SetWindowIcon(*this, icon); }
|
||||
/** @see SDL_SetWindowModal
|
||||
* https://wiki.libsdl.org/SDL3/SDL_SetWindowModal
|
||||
* @brief Set the window to be modal.
|
||||
* @param modal True to make the window modal, false otherwise.
|
||||
* @return bool True if the operation was successful, false otherwise.
|
||||
*/
|
||||
bool SetModal(bool modal) const { return SDL_SetWindowModal(*this, modal); }
|
||||
/** @see SDL_SetWindowResizable
|
||||
* https://wiki.libsdl.org/SDL3/SDL_SetWindowResizable
|
||||
* @brief Set the window to be resizable.
|
||||
* @param resizable True to make the window resizable, false otherwise.
|
||||
* @return bool True if the operation was successful, false otherwise.
|
||||
*/
|
||||
bool SetResizable(bool resizable) const { return SDL_SetWindowResizable(*this, resizable); }
|
||||
/** @see SDL_SetWindowShape
|
||||
* https://wiki.libsdl.org/SDL3/SDL_SetWindowShape
|
||||
* @brief Set the shape of the window.
|
||||
* @param shape The shape mode to set for the window. If the window is invalid, this function will return false.
|
||||
* @return bool True if the shape was successfully set, false otherwise.
|
||||
*/
|
||||
bool SetShape(SDL_Surface* shape) const { return SDL_SetWindowShape(*this, shape); }
|
||||
/** @see SDL_CreatePopupWindow
|
||||
* https://wiki.libsdl.org/SDL3/SDL_CreatePopupWindow
|
||||
* @brief Create a popup window.
|
||||
* @param offset_x The x position of the popup window relative to the parent window.
|
||||
* @param offset_y The y position of the popup window relative to the parent window.
|
||||
* @param w The width of the popup window.
|
||||
* @param h The height of the popup window.
|
||||
* @param flags The flags for the popup window.
|
||||
* @return Window The created popup window. If the creation fails, returns an invalid window.
|
||||
*/
|
||||
Window CreatePopup(int offset_x, int offset_y, int w, int h, SDL_WindowFlags flags) const {
|
||||
return Window(
|
||||
get_or_cache(SDL_CreatePopupWindow(*this, offset_x, offset_y, w, h, flags), SDL_DestroyWindow));
|
||||
}
|
||||
/** @see SDL_DestroyWindowSurface
|
||||
* https://wiki.libsdl.org/SDL3/SDL_DestroyWindowSurface
|
||||
* @brief Destroy the window surface.
|
||||
* @return bool True if the surface was successfully destroyed, false otherwise.
|
||||
*/
|
||||
bool DestroySurface() const { return SDL_DestroyWindowSurface(*this); }
|
||||
/** @see SDL_FlashWindow
|
||||
* https://wiki.libsdl.org/SDL3/SDL_FlashWindow
|
||||
* @brief Flash the window to get the user's attention.
|
||||
* @param flashType The type of flash to perform.
|
||||
* @return bool True if the window was successfully flashed, false otherwise.
|
||||
*/
|
||||
bool Flash(SDL_FlashOperation flashType) const { return SDL_FlashWindow(*this, flashType); }
|
||||
/** @see SDL_HideWindow
|
||||
* https://wiki.libsdl.org/SDL3/SDL_HideWindow
|
||||
* @brief Hide the window.
|
||||
* @return bool True if the window was successfully hidden, false otherwise.
|
||||
*/
|
||||
bool Hide() const { return SDL_HideWindow(*this); }
|
||||
/** @see SDL_MaximizeWindow
|
||||
* https://wiki.libsdl.org/SDL3/SDL_MaximizeWindow
|
||||
* @brief Maximize the window. If the window is already maximized, this function will return false.
|
||||
* @return bool True if the window was successfully maximized, false otherwise.
|
||||
*/
|
||||
bool Maximize() const { return SDL_MaximizeWindow(*this); }
|
||||
/** @see SDL_MinimizeWindow
|
||||
* https://wiki.libsdl.org/SDL3/SDL_MinimizeWindow
|
||||
* @brief Minimize the window. If the window is already minimized, this function will
|
||||
* return false.
|
||||
* @return bool True if the window was successfully minimized, false otherwise.
|
||||
*/
|
||||
bool Minimize() const { return SDL_MinimizeWindow(*this); }
|
||||
/** @see SDL_RaiseWindow
|
||||
* https://wiki.libsdl.org/SDL3/SDL_RaiseWindow
|
||||
* @brief Raise the window above other windows. If the window is already raised, this function will return false.
|
||||
* @return bool True if the window was successfully raised, false otherwise.
|
||||
*/
|
||||
bool Raise() const { return SDL_RaiseWindow(*this); }
|
||||
/** @see SDL_RestoreWindow
|
||||
* https://wiki.libsdl.org/SDL3/SDL_RestoreWindow
|
||||
* @brief Restore the window to its normal size and position. If the window is not minimized or maximized, this
|
||||
* function will return false.
|
||||
* @return bool True if the window was successfully restored, false otherwise.
|
||||
*/
|
||||
bool Restore() const { return SDL_RestoreWindow(*this); }
|
||||
/** @see SDL_ShowWindow
|
||||
* https://wiki.libsdl.org/SDL3/SDL_ShowWindow
|
||||
* @brief Show the window.
|
||||
* @return bool True if the window was successfully shown, false otherwise.
|
||||
*/
|
||||
bool Show() const { return SDL_ShowWindow(*this); }
|
||||
/** @see SDL_ShowWindowSystemMenu
|
||||
* https://wiki.libsdl.org/SDL3/SDL_ShowWindowSystemMenu
|
||||
* @brief Show the window's system menu.
|
||||
* @param x
|
||||
* @param y
|
||||
* @return bool True if the system menu was successfully shown, false otherwise.
|
||||
*/
|
||||
bool ShowSystemMenu(int x, int y) const { return SDL_ShowWindowSystemMenu(*this, x, y); }
|
||||
/** @see SDL_SyncWindow
|
||||
* https://wiki.libsdl.org/SDL3/SDL_SyncWindow
|
||||
* @brief Sync the window's state with the display. This is useful after changing display modes or other
|
||||
* operations that may affect the window's appearance.
|
||||
* @return bool True if the window was successfully synced, false otherwise.
|
||||
*/
|
||||
bool Sync() const { return SDL_SyncWindow(*this); }
|
||||
/** @see SDL_UpdateWindowSurface
|
||||
* https://wiki.libsdl.org/SDL3/SDL_UpdateWindowSurface
|
||||
* @brief Update the window surface with any changes made to the surface. This should only be used if you are
|
||||
* using the window surface for rendering. If the window is invalid, this function will return false.
|
||||
* @return bool True if the window surface was successfully updated, false otherwise.
|
||||
*/
|
||||
bool UpdateSurface() const { return SDL_UpdateWindowSurface(*this); }
|
||||
/** @see SDL_UpdateWindowSurfaceRects
|
||||
* https://wiki.libsdl.org/SDL3/SDL_UpdateWindowSurfaceRects
|
||||
* @brief Update the window surface with any changes made to the specified rectangles on the surface. This should
|
||||
* only be used if you are using the window surface for rendering. If the window is invalid, this function will
|
||||
* return false.
|
||||
* @param rects An array of SDL_Rect structures that define the rectangles to update on the window surface.
|
||||
* @param num_rects The number of rectangles in the rects array.
|
||||
* @return bool True if the window surface was successfully updated, false otherwise.
|
||||
*/
|
||||
bool UpdateSurfaceRects(const SDL_Rect* rects, int num_rects) const {
|
||||
return SDL_UpdateWindowSurfaceRects(*this, rects, num_rects);
|
||||
}
|
||||
};
|
||||
} // namespace hdk::sdl
|
||||
Reference in New Issue
Block a user