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)
 
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)
 
const auto & getModalWindow () const
 
std::shared_ptr< Font > getDefaultFont () const
 
float getDefaultFontScale () const
 
StylegetDefaultStyle () const
 
void setDefaultStyle (const std::shared_ptr< Style > &style)
 
void setDefaultFontScale (float fontScale)
 
void setDefaultFont (std::shared_ptr< Font > &font)
 
RenderingWindow & getRenderingWindow () const
 
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)
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.

Style& getDefaultStyle ( ) const
inline

Returns the default style applied to the windows that do not set their own.

const auto& getModalWindow ( ) const
inline

Returns the Window blocking the input events of all the other Windows or nullptr.

Vector2DRenderer& getRenderer ( )
inline

Returns the 2D renderer used by the manager.

RenderingWindow& getRenderingWindow ( ) const
inline

Returns the rendering window the managed windows are displayed in.

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 setDefaultFont ( std::shared_ptr< Font > &  font)

Sets the default font scale

void setDefaultFontScale ( float  fontScale)

Sets the default font scale

void setDefaultStyle ( const std::shared_ptr< Style > &  style)

Sets the default style applied to the windows that do not set their own.

The widgets already attached keep the UIResource built by the previous style : the resource strings are shared by the built-in styles, but the colors baked in the resource strings of the composite widgets are not updated. Rebuild the windows to apply the new style everywhere.

Parameters
styleThe new default style, ignored when null.
void setEnableWindowResizing ( const bool  enable)
inline

Enables or disables UI window resizing by the user.

Friends And Related Function Documentation

friend class Window
friend