rolmodl
C++ API for the Simple Directmedia Library 2 (SDL2)
|
17 throwOnErr(SDL_GetWindowBordersSize(w.unsafeRaw(), &top_, &l_, &bot_, &r_));
34 Win_Base::Win_Base() noexcept :
38 h_(SDL_CreateWindow(title, p.x, p.y, s.w, s.h, flags.raw()))
40 assert(0 <= s.w); assert(s.w <= 16384);
41 assert(0 <= s.h); assert(s.h <= 16384);
46 Win_Base(title, geom::Pos{SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED}, s, flags) {}
48 Win_Base(title, p, s, win::Flags()) {}
49 Win_Base::Win_Base(
const char* title,
const geom::Size s) :
54 SDL_DestroyWindow(h_);
82 assert(h_ !=
nullptr);
86 assert(h_ !=
nullptr);
91 const uint32_t res = SDL_GetWindowID(
unsafeRaw());
97 const uint32_t f = SDL_GetWindowPixelFormat(
unsafeRaw());
98 if (f == SDL_PIXELFORMAT_UNKNOWN)
100 return pixelfmt::id::unsafe::fromSDLEnum(f);
103 SDL_WarpMouseInWindow(unsafeRaw(), p.x, p.y);
145 SDL_GetWindowPosition(
unsafeRaw(), &res.x, &res.y);
149 SDL_SetWindowPosition(unsafeRaw(), p.x, p.y);
156 SDL_SetWindowTitle(unsafeRaw(), str);
162 SDL_GetWindowSize(
unsafeRaw(), &res.w, &res.h);
166 SDL_SetWindowSize(unsafeRaw(), s.w, s.h);
171 SDL_GetWindowMaximumSize(
unsafeRaw(), &res.w, &res.h);
175 SDL_SetWindowMaximumSize(unsafeRaw(), s.w, s.h);
180 SDL_GetWindowMinimumSize(
unsafeRaw(), &res.w, &res.h);
184 SDL_SetWindowMinimumSize(unsafeRaw(), s.w, s.h);
geom::Size maxSize() noexcept
Get the current maximum window size.
int throwOnErr(const int code)
Throw a rolmodl::sdlexception if code < 0.
void setMaxSize(const geom::Size s) noexcept
Set the maximum window size.
void show() noexcept
Show the window.
void hide() noexcept
Hide the window.
geom::Size size() noexcept
Get the current window size.
Display information snapshot.
int dimensions data type. The value is in pixels. Semantically different from rolmodl::geom::Pos.
void maximize() noexcept
Maximize the window setting its size to the largest that will fit on screen.
SDL_Window * unsafeRaw() noexcept
Get the underlying SDL_Window*. Unsafe because this value might be nullptr and using it with some SDL...
void raise() noexcept
Place this window above all other windows and grab input focus.
uint32_t unsafeId()
Get the underlying SDL window id. Unsafe because this can be used to make a pointer to the underlying...
void setPos(const geom::Pos p) noexcept
Set the window screen position.
sys::Display display()
Get the display information snapshot for the display that contains this window's center.
BorderSizes(Win_Base &w)
Initialize from the current decoration (border) sizes for window w.
Window configuration (flags) container.
pixelfmt::Id pixelFmt()
Get the window pixel format.
Win_Base & operator=(const Win_Base &that)=delete
Copying rolmodl windows is not allowed because their lifetime is tied to the underlying SDL_Window's....
~Win_Base() noexcept
Free the underlying SDL_Window.
int r() const noexcept
Get the recorded right border size.
geom::Size minSize() noexcept
Get the current minimum window size.
int top() const noexcept
Get the recorded top border size.
void setOpacity(const float v)
Set the window opacity.
Exception type containing an error code and the last SDL error at the moment of creation.
float opacity()
Get the window opacity.
void moveMouseIn(const geom::Pos p) noexcept
Move the mouse pointer to a position relative to this window.
geom::Pos pos() noexcept
Get the window screen position.
void setMinSize(const geom::Size s) noexcept
Set the minimum window size.
void minimize() noexcept
Minimize the window hiding it in the start menu or dock or an equivalent.
int point data type. The value is in pixels. Semantically different from rolmodl::geom::Size.
unsigned int unsafeDisplayIndex()
Get the index of the display that contains this window's center. Unsafe because storing this index ca...
Common window class. Use rolmodl::Win for use with accelerated rendering (rolmodl::Ren) and rolmodl::...
void setSize(const geom::Size s) noexcept
Set the window size.
int bot() const noexcept
Get the recorded bottom border size.
Display byIndex(unsigned int i)
Get display information for the ith display. Unsafe because there is no bounds checking on the index.
void setTitle(const char *str) noexcept
Set the window title. str is in UTF-8.
const char * title() noexcept
Get the window title in UTF-8. Will be an empty string if there is no title.
int l() const noexcept
Get the recorded left border size.
void restore() noexcept
Restore the window to the size and screen position it had before being maximized or minimized.