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.

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
 
auto getDefaultFontScale () const
 
auto getDefaultTextColor () const
 
float getAspectRatio () const
 
void refresh ()
 
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) 
)

Constructor.

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.

auto getDefaultFontScale ( ) const
inline

Returns the default font scale.

auto 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 refresh ( )
inline

Forces a redrawing of all the UI at the start of the next frame.

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 setEnableWindowResizing ( const bool  enable)
inline

Enables or disables UI window resizing by the user.