Files
Seele/src/Engine/UI/HorizontalLayout.cpp
T

34 lines
821 B
C++
Raw Normal View History

2021-09-23 10:10:39 +02:00
#include "HorizontalLayout.h"
2022-04-18 18:08:38 +02:00
#include "Elements/Element.h"
2021-09-23 10:10:39 +02:00
using namespace Seele;
using namespace Seele::UI;
HorizontalLayout::HorizontalLayout(PElement element)
: Layout(element)
{
}
HorizontalLayout::~HorizontalLayout()
{
}
void HorizontalLayout::apply()
{
Array<PElement> children = element->getChildren();
2023-01-21 18:43:21 +01:00
const Rect parent = element->getBoundingBox();
2021-09-23 10:10:39 +02:00
float xOffset = parent.offset.x;
float yOffset = parent.offset.y;
float xSize = parent.size.x / children.size();
float ySize = parent.size.y;
for(uint32 index = 0; index < children.size(); ++index)
{
2023-01-21 18:43:21 +01:00
Rect& child = children[index]->getBoundingBox();
2021-09-23 10:10:39 +02:00
child.offset.x = xOffset + (index * xSize);
child.offset.y = yOffset;
child.size.x = xSize;
child.size.y = ySize;
}
}