Chesto 0.9
A declarative and element-based library for creating GUIs on homebrew'd consoles
Constraint.hpp
1#pragma once
2#include "Element.hpp"
3
4#include <vector>
5
6namespace Chesto {
7
8class Element;
9
10
11// clang-format on
12#define ALIGN_LEFT 0x01
13#define ALIGN_RIGHT 0x02
14#define ALIGN_TOP 0x04
15#define ALIGN_BOTTOM 0x08
16#define ALIGN_CENTER_HORIZONTAL 0x10
17#define ALIGN_CENTER_VERTICAL 0x20
18#define ALIGN_CENTER_BOTH 0x30
19
20#define OFFSET_LEFT 0x40
21#define OFFSET_RIGHT 0x80
22#define OFFSET_TOP 0x100
23#define OFFSET_BOTTOM 0x200
24#define OFFSET_ALL 0x3C0
25// clang-format off
26
28public:
29 Constraint(int flags, int padding = 0, std::vector<Element*> targets = {});
30 void clearFlags();
31 void addFlags(int flags);
32 void clearTargets();
33 void addTarget(Element* target);
34 void update();
35
36 void apply(Element* element);
37
38 /* positioning flags */
39 int positioningFlags = 0;
40
41 /* any referenced Elements that this constraint may define itself relative to */
42 std::vector<Element*> targets;
43
44 /* the amount to pad or offset this element by */
45 int paddingOffset = 0;
46};
47
48} // namespace Chesto
Constraint(int flags, int padding=0, std::vector< Element * > targets={})
Definition: Constraint.cpp:17