-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTextInput.hpp
41 lines (33 loc) · 1.11 KB
/
TextInput.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
#ifndef BREAK_IT_TEXTINPUT_HPP
#define BREAK_IT_TEXTINPUT_HPP
#include <SFML/Graphics/Text.hpp>
#include <SFML/Graphics/RectangleShape.hpp>
#include "Component.hpp"
#include "../ResourceIdentifiers.hpp"
namespace gui {
class TextInput : public Component {
public:
typedef std::function<void(std::string)> Callback;
explicit TextInput(const FontHolder& fonts);
bool selectable() const override;
void select() override;
void deselect() override;
void activate() override;
sf::FloatRect getBounds() const override;
void handleEvent(const sf::Event &event) override;
void setCallback(TextInput::Callback callback);
void setSize(float width, float height);
void setPlaceholder(std::string placeholder);
protected:
void draw(sf::RenderTarget &target, sf::RenderStates states) const override;
private:
bool hasFocus;
std::string inputString;
sf::Text text;
sf::Text placeholder;
sf::RectangleShape background;
sf::RectangleShape caret;
TextInput::Callback callback;
};
}
#endif //BREAK_IT_TEXTINPUT_HPP