mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-10-01 01:26:06 -04:00
RecentEntriesView: Extract duplicate focus+selection style code.
This commit is contained in:
parent
1e0d452f57
commit
c6f7d7f844
@ -190,11 +190,8 @@ void RecentEntriesView<AISRecentEntries>::draw(
|
||||
const Entry& entry,
|
||||
const Rect& target_rect,
|
||||
Painter& painter,
|
||||
const Style& style,
|
||||
const bool is_selected
|
||||
const Style& style
|
||||
) {
|
||||
const auto& draw_style = is_selected ? style.invert() : style;
|
||||
|
||||
std::string line = ais::format::mmsi(entry.mmsi) + " ";
|
||||
if( !entry.name.empty() ) {
|
||||
line += entry.name;
|
||||
@ -203,7 +200,7 @@ void RecentEntriesView<AISRecentEntries>::draw(
|
||||
}
|
||||
|
||||
line.resize(target_rect.width() / 8, ' ');
|
||||
painter.draw_string(target_rect.pos, draw_style, line);
|
||||
painter.draw_string(target_rect.pos, style, line);
|
||||
}
|
||||
|
||||
AISRecentEntryDetailView::AISRecentEntryDetailView() {
|
||||
|
@ -80,11 +80,8 @@ void RecentEntriesView<ERTRecentEntries>::draw(
|
||||
const Entry& entry,
|
||||
const Rect& target_rect,
|
||||
Painter& painter,
|
||||
const Style& style,
|
||||
const bool is_selected
|
||||
const Style& style
|
||||
) {
|
||||
const auto& draw_style = is_selected ? style.invert() : style;
|
||||
|
||||
std::string line = ert::format::id(entry.id) + " " + ert::format::commodity_type(entry.commodity_type) + " " + ert::format::consumption(entry.last_consumption);
|
||||
|
||||
if( entry.received_count > 999 ) {
|
||||
@ -94,7 +91,7 @@ void RecentEntriesView<ERTRecentEntries>::draw(
|
||||
}
|
||||
|
||||
line.resize(target_rect.width() / 8, ' ');
|
||||
painter.draw_string(target_rect.pos, draw_style, line);
|
||||
painter.draw_string(target_rect.pos, style, line);
|
||||
}
|
||||
|
||||
ERTAppView::ERTAppView(NavigationView&) {
|
||||
|
@ -170,7 +170,8 @@ public:
|
||||
for(auto p = range.first; p != range.second; p++) {
|
||||
const auto& entry = *p;
|
||||
const auto is_selected_key = (selected_key == entry.key());
|
||||
draw(entry, target_rect, painter, s, (has_focus() && is_selected_key));
|
||||
const auto item_style = (has_focus() && is_selected_key) ? s.invert() : s;
|
||||
draw(entry, target_rect, painter, item_style);
|
||||
target_rect.pos.y += target_rect.height();
|
||||
}
|
||||
|
||||
@ -257,8 +258,7 @@ private:
|
||||
const Entry& entry,
|
||||
const Rect& target_rect,
|
||||
Painter& painter,
|
||||
const Style& style,
|
||||
const bool is_selected
|
||||
const Style& style
|
||||
);
|
||||
};
|
||||
|
||||
|
@ -100,11 +100,8 @@ void RecentEntriesView<TPMSRecentEntries>::draw(
|
||||
const Entry& entry,
|
||||
const Rect& target_rect,
|
||||
Painter& painter,
|
||||
const Style& style,
|
||||
const bool is_selected
|
||||
const Style& style
|
||||
) {
|
||||
const auto& draw_style = is_selected ? style.invert() : style;
|
||||
|
||||
std::string line = tpms::format::type(entry.type) + " " + tpms::format::id(entry.id);
|
||||
|
||||
if( entry.last_pressure.is_valid() ) {
|
||||
@ -132,7 +129,7 @@ void RecentEntriesView<TPMSRecentEntries>::draw(
|
||||
}
|
||||
|
||||
line.resize(target_rect.width() / 8, ' ');
|
||||
painter.draw_string(target_rect.pos, draw_style, line);
|
||||
painter.draw_string(target_rect.pos, style, line);
|
||||
}
|
||||
|
||||
TPMSAppView::TPMSAppView(NavigationView&) {
|
||||
|
Loading…
Reference in New Issue
Block a user