-
Notifications
You must be signed in to change notification settings - Fork 7
/
Button.hpp
75 lines (62 loc) · 1.61 KB
/
Button.hpp
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/******************************************************************************
* @file Button.hpp
* @author Andrés Gavín Murillo, 716358
* @author Rubén Rodríguez Esteban, 737215
* @date Mayo 2020
* @coms Videojuegos - OutRun
******************************************************************************/
#ifndef BUTTON_H
#define BUTTON_H
#include <iostream>
#include <cstring>
#include "SFML/Graphics.hpp"
enum button_states {
BUTTON_IDLE = 0,
BUTTON_PRESSED,
BUTTON_HOVER,
};
class Button {
private:
sf::RectangleShape shape;
sf::Text textButton;
sf::Color idleColorButton;
sf::Color hoverColorButton;
sf::Color activeColorButton;
public:
/**
* Constructor por defecto.
*/
Button();
/**
* Constructor del botón.
* @param x
* @param y
* @param width
* @param height
* @param f
* @param text
* @param idleColor
* @param hoverColor
* @param activeColor
* @param initialState
* @param screenScale
*/
Button(float x, float y, float width, float height, sf::Font &f, const std::string &text,
sf::Color idleColor, sf::Color hoverColor, sf::Color activeColor, int initialState, float screenScale);
/**
* Determina el estado del botón.
* @param buttonState
*/
void setButtonState(button_states buttonState);
/**
* Dibuja el botón.
* @param app
*/
void render(sf::RenderTexture *app);
/**
* Establece el texto del botón.
* @param newString
*/
void setTextButton(const std::string &newString);
};
#endif // BUTTON_H