Cache inf cached state for labels
This commit is contained in:
parent
5d116ad79a
commit
512e9b51b7
2 changed files with 5 additions and 2 deletions
|
|
@ -83,6 +83,7 @@ namespace psemek::ui
|
||||||
};
|
};
|
||||||
|
|
||||||
mutable std::optional<cached_state> cached_state_;
|
mutable std::optional<cached_state> cached_state_;
|
||||||
|
mutable std::optional<cached_state> cached_state_inf_;
|
||||||
|
|
||||||
void update_cached_state() const;
|
void update_cached_state() const;
|
||||||
cached_state cached_state_for(geom::box<float, 2> const & bbox) const;
|
cached_state cached_state_for(geom::box<float, 2> const & bbox) const;
|
||||||
|
|
|
||||||
|
|
@ -56,9 +56,10 @@ namespace psemek::ui
|
||||||
{
|
{
|
||||||
static float const inf = std::numeric_limits<float>::infinity();
|
static float const inf = std::numeric_limits<float>::infinity();
|
||||||
|
|
||||||
auto state = cached_state_for({{{0.f, inf}, {0.f, inf}}});
|
if (!cached_state_inf_)
|
||||||
|
cached_state_inf_ = cached_state_for({{{0.f, inf}, {0.f, inf}}});
|
||||||
|
|
||||||
return {{{state.size[0], inf}, {state.size[1], inf}}};
|
return {{{cached_state_inf_->size[0], inf}, {cached_state_inf_->size[1], inf}}};
|
||||||
}
|
}
|
||||||
|
|
||||||
void label::draw(painter & p) const
|
void label::draw(painter & p) const
|
||||||
|
|
@ -82,6 +83,7 @@ namespace psemek::ui
|
||||||
void label::on_state_changed()
|
void label::on_state_changed()
|
||||||
{
|
{
|
||||||
cached_state_.reset();
|
cached_state_.reset();
|
||||||
|
cached_state_inf_.reset();
|
||||||
post_reshape();
|
post_reshape();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue