-
Notifications
You must be signed in to change notification settings - Fork 0
/
Button.h
63 lines (46 loc) · 1.23 KB
/
Button.h
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
//
// Created by Zakelis on 11/01/2018.
//
#ifndef R_TYPE_BUTTON_H
#define R_TYPE_BUTTON_H
#include <iostream>
#include <SFML/Graphics.hpp>
#include <Thor/Shapes.hpp>
#include <Thor/Graphics.hpp>
#include <functional>
namespace buttonState
{
enum
{
NORMAL = 0,
HOVERED = 1,
CLICKED = 2
};
};
class Button
{
public:
explicit Button(std::vector<std::string> buttonEffectsPaths);
~Button();
void setPosition(sf::Vector2f position);
// TODO : REPRENDRE L'ALGO DE POSITION DANS LA CLASSE HUD DANS UNE BOUCLE ET APPELER SETPOSITION POUR CHAQUE BOUTONS ?
void setSize(sf::Vector2f size);
void setBackground();
sf::Vector2f getPosition();
sf::Vector2f getDimensions();
sf::Vector2f getTextureSize();
sf::Uint32 getState();
void setState(sf::Uint32 state);
sf::RectangleShape buttonShape;
std::function<void()> onClick;
void update(sf::Event& e, sf::RenderWindow& window);
void setButtonColor(const sf::Color &);
private:
sf::Texture *textureNormal;
sf::Texture *textureHovered;
sf::Texture *textureClicked;
sf::Vector2f buttonSize;
sf::Vector2f buttonPosition;
sf::Uint32 actualButtonState;
};
#endif //R_TYPE_BUTTON_H