Abstract base class for all UI components. More...
#include <UIComponent.h>
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. | |
Canvas * | pOwningCanvas = 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 |
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):
|
inline |
Gets the rendering layer of the component.
|
inline |
Gets the type of the UI component.
|
inline |
Returns whether the component is enabled or not.
|
privatepure virtual |
Checks if the mouse is over the component. Must be implemented by derived classes.
xPos | The x-coordinate of the mouse. |
yPos | The y-coordinate of the mouse. |
Implemented in Button, Dropdown, ScrollList, Slider, and Textbox.
|
privatepure virtual |
Handles press events on the component. Must be implemented by derived classes.
Implemented in Button, Dropdown, ScrollList, Slider, and Textbox.
|
privatepure virtual |
Renders the UI component. Must be implemented by derived classes.
Implemented in Button, Dropdown, ScrollList, Slider, and Textbox.
|
inline |
Sets the enabled state of the component.
enabled | True to enable, false to disable. Sets the component's enabled state. |
|
virtual |
|
inline |
Gets the owning canvas of the component.