Window

D class that wraps SDL_Window managing a window instance specific to the OS

dsdl2.Window provides access to creating windows and managing them for rendering. Internally, SDL uses OS functions to summon the window.

@safe final
class Window {}

Constructors

this
this(SDL_Window* sdlWindow, bool isOwner, void* userRef)

Constructs a dsdl2.Window from a vanilla SDL_Window* from bindbc-sdl

this
this(void* nativeHandle)

Creates an SDL-handled window from a native pointer handle of the OS, which wraps SDL_CreateWindowFrom

this
this(string title, uint[2] position, uint[2] size, bool shaped, bool fullscreen, bool fullscreenDesktop, bool openGL, bool shown, bool hidden, bool borderless, bool resizable, bool minimized, bool maximized, bool inputGrabbed, bool inputFocus, bool mouseFocus, bool foreign, bool allowHighDPI, bool mouseCapture, bool alwaysOnTop, bool skipTaskbar, bool utility, bool tooltip, bool popupMenu, bool vulkan, bool metal, bool mouseGrabbed, bool keyboardGrabbed)

Creates a window on the desktop placed at a coordinate in the screen, which wraps SDL_CreateWindow

Destructor

~this
~this()
Undocumented in source.

Members

Functions

allowsHighDPI
bool allowsHighDPI()

Wraps SDL_GetWindowFlags to check whether the window allows high DPI (from SDL 2.0.1)

alwaysOnTop
bool alwaysOnTop()

Wraps SDL_GetWindowFlags to check whether the window is always on top (from SDL 2.0.5)

bordered
bool bordered()

Wraps SDL_GetWindowFlags to check whether the borders of the window are visible

bordered
void bordered(bool newBordered)

Wraps SDL_SetWindowBordered which sets whether the borders' visibility

borderless
bool borderless()

Wraps SDL_GetWindowFlags to check whether the borders of the window are non-existent

brightness
float brightness()

Wraps SDL_GetWindowBrightness which gets the window's brightness value

brightness
void brightness(float newBrightness)

Wraps SDL_SetWindowBrightness which sets the window's brightness value

display
const(Display) display()

Wraps SDL_GetWindowDisplayIndex which gets the display where the center of the window is located

displayMode
DisplayMode displayMode()

Wraps SDL_GetWindowDisplayMode which gets the window's display mode attributes

displayMode
void displayMode(DisplayMode newDisplayMode)

Wraps SDL_SetWindowDisplayMode which sets new display mode attributes to the window

drawableGLHeight
uint drawableGLHeight()

Wraps SDL_GL_GetDrawableSize (from SDL 2.0.1) which gets the drawable width of the window in OpenGL in pixels

drawableGLSize
uint[2] drawableGLSize()

Wraps SDL_GL_GetDrawableSize (from SDL 2.0.1) which gets the drawable size of the window in OpenGL in pixels

drawableGLWidth
uint drawableGLWidth()

Wraps SDL_GL_GetDrawableSize (from SDL 2.0.1) which gets the drawable height of the window in OpenGL in pixels

flash
void flash(FlashOperation operation)

Wraps SDL_FlashWindow (from SDL 2.0.16) which flashes the window in the desktop environment

focus
void focus()

Wraps SDL_SetWindowInputFocus (from SDL 2.0.5) which focuses the window to be in reach to the user

foreign
bool foreign()

Wraps SDL_GetWindowFlags to check whether the window is foreign

fullscreen
bool fullscreen()

Wraps SDL_GetWindowFlags to check whether the window is in real fullscreen

fullscreen
void fullscreen(bool newFullscreen)

Wraps SDL_SetWindowFullscreen which sets the fullscreen mode of the window

fullscreenDesktop
bool fullscreenDesktop()

Wraps SDL_GetWindowFlags to check whether the window is in desktop fullscreen

hasShownScreenKeyboard
bool hasShownScreenKeyboard()

Wraps SDL_IsScreenKeyboardShown which checks whether the screen keyboard is shown on the window

hasSurface
bool hasSurface()

Wraps SDL_HasWindowSurface (from SDL 2.28) which checks whether there is a surface associated with the window

height
uint height()

Wraps SDL_GetWindowSize which gets the height of the window in pixels

height
void height(uint newHeight)

Wraps SDL_SetWindowSize which resizes the height of the window in pixels

hidden
bool hidden()

Wraps SDL_GetWindowFlags to check whether the window is hidden

hide
void hide()

