blob: 005623814c0213b296a3dddd8d1c1efd77771699 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
#pragma once
#include <functional>
#include "UiObject.h"
namespace crepe {
/**
* \class Button
* \brief Represents a clickable UI button, derived from the UiObject class.
*/
class Button : public UiObject {
public:
/**
* \brief Constructs a Button with the specified game object ID.
* \param id The unique ID of the game object associated with this button.
*/
Button(game_object_id_t id);
//! Indicates if the button is interactable (can be clicked).
bool interactable = true;
//! Indicates if the button is a toggle button (can be pressed and released).
bool is_toggle = false;
//! Indicates whether the button is currently pressed.
bool is_pressed = false;
//! Indicates whether the mouse is currently hovering over the button.
bool hover = false;
//! The callback function to be executed when the button is clicked.
std::function<void()> on_click;
public:
/**
* \brief Retrieves the maximum number of instances allowed for this button type.
* \return Always returns 1, as only a single instance is allowed.
*/
virtual int get_instances_max() const override { return 1; }
};
} // namespace crepe
|