Potato Engine
Loading...
Searching...
No Matches
Widget Class Reference

UI element that can be displayed on screen. More...

#include <Widget.hpp>

Inheritance diagram for Widget:
Tickable UIElement DebugInfo

Public Member Functions

 Widget (std::string UID)
 Constructs widget.
std::string GetUID () const
 Gets unique ID of widget.
template<typename ElemType>
ElemType * AddElement (std::string name)
 Creates and adds WidgetElement to widget screen.
const std::unordered_map< std::string, WidgetElement * > & GetAllElements () const
 Gets map of all elements.
WidgetElementGetElement (std::string name)
 Gets specific element by name.
Public Member Functions inherited from Tickable
bool isTicking () const
 Checks if object is ticking.
void SetTicking (bool isEnabled)
 Sets tick state for object.
Public Member Functions inherited from UIElement
Vector2 GetScreenSize () const
 Gets size of UI.
void SetScreenSize (const Vector2 &size)
 Sets size of UI.
Vector2 GetScreenPosition () const
 Gets screen position of UI.
void SetScreenPosition (const Vector2 &ScreenPosition)
 Sets screen position of UI.
void AddScreenOffset (const Vector2 &offset)
 Adds offset to UI position.
bool isVisible () const
 Checks if UI is visible.
void SetVisibility (bool visibility)
 Sets visibility of UI.

Additional Inherited Members

Protected Member Functions inherited from Tickable
virtual void Tick (float dt)
 Update tick event.

Detailed Description

UI element that can be displayed on screen.

Definition at line 14 of file Widget.hpp.

Constructor & Destructor Documentation

◆ Widget()

Widget::Widget ( std::string UID)

Constructs widget.

Put all class level functionality here (member initializations, default values, etc.)

Parameters
UIDUnique ID that identifies this widget
Warning
Never construct widgets manually.
See also
HUDController::AddWidget

Definition at line 7 of file Widget.cpp.

◆ ~Widget()

Widget::~Widget ( )
virtual

Definition at line 29 of file Widget.cpp.

Member Function Documentation

◆ GetUID()

std::string Widget::GetUID ( ) const

Gets unique ID of widget.

Returns
UID

Definition at line 14 of file Widget.cpp.

◆ AddElement()

template<typename ElemType>
ElemType * Widget::AddElement ( std::string name)

Creates and adds WidgetElement to widget screen.

  • Template Parameters
    ElemTypeElement class to add
    Parameters
    nameUnique name of element
    Returns
    WidgetElement* that was added

Definition at line 54 of file Widget.hpp.

◆ GetAllElements()

const std::unordered_map< std::string, WidgetElement * > & Widget::GetAllElements ( ) const

Gets map of all elements.

Returns
[name, WidgetElement*] map

Definition at line 18 of file Widget.cpp.

◆ GetElement()

WidgetElement * Widget::GetElement ( std::string name)

Gets specific element by name.

Parameters
namename of element
Returns
element

Definition at line 21 of file Widget.cpp.