psemek/libs/ui/source/element.cpp

37 lines
651 B
C++

#include <psemek/ui/element.hpp>
namespace psemek::ui
{
element * element::root()
{
element * r = this;
while (r->parent()) r = r->parent();
return r;
}
element const * element::root() const
{
element const * r = this;
while (r->parent()) r = r->parent();
return r;
}
void element::reshape()
{
reshape(shape().bbox());
}
geom::box<float, 2> element::size_constraints() const
{
static float const inf = std::numeric_limits<float>::infinity();
return {{{0.f, inf}, {0.f, inf}}};
}
std::shared_ptr<style const> element::set_style(std::shared_ptr<struct style const> st)
{
std::swap(st, style_);
return st;
}
}