Don't draw or send events to hidden ui children

This commit is contained in:
Nikita Lisitsa 2021-03-06 10:56:38 +03:00
parent e6506062b0
commit 03acb43dc4

View file

@ -81,6 +81,8 @@ namespace psemek::ui
bool controller::impl::event(E const & e) bool controller::impl::event(E const & e)
{ {
auto visitor = util::recursive([&](auto && self, element * elem) -> bool { auto visitor = util::recursive([&](auto && self, element * elem) -> bool {
if (elem->hidden()) return false;
auto cs = elem->children(); auto cs = elem->children();
for (auto it = cs.rbegin(); it != cs.rend(); ++it) for (auto it = cs.rbegin(); it != cs.rend(); ++it)
if (*it && self(*it)) return true; if (*it && self(*it)) return true;
@ -182,6 +184,7 @@ namespace psemek::ui
gl::Disable(gl::CULL_FACE); gl::Disable(gl::CULL_FACE);
auto visitor = util::recursive([&](auto && self, element * elem) -> void { auto visitor = util::recursive([&](auto && self, element * elem) -> void {
if (elem->hidden()) return;
elem->draw(impl().painter); elem->draw(impl().painter);
for (auto c : elem->children()) for (auto c : elem->children())
if (c) self(c); if (c) self(c);