]> git.localhorst.tv Git - blobs.git/blob - src/ui/Label.hpp
basic info box
[blobs.git] / src / ui / Label.hpp
1 #ifndef BLOBS_UI_LABEL_HPP_
2 #define BLOBS_UI_LABEL_HPP_
3
4 #include "align.hpp"
5 #include "../graphics/Texture.hpp"
6
7 #include <string>
8
9
10 namespace blobs {
11 namespace app {
12         struct Assets;
13 }
14 namespace graphics {
15         class Font;
16         class Viewport;
17 }
18 namespace ui {
19
20 class Label {
21
22 public:
23         explicit Label(const graphics::Font &);
24         ~Label();
25
26         Label(const Label &) = delete;
27         Label &operator =(const Label &) = delete;
28
29         Label(Label &&) = delete;
30         Label &operator =(Label &&) = delete;
31
32 public:
33         Label &Text(const std::string &);
34         Label &Font(const graphics::Font &);
35         Label &Foreground(const glm::vec4 &);
36         Label &Background(const glm::vec4 &);
37
38         Label &Position(const glm::vec3 &p) noexcept { pos = p; return *this; }
39         const glm::vec3 &Position() const noexcept { return pos; }
40
41         Label &Origin(Gravity o) noexcept { origin = o; return *this; }
42         Gravity Origin() const noexcept { return origin; }
43
44         glm::vec2 Size();
45         void Draw(app::Assets &, graphics::Viewport &) noexcept;
46
47 private:
48         void Update();
49
50 private:
51         const graphics::Font *font;
52         std::string text;
53         graphics::Texture tex;
54         glm::vec4 fg_color;
55         glm::vec4 bg_color;
56         glm::vec3 pos;
57         Gravity origin;
58         bool dirty;
59
60 };
61
62 }
63 }
64
65 #endif