XII Release 0.1.0
Loading...
Searching...
No Matches
xiiWindow Class Reference

#include <Window.h>

Inheritance diagram for xiiWindow:
[legend]

Public Member Functions

 xiiWindow ()
virtual ~xiiWindow ()
 Destroys the window if not already done.
const xiiWindowCreationDescription & GetCreationDescription () const
 Returns the currently active description struct.
virtual xiiSizeU32 GetClientAreaSize () const override
 Returns the size of the client area of the window, i.e. the area that can be drawn into.
virtual xiiWindowHandle GetNativeWindowHandle () const override
 Returns the position and size of the entire window, including borders and title bar.
virtual bool IsFullscreenWindow (bool bOnlyProperFullscreenMode=false) const override
virtual bool IsVisible () const override
virtual void AddReference () override
 Adds a reference to the window. The window will not be destroyed until all references are removed.
virtual void RemoveReference () override
 Removes a reference from the window. If this was the last reference, the window will be destroyed.
virtual void ProcessWindowMessages () override
 Processes all pending window messages, such as input or resize events. This should be called regularly (typically once per frame) to keep the window responsive.
xiiResult Initialize ()
xiiResult Initialize (const xiiWindowCreationDescription &creationDescription)
bool IsInitialized () const
 Gets if the window is up and running.
xiiResult Destroy ()
 Destroys the window.
xiiResult Resize (const xiiSizeU32 &newWindowSize)
virtual void OnResize (const xiiSizeU32 &newWindowSize)
virtual void OnWindowMove (const xiiInt32 iNewPosX, const xiiInt32 iNewPosY)
 Called when the window position is changed. Not possible on all OSes.
virtual void OnFocus (bool bHasFocus)
 Called when the window gets focus or loses focus.
virtual void OnVisibleChange (bool bVisible)
 Called when the window gets focus or loses focus.
virtual void OnClickClose ()
 Called when the close button of the window is clicked.
xiiStandardInputDevice * GetInputDevice () const
 Returns the input device that is attached to this window and typically provides mouse / keyboard input.
virtual void SetOutputTarget (xiiUniquePtr< xiiWindowOutputTargetBase > &&pOutputTarget) override
virtual xiiWindowOutputTargetBase * GetOutputTarget () const override
 Gets the output target for this window.
const xiiEvent< xiiWindowEvent > & GetWindowEvents () const

Static Public Member Functions

static xiiUInt8 GetNextUnusedWindowNumber ()

Protected Attributes

xiiWindowCreationDescription m_CreationDescription
xiiEvent< xiiWindowEvent > m_WindowEvents
 This event is broadcast when various things happen to the window, such as when it is resized or when the close button is clicked. You can subscribe to this event to be notified about these events.
bool m_bInitialized = false
 Whether the window is initialized and has a valid native handle.
bool m_bVisible = true
 Whether the window is visible.
bool m_bHasFocus = true
 Whether the window has focus.
xiiUniquePtr< xiiStandardInputDevice > m_pInputDevice
 The input device attached to this window, typically providing mouse and keyboard input.
xiiUniquePtr< xiiWindowOutputTargetBase > m_pOutputTarget
 The output target for this window, typically representing the graphics API side of the render output.
xiiWindowInternalHandle m_hWindowHandle = xiiWindowInternalHandle()
 The platform specific window handle.
xiiAtomicInteger32 m_iReferenceCount = 0
 The reference count for this window. The window will be destroyed when this reaches zero.

Static Protected Attributes

static xiiUInt8 s_uiNextUnusedWindowNumber = 0
 This just increments whenever a xiiWindow is created. It starts at zero.

Detailed Description

A simple abstraction for platform specific window creation.

Will handle basic message looping. Notable events can be listened to by overriding the corresponding callbacks. You should call ProcessWindowMessages every frame to keep the window responsive. Input messages will not be forwarded automatically. You can do so by overriding the OnWindowMessage function.

Constructor & Destructor Documentation

◆ xiiWindow()

xiiWindow::xiiWindow ( )

Creates empty window instance with standard settings

You need to call Initialize to actually create a window.

See also
xiiWindow::Initialize

Member Function Documentation

◆ AddReference()

virtual void xiiWindow::AddReference ( )
inlineoverridevirtual

Adds a reference to the window. The window will not be destroyed until all references are removed.

Implements xiiWindowBase.

◆ GetClientAreaSize()

