diff --git a/firmware/application/recent_entries.cpp b/firmware/application/recent_entries.cpp index bfb21aee..0521238a 100644 --- a/firmware/application/recent_entries.cpp +++ b/firmware/application/recent_entries.cpp @@ -20,3 +20,42 @@ */ #include "recent_entries.hpp" + +namespace ui { + +RecentEntriesColumns::RecentEntriesColumns( + const std::initializer_list columns +) : _columns { columns } +{ +} + +RecentEntriesHeader::RecentEntriesHeader( + const RecentEntriesColumns& columns +) : _columns { columns } +{ +} + +void RecentEntriesHeader::paint(Painter& painter) { + const auto r = screen_rect(); + const auto& parent_style = style(); + + const Style style { + .font = parent_style.font, + .background = Color::blue(), + .foreground = parent_style.foreground, + }; + + auto p = r.pos; + for(const auto& column : _columns) { + const auto width = column.second; + auto text = column.first; + if( width > text.length() ) { + text.append(width - text.length(), ' '); + } + + painter.draw_string(p, style, text); + p += { static_cast((width * 8) + 8), 0 }; + } +} + +} /* namespace ui */ diff --git a/firmware/application/recent_entries.hpp b/firmware/application/recent_entries.hpp index e4068270..568f5e6c 100644 --- a/firmware/application/recent_entries.hpp +++ b/firmware/application/recent_entries.hpp @@ -101,9 +101,7 @@ public: RecentEntriesColumns( const std::initializer_list columns - ) : _columns { columns } - { - } + ); ContainerType::const_iterator begin() const { return std::begin(_columns); } ContainerType::const_iterator end() const { return std::end(_columns); } @@ -116,32 +114,9 @@ class RecentEntriesHeader : public Widget { public: RecentEntriesHeader( const RecentEntriesColumns& columns - ) : _columns { columns } - { - } + ); - void paint(Painter& painter) override { - const auto r = screen_rect(); - const auto& parent_style = style(); - - const Style style { - .font = parent_style.font, - .background = Color::blue(), - .foreground = parent_style.foreground, - }; - - auto p = r.pos; - for(const auto& column : _columns) { - const auto width = column.second; - auto text = column.first; - if( width > text.length() ) { - text.append(width - text.length(), ' '); - } - - painter.draw_string(p, style, text); - p += { static_cast((width * 8) + 8), 0 }; - } - } + void paint(Painter& painter) override; private: const RecentEntriesColumns& _columns;