summaryrefslogtreecommitdiff
path: root/ui/uiComponentPlacer.cpp
blob: 5e645d89966514b147bc1d342f0b1926d5fa27d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#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;
}