diff --git a/radio/src/gui/colorlcd/widgets/modelbmp.cpp b/radio/src/gui/colorlcd/widgets/modelbmp.cpp index 0d5a8d3cda4..4c2d96c1281 100644 --- a/radio/src/gui/colorlcd/widgets/modelbmp.cpp +++ b/radio/src/gui/colorlcd/widgets/modelbmp.cpp @@ -29,48 +29,44 @@ class ModelBitmapWidget: public Widget ModelBitmapWidget(const WidgetFactory * factory, FormGroup * parent, const rect_t & rect, Widget::PersistentData * persistentData): Widget(factory, parent, rect, persistentData) { + loadBitmap(); } void refresh(BitmapBuffer * dc) override { - if (buffer && ((buffer->width() != width()) || (buffer->height() != height()))) { + if (buffer && + ((buffer->width() != width()) || (buffer->height() != height()) || + (deps_hash != getHash()))) { loadBitmap(); } // big space to draw if (rect.h >= 96 && rect.w >= 120) { - dc->drawFilledRect(0, 0, rect.w, rect.h, SOLID, MAINVIEW_PANES_COLOR, OPACITY(5)); - + if (buffer) { + dc->drawBitmap(0, 0, buffer.get()); + } + auto iconMask = theme->getIconMask(ICON_MODEL); if (iconMask) { - dc->drawMask(6, 4, iconMask, MAINVIEW_GRAPHICS_COLOR); + dc->drawMask(6, 4, iconMask, HEADER_COLOR); } - dc->drawSizedText(45, 10, g_model.header.name, LEN_MODEL_NAME, FONT(XS)); - dc->drawSolidFilledRect(39, 27, rect.w - 48, 2, MAINVIEW_GRAPHICS_COLOR); - - if (buffer) { - dc->drawBitmap(0, 38, buffer.get()); - } + dc->drawSizedText(45, 10, g_model.header.name, LEN_MODEL_NAME, + FONT(XS) | DEFAULT_COLOR); + dc->drawSolidFilledRect(39, 27, rect.w - 48, 2, HEADER_COLOR); } // smaller space to draw else if (buffer) { - dc->drawBitmap(0, 38, buffer.get()); - } + dc->drawBitmap(0, 0, buffer.get()); + } } void checkEvents() override { Widget::checkEvents(); - - uint32_t new_hash = hash(g_model.header.bitmap, sizeof(g_model.header.bitmap)); - new_hash ^= hash(g_model.header.name, sizeof(g_model.header.name)); - new_hash ^= hash(g_eeGeneral.themeName, sizeof(g_eeGeneral.themeName)); - - if (new_hash != deps_hash) { - deps_hash = new_hash; - loadBitmap(); + if (getHash() != deps_hash) { + invalidate(); } } @@ -78,6 +74,11 @@ class ModelBitmapWidget: public Widget std::unique_ptr buffer; uint32_t deps_hash = 0; + uint32_t getHash() + { + return hash(g_model.header.bitmap, sizeof(g_model.header.bitmap)); + } + void loadBitmap() { std::string filename = std::string(g_model.header.bitmap); @@ -94,7 +95,7 @@ class ModelBitmapWidget: public Widget } buffer->clear(DEFAULT_BGCOLOR); - buffer->drawScaledBitmap(bitmap.get(), 0, 0, width(), height() - 38); + buffer->drawScaledBitmap(bitmap.get(), 0, 38, width(), height() - 38); } };