rolmodl
C++ API for the Simple Directmedia Library 2 (SDL2)
Public Member Functions | Friends | List of all members
rolmodl::Win_Base Class Reference

Common window class. Use rolmodl::Win for use with accelerated rendering (rolmodl::Ren) and rolmodl::Win_SW for use with software rendering (rolmodl::SWTex). More...

#include <Win.hpp>

Inheritance diagram for rolmodl::Win_Base:
rolmodl::Win rolmodl::Win_SW

Public Member Functions

 Win_Base (const char *title, const geom::Pos p, const geom::Size s, const win::Flags flags)
 Initialize a window with title title, at the screen position p, of size s, with configuration flags. More...
 
 Win_Base (const char *title, const geom::Size s, const win::Flags flags)
 Initialize a window with title title, at the center of the screen, of size s, with configuration flags. More...
 
 Win_Base (const char *title, const geom::Pos p, const geom::Size s)
 Initialize a window with title title, at the screen position p, of size s, with the default configuration. More...
 
 Win_Base (const char *title, const geom::Size s)
 Initialize a window with title title, at the center of the screen, of size s, with the default configuration. More...
 
 ~Win_Base () noexcept
 Free the underlying SDL_Window. More...
 
 Win_Base (const Win_Base &that)=delete
 Copying rolmodl windows is not allowed because their lifetime is tied to the underlying SDL_Window's. Use references or some other pointer type instead.
 
 Win_Base (Win_Base &&that) noexcept
 Take over the underlying SDL_Window of that.
 
Win_Baseoperator= (const Win_Base &that)=delete
 Copying rolmodl windows is not allowed because their lifetime is tied to the underlying SDL_Window's. Use references or some other pointer type instead.
 
Win_Baseoperator= (Win_Base &&that) noexcept
 Take over the underlying SDL_Window of that.
 
SDL_Window * unsafeRaw () noexcept
 Get the underlying SDL_Window*. Unsafe because this value might be nullptr and using it with some SDL functions can lead to rolmodl invariant violation.
 
const SDL_Window * unsafeRaw () const noexcept
 Get the underlying SDL_Window* in a const context. Unsafe because this value might be nullptr and using it with some SDL functions can lead to rolmodl invariant violation.
 
void hide () noexcept
 Hide the window. More...
 
void show () noexcept
 Show the window. More...
 
void raise () noexcept
 Place this window above all other windows and grab input focus. More...
 
void maximize () noexcept
 Maximize the window setting its size to the largest that will fit on screen. More...
 
void minimize () noexcept
 Minimize the window hiding it in the start menu or dock or an equivalent. More...
 
void restore () noexcept
 Restore the window to the size and screen position it had before being maximized or minimized. More...
 
unsigned int unsafeDisplayIndex ()
 Get the index of the display that contains this window's center. Unsafe because storing this index can lead to an out-of-bounds error if the display is later disconnected. More...
 
sys::Display display ()
 Get the display information snapshot for the display that contains this window's center. More...
 
float opacity ()
 Get the window opacity. More...
 
void setOpacity (const float v)
 Set the window opacity. More...
 
geom::Pos pos () noexcept
 Get the window screen position. More...
 
void setPos (const geom::Pos p) noexcept
 Set the window screen position. More...
 
const char * title () noexcept
 Get the window title in UTF-8. Will be an empty string if there is no title. More...
 
void setTitle (const char *str) noexcept
 Set the window title. str is in UTF-8. More...
 
geom::Size size () noexcept
 Get the current window size. More...
 
void setSize (const geom::Size s) noexcept
 Set the window size. More...
 
geom::Size maxSize () noexcept
 Get the current maximum window size. More...
 
void setMaxSize (const geom::Size s) noexcept
 Set the maximum window size. More...
 
geom::Size minSize () noexcept
 Get the current minimum window size. More...
 
void setMinSize (const geom::Size s) noexcept
 Set the minimum window size. More...
 
uint32_t unsafeId ()
 Get the underlying SDL window id. Unsafe because this can be used to make a pointer to the underlying window that escapes the window's lifetime. More...
 
pixelfmt::Id pixelFmt ()
 Get the window pixel format. More...
 
void moveMouseIn (const geom::Pos p) noexcept
 Move the mouse pointer to a position relative to this window. More...
 

Friends

