From 275b644edd1b1c6a07545b51b6dad1d012f3ee51 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Wed, 27 Jan 2016 21:47:10 -0800 Subject: [PATCH] Fix flickering freq/gain options views. Was caused by invalidating ALL of the parent view, when only the overlapping views would need to be repainted. --- firmware/common/ui_widget.cpp | 12 +++++++++++- firmware/common/ui_widget.hpp | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) 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 {