28 lines
798 B
C++
28 lines
798 B
C++
#include <psemek/ui/impl/single_container_base.hpp>
|
|
|
|
namespace psemek::ui::impl
|
|
{
|
|
|
|
single_container_base::single_container_base(react::value<geom::vector<float, 2>> margin)
|
|
: margin_(std::move(margin))
|
|
{}
|
|
|
|
void single_container_base::reshape(geom::box<float, 2> const & new_shape)
|
|
{
|
|
single_container::reshape(new_shape);
|
|
|
|
if (child())
|
|
child()->reshape(geom::shrink(new_shape, *margin_));
|
|
}
|
|
|
|
geom::interval<float> single_container_base::size_constraints(int dimension, float other_dimension_size) const
|
|
{
|
|
geom::interval<float> result = single_container::size_constraints(dimension, other_dimension_size);
|
|
|
|
if (child())
|
|
result = child()->size_constraints(dimension, other_dimension_size - 2.f * (*margin_)[dimension ^ 1]);
|
|
|
|
return result + 2.f * (*margin_)[dimension];
|
|
}
|
|
|
|
}
|