Top-level SDL window that serves as a root Widget.
More...
#include <sdlwindow.h>
|
| | SDLWindow (ObjectBase *parent=nullptr) |
| | Constructs a window with default size.
|
| |
| | SDLWindow (const String &title, int width, int height, ObjectBase *parent=nullptr) |
| | Constructs a window with a title and size.
|
| |
|
| ~SDLWindow () |
| | Destructor. Destroys the SDL window and renderer.
|
| |
|
String | title () const |
| | Returns the window title.
|
| |
| void | setTitle (const String &title) |
| | Sets the window title.
|
| |
| void | resize (int width, int height) |
| | Resizes the SDL window.
|
| |
|
Point2Di32 | position () const |
| | Returns the window position on screen.
|
| |
| void | move (int x, int y) |
| | Moves the window on screen.
|
| |
|
void | show () |
| | Shows the window. Creates the SDL window if needed.
|
| |
|
void | hide () |
| | Hides the window.
|
| |
|
bool | isFullScreen () const |
| | Returns true if the window is fullscreen.
|
| |
| void | setFullScreen (bool fullScreen) |
| | Sets fullscreen mode.
|
| |
| SDL_Window * | sdlWindow () const |
| | Returns the underlying SDL_Window pointer.
|
| |
| uint32_t | sdlWindowID () const |
| | Returns the SDL window ID.
|
| |
| SDL_Renderer * | sdlRenderer () const |
| | Returns the SDL_Renderer for this window.
|
| |
| void | paintAll () |
| | Paints the window and all child widgets.
|
| |
|
void | update () override |
| | Marks the window as needing a repaint.
|
| |
Top-level SDL window that serves as a root Widget.
SDLWindow is a Widget that wraps an SDL_Window and owns the SDL_Renderer for that window. Child widgets can be added to it and positioned via the core Layout system. The window's widget geometry always reflects the SDL window's client area.
SDLWindow handles the paint cycle: when paintAll() is called, it clears the renderer, paints all child widgets (which use the renderer via sdlRenderer()), and presents.
- Example
Top-level SDL window that serves as a root Widget.
Definition sdlwindow.h:47
void resize(int width, int height)
Resizes the SDL window.
void setTitle(const String &title)
Sets the window title.
void show()
Shows the window. Creates the SDL window if needed.
- Thread Safety
- Thread-affine via ObjectBase / SDL. Must be created, used, and destroyed on the thread that owns the bound SdlSubsystem (the SDL event thread, typically the main thread).
◆ SDLWindow() [1/2]
| promeki::SDLWindow::SDLWindow |
( |
ObjectBase * |
parent = nullptr | ) |
|
Constructs a window with default size.
- Parameters
-
| parent | Parent ObjectBase, or nullptr. |
◆ SDLWindow() [2/2]
| promeki::SDLWindow::SDLWindow |
( |
const String & |
title, |
|
|
int |
width, |
|
|
int |
height, |
|
|
ObjectBase * |
parent = nullptr |
|
) |
| |
Constructs a window with a title and size.
- Parameters
-
| title | Window title. |
| width | Window width in pixels. |
| height | Window height in pixels. |
| parent | Parent ObjectBase, or nullptr. |
◆ move()
| void promeki::SDLWindow::move |
( |
int |
x, |
|
|
int |
y |
|
) |
| |
Moves the window on screen.
- Parameters
-
| x | New X position. |
| y | New Y position. |
◆ paintAll()
| void promeki::SDLWindow::paintAll |
( |
| ) |
|
Paints the window and all child widgets.
Clears the renderer, calls paintWidget() on each visible child, and presents the result. Call this from the main thread whenever the window needs repainting.
◆ resize()
| void promeki::SDLWindow::resize |
( |
int |
width, |
|
|
int |
height |
|
) |
| |
Resizes the SDL window.
- Parameters
-
| width | New width in pixels. |
| height | New height in pixels. |
This resizes the underlying SDL window. The widget geometry is updated to match via syncSizeFromSDL().
◆ sdlRenderer()
| SDL_Renderer * promeki::SDLWindow::sdlRenderer |
( |
| ) |
const |
|
inline |
Returns the SDL_Renderer for this window.
Child widgets use this to render. Only valid after the window has been shown.
- Returns
- The SDL_Renderer, or nullptr if not created.
◆ sdlWindow()
| SDL_Window * promeki::SDLWindow::sdlWindow |
( |
| ) |
const |
|
inline |
Returns the underlying SDL_Window pointer.
- Returns
- The SDL_Window, or nullptr if not created.
◆ sdlWindowID()
| uint32_t promeki::SDLWindow::sdlWindowID |
( |
| ) |
const |
Returns the SDL window ID.
- Returns
- The window ID, or 0 if not created.
◆ setFullScreen()
| void promeki::SDLWindow::setFullScreen |
( |
bool |
fullScreen | ) |
|
Sets fullscreen mode.
- Parameters
-
| fullScreen | True for fullscreen, false for windowed. |
◆ setTitle()
| void promeki::SDLWindow::setTitle |
( |
const String & |
title | ) |
|
Sets the window title.
- Parameters
-
The documentation for this class was generated from the following file: