mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-04-15 18:01:27 +00:00
Draw AIS entry details.
This commit is contained in:
parent
aa249cbad4
commit
089ef25df9
@ -294,6 +294,42 @@ void AISRecentEntryDetailView::focus() {
|
|||||||
button_done.focus();
|
button_done.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Rect AISRecentEntryDetailView::draw_field(
|
||||||
|
Painter& painter,
|
||||||
|
const Rect& draw_rect,
|
||||||
|
const Style& style,
|
||||||
|
const std::string& label,
|
||||||
|
const std::string& value
|
||||||
|
) {
|
||||||
|
const size_t label_length_max = 4;
|
||||||
|
|
||||||
|
painter.draw_string(Point { draw_rect.left(), draw_rect.top() }, style, label);
|
||||||
|
|
||||||
|
const auto length = value.length();
|
||||||
|
painter.draw_string(Point { draw_rect.left() + (label_length_max + 1) * 8, draw_rect.top() }, style, value);
|
||||||
|
|
||||||
|
return { draw_rect.left(), draw_rect.top() + draw_rect.height(), draw_rect.width(), draw_rect.height() };
|
||||||
|
}
|
||||||
|
|
||||||
|
void AISRecentEntryDetailView::paint(Painter& painter) {
|
||||||
|
View::paint(painter);
|
||||||
|
|
||||||
|
const auto s = style();
|
||||||
|
const auto rect = screen_rect();
|
||||||
|
|
||||||
|
auto field_rect = Rect { rect.left(), rect.top() + 16, rect.width(), 16 };
|
||||||
|
|
||||||
|
const size_t mmsi_length = 9;
|
||||||
|
field_rect = draw_field(painter, field_rect, s, "MMSI", to_string_dec_int(entry.mmsi, mmsi_length));
|
||||||
|
field_rect = draw_field(painter, field_rect, s, "Name", entry.name);
|
||||||
|
field_rect = draw_field(painter, field_rect, s, "Call", entry.call_sign);
|
||||||
|
field_rect = draw_field(painter, field_rect, s, "Dest", entry.destination);
|
||||||
|
field_rect = draw_field(painter, field_rect, s, "Lat ", ais::format::latlon_normalized(entry.last_position.latitude) + "N");
|
||||||
|
field_rect = draw_field(painter, field_rect, s, "Lon ", ais::format::latlon_normalized(entry.last_position.longitude) + "E");
|
||||||
|
field_rect = draw_field(painter, field_rect, s, "Stat", ais::format::navigational_status(entry.navigational_status));
|
||||||
|
field_rect = draw_field(painter, field_rect, s, "Rx #", to_string_dec_uint(entry.received_count, 10));
|
||||||
|
}
|
||||||
|
|
||||||
void AISRecentEntryDetailView::set_entry(const AISRecentEntry& new_entry) {
|
void AISRecentEntryDetailView::set_entry(const AISRecentEntry& new_entry) {
|
||||||
entry = new_entry;
|
entry = new_entry;
|
||||||
}
|
}
|
||||||
|
@ -146,6 +146,7 @@ public:
|
|||||||
void set_entry(const AISRecentEntry& new_entry);
|
void set_entry(const AISRecentEntry& new_entry);
|
||||||
|
|
||||||
void focus() override;
|
void focus() override;
|
||||||
|
void paint(Painter&) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AISRecentEntry entry;
|
AISRecentEntry entry;
|
||||||
@ -154,6 +155,14 @@ private:
|
|||||||
{ 72, 192, 96, 24 },
|
{ 72, 192, 96, 24 },
|
||||||
"Done"
|
"Done"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Rect draw_field(
|
||||||
|
Painter& painter,
|
||||||
|
const Rect& draw_rect,
|
||||||
|
const Style& style,
|
||||||
|
const std::string& label,
|
||||||
|
const std::string& value
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
class AISAppView : public View {
|
class AISAppView : public View {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user