Air-Trap
1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
Loading...
Searching...
No Matches
Button.hpp
Go to the documentation of this file.
1
/*
2
** EPITECH PROJECT, 2025
3
** Air-Trap
4
** File description:
5
** Button
6
*/
7
8
#pragma once
9
10
#include <functional>
11
#include <string>
12
#include "
RType/Math/Vec2.hpp
"
13
14
namespace
rtp::ecs::components::ui
{
15
20
enum class
ButtonState
{
21
Idle
,
22
Hovered
,
23
Pressed
24
};
25
30
struct
Button
{
31
std::string
text
;
32
Vec2f
position
;
33
Vec2f
size
;
34
ButtonState
state
{
ButtonState::Idle
};
35
std::function<void()>
onClick
;
37
// Visual properties
38
uint8_t
idleColor
[3]{100, 100, 100};
39
uint8_t
hoverColor
[3]{150, 150, 150};
40
uint8_t
pressedColor
[3]{50, 50, 50};
41
};
42
43
}
// namespace rtp::ecs::components::ui
Vec2.hpp
Declaration of the 2-dimensional vector class.
rtp::ecs::components::ui
File : SpritePreview.hpp License: MIT Author : GitHub Copilot Date : 14/01/2026.
Definition
Button.hpp:14
rtp::ecs::components::ui::ButtonState
ButtonState
State of a button (idle, hovered, pressed)
Definition
Button.hpp:20
rtp::ecs::components::ui::ButtonState::Hovered
@ Hovered
rtp::ecs::components::ui::ButtonState::Pressed
@ Pressed
rtp::ecs::components::ui::ButtonState::Idle
@ Idle
rtp::Vec2< float >
rtp::ecs::components::ui::Button
Component representing a clickable button.
Definition
Button.hpp:30
rtp::ecs::components::ui::Button::text
std::string text
Text displayed on the button.
Definition
Button.hpp:31
rtp::ecs::components::ui::Button::onClick
std::function< void()> onClick
Callback when clicked.
Definition
Button.hpp:35
rtp::ecs::components::ui::Button::state
ButtonState state
Current state.
Definition
Button.hpp:34
rtp::ecs::components::ui::Button::position
Vec2f position
Position of the button.
Definition
Button.hpp:32
rtp::ecs::components::ui::Button::size
Vec2f size
Size of the button.
Definition
Button.hpp:33
rtp::ecs::components::ui::Button::idleColor
uint8_t idleColor[3]
RGB color when idle.
Definition
Button.hpp:38
rtp::ecs::components::ui::Button::pressedColor
uint8_t pressedColor[3]
RGB color when pressed.
Definition
Button.hpp:40
rtp::ecs::components::ui::Button::hoverColor
uint8_t hoverColor[3]
RGB color when hovered.
Definition
Button.hpp:39
common
include
RType
ECS
Components
UI
Button.hpp
Generated by
1.9.8