Lysa UI  0.0
Lysa UI —UI components for the Lysa Engine
WindowManager Class Reference

Detailed Description

Manages all the UI windows for a rendering window.

The WindowManager must be created as soon as possible to be the first subscriber to receive input event and stop them to be passed to scenes if they are consumed by a widget.

Public Member Functions

 WindowManager (RenderingWindow &renderingWindow, const std::string &defaultFontURI, float defaultFontScale=1.0f, const float4 &defaultTextColor=float4 (1.0f, 1.0f, 1.0f, 1.0f))
 
virtual ~WindowManager ()
 
std::shared_ptr< Windowcreate (const Rect &rect)
 
std::shared_ptr< Windowadd (const std::shared_ptr< Window > &window)
 
void remove (const std::shared_ptr< Window > &window)
 
std::shared_ptr< Font > getDefaultFont () const
 
float getDefaultFontScale () const
 
float4 getDefaultTextColor () const
 
void setDefaultFontScale (const float defaultFontScale)
 
void setDefaultTextColor (const float4 &defaultTextColor)
 
float getAspectRatio () const
 
Vector2DRenderer & getRenderer ()
 
float getResizeDelta () const
 
void setEnableWindowResizing (const bool enable)
 
void drawFrame ()
 
bool onInput (const InputEvent &inputEvent)
 

Constructor & Destructor Documentation

WindowManager ( RenderingWindow &  renderingWindow,
const std::string &  defaultFontURI,
float  defaultFontScale = 1.0f,
const float4 &  defaultTextColor = float4 (1.0f, 1.0f, 1.0f, 1.0f) 
)
Parameters
renderingWindowThe rendering window to manage UI for.
defaultFontURIURI of the default font.
defaultFontScaleDefault scale for the font.
defaultTextColorDefault color for text.
virtual ~WindowManager ( )
virtual

Member Function Documentation

std::shared_ptr<Window> add ( const std::shared_ptr< Window > &  window)

Adds a UI Window to the list of managed windows.

Parameters
windowThe window to add.
Returns
Shared pointer to the added window.
std::shared_ptr<Window> create ( const Rect &  rect)
inline

Creates and adds a UI Window to the list of managed windows.

Parameters
rectThe rectangle (position and size) of the new window.
Returns
Shared pointer to the created window.
void drawFrame ( )

Draws one frame of the UI.

float getAspectRatio ( ) const
inline

Returns the aspect ratio of the managed rendering window.

std::shared_ptr<Font> getDefaultFont ( ) const
inline

Returns the default font loaded at creation.

float getDefaultFontScale ( ) const
inline

Returns the default font scale.

float4 getDefaultTextColor ( ) const
inline

Returns the default text color.

Vector2DRenderer& getRenderer ( )
inline

Returns the 2D renderer used by the manager.

float getResizeDelta ( ) const
inline

Returns the resize delta for window resizing.

bool onInput ( const InputEvent &  inputEvent)

Handles an input event.

Parameters
inputEventThe input event to process.
Returns
True if the event was handled by the UI, false otherwise.
void remove ( const std::shared_ptr< Window > &  window)

Removes a UI Window from the list of managed windows.

The Window will be removed at the start of the next frame.

void setDefaultFontScale ( const float  defaultFontScale)
inline

Sets the default font scale.

void setDefaultTextColor ( const float4 &  defaultTextColor)
inline

Sets the default text color.

void setEnableWindowResizing ( const bool  enable)
inline

Enables or disables UI window resizing by the user.