void swap (Win_Base &a, Win_Base &b) noexcept
 Exchange the underlying SDL_Window with that.
 

Detailed Description

Common window class. Use rolmodl::Win for use with accelerated rendering (rolmodl::Ren) and rolmodl::Win_SW for use with software rendering (rolmodl::SWTex).

Wrapper around SDL_Window.

See also
https://wiki.libsdl.org/SDL_CreateWindow

Definition at line 212 of file Win.hpp.

Constructor & Destructor Documentation

◆ Win_Base() [1/4]

rolmodl::Win_Base::Win_Base ( const char *  title,
const geom::Pos  p,
const geom::Size  s,
const win::Flags  flags 
)

Initialize a window with title title, at the screen position p, of size s, with configuration flags.

See also
https://wiki.libsdl.org/SDL_CreateWindow

Definition at line 37 of file Win.cpp.

◆ Win_Base() [2/4]

rolmodl::Win_Base::Win_Base ( const char *  title,
const geom::Size  s,
const win::Flags  flags 
)

Initialize a window with title title, at the center of the screen, of size s, with configuration flags.

See also
https://wiki.libsdl.org/SDL_CreateWindow

Definition at line 45 of file Win.cpp.

◆ Win_Base() [3/4]

rolmodl::Win_Base::Win_Base ( const char *  title,
const geom::Pos  p,
const geom::Size  s 
)

Initialize a window with title title, at the screen position p, of size s, with the default configuration.

See also
https://wiki.libsdl.org/SDL_CreateWindow

Definition at line 47 of file Win.cpp.

◆ Win_Base() [4/4]

rolmodl::Win_Base::Win_Base ( const char *  title,
const geom::Size  s 
)

Initialize a window with title title, at the center of the screen, of size s, with the default configuration.

See also
https://wiki.libsdl.org/SDL_CreateWindow

Definition at line 49 of file Win.cpp.

◆ ~Win_Base()

rolmodl::Win_Base::~Win_Base ( )
noexcept

Free the underlying SDL_Window.

See also
https://wiki.libsdl.org/SDL_DestroyWindow

Definition at line 52 of file Win.cpp.

Member Function Documentation

◆ hide()

void rolmodl::Win_Base::hide ( )
noexcept

Hide the window.

See also
https://wiki.libsdl.org/SDL_HideWindow

Definition at line 107 of file Win.cpp.

References unsafeRaw().

◆ show()

void rolmodl::Win_Base::show ( )
noexcept

Show the window.

See also
https://wiki.libsdl.org/SDL_ShowWindow

Definition at line 110 of file Win.cpp.

References unsafeRaw().

◆ raise()

void rolmodl::Win_Base::raise ( )
noexcept

Place this window above all other windows and grab input focus.

See also
https://wiki.libsdl.org/SDL_RaiseWindow

Definition at line 113 of file Win.cpp.

References unsafeRaw().

◆ maximize()

void rolmodl::Win_Base::maximize ( )
noexcept

Maximize the window setting its size to the largest that will fit on screen.

See also
https://wiki.libsdl.org/SDL_MaximizeWindow

Definition at line 117 of file Win.cpp.

References unsafeRaw().

◆ minimize()

void rolmodl::Win_Base::minimize ( )
noexcept

Minimize the window hiding it in the start menu or dock or an equivalent.

See also
https://wiki.libsdl.org/SDL_MaximizeWindow

Definition at line 120 of file Win.cpp.

References unsafeRaw().

◆ restore()

void rolmodl::Win_Base::restore ( )
noexcept

Restore the window to the size and screen position it had before being maximized or minimized.

See also
https://wiki.libsdl.org/SDL_RestoreWindow

Definition at line 123 of file Win.cpp.

References unsafeRaw().

◆ unsafeDisplayIndex()

unsigned int rolmodl::Win_Base::unsafeDisplayIndex ( )

Get the index of the display that contains this window's center. Unsafe because storing this index can lead to an out-of-bounds error if the display is later disconnected.

See also
https://wiki.libsdl.org/SDL_GetWindowDisplayIndex

Definition at line 127 of file Win.cpp.

References rolmodl::detail::throwOnErr(), and unsafeRaw().

Referenced by display().

◆ display()

sys::Display rolmodl::Win_Base::display ( )

Get the display information snapshot for the display that contains this window's center.

See also
https://wiki.libsdl.org/SDL_GetWindowDisplayIndex

