From c1e83c20268e4e04749183c7aaef1cbff7789bca Mon Sep 17 00:00:00 2001 From: philmoz Date: Sat, 26 Aug 2023 20:52:32 +1000 Subject: [PATCH] fix(color): Buttons on model setup page not showing active state (#3942) --- radio/src/gui/colorlcd/model_setup.cpp | 44 ++++++++++++++------------ 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/radio/src/gui/colorlcd/model_setup.cpp b/radio/src/gui/colorlcd/model_setup.cpp index 07f0027b6..497036fbc 100644 --- a/radio/src/gui/colorlcd/model_setup.cpp +++ b/radio/src/gui/colorlcd/model_setup.cpp @@ -94,30 +94,32 @@ struct ModelBitmapEdit : public FileChoice { class SubScreenButton : public TextButton { - public: - SubScreenButton(Window* parent, const char* text, - std::function pressHandler); + public: + SubScreenButton(Window* parent, const char* text, + std::function pressHandler) : + TextButton(parent, rect_t{}, text, [=]() -> uint8_t { + pressHandler(); + return 0; + }) + { + // Room for two lines of text + setHeight(62); + setWidth((LCD_W - 30) / 3); - protected: - virtual bool isActive() { return false; } + lv_obj_set_width(label, lv_pct(100)); + lv_label_set_long_mode(label, LV_LABEL_LONG_WRAP); + lv_obj_set_style_text_align(label, LV_TEXT_ALIGN_CENTER, 0); + } + + void checkEvents() override + { + check(isActive()); + } + + protected: + virtual bool isActive() { return false; } }; -SubScreenButton::SubScreenButton(Window* parent, const char* text, - std::function pressHandler) : - TextButton(parent, rect_t{}, text, [=]() -> uint8_t { - pressHandler(); - return 0; - }) -{ - // Room for two lines of text - setHeight(62); - setWidth((LCD_W - 30) / 3); - - lv_obj_set_width(label, lv_pct(100)); - lv_label_set_long_mode(label, LV_LABEL_LONG_WRAP); - lv_obj_set_style_text_align(label, LV_TEXT_ALIGN_CENTER, 0); -} - struct IntmoduleButton : public SubScreenButton { IntmoduleButton(Window* parent) : SubScreenButton(parent, STR_INTERNALRF,