This repository has been archived by the owner on Jan 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathText.hpp
133 lines (115 loc) · 4.12 KB
/
Text.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#ifndef TEXT_H_
#define TEXT_H_
#include "UIObject.hpp"
#include "Color.hpp"
#include <string>
namespace spic {
/**
* @brief Enumeration for different text alignments.
* @spicapi
*/
enum class Alignment {
left,
center,
right
};
/**
* @brief Class representing a piece of text which can be rendered.
* @spicapi
*/
class Text : public UIObject {
public:
/**
* @brief Constructor.
* @param name The name for the game object.
* @param tag The tag for the game object.
* @param layer The layer for the game object.
* @param width The width of the UI object.
* @param height The height of the UI object.
* @sharedapi
*/
Text(const std::string& name, const std::string& tag, int layer, double width, double height);
/**
* @brief Constructor.
* @param name The name for the game object.
* @param tag The tag for the game object.
* @param layer The layer for the game object.
* @param width The width of the UI object.
* @param height The height of the UI object.
* @param text The content of the Text object
* @param font The font the Text object will use to render
* @param size The size the font will be rendered at
* @param alignment The alignment the content will be rendered with
* @param color The color the content will be rendered in
* @sharedapi
*/
Text(const std::string& name, const std::string& tag, int layer, double width, double height, const std::string& text, const std::string& font, int size, Alignment alignment, const Color& color);
/**
* @brief Get the content of the Text object
* @return A reference to the content of the Text object
* @sharedapi
*/
const std::string& Content() const;
/**
* @brief Set the text content of the Text object
* @param text new content
* @sharedapi
*/
void Content(const std::string& text);
/**
* @brief Get the font of the Text object
* @return A reference to the font of the Text object
* @sharedapi
*/
const std::string& Font() const;
/**
* @brief Set the font of the Text object
* @param font the new font
* @sharedapi
*/
void Font(const std::string& font);
/**
* @brief Get the size of the Text object
* @return A reference to the size of the Text object
* @sharedapi
*/
int Size() const;
/**
* @brief Set the size of the Text object
* @param size the new size
* @sharedapi
*/
void Size(int size);
/**
* @brief Get the alignment of the Text object
* @return A reference to the alignment of the Text object
* @sharedapi
*/
Alignment TextAlignment() const;
/**
* @brief Set the alignment of the content of the Text object
* @param alignment the new alignment
* @sharedapi
*/
void TextAlignment(Alignment alignment);
/**
* @brief Get the color of the Text object
* @return A reference to the color of the Text object
* @sharedapi
*/
const Color& TextColor() const;
/**
* @brief Set the color of the Text object
* @param color the new color
* @sharedapi
*/
void TextColor(const Color& color);
private:
std::string text;
std::string font;
int size;
Alignment alignment;
Color color;
};
}
#endif // TEXT_H_