From 4b2157a938dec11e49c7c0980392a4dc9d04e109 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Wed, 13 Jan 2016 11:43:21 -0800 Subject: [PATCH] Push AIS list item draw style into render method. --- firmware/application/ais_app.cpp | 10 ++++++---- firmware/application/ais_app.hpp | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/firmware/application/ais_app.cpp b/firmware/application/ais_app.cpp index 13bf711d..cd2854dd 100644 --- a/firmware/application/ais_app.cpp +++ b/firmware/application/ais_app.cpp @@ -214,8 +214,11 @@ void AISView::draw_entry( const RecentEntry& entry, const Rect& target_rect, Painter& painter, - const Style& s + const Style& style, + const bool is_selected ) { + const auto& draw_style = is_selected ? style.invert() : style; + std::string line = ais::format::mmsi(entry.mmsi) + " "; if( !entry.name.empty() ) { line += entry.name; @@ -224,7 +227,7 @@ void AISView::draw_entry( } line.resize(target_rect.width() / 8, ' '); - painter.draw_string(target_rect.pos, s, line); + painter.draw_string(target_rect.pos, draw_style, line); } void AISView::paint(Painter& painter) { @@ -258,8 +261,7 @@ void AISView::paint(Painter& painter) { for(auto p = start; p != end; p++) { const auto& entry = *p; const auto is_selected_key = (selected_key == entry.mmsi); - const auto& draw_style = (has_focus && is_selected_key) ? s.invert() : s; - draw_entry(entry, target_rect, painter, draw_style); + draw_entry(entry, target_rect, painter, s, (has_focus && is_selected_key)); target_rect.pos.y += target_rect.height(); } } diff --git a/firmware/application/ais_app.hpp b/firmware/application/ais_app.hpp index 9f51ebbd..a941321c 100644 --- a/firmware/application/ais_app.hpp +++ b/firmware/application/ais_app.hpp @@ -109,7 +109,8 @@ private: const RecentEntry& entry, const Rect& target_rect, Painter& painter, - const Style& s + const Style& style, + const bool is_selected ); void truncate_entries();