-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTextInput.hpp
More file actions
99 lines (70 loc) · 2.04 KB
/
Copy pathTextInput.hpp
File metadata and controls
99 lines (70 loc) · 2.04 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#pragma once
#include "../../Modules/Modules.hpp"
namespace alce
{
class TextInput : public UIElement
{
public:
enum FontSize
{
Tiny,
Small,
Medium,
Large,
Big
};
TextInput() : UIElement("TextInput")
{
}
String GetText();
void SetFocus(bool focus = true);
bool HasFocus();
void Clear();
void Init();
void Start();
void Update();
void Render();
void EventManager(sf::Event& event);
Color backgroundColor = Colors::White;
Color cursorColor = Colors::Black;
FontSize fontSize = FontSize::Medium;
Color textColor = Color(120, 120, 120);
float borderWidth = 2;
Color borderColor = Colors::White;
String placeholder = "Enter text here...";
Color placeholderColor = Color(150, 150, 150);
float borderRadius = 2;
float width = 400;
float height = 40;
String fontPath = "fonts/Consolas/CONSOLA.ttf";
Lambda onSubmit;
private:
sf::RectangleShape box;
sfe::RichText richText;
sf::RectangleShape cursor;
alce::String inputText;
unsigned int cursorPosition;
sf::Font font;
bool showCursor;
sf::Clock clock;
bool focused;
float textOffset;
unsigned int maxCharacters;
sf::ConvexShape roundedBox;
sf::FloatRect getLocalBounds() const;
sf::FloatRect getGlobalBounds() const;
void updateRoundedBox();
void calculateMaxCharacters();
void setPosition(float x, float y);
void adjustTextPosition();
void toggleCursorVisibility();
void updateCursor();
void insertText(const sf::String& text);
void deleteCharacter();
void moveCursorLeft();
void moveCursorRight();
void moveCursorStart();
void moveCursorEnd();
};
typedef std::shared_ptr<TextInput> TextInputPtr;
}