Add ui::frame::width/height_constraints
This commit is contained in:
parent
9a2c562eec
commit
62cfba7711
2 changed files with 32 additions and 0 deletions
|
|
@ -18,6 +18,8 @@ namespace psemek::ui
|
|||
struct shape const & shape() const override;
|
||||
void reshape(geom::box<float, 2> const & box) override;
|
||||
geom::box<float, 2> size_constraints() const override;
|
||||
geom::interval<float> width_constraints(float height) const override;
|
||||
geom::interval<float> height_constraints(float width) const override;
|
||||
|
||||
void draw(painter &) const override {}
|
||||
|
||||
|
|
|
|||
|
|
@ -58,4 +58,34 @@ namespace psemek::ui
|
|||
return sc;
|
||||
}
|
||||
|
||||
geom::interval<float> frame::width_constraints(float height) const
|
||||
{
|
||||
auto wc = element::width_constraints(height);
|
||||
if (child_)
|
||||
wc = child_->width_constraints(height);
|
||||
|
||||
if (min_size_)
|
||||
wc.min = std::max(wc.min, (*min_size_)[0]);
|
||||
|
||||
if (max_size_)
|
||||
wc.max = std::min(wc.max, (*max_size_)[0]);
|
||||
|
||||
return wc;
|
||||
}
|
||||
|
||||
geom::interval<float> frame::height_constraints(float width) const
|
||||
{
|
||||
auto wc = element::height_constraints(width);
|
||||
if (child_)
|
||||
wc = child_->height_constraints(width);
|
||||
|
||||
if (min_size_)
|
||||
wc.min = std::max(wc.min, (*min_size_)[1]);
|
||||
|
||||
if (max_size_)
|
||||
wc.max = std::min(wc.max, (*max_size_)[1]);
|
||||
|
||||
return wc;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue