summaryrefslogtreecommitdiff
path: root/ui/uiComponentPlacer.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-12-22 12:16:38 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2021-12-22 12:16:38 +0000
commite806d41c8703ddc4bcaf2186d0c1701bd1e1ada3 (patch)
tree1612baf22456c0b5a1bef82980177afb34b2756c /ui/uiComponentPlacer.cpp
parentWindow handles UIComponent rendering (diff)
downloadilt-e806d41c8703ddc4bcaf2186d0c1701bd1e1ada3.tar.bz2
ilt-e806d41c8703ddc4bcaf2186d0c1701bd1e1ada3.tar.xz
ilt-e806d41c8703ddc4bcaf2186d0c1701bd1e1ada3.zip
Initial commit with some basic UI
Diffstat (limited to 'ui/uiComponentPlacer.cpp')
-rw-r--r--ui/uiComponentPlacer.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/ui/uiComponentPlacer.cpp b/ui/uiComponentPlacer.cpp
new file mode 100644
index 0000000..368e772
--- /dev/null
+++ b/ui/uiComponentPlacer.cpp
@@ -0,0 +1,26 @@
+#include "uiComponentPlacer.h"
+#include <algorithm>
+
+UIComponentPlacer::UIComponentPlacer(glm::vec2 padding, float spacing, glm::length_t axis) :
+ padding {padding}, spacing {spacing}, axis {axis}, current {padding[axis]}
+{
+}
+
+glm::vec2
+UIComponentPlacer::next(glm::vec2 size)
+{
+ glm::vec2 n {};
+ n[axis] = current;
+ n[1 - axis] = padding[1 - axis];
+ current += spacing + size[axis];
+ max = std::max(max, size[1 - axis]);
+ return n;
+}
+glm::vec2
+UIComponentPlacer::getLimit() const
+{
+ glm::vec2 n {};
+ n[axis] = current + padding[axis];
+ n[1 - axis] = max + padding[1 - axis];
+ return n;
+}