#ifndef MARGIN_HPP_
#define MARGIN_HPP_

#include <Widget/Layout/Layout.hpp>

/**
 * @brief A widget which puts a margin around its child.
 */
template<int top, int right = top, int bottom = top, int left = right>
class Margin final : public Layout
{
public:
    Margin(Widget *child) : Layout(child) {}

    virtual void layout() override
    {
        ChildNode &childNode = m_children.back();
        childNode.pos = glm::ivec2(left, top);
        childNode.widget->onResize(m_size - glm::ivec2(left + right, top + bottom));
    }

    virtual glm::ivec2 getMinSize() override
    {
        return m_children.back().widget->getMinSize() + glm::ivec2(left + right, top + bottom);
    }
};

#endif