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