]> git.localhorst.tv Git - blobs.git/blob - src/ui/Panel.hpp
remote outdated TODO
[blobs.git] / src / ui / Panel.hpp
1 #ifndef BLOBS_UI_PANEL_HPP_
2 #define BLOBS_UI_PANEL_HPP_
3
4 #include "Widget.hpp"
5
6 #include <memory>
7 #include <vector>
8
9
10 namespace blobs {
11 namespace ui {
12
13 class Panel
14 : public Widget {
15
16 public:
17         enum Dir {
18                 HORIZONTAL,
19                 VERTICAL,
20         };
21         using Children_t = std::vector<std::unique_ptr<Widget>>;
22
23 public:
24         Panel();
25         ~Panel() override;
26
27 public:
28         // panel takes ownership
29         Panel *Add(Widget *);
30         Panel *Clear();
31         Panel *Reserve(int n) { widgets.reserve(n); return this; }
32         const Children_t &Children() const noexcept { return widgets; }
33
34         Panel *Background(const glm::vec4 &);
35         Panel *Padding(const glm::vec2 &);
36         Panel *Spacing(float);
37         Panel *Direction(Dir);
38
39         glm::vec2 Size() override;
40         void Relayout();
41         void Draw(app::Assets &, graphics::Viewport &) noexcept override;
42
43 private:
44         Children_t widgets;
45         glm::vec4 bg_color;
46         glm::vec2 padding;
47         float spacing;
48         Dir dir;
49         glm::vec2 size;
50
51 };
52
53 }
54 }
55
56 #endif