Move UI dirty tracking out of application main.cpp.

This commit is contained in:
Jared Boone 2015-08-14 21:17:23 -07:00
parent fa465c14c4
commit a9bb7c96e5
3 changed files with 20 additions and 10 deletions

View File

@ -96,12 +96,6 @@ static spi_bus_t ssp0 = {
}; };
#endif #endif
static bool ui_dirty = true;
void ui::dirty_event() {
ui_dirty = true;
}
class EventDispatcher { class EventDispatcher {
public: public:
EventDispatcher( EventDispatcher(
@ -316,9 +310,9 @@ private:
} }
void handle_lcd_frame_sync() { void handle_lcd_frame_sync() {
if( ui_dirty ) { if( ui::is_dirty() ) {
paint_widget(top_widget); paint_widget(top_widget);
ui_dirty = false; ui::dirty_clear();
} }
} }

View File

@ -28,6 +28,20 @@
namespace ui { namespace ui {
static bool ui_dirty = true;
void dirty_set() {
ui_dirty = true;
}
void dirty_clear() {
ui_dirty = false;
}
bool is_dirty() {
return ui_dirty;
}
constexpr size_t to_string_max_length = 16; constexpr size_t to_string_max_length = 16;
static char* to_string_dec_uint_internal( static char* to_string_dec_uint_internal(
@ -155,7 +169,7 @@ void Widget::set_parent(Widget* const widget) {
void Widget::set_dirty() { void Widget::set_dirty() {
flags.dirty = true; flags.dirty = true;
dirty_event(); dirty_set();
} }
bool Widget::dirty() const { bool Widget::dirty() const {

View File

@ -37,7 +37,9 @@
namespace ui { namespace ui {
extern void dirty_event(); void dirty_set();
void dirty_clear();
bool is_dirty();
// TODO: Move these somewhere else! // TODO: Move these somewhere else!
// TODO: Allow l=0 to not fill/justify? Already using this way in ui_spectrum.hpp... // TODO: Allow l=0 to not fill/justify? Already using this way in ui_spectrum.hpp...