Chesto 0.9
A declarative and element-based library for creating GUIs on homebrew'd consoles
Container.hpp
1#ifndef CONTAINER_H
2#define CONTAINER_H
3#include "Element.hpp"
4
5#define ROW_LAYOUT 1
6#define COL_LAYOUT 2
7
8namespace Chesto {
9
10class Container : public Element {
11public:
12 Container(int layout = 0, int padding = 10);
13 Element *add(std::unique_ptr<Element> elem);
14
15 // override createNode to use Container's add logic instead
16 template <typename T, typename... Args> T *createNode(Args &&...args) {
17 auto ptr = std::make_unique<T>(std::forward<Args>(args)...);
18 T *rawPtr = ptr.get();
19 add(std::move(ptr));
20 return rawPtr;
21 }
22
23 int layout = 0;
24 int padding = 10;
25};
26
27} // namespace Chesto
28
29#endif