diff --git a/firmware/application/ui_navigation.cpp b/firmware/application/ui_navigation.cpp index 364db962..fc7248c3 100644 --- a/firmware/application/ui_navigation.cpp +++ b/firmware/application/ui_navigation.cpp @@ -46,7 +46,6 @@ SystemStatusView::SystemStatusView() { &button_sleep, &sd_card_status_view, } }); - sd_card_status_view.set_parent_rect({ 28 * 8, 0 * 16, 2 * 8, 1 * 16 }); button_back.on_select = [this](Button&){ if( this->on_back ) { diff --git a/firmware/application/ui_navigation.hpp b/firmware/application/ui_navigation.hpp index a0c0ce04..14beadc9 100644 --- a/firmware/application/ui_navigation.hpp +++ b/firmware/application/ui_navigation.hpp @@ -64,7 +64,9 @@ private: "ZZ", }; - SDCardStatusView sd_card_status_view; + SDCardStatusView sd_card_status_view { + { 28 * 8, 0 * 16, 2 * 8, 1 * 16 } + }; }; class NavigationView : public View { diff --git a/firmware/application/ui_sd_card_status_view.cpp b/firmware/application/ui_sd_card_status_view.cpp index 95b82fec..46a07720 100644 --- a/firmware/application/ui_sd_card_status_view.cpp +++ b/firmware/application/ui_sd_card_status_view.cpp @@ -111,6 +111,12 @@ const Color color_sd_card(const sd_card::Status status) { } /* namespace detail */ +SDCardStatusView::SDCardStatusView( + const Rect parent_rect +) : Image { parent_rect, &detail::bitmap_sd_card_unknown, detail::color_sd_card_unknown, Color::black() } +{ +} + void SDCardStatusView::on_show() { sd_card_status_signal_token = sd_card::status_signal += [this](const sd_card::Status status) { this->on_status(status); @@ -123,15 +129,14 @@ void SDCardStatusView::on_hide() { void SDCardStatusView::paint(Painter& painter) { const auto status = sd_card::status(); - painter.draw_bitmap( - screen_pos(), - detail::bitmap_sd_card(status), - detail::color_sd_card(status), - style().background - ); + set_bitmap(&detail::bitmap_sd_card(status)); + set_foreground(detail::color_sd_card(status)); + + Image::paint(painter); } void SDCardStatusView::on_status(const sd_card::Status) { + // Don't update image properties here, they might change. Wait until paint. set_dirty(); } diff --git a/firmware/application/ui_sd_card_status_view.hpp b/firmware/application/ui_sd_card_status_view.hpp index 7c426260..31388cfa 100644 --- a/firmware/application/ui_sd_card_status_view.hpp +++ b/firmware/application/ui_sd_card_status_view.hpp @@ -27,8 +27,10 @@ namespace ui { -class SDCardStatusView : public View { +class SDCardStatusView : public Image { public: + SDCardStatusView(const Rect parent_rect); + void on_show() override; void on_hide() override;