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

Abstract base class for UI-related command objects. More...

#include <UICommand.h>

Inheritance diagram for UICommand:
Inheritance graph

Public Member Functions

void Execute () override=0
 Pure virtual method to execute the command. Must be implemented by derived classes.
 
virtual ~UICommand () override=default
 Virtual destructor.
 
void SetUIComponent (UIComponent *p, UIComponentType t)
 Associates this command with a UIComponent and its type.
 
UIComponentGetUIComponent () const
 Gets the associated UIComponent.
 
UIComponentType GetType () const
 Gets the type of the associated UIComponent.
 
- Public Member Functions inherited from CommandBase
virtual ~CommandBase ()=default
 Destructor for CommandBase.
 

Private Attributes

UIComponentType Type = UIComponentType::None
 Type of the associated UIComponent.
 
UIComponentpUIComponent = nullptr
 Pointer to the associated UIComponent.
 

Friends

class UIAttorney::GameLoop
 

Detailed Description

Abstract base class for UI-related command objects.

The UICommand class defines the interface for commands that can be executed by UI components (such as Button, Slider, Dropdown, etc.). It inherits from CommandBase and provides a mechanism to associate the command with a specific UIComponent and its type. Derived classes must implement the Execute() method to define the command's behavior.

Example usage:

class MyButtonCommand : public UICommand {
public:
void Execute() override {
// Custom action when button is pressed
}
};
Button* btn = new Button("ButtonTexture");
btn->SetOnPressCommand(new MyButtonCommand());
void SetOnPressCommand(UICommand *cmd)
Sets the command to be executed when the button is pressed.
Definition Button.cpp:218
Abstract base class for UI-related command objects.
Definition UICommand.h:32
void Execute() override=0
Pure virtual method to execute the command. Must be implemented by derived classes.
See also
CommandBase, UIComponent, Button, Slider, Dropdown

Member Function Documentation

◆ Execute()

void UICommand::Execute ( )
overridepure virtual

Pure virtual method to execute the command. Must be implemented by derived classes.

Implements CommandBase.

Implemented in UIDropdownCommand.

◆ GetType()

UIComponentType UICommand::GetType ( ) const

Gets the type of the associated UIComponent.

Returns
The UIComponentType.

◆ GetUIComponent()

UIComponent * UICommand::GetUIComponent ( ) const

Gets the associated UIComponent.

Returns
Pointer to the UIComponent, or nullptr if not set.

◆ SetUIComponent()

void UICommand::SetUIComponent ( UIComponent * p,
UIComponentType t )

Associates this command with a UIComponent and its type.

Parameters
pPointer to the UIComponent.
tThe UIComponentType.

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