cangine
Loading...
Searching...
No Matches
button_component.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "../component.hpp"
4#include "../../../util/color.hpp"
5#include "../../../render/texture.hpp"
6#include "../textrenderer_component.hpp"
7
8namespace cangine {
9 class Button;
16 class ButtonComponent : public IComponent {
17 private:
18 bool mouseHover = false;
19 bool mousePressed = false;
22
23 public:
27 void firstFrame() override;
28 void onMouseEvent(const MouseEvent* e) override;
29
34 void setTexture(Texture* textureIn);
40 };
41}
42
Component providing clickable-button behavior and visuals.
Definition button_component.hpp:16
Color hoverColor
Background color while hovered.
Definition button_component.hpp:24
bool mouseHover
Whether the cursor is over the button.
Definition button_component.hpp:18
Color focusColor
Background color while pressed.
Definition button_component.hpp:25
Color backgroundColor
Default background color.
Definition button_component.hpp:26
Texture * getTexture()
Returns the button's background texture.
Definition button_component.cpp:35
void onMouseEvent(const MouseEvent *e) override
Called when a mouse event is dispatched to the owning object.
Definition button_component.cpp:11
TextRendererComponent * trc
Label text renderer, if present.
Definition button_component.hpp:21
bool mousePressed
Whether the button is currently pressed.
Definition button_component.hpp:19
void firstFrame() override
Called once before the first frame update.
Definition button_component.cpp:6
Button * button
Owning button object.
Definition button_component.hpp:20
void setTexture(Texture *textureIn)
Sets the button's background texture.
Definition button_component.cpp:32
Clickable button game object with a text label.
Definition button_object.hpp:19
Base interface for all components attached to a GameObject.
Definition component.hpp:17
Component that renders a text string, optionally over a background.
Definition textrenderer_component.hpp:18
Wraps an OpenGL texture object.
Definition texture.hpp:12
const Color WHITE(255, 255, 255)
White.
const Color DARK_GRAY(99, 99, 99)
Dark gray.
const Color GRAY(128, 128, 128)
Medium gray.
Definition audiomanager.cpp:4
RGBA color stored as normalized floating-point components.
Definition color.hpp:12
A mouse event carrying its type, button, position and scroll offset.
Definition mouse.hpp:37