Classes¶
UI/Button
Brief descriptions¶
Classes |
|
Encapsulates GUI button logic and data. |
|
Structures |
|
Encapsulates button animation data used for a specific state. |
|
Encapsulates button per-state parameters. |
Detailed information¶
ui::NauButton¶
engine/core/modules/ui/include/nau/ui/button.h
-
class NauButton : public nau::ui::UIControl¶
Encapsulates GUI button logic and data.
A button is a container storing a sprite or a text label providing means to custom handle various cursor events.
Public Types
-
using OnClickCallback = std::function<void()>¶
Functor type that is called when the button is clicked on.
Public Functions
-
NauButton()¶
Default constructor.
-
virtual ~NauButton()¶
Destructor.
-
void setOnClickCallback(OnClickCallback cb)¶
Changes the callback that is dispatched when the button is clicked.
-
const Sprite *getButtonSprite() const¶
Retrieves the button sprite.
- Returns:
A pointer to the button sprite.
-
void changeState(UIState toState)¶
Changes the button state.
- Parameters:
toState – [in] State to transition the button to.
-
virtual void handleEvent(EventType eventType) override¶
This function is called when any cursor event is triggered.
- Parameters:
eventType – [in] Type of the triggered event.
-
virtual void update(float delta) override¶
-
virtual void setInteractable(bool interactable) override¶
Changes whether the button can be interacted with (i.e. whether it can trigger cursor events).
- Parameters:
interactable – [in] Indicates whether the button should be interactable.
-
virtual void setContentSize(const math::vec2 &contentSize) override¶
Changes the button size.
- Parameters:
contentSize – [in] Size to assign.
-
void setTitleLabel(NauLabel *title)¶
Changes the title label of the button.
- Parameters:
title – [in] Label to assign
-
NauLabel *getTitleLabel()¶
Retrieves the label that contains the button title.
- Returns:
Button title label.
-
void updateSpriteLocation()¶
Aligns the button sprite by the button center.
-
void updateTitleLocation()¶
Aligns the button title label by the button center.
-
void updateButtonData(NauButtonData &data)¶
Changes button data.
- Parameters:
data – [in] Value to set.
Public Static Functions
-
static NauButton *create(NauButtonData &data)¶
Creates a button object.
- Returns:
A pointer to the created button object.
Protected Functions
-
bool init(NauButtonData &data)¶
-
virtual nau::Ptr<UiNodeAnimator> createAnimator() override¶
Protected Attributes
-
OnClickCallback m_onClick¶
Private Functions
-
void InvokeClick()¶
Private Members
-
ButtonTransition m_transitionType = {ButtonTransition::sprite}¶
Friends
- friend class PressedComboState
-
using OnClickCallback = std::function<void()>¶
ui::NauButtonStateAnimationData¶
engine/core/modules/ui/include/nau/ui/button_data.h
ui::NauButtonData¶
engine/core/modules/ui/include/nau/ui/button_data.h
-
struct NauButtonData¶
Encapsulates button per-state parameters.
Public Members
-
std::string defaultImageFileName = {}¶
Image to display when the button is in EventType::normal state.
-
std::string hoveredImageFileName = {}¶
Image to display when the button is in EventType::hovered state.
-
std::string clickedImageFileName = {}¶
Image to display when the button is clicked on.
-
std::string disableImageFileName = {}¶
Image to display when the button is in EventType::disabled state.
-
math::Color4 defaultColor = {1.0f, 1.0f, 1.0f, 1.0f}¶
Color to use for the button when it is in EventType::normal state.
-
math::Color4 hoveredColor = {1.0f, 1.0f, 1.0f, 1.0f}¶
Color to use for the button when it is in EventType::hovered state.
-
math::Color4 clickedColor = {1.0f, 1.0f, 1.0f, 1.0f}¶
Color to use for the button when it is clicked on.
-
math::Color4 disableColor = {1.0f, 1.0f, 1.0f, 1.0f}¶
Color to use for the button when it is in EventType::disabled state.
-
NauButtonStateAnimationData normalAnimation¶
Animation to play when the button transitions to EventType::normal.
-
NauButtonStateAnimationData hoveredAnimation¶
Animation to play when the button transitions to EventType::hovered.
-
NauButtonStateAnimationData clickedAnimation¶
Animation to play when the button is clicked.
-
NauButtonStateAnimationData disabledAnimation¶
Animation to play when the button transitions to EventType::disabled.
-
float defaultScale = 1.0f¶
Button scale to set when the button is in EventType::normal state.
-
float hoveredScale = 1.0f¶
Button scale to set when the button is in EventType::hovered state.
-
float clickedScale = 1.0f¶
Button scale to set when the button is clicked.
-
float disableScale = 1.0f¶
Button scale to set when the button is in EventType::disabled state.
-
std::string defaultImageFileName = {}¶