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