Definition at line 130 of file Win.cpp.

References rolmodl::sys::display::unsafe::byIndex(), and unsafeDisplayIndex().

◆ opacity()

float rolmodl::Win_Base::opacity ( )

Get the window opacity.

See also
https://wiki.libsdl.org/SDL_GetWindowOpacity

Definition at line 134 of file Win.cpp.

References rolmodl::detail::throwOnErr(), and unsafeRaw().

◆ setOpacity()

void rolmodl::Win_Base::setOpacity ( const float  v)

Set the window opacity.

See also
https://wiki.libsdl.org/SDL_SetWindowOpacity

Definition at line 139 of file Win.cpp.

References rolmodl::detail::throwOnErr(), and unsafeRaw().

◆ pos()

geom::Pos rolmodl::Win_Base::pos ( )
noexcept

Get the window screen position.

See also
https://wiki.libsdl.org/SDL_GetWindowPosition

Definition at line 143 of file Win.cpp.

References unsafeRaw().

◆ setPos()

void rolmodl::Win_Base::setPos ( const geom::Pos  p)
noexcept

Set the window screen position.

See also
https://wiki.libsdl.org/SDL_SetWindowPosition

Definition at line 148 of file Win.cpp.

◆ title()

const char * rolmodl::Win_Base::title ( )
noexcept

Get the window title in UTF-8. Will be an empty string if there is no title.

See also
https://wiki.libsdl.org/SDL_GetWindowTitle

Definition at line 152 of file Win.cpp.

References unsafeRaw().

◆ setTitle()

void rolmodl::Win_Base::setTitle ( const char *  str)
noexcept

Set the window title. str is in UTF-8.

See also
https://wiki.libsdl.org/SDL_SetWindowTitle

Definition at line 155 of file Win.cpp.

◆ size()

geom::Size rolmodl::Win_Base::size ( )
noexcept

Get the current window size.

See also
https://wiki.libsdl.org/SDL_GetWindowSize

Definition at line 160 of file Win.cpp.

References unsafeRaw().

◆ setSize()

void rolmodl::Win_Base::setSize ( const geom::Size  s)
noexcept

Set the window size.

See also
https://wiki.libsdl.org/SDL_SetWindowSize

Definition at line 165 of file Win.cpp.

◆ maxSize()

geom::Size rolmodl::Win_Base::maxSize ( )
noexcept

Get the current maximum window size.

See also
https://wiki.libsdl.org/SDL_GetWindowMaximumSize

Definition at line 169 of file Win.cpp.

References unsafeRaw().

◆ setMaxSize()

void rolmodl::Win_Base::setMaxSize ( const geom::Size  s)
noexcept

Set the maximum window size.

See also
https://wiki.libsdl.org/SDL_SetWindowMaximumSize

Definition at line 174 of file Win.cpp.

◆ minSize()

geom::Size rolmodl::Win_Base::minSize ( )
noexcept

Get the current minimum window size.

See also
https://wiki.libsdl.org/SDL_GetWindowMinimumSize

Definition at line 178 of file Win.cpp.

References unsafeRaw().

◆ setMinSize()

void rolmodl::Win_Base::setMinSize ( const geom::Size  s)
noexcept

Set the minimum window size.

See also
https://wiki.libsdl.org/SDL_SetWindowMinimumSize

Definition at line 183 of file Win.cpp.

◆ unsafeId()

uint32_t rolmodl::Win_Base::unsafeId ( )

Get the underlying SDL window id. Unsafe because this can be used to make a pointer to the underlying window that escapes the window's lifetime.

See also
https://wiki.libsdl.org/SDL_GetWindowID

Definition at line 90 of file Win.cpp.

References unsafeRaw().

◆ pixelFmt()

pixelfmt::Id rolmodl::Win_Base::pixelFmt ( )

Get the window pixel format.

See also
https://wiki.libsdl.org/SDL_GetWindowPixelFormat

Definition at line 96 of file Win.cpp.

References unsafeRaw().

◆ moveMouseIn()

void rolmodl::Win_Base::moveMouseIn ( const geom::Pos  p)
noexcept

Move the mouse pointer to a position relative to this window.

See also
https://wiki.libsdl.org/SDL_WarpMouseInWindow

Definition at line 102 of file Win.cpp.


The documentation for this class was generated from the following files: