|
cangine
|
Component providing clickable-button behavior and visuals. More...
#include <button_component.hpp>


Public Member Functions | |
| void | firstFrame () override |
| Called once before the first frame update. | |
| void | onMouseEvent (const MouseEvent *e) override |
| Called when a mouse event is dispatched to the owning object. | |
| void | setTexture (Texture *textureIn) |
| Sets the button's background texture. | |
| Texture * | getTexture () |
| Returns the button's background texture. | |
Public Member Functions inherited from cangine::IComponent | |
| IComponent (GameObject *gameObject=nullptr) | |
| Constructs the component, optionally bound to a game object. | |
| virtual | ~IComponent () |
| GameObject * | getGameObject () const |
| Returns the game object this component is attached to. | |
| virtual void | frame (double deltaTime) |
| Called every frame to update the component. | |
Public Attributes | |
| Color | hoverColor = Colors::GRAY |
| Background color while hovered. | |
| Color | focusColor = Colors::DARK_GRAY |
| Background color while pressed. | |
| Color | backgroundColor = Colors::WHITE |
| Default background color. | |
Public Attributes inherited from cangine::IComponent | |
| bool | isUnique = true |
| If true, only one of this component type may exist per object. | |
Private Attributes | |
| bool | mouseHover = false |
| Whether the cursor is over the button. | |
| bool | mousePressed = false |
| Whether the button is currently pressed. | |
| Button * | button |
| Owning button object. | |
| TextRendererComponent * | trc = nullptr |
| Label text renderer, if present. | |
Component providing clickable-button behavior and visuals.
Tracks hover/press state from mouse events and swaps the background color accordingly. Attaches to a Button game object.
|
overridevirtual |
Called once before the first frame update.
Reimplemented from cangine::IComponent.
| Texture * cangine::ButtonComponent::getTexture | ( | ) |
Returns the button's background texture.
|
overridevirtual |
Called when a mouse event is dispatched to the owning object.
| e | The mouse event. |
Reimplemented from cangine::IComponent.
| void cangine::ButtonComponent::setTexture | ( | Texture * | textureIn | ) |
Sets the button's background texture.
| textureIn | Texture to use. |
| Color cangine::ButtonComponent::backgroundColor = Colors::WHITE |
Default background color.
|
private |
Owning button object.
| Color cangine::ButtonComponent::focusColor = Colors::DARK_GRAY |
Background color while pressed.
| Color cangine::ButtonComponent::hoverColor = Colors::GRAY |
Background color while hovered.
|
private |
Whether the cursor is over the button.
|
private |
Whether the button is currently pressed.
|
private |
Label text renderer, if present.