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

Represents a UI element that displays a textured sprite. Inherits from WidgetElement and provides functionality for rendering a texture. More...

#include <SpriteElement.h>

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

Public Member Functions

 SpriteElement (const std::string textureName, Vector2 size={ 1, 1 }, Vector2 position={ 0, 0 }, int ZOrder=0)
 Constructs a SpriteElement with a texture name, size, position, and Z order.
 
 SpriteElement (Vector2 size={ 1, 1 }, Vector2 position={ 0, 0 }, int ZOrder=0)
 Constructs a SpriteElement with size, position, and Z order. No texture is set.
 
 SpriteElement (Texture *texture, Vector2 size={ 1, 1 }, Vector2 position={ 0, 0 }, int ZOrder=0)
 Constructs a SpriteElement with a texture pointer, size, position, and Z order.
 
 ~SpriteElement ()=default
 Destructor for SpriteElement.
 
virtual Transform2D GetTransform () const override
 Gets the transform of the sprite element.
 
virtual Vector2 GetSize () const override
 Gets the size of the sprite element.
 
virtual void Update () override
 Updates the sprite element. (No-op in this implementation.)
 
virtual void Draw (RendererGL *renderer) override
 Draws the sprite element using the provided renderer.
 
void SetTexture (Texture *pTexture)
 Sets the texture for the sprite element.
 
void SetTexture (std::string pTexture)
 Sets the texture for the sprite element by texture name.
 
TextureGetTexture () const
 Gets the current texture of the sprite element.
 
- Public Member Functions inherited from clt::WidgetElement
 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.
 
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.
 
Vector2 GetPosition () const
 Gets the position of the widget.
 
float GetRotation () const
 Gets the rotation 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.
 

Protected Attributes

TexturemTexture
 Pointer to the texture used by this sprite element.
 
- Protected Attributes inherited from clt::WidgetElement
Transform2D mTransform
 
friend UIPanel
 

Additional Inherited Members

- Public Attributes inherited from clt::WidgetElement
bool mVisibility
 
- Protected Member Functions inherited from clt::WidgetElement
void SetOwner (UIPanel *pOwner)
 Sets the owner UIPanel of this widget.
 

Detailed Description

Represents a UI element that displays a textured sprite. Inherits from WidgetElement and provides functionality for rendering a texture.

Constructor & Destructor Documentation

◆ SpriteElement() [1/3]

clt::SpriteElement::SpriteElement ( const std::string textureName,
Vector2 size = { 1,1 },
Vector2 position = { 0, 0 },
int ZOrder = 0 )
inline

Constructs a SpriteElement with a texture name, size, position, and Z order.

Parameters
textureNameThe name of the texture to use.
sizeThe size of the sprite element.
positionThe position of the sprite element.
ZOrderThe Z order for rendering.

◆ SpriteElement() [2/3]

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

Constructs a SpriteElement with size, position, and Z order. No texture is set.

Parameters
sizeThe size of the sprite element.
positionThe position of the sprite element.
ZOrderThe Z order for rendering.

◆ SpriteElement() [3/3]

clt::SpriteElement::SpriteElement ( Texture * texture,
Vector2 size = { 1,1 },
Vector2 position = { 0, 0 },
int ZOrder = 0 )
inline

Constructs a SpriteElement with a texture pointer, size, position, and Z order.

Parameters
texturePointer to the texture to use.
sizeThe size of the sprite element.
positionThe position of the sprite element.
ZOrderThe Z order for rendering.

Member Function Documentation

◆ Draw()

virtual void clt::SpriteElement::Draw ( RendererGL * renderer)
inlineoverridevirtual

Draws the sprite element using the provided renderer.

Parameters
rendererThe renderer to use for drawing.

Implements clt::WidgetElement.

Reimplemented in clt::ButtonElement.

◆ GetSize()

virtual Vector2 clt::SpriteElement::GetSize ( ) const
inlineoverridevirtual

Gets the size of the sprite element.

Returns
The scaled size of the texture.

Reimplemented from clt::WidgetElement.

◆ GetTexture()

Texture * clt::SpriteElement::GetTexture ( ) const
inline

Gets the current texture of the sprite element.

Returns
Pointer to the current texture.

◆ GetTransform()

virtual Transform2D clt::SpriteElement::GetTransform ( ) const
inlineoverridevirtual

Gets the transform of the sprite element.

Returns
The 2D transform including location, scaled size, and rotation.

Reimplemented from clt::WidgetElement.

◆ SetTexture() [1/2]

void clt::SpriteElement::SetTexture ( std::string pTexture)
inline

Sets the texture for the sprite element by texture name.

Parameters
pTextureThe name of the texture to set.

◆ SetTexture() [2/2]

void clt::SpriteElement::SetTexture ( Texture * pTexture)
inline

Sets the texture for the sprite element.

Parameters
pTexturePointer to the texture to set.

◆ Update()

virtual void clt::SpriteElement::Update ( )
inlineoverridevirtual

Updates the sprite element. (No-op in this implementation.)

Reimplemented from clt::WidgetElement.

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


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