libpromeki 1.0.0-alpha
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
sdlwindow.h
Go to the documentation of this file.
1
8#pragma once
9
10#include <promeki/namespace.h>
11#include <promeki/widget.h>
12#include <promeki/string.h>
13
14struct SDL_Window;
15struct SDL_Renderer;
16
17PROMEKI_NAMESPACE_BEGIN
18
19class SDLEventPump;
20
47class SDLWindow : public Widget {
48 PROMEKI_OBJECT(SDLWindow, Widget)
49 friend class SDLEventPump;
50
51 public:
56 SDLWindow(ObjectBase *parent = nullptr);
57
65 SDLWindow(const String &title, int width, int height, ObjectBase *parent = nullptr);
66
69
71 String title() const { return _title; }
72
77 void setTitle(const String &title);
78
87 void resize(int width, int height);
88
90 Point2Di32 position() const { return _position; }
91
97 void move(int x, int y);
98
100 void show();
101
103 void hide();
104
106 bool isFullScreen() const { return _fullScreen; }
107
112 void setFullScreen(bool fullScreen);
113
118 SDL_Window *sdlWindow() const { return _sdlWindow; }
119
124 uint32_t sdlWindowID() const;
125
134 SDL_Renderer *sdlRenderer() const { return _sdlRenderer; }
135
144 void paintAll();
145
147 void update() override;
148
150 PROMEKI_SIGNAL(closed)
151
152
153 PROMEKI_SIGNAL(moved, Point2Di32)
154
155 private:
156 SDL_Window *_sdlWindow = nullptr;
157 SDL_Renderer *_sdlRenderer = nullptr;
158 String _title = "promeki";
159 Point2Di32 _position{0, 0};
160 bool _fullScreen = false;
161
162 void createWindow();
163 void destroyWindow();
164 void syncSizeFromSDL();
165 void syncPositionFromSDL();
166 void paintWidget(Widget *widget);
167};
168
169PROMEKI_NAMESPACE_END
Pumps SDL events into the promeki event system.
Definition sdleventpump.h:37
Top-level SDL window that serves as a root Widget.
Definition sdlwindow.h:47
Point2Di32 position() const
Returns the window position on screen.
Definition sdlwindow.h:90
void hide()
Hides the window.
SDLWindow(ObjectBase *parent=nullptr)
Constructs a window with default size.
void paintAll()
Paints the window and all child widgets.
void move(int x, int y)
Moves the window on screen.
void resize(int width, int height)
Resizes the SDL window.
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.
void setTitle(const String &title)
Sets the window title.
void update() override
Marks the window as needing a repaint.
bool isFullScreen() const
Returns true if the window is fullscreen.
Definition sdlwindow.h:106
uint32_t sdlWindowID() const
Returns the SDL window ID.
void show()
Shows the window. Creates the SDL window if needed.
SDL_Renderer * sdlRenderer() const
Returns the SDL_Renderer for this window.
Definition sdlwindow.h:134
SDL_Window * sdlWindow() const
Returns the underlying SDL_Window pointer.
Definition sdlwindow.h:118
String title() const
Returns the window title.
Definition sdlwindow.h:71
void setFullScreen(bool fullScreen)
Sets fullscreen mode.