From cac9f02c48284f365d41c63ea3bc31217597a33f Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Tue, 26 Jan 2016 17:25:51 -0800 Subject: [PATCH] Add simple column headers to recents list views. --- firmware/application/ais_app.cpp | 9 +++++++++ firmware/application/ert_app.cpp | 9 +++++++++ firmware/application/recent_entries.hpp | 16 ++++++++++++++++ firmware/application/tpms_app.cpp | 9 +++++++++ 4 files changed, 43 insertions(+) diff --git a/firmware/application/ais_app.cpp b/firmware/application/ais_app.cpp index ef96ec09..e186d1fa 100644 --- a/firmware/application/ais_app.cpp +++ b/firmware/application/ais_app.cpp @@ -218,6 +218,15 @@ void AISRecentEntry::update(const ais::Packet& packet) { namespace ui { +template<> +void RecentEntriesView::draw_header( + const Rect& target_rect, + Painter& painter, + const Style& style +) { + painter.draw_string(target_rect.pos, style, " MMSI |Name/Call "); +} + template<> void RecentEntriesView::draw( const Entry& entry, diff --git a/firmware/application/ert_app.cpp b/firmware/application/ert_app.cpp index ab4c4ba8..74982425 100644 --- a/firmware/application/ert_app.cpp +++ b/firmware/application/ert_app.cpp @@ -71,6 +71,15 @@ void ERTRecentEntry::update(const ert::Packet& packet) { namespace ui { +template<> +void RecentEntriesView::draw_header( + const Rect& target_rect, + Painter& painter, + const Style& style +) { + painter.draw_string(target_rect.pos, style, " ID | Consumpt |Cnt "); +} + template<> void RecentEntriesView::draw( const Entry& entry, diff --git a/firmware/application/recent_entries.hpp b/firmware/application/recent_entries.hpp index 68c8c4a4..87d647ec 100644 --- a/firmware/application/recent_entries.hpp +++ b/firmware/application/recent_entries.hpp @@ -23,6 +23,7 @@ #define __RECENT_ENTRIES_H__ #include "ui_widget.hpp" +#include "ui_font_fixed_8x16.hpp" #include #include @@ -138,6 +139,15 @@ public: Rect target_rect { r.pos, { r.width(), s.font.line_height() }}; const size_t visible_item_count = r.height() / s.font.line_height(); + const Style style_header { + .font = font::fixed_8x16, + .background = Color::blue(), + .foreground = Color::white(), + }; + + draw_header(target_rect, painter, style_header); + target_rect.pos.y += target_rect.height(); + auto selected = recent.find(selected_key); if( selected == std::end(recent) ) { selected = std::begin(recent); @@ -208,6 +218,12 @@ private: set_dirty(); } + void draw_header( + const Rect& target_rect, + Painter& painter, + const Style& style + ); + void draw( const Entry& entry, const Rect& target_rect, diff --git a/firmware/application/tpms_app.cpp b/firmware/application/tpms_app.cpp index 6073e051..2ca0e06d 100644 --- a/firmware/application/tpms_app.cpp +++ b/firmware/application/tpms_app.cpp @@ -165,6 +165,15 @@ void TPMSRecentEntry::update(const tpms::Reading& reading) { namespace ui { +template<> +void RecentEntriesView::draw_header( + const Rect& target_rect, + Painter& painter, + const Style& style +) { + painter.draw_string(target_rect.pos, style, "Tp| ID |kPa| C |Cnt "); +} + template<> void RecentEntriesView::draw( const Entry& entry,