SUNENGINE 0.0.2
A simple and bright C++ game engine.
 
Loading...
Searching...
No Matches
UIComponent Class Referenceabstract

Abstract base class for all UI components. More...

#include <UIComponent.h>

Inheritance diagram for UIComponent:
Inheritance graph

Public Member Functions

virtual ~UIComponent ()=default
 Virtual destructor.
 
int GetLayer () const
 Gets the rendering layer of the component.
 
virtual void SetLayer (int layer)
 Sets the rendering layer of the component.
 
UIComponentType GetType () const
 Gets the type of the UI component.
 
bool IsEnabled () const
 Returns whether the component is enabled or not.
 
void SetEnabled (bool enabled)
 Sets the enabled state of the component.
 
void SetOwningCanvas (Canvas *canvas)
 Gets the owning canvas of the component.
 

Protected Attributes

bool Enabled = true
 Indicates if the component is enabled or not.
 
int Layer = 0
 Rendering layer in.
 
UIComponentType Type = UIComponentType::None
 Type of the UI component.
 
CanvaspOwningCanvas = nullptr
 Pointer to the owning canvas, if any.
 

Private Member Functions

virtual void Render ()=0
 Renders the UI component. Must be implemented by derived classes.
 
virtual bool IsMouseOver (float xPos, float yPos)=0
 Checks if the mouse is over the component. Must be implemented by derived classes.
 
virtual void OnPress ()=0
 Handles press events on the component. Must be implemented by derived classes.
 

Friends

class UIAttorney
 

Detailed Description

Abstract base class for all UI components.

The UIComponent class serves as the base class for all user interface elements in the engine, such as Button, Slider, Dropdown, Textbox, and more. It provides common properties like layer and type, and defines the interface for rendering, hit-testing, and input handling.

All UI components must inherit from this class and implement the pure virtual methods for rendering, mouse-over detection, and press handling.

Example usage (in a derived class):

class MyCustomUI : public UIComponent {
public:
void Render() override { /* ... *\/ }
* bool IsMouseOver(float x, float y) override { /* ... *\/ }
* void OnPress() override { /* ... *\/ }
* };
*
Abstract base class for all UI components.
Definition UIComponent.h:32
virtual void Render()=0
Renders the UI component. Must be implemented by derived classes.
See also
UIComponentType, UIAttorney

Member Function Documentation

◆ GetLayer()

int UIComponent::GetLayer ( ) const
inline

Gets the rendering layer of the component.

Returns
The layer index.
Here is the caller graph for this function:

◆ GetType()

UIComponentType UIComponent::GetType ( ) const
inline

Gets the type of the UI component.

Returns
The UIComponentType.
Here is the caller graph for this function:

◆ IsEnabled()

bool UIComponent::IsEnabled ( ) const
inline

Returns whether the component is enabled or not.

Returns
True if enabled, false otherwise. Checks if the component is enabled.
Here is the caller graph for this function:

◆ IsMouseOver()

virtual bool UIComponent::IsMouseOver ( float xPos,
float yPos )
privatepure virtual

Checks if the mouse is over the component. Must be implemented by derived classes.

Parameters
xPosThe x-coordinate of the mouse.
yPosThe y-coordinate of the mouse.
Returns
True if the mouse is over the component, false otherwise.

Implemented in Button, Dropdown, ScrollList, Slider, and Textbox.

Here is the caller graph for this function:

◆ OnPress()

virtual void UIComponent::OnPress ( )
privatepure virtual

Handles press events on the component. Must be implemented by derived classes.

Implemented in Button, Dropdown, ScrollList, Slider, and Textbox.

Here is the caller graph for this function:

◆ Render()

virtual void UIComponent::Render ( )
privatepure virtual

Renders the UI component. Must be implemented by derived classes.

Implemented in Button, Dropdown, ScrollList, Slider, and Textbox.

Here is the caller graph for this function:

◆ SetEnabled()

void UIComponent::SetEnabled ( bool enabled)
inline

Sets the enabled state of the component.

Parameters
enabledTrue to enable, false to disable. Sets the component's enabled state.

◆ SetLayer()

void UIComponent::SetLayer ( int layer)
virtual

Sets the rendering layer of the component.

Parameters
layerThe layer index.

Reimplemented in Dropdown, Slider, and Textbox.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetOwningCanvas()

void UIComponent::SetOwningCanvas ( Canvas * canvas)
inline

Gets the owning canvas of the component.

Returns
Pointer to the owning canvas, or nullptr if not set.
Here is the caller graph for this function:

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