Wraps SDL_HideWindow which sets the window to be invisible in the desktop environment

iccProfile
void[] iccProfile()

Wraps SDL_GetWindowICCProfile (from SDL 2.0.18) which gets the raw ICC profile data for the screen the window is currently on

icon
void icon(Surface newIcon)

Wraps SDL_SetWindowIcon which sets a new icon to the window

id
uint id()

Wraps SDL_GetWindowID which gets the internal window ID of the dsdl2.Window

inputGrab
bool inputGrab()

Wraps SDL_GetWindowGrab which gets the window's input grab mode

inputGrab
void inputGrab(bool newGrab)

Wraps SDL_SetWindowGrab which sets the window's input grab mode

keyboardFocused
bool keyboardFocused()

Wraps SDL_GetKeyboardFocus which verifies whether keyboard input is focused to the window

keyboardGrab
bool keyboardGrab()

Wraps SDL_GetWindowKeyboardGrab (from SDL 2.0.16) which gets the status of the window grabbing onto keyboard input

keyboardGrab
void keyboardGrab(bool newKeyboardGrab)

Wraps SDL_SetWindowKeyboardGrab (from SDL 2.0.16) which sets the status of the window grabbing onto keyboard input

maximize
void maximize()

Wraps SDL_MaximizeWindow which maximizes the window in the desktop environment

maximized
bool maximized()

Wraps SDL_GetWindowFlags to check whether the window is maximized

maximumSize
uint[2] maximumSize()

Wraps SDL_GetWindowMaximumSize which gets the maximum size in pixels that the window can be resized to

maximumSize
void maximumSize(uint[2] newMaximumSize)

Wraps SDL_SetWindowMaximumSize which sets the maximum size in pixels that the window can be resized to

metal
bool metal()

Wraps SDL_GetWindowFlags to check whether the window utilizes Metal (from SDL 2.0.6)

minimize
void minimize()

Wraps SDL_MinimizeWindow which minimizes the window in the desktop environment

minimized
bool minimized()

Wraps SDL_GetWindowFlags to check whether the window is minimized

minimumSize
uint[2] minimumSize()

Wraps SDL_GetWindowMinimumSize which gets the minimum size in pixels that the window can be resized to

minimumSize
void minimumSize(uint[2] newMinimumSize)

Wraps SDL_SetWindowMinimumSize which sets the minimum size in pixels that the window can be resized to

modalFor
void modalFor(Window parent)

Wraps SDL_SetWindowModalFor (from SDL 2.0.5) which sets the window to be a modal of another parent window, making the window always be above its parent window

mouseFocused
bool mouseFocused()

Wraps SDL_GetMouseFocus which verifies whether mouse input is focused to the window

mouseGrab
bool mouseGrab()

Wraps SDL_GetWindowMouseGrab (from SDL 2.0.16) which gets the status of the window grabbing onto mouse input

mouseGrab
void mouseGrab(bool newMouseGrab)

Wraps SDL_SetWindowMouseGrab (from SDL 2.0.16) which sets the status of the window grabbing onto mouse input

mousePosition
int[2] mousePosition()

Wraps SDL_GetMouseState which gets the mouse position in the window

mousePosition
void mousePosition(int[2] newMousePosition)

Wraps SDL_WarpMouseInWindow which sets the mouse position in the window

mouseRect
Nullable!Rect mouseRect()

Wraps SDL_GetWindowMouseRect (from SDL 2.0.18) which gets the window's mouse confinement rectangle

mouseRect
void mouseRect(Rect newMouseRect)

Wraps SDL_SetWindowMouseRect (from SDL 2.0.18) which sets the window's mouse confinement rectangle

mouseRect
void mouseRect(typeof(null) _)

Acts as SDL_SetWindowMouseRect(window, NULL) (from SDL 2.0.18) which resets the window's mouse confinement rectangle

mouseRect
void mouseRect(Nullable!Rect newMouseRect)

Wraps SDL_SetWindowMouseRect (from SDL 2.0.18) which sets or resets the window's mouse confinement rectangle

onTop
void onTop(bool newOnTop)

Wraps SDL_SetWindowAlwaysOnTop (from SDL 2.0.16) which sets the status of the window always being on top above other windows

opEquals
bool opEquals(Window rhs)

Equality operator overload

opacity
float opacity()

Wraps SDL_GetWindowOpacity (from SDL 2.0.5) which gets the opacity of the window

opacity
void opacity(float newOpacity)

