diff --git a/firmware/common/ui_widget.cpp b/firmware/common/ui_widget.cpp index 8053d9fd7..0b9cc01ca 100644 --- a/firmware/common/ui_widget.cpp +++ b/firmware/common/ui_widget.cpp @@ -95,7 +95,9 @@ void Widget::hidden(bool hide) { // If parent is hidden, either of these is a no-op. if( hide ) { - parent()->set_dirty(); + // TODO: Instead of dirtying parent entirely, dirty only children + // that overlap with this widget. + parent()->dirty_overlapping_children_in_rect(parent_rect); /* TODO: Notify self and all non-hidden children that they're * now effectively hidden? */ @@ -198,6 +200,14 @@ void Widget::visible(bool v) { } } +void Widget::dirty_overlapping_children_in_rect(const Rect& child_rect) { + for(auto child : children()) { + if( !child_rect.intersect(child->parent_rect).is_empty() ) { + child->set_dirty(); + } + } +} + /* View ******************************************************************/ void View::set_parent_rect(const Rect new_parent_rect) { diff --git a/firmware/common/ui_widget.hpp b/firmware/common/ui_widget.hpp index d292d8e2a..e1e886894 100644 --- a/firmware/common/ui_widget.hpp +++ b/firmware/common/ui_widget.hpp @@ -131,6 +131,8 @@ protected: .highlighted = false, .visible = false, }; + + void dirty_overlapping_children_in_rect(const Rect& child_rect); }; class View : public Widget {