Support moving ui::screen child to top

This commit is contained in:
Nikita Lisitsa 2022-05-27 19:59:03 +03:00
parent 203d0504ac
commit a567cbbbf5
2 changed files with 17 additions and 2 deletions

View file

@ -36,6 +36,7 @@ namespace psemek::ui
bool add_child(std::shared_ptr<element> c) override;
bool has_child(element * c) const override;
std::shared_ptr<element> remove_child(element * c) override;
bool move_to_top(element * c);
struct shape const & shape() const override { return shape_; }
void reshape(geom::box<float, 2> const & bbox) override;

View file

@ -37,6 +37,20 @@ namespace psemek::ui
return container_.remove(c);
}
bool screen::move_to_top(element * c)
{
if (auto idx = container_.find(c))
{
auto e = container_.remove(*idx);
auto new_idx = container_.size();
container_.add(e, new_idx);
policies_.resize(container_.size());
policies_[new_idx] = policies_[*idx];
return true;
}
return false;
}
void screen::reshape(geom::box<float, 2> const & bbox)
{
shape_.box = bbox;