Clutter Engine 0.0.1
Loading...
Searching...
No Matches
clt::UIPanel Class Reference

Represents a UI panel that manages WidgetElements and their z-ordering. More...

#include <UIPanel.h>

Public Member Functions

 UIPanel (HUDComponent *hud)
 Constructs a UIPanel with the given HUD component.
 
 ~UIPanel ()
 Destructor for UIPanel. Cleans up all elements.
 
template<typename T , typename... Args>
T * CreateElement (const std::string &pName, Args &&... args)
 Creates a new WidgetElement of type T and adds it to the panel.
 
template<typename T >
T * GetElement (const std::string &pName)
 Gets a WidgetElement of type T by name.
 
void RemoveElement (const std::string &pName)
 Removes a WidgetElement from the panel by name.
 
virtual void Update ()
 Updates the panel and its elements. Override to provide custom update logic.
 
HUDComponentGetHUD () const
 Gets the HUD component that owns this panel.
 
std::vector< WidgetElement * > GetElements ()
 Gets all WidgetElements in the panel, sorted by Z order.
 

Detailed Description

Represents a UI panel that manages WidgetElements and their z-ordering.

Constructor & Destructor Documentation

◆ UIPanel()

clt::UIPanel::UIPanel ( HUDComponent * hud)
inline

Constructs a UIPanel with the given HUD component.

Parameters
hudThe HUD component that owns this panel.

Member Function Documentation

◆ CreateElement()

template<typename T , typename ... Args>
T * clt::UIPanel::CreateElement ( const std::string & pName,
Args &&... args )
inline

Creates a new WidgetElement of type T and adds it to the panel.

Template Parameters
TThe type of WidgetElement to create.
ArgsConstructor argument types for T.
Parameters
pNameThe unique name for the element.
argsArguments to forward to the constructor of T.
Returns
Pointer to the created element, or nullptr if the name already exists.

◆ GetElement()

template<typename T >
T * clt::UIPanel::GetElement ( const std::string & pName)
inline

Gets a WidgetElement of type T by name.

Template Parameters
TThe type of WidgetElement to retrieve.
Parameters
pNameThe name of the element.
Returns
Pointer to the element if found and of type T, otherwise nullptr.

◆ GetElements()

std::vector< WidgetElement * > clt::UIPanel::GetElements ( )
inline

Gets all WidgetElements in the panel, sorted by Z order.

Returns
Vector of WidgetElement pointers.

◆ GetHUD()

HUDComponent * clt::UIPanel::GetHUD ( ) const
inline

Gets the HUD component that owns this panel.

Returns
Pointer to the HUDComponent.

◆ RemoveElement()

void UIPanel::RemoveElement ( const std::string & pName)

Removes a WidgetElement from the panel by name.

Parameters
pNameThe name of the element to remove.

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