#include <Widget/Layout/Center/Center.hpp>

Center::Center(Widget *child) : Layout(child) {}

void Center::layout()
{
    ChildNode &childNode = m_children.back();
    glm::ivec2 minSize = childNode.widget->getMinSize();

    glm::ivec2 pos = (m_size - minSize) / 2;
    childNode.pos = pos;
    childNode.widget->onResize(minSize);
}

glm::ivec2 Center::getMinSize()
{
    return m_children.back().widget->getMinSize();
}