ezEngine Release 26.3
Loading...
Searching...
No Matches
ezWindowPlatformShared Class Referenceabstract

A simple abstraction for platform specific window creation. More...

#include <Window.h>

Inheritance diagram for ezWindowPlatformShared:

Public Member Functions

 ezWindowPlatformShared ()
 Creates empty window instance with standard settings.
 
 ~ezWindowPlatformShared ()
 Destroys the window if not already done.
 
const ezWindowCreationDescGetCreationDescription () const
 Returns the window creation description. The description may get updated by window moves, resizes and such.
 
virtual ezSizeU32 GetClientAreaSize () const override
 Returns the size of the client area / ie. the window resolution.
 
virtual bool IsFullscreenWindow (bool bOnlyProperFullscreenMode=false) const override
 Returns whether the window covers an entire monitor.
 
bool IsVisible () const override
 
virtual ezResult InitializeWindow ()=0
 Creates a new platform specific window with the current settings.
 
ezResult Initialize (const ezWindowCreationDesc &creationDescription)
 Creates a new platform specific window with the given settings.
 
bool IsInitialized () const
 Gets if the window is up and running.
 
virtual void DestroyWindow ()=0
 Destroys the window.
 
virtual ezResult Resize (const ezSizeU32 &newWindowSize)=0
 Tries to resize the window.
 
virtual void OnResize (const ezSizeU32 &newWindowSize)
 Called when a window got resized.
 
virtual void OnWindowMove (const ezInt32 iNewPosX, const ezInt32 iNewPosY)
 Called when the window position is changed. Not possible on all OSes.
 
virtual void OnFocus (bool bHasFocus)
 Called when the window gets 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. Does nothing by default.
 
ezInputDeviceGetInputDevice () const
 Returns the input device that is attached to this window and typically provides mouse / keyboard input.
 
const ezEvent< ezWindowEvent > & WindowEvents () const
 Allows to subscribe to window events.
 
virtual void AddReference () override
 
virtual void RemoveReference () override
 
- Public Member Functions inherited from ezWindowBase
virtual ezWindowHandle GetNativeWindowHandle () const =0
 Returns the platform specific window handle.
 
virtual void ProcessWindowMessages ()=0
 Runs the platform specific message pump.
 

Protected Attributes

ezWindowCreationDesc m_CreationDescription
 
ezEvent< ezWindowEventm_WindowEvents
 
bool m_bInitialized = false
 
bool m_bVisible = true
 
bool m_bHasFocus = true
 
ezUniquePtr< ezInputDevicem_pInputDevice
 
ezWindowInternalHandle m_hWindowHandle = ezWindowInternalHandle()
 
ezAtomicInteger32 m_iReferenceCount = 0
 

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

◆ ezWindowPlatformShared()

ezWindowPlatformShared::ezWindowPlatformShared ( )
default

Creates empty window instance with standard settings.

You need to call InitializeWindow() to actually create a window.

◆ ~ezWindowPlatformShared()

ezWindowPlatformShared::~ezWindowPlatformShared ( )

Destroys the window if not already done.

Also broadcasts ezWindowEvent::Type::WindowDestruction.

Member Function Documentation

◆ AddReference()

virtual void ezWindowPlatformShared::AddReference ( )
inlineoverridevirtual

Implements ezWindowBase.

◆ DestroyWindow()

virtual void ezWindowPlatformShared::DestroyWindow ( )
pure virtual

Destroys the window.

Implemented in ezWindowAndroid, ezWindowGLFW, ezWindowNoImpl, and ezWindowWin.

◆ GetClientAreaSize()

virtual ezSizeU32 ezWindowPlatformShared::GetClientAreaSize ( ) const
inlineoverridevirtual

Returns the size of the client area / ie. the window resolution.

Implements ezWindowBase.

◆ Initialize()

ezResult ezWindowPlatformShared::Initialize ( const ezWindowCreationDesc creationDescription)
inline

Creates a new platform specific window with the given settings.

Will automatically call DestroyWindow() if window is already initialized.

Parameters
creationDescriptionStruct with various settings for window creation. Will be saved internally for later lookup.
See also
DestroyWindow(), InitializeWindow()

◆ InitializeWindow()

virtual ezResult ezWindowPlatformShared::InitializeWindow ( )
pure virtual

Creates a new platform specific window with the current settings.

Will automatically call DestroyWindow() if window is already initialized.

See also
ezWindow::Destroy, ezWindow::Initialize

Implemented in ezWindowAndroid, ezWindowGLFW, ezWindowNoImpl, and ezWindowWin.

◆ IsFullscreenWindow()

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

Returns whether the window covers an entire monitor.

If bOnlyProperFullscreenMode == false, this includes borderless windows.

Implements ezWindowBase.

◆ IsVisible()

bool ezWindowPlatformShared::IsVisible ( ) const
inlineoverridevirtual

Whether the window is currently theoretically visible.

How accurate this is, depends on the platform specific implementation. The implementation may return "visible" even though the window can't be seen. However, it should never err the other way round.

Implements ezWindowBase.

◆ OnClickClose()

void ezWindowPlatformShared::OnClickClose ( )
virtual

Called when the close button of the window is clicked. Does nothing by default.

The function also broadcasts ezWindowEvent::Type::CloseButtonClicked.

◆ OnFocus()

void ezWindowPlatformShared::OnFocus ( bool  bHasFocus)
virtual

Called when the window gets or loses focus.

The function also broadcasts ezWindowEvent::Type::FocusChanged.

◆ OnResize()

void ezWindowPlatformShared::OnResize ( const ezSizeU32 newWindowSize)
virtual

Called when a window got resized.

The new window size is also saved to the creation description. The function also broadcasts ezWindowEvent::Type::SizeChanged.

◆ OnVisibleChange()

void ezWindowPlatformShared::OnVisibleChange ( bool  bVisible)
virtual

Called when the window gets focus or loses focus.

The function also broadcasts ezWindowEvent::Type::VisibilityChanged.

◆ OnWindowMove()

void ezWindowPlatformShared::OnWindowMove ( const ezInt32  iNewPosX,
const ezInt32  iNewPosY 
)
virtual

Called when the window position is changed. Not possible on all OSes.

The function also broadcasts ezWindowEvent::Type::PositionChanged.

◆ RemoveReference()

virtual void ezWindowPlatformShared::RemoveReference ( )
inlineoverridevirtual

Implements ezWindowBase.

◆ Resize()

virtual ezResult ezWindowPlatformShared::Resize ( const ezSizeU32 newWindowSize)
pure virtual

Tries to resize the window.

Override OnResize to get the actual new window size.

Implemented in ezWindowAndroid, ezWindowGLFW, ezWindowNoImpl, and ezWindowWin.

◆ WindowEvents()

const ezEvent< ezWindowEvent > & ezWindowPlatformShared::WindowEvents ( ) const
inline

Allows to subscribe to window events.

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

Member Data Documentation

◆ m_CreationDescription

ezWindowCreationDesc ezWindowPlatformShared::m_CreationDescription
protected

Description at creation time. ezWindow 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.

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