From b1a4418f0686a00196d562d393fe793e47f6b1c0 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Fri, 14 Aug 2015 21:36:51 -0700 Subject: [PATCH] Push more widget painting code into ui::Painter Hide knowledge of damage tracking strategy. --- firmware/application/main.cpp | 5 +---- firmware/common/ui_painter.cpp | 7 +++++++ firmware/common/ui_painter.hpp | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/firmware/application/main.cpp b/firmware/application/main.cpp index 54663811..4fd904ba 100755 --- a/firmware/application/main.cpp +++ b/firmware/application/main.cpp @@ -266,10 +266,7 @@ private: } void handle_lcd_frame_sync() { - if( ui::is_dirty() ) { - painter.paint_widget(top_widget); - ui::dirty_clear(); - } + painter.paint_widget_tree(top_widget); } void handle_sd_card_detect() { diff --git a/firmware/common/ui_painter.cpp b/firmware/common/ui_painter.cpp index 77f2c34e..1f772fa1 100644 --- a/firmware/common/ui_painter.cpp +++ b/firmware/common/ui_painter.cpp @@ -73,6 +73,13 @@ void Painter::fill_rectangle(const Rect r, const Color c) { display.fill_rectangle(r, c); } +void Painter::paint_widget_tree(Widget* const w) { + if( ui::is_dirty() ) { + paint_widget(w); + ui::dirty_clear(); + } +} + void Painter::paint_widget(Widget* const w) { if( w->hidden() ) { // Mark widget (and all children) as invisible. diff --git a/firmware/common/ui_painter.hpp b/firmware/common/ui_painter.hpp index aba85b77..40e03edf 100644 --- a/firmware/common/ui_painter.hpp +++ b/firmware/common/ui_painter.hpp @@ -53,11 +53,13 @@ public: void draw_rectangle(const Rect r, const Color c); void fill_rectangle(const Rect r, const Color c); - void paint_widget(Widget* const w); - + void paint_widget_tree(Widget* const w); + private: void draw_hline(Point p, size_t width, const Color c); void draw_vline(Point p, size_t height, const Color c); + + void paint_widget(Widget* const w); }; } /* namespace ui */