]> git.localhorst.tv Git - blank.git/blob - src/ui/MessageBox.hpp
b5a82c8b0a7b21f65be52587ee42b0c81dbd30e3
[blank.git] / src / ui / MessageBox.hpp
1 #ifndef BLANK_UI_MESSAGEBOX_HPP_
2 #define BLANK_UI_MESSAGEBOX_HPP_
3
4 #include "Text.hpp"
5 #include "../graphics/align.hpp"
6 #include "../graphics/PrimitiveMesh.hpp"
7
8 #include <deque>
9 #include <string>
10 #include <glm/glm.hpp>
11
12
13 namespace blank {
14
15 class Font;
16 class Viewport;
17
18 class MessageBox {
19
20 public:
21         explicit MessageBox(const Font &);
22
23         void Position(const glm::vec3 &, Gravity) noexcept;
24
25         void Foreground(const glm::vec4 &col) noexcept { fg = col; }
26         void Background(const glm::vec4 &col) noexcept { bg = col; dirty = true; }
27
28         void PushLine(const char *);
29         void PushLine(const std::string &l) {
30                 PushLine(l.c_str());
31         }
32
33         void Render(Viewport &) noexcept;
34
35 private:
36         void Recalc();
37
38 private:
39         const Font &font;
40         std::deque<Text> lines;
41         std::size_t max_lines;
42
43         glm::vec3 pos;
44         glm::vec3 adv;
45         glm::vec2 size;
46
47         glm::vec4 bg;
48         glm::vec4 fg;
49
50         PrimitiveMesh bg_mesh;
51
52         Gravity grav;
53         bool dirty;
54
55 };
56
57 }
58
59 #endif