Class Window#
Defined in File Window.h
Nested Relationships#
Nested Types#
Class Documentation#
-
class Window#
Class representing a desktop system based window.
Remark
Headless mode: This class is not available in headless mode.
Public Types
-
enum class DisplayMode#
Specifies the display mode of a window.
Values:
-
enumerator Windowed#
-
enumerator Fullscreen#
-
enumerator Borderless#
-
enumerator Windowed#
-
using CursorMode = INTERNAL::WindowingAPI::CursorMode#
Same as WindowingAPI::CursorMode. Specifies the cursor mode of a window.
-
using CursorType = INTERNAL::WindowingAPI::CursorType#
Same as WindowingAPI::CursorType. Specifies the cursor type (visual appearance) of a window.
-
using ProgressState = INTERNAL::WindowingAPI::ProgressState#
Same as WindowingAPI::ProgressState. Specifies the progress state of a window.
Public Functions
-
explicit Window(const WindowProps &props)#
Create a new Window.
- Parameters:
props – Properties to be applied to the new window.
-
~Window()#
Destructor.
-
constexpr std::string GetTitle() const noexcept#
Get the current title of the window.
- Returns:
Title of the window.
-
u32 GetHeight() const noexcept#
Get the current height of the window.
- Returns:
Height of the window.
-
Math::Vec2ui GetSize() const noexcept#
Get the current width and height of the window.
- Returns:
Vec2ui containing the width and height of the window.
-
u32 GetFrameBufferWidth() const#
Get the current framebuffer width of the window.
- Returns:
Framebuffer width of the window.
-
u32 GetFrameBufferHeight() const#
Get the current framebuffer height of the window.
- Returns:
Framebuffer height of the window.
-
Math::Vec2ui GetFrameBufferSize() const#
Get the current framebuffer width and height of the window.
- Returns:
Vec2ui containing the framebuffer width and height of the window.
-
Math::Vec2i GetPosition() const#
Get the current position of the window. Retrieves the position, in screen coordinates, of the upper-left corner of the content area.
- Returns:
Vec2i containing the position of the window.
-
f64 GetRefreshRate() const noexcept#
Get the current refresh rate of the window.
- Returns:
Refresh rate of the window.
-
constexpr DisplayMode GetDisplayMode() const noexcept#
Get the current display mode of the window.
- Returns:
Display mode of the window.
-
Monitor GetMonitor() const#
Get the current monitor used by the window (only for display modes fullscreen and borderless).
- Returns:
Object of monitor class used by the window.
-
CursorMode GetCursorMode() const noexcept#
Get the current cursor mode of the window.
- Returns:
Cursor mode of the window.
-
bool GetRawMouseInput() const noexcept#
Get the current raw mouse input (false = off, true = on) usage of the window.
- Returns:
Raw mouse input status of the window.
-
Math::Vec2 GetContentScale() const#
Get the ratio between the current DPI and the platforms DPI.
- Returns:
Vec2 containing the x and y scale.
-
std::optional<f32> GetOpacity() const#
Get the current opacity of the window.
- Returns:
Opacity of the window on success, empty optional otherwise.
-
bool GetVSync() const noexcept#
Get whether VSync is enabled or disabled.
Same as calling TRAP::Graphics::RendererAPI::GetRenderer()->GetVSync().
- Returns:
True if VSync is enabled, false otherwise.
-
f32 GetAspectRatio() const#
Get the aspect ratio of the window.
- Returns:
Aspect ratio of window framebuffer.
-
constexpr void *GetInternalWindow() const noexcept#
Get the internal handle of the window.
- Returns:
Pointer to the internal window handle.
-
void SetTitle(const std::string &title)#
Set a new title for the window.
- Parameters:
title – New window title.
-
void SetFullscreen()#
Set the window to fullscreen display mode using the monitors native video mode.
-
void SetFullscreen(const Monitor::VideoMode &videoMode)#
Set the window to fullscreen display mode using the given video mode.
Note
If the given video mode is not supported by the monitor then this function does nothing.
- Parameters:
videoMode – Video mode to use.
-
void SetFullscreenBorderless()#
Set the window to fullscreen borderless display mode.
-
void SetWindowed()#
Set the window to windowed display mode using the previously used window size.
-
void SetWindowed(u32 width, u32 height)#
Set the Windowed object.
- Parameters:
width – New window width.
height – New window height.
-
void SetMonitor(const Monitor &monitor)#
Set a new monitor for the window.
Note
If the current display mode is fullscreen or fullscreen borderless, the window will use the new monitors native resolution.
- Parameters:
monitor – Monitor object to be used from now on.
-
void SetCursorMode(const CursorMode &mode)#
Set the cursor mode for the window.
- Parameters:
mode – New cursor mode.
-
void SetCursorType(const CursorType &cursor) const#
Set the cursor type for the window.
- Parameters:
cursor – New cursor type.
-
void SetCursorIcon(const Image *image, u32 xHotspot = 0, u32 yHotspot = 0) const#
Set the cursor to a custom image (image must be non HDR RGB/RGBA with 24/32 bits per pixel).
- Parameters:
image – Image to be used as a cursor.
xHotspot – X hotspot of the image.
yHotspot – Y hotspot of the image.
-
void SetRawMouseInput(bool enabled)#
Set if raw mouse input should be used.
- Parameters:
enabled – New status for raw mouse input.
-
void SetProgress(ProgressState state, f64 progress) const#
Sets the progress on the taskbar for the specified window.
Linux: This only works on KDE & Unity environments. A .desktop file must exist for the application with the same name as given to TRAP::Application.
- Parameters:
state – State of progress.
progress – How much has been completed. Valid range [0.0-1.0].
-
void SetIcon() const#
Resets the window icon to the TRAP logo.
-
void SetIcon(const Image *image) const#
Set a custom logo as window icon (image must be non HDR RGBA 32 bits per pixel) (nullptr resets the icon to the TRAP logo).
- Parameters:
image – New logo to be used by the window.
-
void SetEventCallback(const EventCallbackFn &callback) noexcept#
Set the function where events should be reported to from the window.
- Parameters:
callback – Callback function used to report events to.
-
void SetResizable(bool enabled) const#
Set whether resizing of the window should be allowed.
- Parameters:
enabled – Set resizable or non resizable.
-
void SetMinimumSize(u32 minWidth, u32 minHeight)#
Limit the minimum size of the window. Setting any of the two parameters to 0 will disable the minimum size restriction.
- Parameters:
minWidth – Min width.
minHeight – Min height.
-
void SetMaximumSize(u32 maxWidth, u32 maxHeight)#
Limit the maximum size of the window. Setting any of the two parameters to 0 will disable the maximum size restriction.
- Parameters:
maxWidth – Max width.
maxHeight – Max height.
-
void SetAspectRatio(u32 numerator, u32 denominator)#
Set the aspect ratio of the window. This makes sure that the window size always matches the specified aspect ratio.
Set both parameters to 0 to disable the aspect ratio restriction.
Note
This only takes effect in windowed mode.
Note
This function does nothing if the window is not resizable.
Note
If you set size limits and an aspect ratio that conflict, the results are undefined.
- Parameters:
numerator – Numerator of the desired aspect ratio, or 0.
denominator – Denominator of the desired aspect ratio, or 0.
-
void SetPosition(u32 x, u32 y)#
Set the position of the window.
- Parameters:
x – New x position.
y – New x position.
-
void SetOpacity(f32 opacity) const#
Set the opacity of the window (1.0f = fully opaque, 0.0f = fully transparent).
- Parameters:
opacity – Opacity strength.
-
void SetDragAndDrop(bool enabled) const#
Enable or disable drag and drop feature for the window.
- Parameters:
enabled – True to enable, false otherwise.
-
void SetVSync(bool enabled) const#
Enable or disable VSync for the window.
Same as calling TRAP::Graphics::RendererAPI::GetRenderer()->SetVSync().
- Parameters:
enabled – Whether to enable VSync or not.
-
bool IsMaximized() const#
Query whether the window is maximized or not.
- Returns:
Window maximization status.
-
bool IsMinimized() const#
Query whether the window is minimized or not.
- Returns:
Window minimization status.
-
bool IsResizable() const#
Query whether the window is resizable or not.
- Returns:
Window resizable status.
-
bool IsVisible() const#
Query whether the window is visible or not.
- Returns:
Window visibility status.
-
bool IsDecorated() const#
Query whether the window is decorated or not.
- Returns:
Window decoration status.
-
bool IsHovered() const#
Query whether the mouse is hovered on the window or not.
- Returns:
Window mouse hover status.
-
void Maximize() const#
Maximize the window.
Note
This function only affects the window when using DisplayMode::Windowed.
-
void Minimize() const#
Minimize the window.
-
void RequestAttention() const#
Request attention/focus for the window.
-
void Focus() const#
Focus the window.
-
void Hide() const#
Hide the window.
-
void Show() const#
Show the window.
-
void Restore() const#
Restore/Show the window.
-
enum class DisplayMode#