From c8a798a66c26676fef3569814a956a04d6b635ed Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Fri, 9 Oct 2020 19:12:21 +0200 Subject: [PATCH] [StaticText] Possibility to have a background color --- radio/src/thirdparty/libopenui/src/static.cpp | 4 ++-- radio/src/thirdparty/libopenui/src/static.h | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/radio/src/thirdparty/libopenui/src/static.cpp b/radio/src/thirdparty/libopenui/src/static.cpp index b511b6715..8d1ef9c40 100755 --- a/radio/src/thirdparty/libopenui/src/static.cpp +++ b/radio/src/thirdparty/libopenui/src/static.cpp @@ -22,8 +22,8 @@ void StaticText::paint(BitmapBuffer * dc) { - if (windowFlags & BUTTON_BACKGROUND) { - dc->drawSolidFilledRect(0, 0, rect.w, rect.h, DISABLE_COLOR); + if (bgColor) { + dc->drawSolidFilledRect(0, 0, rect.w, rect.h, bgColor); } coord_t x; diff --git a/radio/src/thirdparty/libopenui/src/static.h b/radio/src/thirdparty/libopenui/src/static.h index bf5486aac..159e71ad9 100644 --- a/radio/src/thirdparty/libopenui/src/static.h +++ b/radio/src/thirdparty/libopenui/src/static.h @@ -29,6 +29,9 @@ class StaticText: public Window { Window(parent, rect, windowFlags, textFlags), text(std::move(text)) { + if (windowFlags & BUTTON_BACKGROUND) { + setBackgroundColor(DISABLE_COLOR); + } } #if defined(DEBUG_WINDOWS) @@ -46,8 +49,14 @@ class StaticText: public Window { invalidate(); } + void setBackgroundColor(LcdFlags color) + { + bgColor = color; + } + protected: std::string text; + LcdFlags bgColor = 0; }; class Subtitle: public StaticText { @@ -124,14 +133,15 @@ class StaticBitmap: public Window { class DynamicText: public StaticText { public: - DynamicText(Window * parent, const rect_t & rect, std::function textHandler): - StaticText(parent, rect), + DynamicText(Window * parent, const rect_t & rect, std::function textHandler, LcdFlags textFlags = 0): + StaticText(parent, rect, "", 0, textFlags), textHandler(std::move(textHandler)) { } void checkEvents() override { + StaticText::checkEvents(); std::string newText = textHandler(); if (newText != text) { text = newText;