]> git.localhorst.tv Git - blank.git/blob - src/ui/Text.hpp
84a6190999f89f4d2d340dd6ba4b64d1e1eb70b3
[blank.git] / src / ui / Text.hpp
1 #ifndef BLANK_UI_TEXT_HPP_
2 #define BLANK_UI_TEXT_HPP_
3
4 #include "../graphics/align.hpp"
5 #include "../graphics/Texture.hpp"
6 #include "../graphics/SpriteMesh.hpp"
7
8 #include <string>
9 #include <glm/glm.hpp>
10
11
12 namespace blank {
13
14 class Font;
15 class Viewport;
16
17 class Text {
18
19 public:
20         Text() noexcept;
21
22         void Set(const Font &, const char *);
23         void Set(const Font &f, const std::string &s) {
24                 Set(f, s.c_str());
25         }
26
27         void Pivot(Gravity p) {
28                 pivot = p;
29                 dirty = true;
30         }
31
32         const glm::vec2 &Size() const noexcept { return size; }
33
34         void Render(Viewport &) noexcept;
35
36 private:
37         void Update();
38
39 private:
40         Texture tex;
41         SpriteMesh sprite;
42         glm::vec2 size;
43         Gravity pivot;
44         bool dirty;
45
46 };
47
48 }
49
50 #endif