From 85ac3fa4ac86489455dd9c7afa11a8f7a3da49f8 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Sun, 6 Dec 2015 09:50:53 -0800 Subject: [PATCH] Show selected item at bottom of visible list even if it should be off-screen. Not convinced this is the most intuitive approach, but it's better than before. --- firmware/application/app_ais.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/firmware/application/app_ais.cpp b/firmware/application/app_ais.cpp index 1b2df09f9..2188539d7 100644 --- a/firmware/application/app_ais.cpp +++ b/firmware/application/app_ais.cpp @@ -446,14 +446,21 @@ void AISView::paint(Painter& painter) { const auto& s = style(); Rect target_rect { r.pos, { r.width(), s.font.line_height() }}; + bool found_selected_item = false; for(const auto entry : recent) { + const auto next_y = target_rect.pos.y + target_rect.height(); + const auto last_visible_entry = (next_y >= r.bottom()); + 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); + found_selected_item |= is_selected_key; - target_rect.pos.y += target_rect.height(); + if( !last_visible_entry || (last_visible_entry && found_selected_item) ) { + const auto& draw_style = (has_focus && is_selected_key) ? s.invert() : s; + draw_entry(entry, target_rect, painter, draw_style); + target_rect.pos.y += target_rect.height(); + } - if( target_rect.pos.y >= r.bottom() ) { + if( last_visible_entry && found_selected_item ) { break; } }