virtual xiiSizeU32 xiiWindow::GetClientAreaSize ( ) const
inlineoverridevirtual

Returns the size of the client area of the window, i.e. the area that can be drawn into.

Implements xiiWindowBase.

◆ GetNativeWindowHandle()

virtual xiiWindowHandle xiiWindow::GetNativeWindowHandle ( ) const
overridevirtual

Returns the position and size of the entire window, including borders and title bar.

Implements xiiWindowBase.

◆ GetNextUnusedWindowNumber()

xiiUInt8 xiiWindow::GetNextUnusedWindowNumber ( )
static

Returns a number that can be used as a window number in xiiWindowCreationDescription.

This number just increments whenever a xiiWindow is created. It starts at zero.

◆ GetOutputTarget()

xiiWindowOutputTargetBase * xiiWindow::GetOutputTarget ( ) const
overridevirtual

Gets the output target for this window.

Implements xiiWindowBase.

◆ GetWindowEvents()

const xiiEvent< xiiWindowEvent > & xiiWindow::GetWindowEvents ( ) const
inline

Allows to subscribe to window events.

Note that AddEventHandler() is a const function, so can be called on the returned const xiiEvent reference.

◆ Initialize() [1/2]

xiiResult xiiWindow::Initialize ( )

Creates a new platform specific window with the current settings

Will automatically call xiiWindow::Destroy if window is already initialized.

See also
xiiWindow::Destroy, xiiWindow::Initialize

◆ Initialize() [2/2]

xiiResult xiiWindow::Initialize ( const xiiWindowCreationDescription & creationDescription)
inline

Creates a new platform specific window with the given settings.

Will automatically call xiiWindow::Destroy if window is already initialized.

Parameters
creationDescriptionStruct with various settings for window creation. Will be saved internally for later lookup.
See also
xiiWindow::Destroy, xiiWindow::Initialize

◆ IsFullscreenWindow()

virtual bool xiiWindow::IsFullscreenWindow ( bool bOnlyProperFullscreenMode = false) const
inlineoverridevirtual

Whether the window is a fullscreen window or should be one - some platforms may enforce this via the GALSwapchain.

If bOnlyProperFullscreenMode, the caller accepts borderless windows that cover the entire screen as "fullscreen".

Implements xiiWindowBase.

◆ IsVisible()

virtual bool xiiWindow::IsVisible ( ) const
inlineoverridevirtual

Whether the window can potentially be seen by the user.

Windows that are minimized or hidden are not visible.

Implements xiiWindowBase.

◆ OnResize()

void xiiWindow::OnResize ( const xiiSizeU32 & newWindowSize)
virtual

Called on window resize messages.

Parameters
newWindowSizeNew window size in pixel.
See also
OnWindowMessage

◆ ProcessWindowMessages()

virtual void xiiWindow::ProcessWindowMessages ( )
overridevirtual

Processes all pending window messages, such as input or resize events. This should be called regularly (typically once per frame) to keep the window responsive.

Implements xiiWindowBase.

◆ RemoveReference()

virtual void xiiWindow::RemoveReference ( )
inlineoverridevirtual

Removes a reference from the window. If this was the last reference, the window will be destroyed.

Implements xiiWindowBase.

◆ Resize()

xiiResult xiiWindow::Resize ( const xiiSizeU32 & newWindowSize)

Tries to resize the window. Override OnResize to get the actual new window size.

◆ SetOutputTarget()

void xiiWindow::SetOutputTarget ( xiiUniquePtr< xiiWindowOutputTargetBase > && pOutputTarget)
overridevirtual

Sets the output target for this window.

Output targets are destroyed before the window to ensure proper cleanup order. Setting a new output target replaces any existing one.

Implements xiiWindowBase.

Member Data Documentation

◆ m_CreationDescription

xiiWindowCreationDescription xiiWindow::m_CreationDescription
protected

Description at creation time. xiiWindow will not update this in any method other than Initialize.

Remarks
That means that messages like Resize will also have no effect on this variable.

◆ s_uiNextUnusedWindowNumber

xiiUInt8 xiiWindow::s_uiNextUnusedWindowNumber = 0
staticprotected

This just increments whenever a xiiWindow is created. It starts at zero.

Copyright (c) Theophilus Eriata. All Rights Reserved.


The documentation for this class was generated from the following files:
  • /home/runner/work/XII/XII/Source/Engine/Core/System/Window.h
  • /home/runner/work/XII/XII/Source/Engine/Core/System/Implementation/Window.cpp