-
Notifications
You must be signed in to change notification settings - Fork 4
/
Button.h
40 lines (26 loc) · 917 Bytes
/
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
#ifndef BUTTON_H
#define BUTTON_H
#include "SFML/Graphics.hpp"
#include "SFML/System.hpp"
#include "SFML/Window.hpp"
#include <iostream>
#include <ctime>
#include <cstdlib>
#include <sstream>
enum ButtonStates { BTN_IDLE = 0, BTN_HOVER, BTN_ACTIVE };
class Button {
public:
Button(float posX, float posY, float width, float height, unsigned int characterSize, std::string fontFile, std::string text,
sf::Color idleColor, sf::Color hoverColor, sf::Color activeColor, sf::Color textColor, sf::Color textHoverColor);
//Button functionality
const bool isPressed() const;
void update(const sf::Vector2<float> mousePos);
void renderTo(sf::RenderWindow& window);
private:
short unsigned buttonState;
sf::RectangleShape shape;
sf::Font buttonFont;
sf::Text text;
sf::Color idleColor, hoverColor, activeColor, textColor, textHoverColor;
};
#endif