From cb403160b3a22696d65edba05515c008d80448b0 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Wed, 27 Jan 2016 09:02:17 -0800 Subject: [PATCH] Really dumb list view columns structures. --- firmware/application/ais_app.cpp | 17 ++++++++++++++++- firmware/application/ert_app.cpp | 18 +++++++++++++++++- firmware/application/tpms_app.cpp | 20 +++++++++++++++++++- 3 files changed, 52 insertions(+), 3 deletions(-) diff --git a/firmware/application/ais_app.cpp b/firmware/application/ais_app.cpp index e186d1fa6..c3867e347 100644 --- a/firmware/application/ais_app.cpp +++ b/firmware/application/ais_app.cpp @@ -218,13 +218,28 @@ void AISRecentEntry::update(const ais::Packet& packet) { namespace ui { +static const std::array, 2> ais_columns { { + { "MMSI", 9 }, + { "Name/Call", 20 }, +} }; + template<> void RecentEntriesView::draw_header( const Rect& target_rect, Painter& painter, const Style& style ) { - painter.draw_string(target_rect.pos, style, " MMSI |Name/Call "); + auto x = 0; + for(const auto& column : ais_columns) { + const auto width = column.second; + auto text = column.first; + if( width > text.length() ) { + text.append(width - text.length(), ' '); + } + + painter.draw_string({ x, target_rect.pos.y }, style, text); + x += (width * 8) + 8; + } } template<> diff --git a/firmware/application/ert_app.cpp b/firmware/application/ert_app.cpp index 749824257..0fb8b709c 100644 --- a/firmware/application/ert_app.cpp +++ b/firmware/application/ert_app.cpp @@ -71,13 +71,29 @@ void ERTRecentEntry::update(const ert::Packet& packet) { namespace ui { +static const std::array, 3> ert_columns { { + { "ID", 10 }, + { "Consumpt", 10 }, + { "Cnt", 3 }, +} }; + template<> void RecentEntriesView::draw_header( const Rect& target_rect, Painter& painter, const Style& style ) { - painter.draw_string(target_rect.pos, style, " ID | Consumpt |Cnt "); + auto x = 0; + for(const auto& column : ert_columns) { + const auto width = column.second; + auto text = column.first; + if( width > text.length() ) { + text.append(width - text.length(), ' '); + } + + painter.draw_string({ x, target_rect.pos.y }, style, text); + x += (width * 8) + 8; + } } template<> diff --git a/firmware/application/tpms_app.cpp b/firmware/application/tpms_app.cpp index 2ca0e06d5..a7e4e5eca 100644 --- a/firmware/application/tpms_app.cpp +++ b/firmware/application/tpms_app.cpp @@ -165,13 +165,31 @@ void TPMSRecentEntry::update(const tpms::Reading& reading) { namespace ui { +static const std::array, 5> tpms_columns { { + { "Tp", 2 }, + { "ID", 8 }, + { "kPa", 3 }, + { "C", 3 }, + { "Cnt", 3 }, +} }; + 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 "); + auto x = 0; + for(const auto& column : tpms_columns) { + const auto width = column.second; + auto text = column.first; + if( width > text.length() ) { + text.append(width - text.length(), ' '); + } + + painter.draw_string({ x, target_rect.pos.y }, style, text); + x += (width * 8) + 8; + } } template<>