Wraps SDL_SetWindowOpacity (from SDL 2.0.5) which sets the opacity of the window

openGL
bool openGL()

Wraps SDL_GetWindowFlags to check whether the window utilizes OpenGL

pixelFormat
const(PixelFormat) pixelFormat()

Gets the dsdl2.PixelFormat used for pixel data of the window

popupMenu
bool popupMenu()

Wraps SDL_GetWindowFlags to check whether the window is treated as a popup menu (from SDL 2.0.5)

position
int[2] position()

Wraps SDL_GetWindowPosition which gets the top-left coordinate position of the window in the desktop environment

position
void position(int[2] newPosition)

Wraps SDL_SetWindowPosition which sets the position of the window in the desktop environment

raise
void raise()

Wraps SDL_RaiseWindow which raises the window above other windows, and sets input focus to the window

renderer
inout(Renderer) renderer()

Wraps SDL_GetRenderer which gets the renderer of the window

resizable
bool resizable()

Wraps SDL_GetWindowFlags to check whether the window's size is resizable by the user

resizable
void resizable(bool newResizable)

Wraps SDL_SetWindowResizable (from SDL 2.0.5) which sets the window's resizability

restore
void restore()

Wraps SDL_RestoreWindow which restores the size and position of the window as it was originally

show
void show()

Wraps SDL_ShowWindow which sets the window to be visible in the desktop environment

shown
bool shown()

Wraps SDL_GetWindowFlags to check whether the window is shown

size
uint[2] size()

Wraps SDL_GetWindowSize which gets the size of the window in pixels

size
void size(uint[2] newSize)

Wraps SDL_SetWindowSize which resizes the size of the window in pixels

sizeInPixels
uint[2] sizeInPixels()

Wraps SDL_GetWindowSizeInPixels (from SDL 2.26) which gets the actual size of the window in the screen in pixels

skipsTaskbar
bool skipsTaskbar()

Wraps SDL_GetWindowFlags to check whether the window is not on the taskbar (from SDL 2.0.5)

surface
inout(Surface) surface()

Wraps SDL_GetWindowSurface which gets the window's surface for software rendering

surface
void surface(typeof(null) _)

Wraps SDL_DestroyWindowSurface (from SDL 2.28) which destructs the underlying associated surface of the window

swapGL
void swapGL()

Wraps SDL_GL_SwapWindow which updates the window with any OpenGL changes

title
string title()

Wraps SDL_GetWindowTitle which gets the shown title of the window

title
void title(string newTitle)

Wraps SDL_SetWindowTitle which sets a new title to the window

toHash
hash_t toHash()

Gets the hash of the dsdl2.Window

toString
string toString()

Formats the dsdl2.Window into its construction representation: "dsdl2.Window(<sdlWindow>)"

tooltip
bool tooltip()

Wraps SDL_GetWindowFlags to check whether the window is treated as a tooltip window (from SDL 2.0.5)

update
void update()

Wraps SDL_UpdateWindowSurface which makes the changes to the window's surface current

update
void update(Rect[] rects)

Wraps SDL_UpdateWindowSurfaceRects which makes the changes of certain parts of the window surface as defined by a list of dsdl2.Rects current

utility
bool utility()

Wraps SDL_GetWindowFlags to check whether the window is treated as a utility window (from SDL 2.0.5)

vulkan
bool vulkan()

Wraps SDL_GetWindowFlags to check whether the window utilizes Vulkan (from SDL 2.0.6)

width
uint width()

Wraps SDL_GetWindowSize which gets the width of the window in pixels

width
void width(uint newWidth)

Wraps SDL_SetWindowSize which resizes the width of the window in pixels

x
int x()

Wraps SDL_GetWindowPosition which gets the top-left X coordinate position of the window in the desktop environment

x
void x(int newX)

Wraps SDL_SetWindowPosition which sets the X position of the window in the desktop environment

y
int y()

Wraps SDL_GetWindowPosition which gets the top-left Y coordinate position of the window in the desktop environment

y
void y(int newY)

Wraps SDL_SetWindowPosition which sets the Y position of the window in the desktop environment

Variables

sdlWindow
SDL_Window* sdlWindow;

Internal SDL_Window pointer

Examples

auto window = new dsdl2.Window("My Window", [dsdl2.WindowPos.centered, dsdl2.WindowPos.centered], [800, 600]);
window.surface.fill(dsdl2.Color(255, 0, 0));
window.update();

Meta