Add simple column headers to recents list views.

This commit is contained in:
Jared Boone 2016-01-26 17:25:51 -08:00
parent bd829d7d85
commit cac9f02c48
4 changed files with 43 additions and 0 deletions

View File

@ -218,6 +218,15 @@ void AISRecentEntry::update(const ais::Packet& packet) {
namespace ui {
template<>
void RecentEntriesView<AISRecentEntries>::draw_header(
const Rect& target_rect,
Painter& painter,
const Style& style
) {
painter.draw_string(target_rect.pos, style, " MMSI |Name/Call ");
}
template<>
void RecentEntriesView<AISRecentEntries>::draw(
const Entry& entry,

View File

@ -71,6 +71,15 @@ void ERTRecentEntry::update(const ert::Packet& packet) {
namespace ui {
template<>
void RecentEntriesView<ERTRecentEntries>::draw_header(
const Rect& target_rect,
Painter& painter,
const Style& style
) {
painter.draw_string(target_rect.pos, style, " ID | Consumpt |Cnt ");
}
template<>
void RecentEntriesView<ERTRecentEntries>::draw(
const Entry& entry,

View File

@ -23,6 +23,7 @@
#define __RECENT_ENTRIES_H__
#include "ui_widget.hpp"
#include "ui_font_fixed_8x16.hpp"
#include <cstddef>
#include <cstdint>
@ -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,

View File

@ -165,6 +165,15 @@ void TPMSRecentEntry::update(const tpms::Reading& reading) {
namespace ui {
template<>
void RecentEntriesView<TPMSRecentEntries>::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<TPMSRecentEntries>::draw(
const Entry& entry,