Reset ui::label cached state on style change

This commit is contained in:
Nikita Lisitsa 2022-03-09 19:55:43 +03:00
parent 6412238e19
commit b215d52289
2 changed files with 15 additions and 0 deletions

View file

@ -60,6 +60,9 @@ namespace psemek::ui
geom::box<float, 2> size_constraints() const override;
std::shared_ptr<struct style const> set_style(std::shared_ptr<struct style const> st) override;
std::shared_ptr<struct style const> set_own_style(std::shared_ptr<struct style const> st) override;
void draw(painter & p) const override;
protected:

View file

@ -62,6 +62,18 @@ namespace psemek::ui
return {{{cached_state_inf_->size[0], inf}, {cached_state_inf_->size[1], inf}}};
}
std::shared_ptr<style const> label::set_style(std::shared_ptr<struct style const> st)
{
cached_state_.reset();
return element::set_style(st);
}
std::shared_ptr<style const> label::set_own_style(std::shared_ptr<struct style const> st)
{
cached_state_.reset();
return element::set_own_style(st);
}
void label::draw(painter & p) const
{
if (!cached_state_)