Clutter Engine 0.0.1
Loading...
Searching...
No Matches
clt::WidgetElement Class Referenceabstract

Base class for UI widget elements. More...

#include <WidgetElement.h>

Inheritance diagram for clt::WidgetElement:
clt::SpriteElement clt::TextElement clt::ButtonElement clt::FlipbookElement clt::AnimatorElement

Public Member Functions

 WidgetElement (Vector2 size={ 1, 1 }, Vector2 position={ 0, 0 }, int ZOrder=0)
 Constructs a WidgetElement with given size, position, and Z-order.
 
 ~WidgetElement ()=default
 Default destructor.
 
virtual void Update ()
 Updates the widget element. Override in derived classes.
 
virtual void Draw (RendererGL *renderer)=0
 Draws the widget element. Must be implemented by derived classes.
 
int GetZOrder () const
 Gets the Z-order of the widget.
 
void SetZOrder (int ZOrder)
 Sets the Z-order and updates the widget order in the owner panel.
 
virtual Vector2 GetSize () const
 Gets the size of the widget.
 
Vector2 GetPosition () const
 Gets the position of the widget.
 
float GetRotation () const
 Gets the rotation of the widget.
 
virtual Transform2D GetTransform () const
 Gets the transform of the widget.
 
void SetSize (Vector2 size)
 Sets the size of the widget.
 
void SetSize (float size)
 Sets the size of the widget (uniform scale).
 
void SetAnchor (Anchor anchor)
 Sets the anchor type for the widget.
 
void SetPosition (Vector2 position)
 Sets the position of the widget.
 
void SetRotation (float rotation)
 Sets the rotation of the widget.
 
void ToggleVisibility ()
 Toggles the visibility of the widget.
 

Public Attributes

bool mVisibility
 

Protected Member Functions

void SetOwner (UIPanel *pOwner)
 Sets the owner UIPanel of this widget.
 

Protected Attributes

Transform2D mTransform
 
friend UIPanel
 

Detailed Description

Base class for UI widget elements.

Constructor & Destructor Documentation

◆ WidgetElement()

clt::WidgetElement::WidgetElement ( Vector2 size = { 1,1 },
Vector2 position = { 0, 0 },
int ZOrder = 0 )
inline

Constructs a WidgetElement with given size, position, and Z-order.

Parameters
sizeSize of the widget (default: {1,1}).
positionPosition of the widget (default: {0,0}).
ZOrderZ-order for rendering (default: 0).

Member Function Documentation

◆ Draw()

virtual void clt::WidgetElement::Draw ( RendererGL * renderer)
pure virtual

Draws the widget element. Must be implemented by derived classes.

Parameters
rendererPointer to the renderer.

Implemented in clt::ButtonElement, clt::SpriteElement, and clt::TextElement.

◆ GetPosition()

Vector2 clt::WidgetElement::GetPosition ( ) const
inline

Gets the position of the widget.

Returns
The position as a Vector2.

◆ GetRotation()

float clt::WidgetElement::GetRotation ( ) const
inline

Gets the rotation of the widget.

Returns
The rotation in radians.

◆ GetSize()

virtual Vector2 clt::WidgetElement::GetSize ( ) const
inlinevirtual

Gets the size of the widget.

Returns
The size as a Vector2.

Reimplemented in clt::SpriteElement.

◆ GetTransform()

virtual Transform2D clt::WidgetElement::GetTransform ( ) const
inlinevirtual

Gets the transform of the widget.

Returns
The Transform2D object.

Reimplemented in clt::SpriteElement.

◆ GetZOrder()

int clt::WidgetElement::GetZOrder ( ) const
inline

Gets the Z-order of the widget.

Returns
The Z-order value.

◆ SetAnchor()

void clt::WidgetElement::SetAnchor ( Anchor anchor)
inline

Sets the anchor type for the widget.

Parameters
anchorThe new anchor type.

◆ SetOwner()

void clt::WidgetElement::SetOwner ( UIPanel * pOwner)
inlineprotected

Sets the owner UIPanel of this widget.

Parameters
pOwnerPointer to the UIPanel owner.

◆ SetPosition()

void clt::WidgetElement::SetPosition ( Vector2 position)
inline

Sets the position of the widget.

Parameters
positionThe new position as a Vector2.

◆ SetRotation()

void clt::WidgetElement::SetRotation ( float rotation)
inline

Sets the rotation of the widget.

Parameters
rotationThe new rotation in radians.

◆ SetSize() [1/2]

void clt::WidgetElement::SetSize ( float size)
inline

Sets the size of the widget (uniform scale).

Parameters
sizeThe new size as a float.

◆ SetSize() [2/2]

void clt::WidgetElement::SetSize ( Vector2 size)
inline

Sets the size of the widget.

Parameters
sizeThe new size as a Vector2.

◆ SetZOrder()

void clt::WidgetElement::SetZOrder ( int ZOrder)
inline

Sets the Z-order and updates the widget order in the owner panel.

Parameters
ZOrderNew Z-order value.

◆ Update()

virtual void clt::WidgetElement::Update ( )
inlinevirtual

Updates the widget element. Override in derived classes.

Reimplemented in clt::ButtonElement, clt::FlipbookElement, and clt::SpriteElement.

Member Data Documentation

◆ mTransform

Transform2D clt::WidgetElement::mTransform
protected

2D transform for position, scale, rotation

◆ mVisibility

bool clt::WidgetElement::mVisibility

Visibility flag


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