From c5175f7061229d8131b7e4345cbf37fab2e56895 Mon Sep 17 00:00:00 2001 From: "kkoenig1@optonline.com" Date: Mon, 7 Feb 2022 04:53:03 -0500 Subject: [PATCH] more menu changes --- radio/src/thirdparty/libopenui/src/button.cpp | 53 +------------------ radio/src/thirdparty/libopenui/src/button.h | 6 --- radio/src/thirdparty/libopenui/src/menu.cpp | 11 +++- .../thirdparty/libopenui/src/menutoolbar.h | 3 +- 4 files changed, 12 insertions(+), 61 deletions(-) diff --git a/radio/src/thirdparty/libopenui/src/button.cpp b/radio/src/thirdparty/libopenui/src/button.cpp index d59a3c5a0..8d8bf6239 100644 --- a/radio/src/thirdparty/libopenui/src/button.cpp +++ b/radio/src/thirdparty/libopenui/src/button.cpp @@ -81,14 +81,7 @@ void Button::checkEvents() } lv_style_t style_btn; - - -LvglWidgetFactory textButtonFactory = LvglWidgetFactory( - [](lv_obj_t *parent) { - return lv_btn_create(parent); - }, - [] (LvglWidgetFactory *factory) { - }); +LvglWidgetFactory textButtonFactory = {lv_btn_create, nullptr}; TextButton::TextButton(FormGroup* parent, const rect_t& rect, std::string text, std::function pressHandler, @@ -125,50 +118,6 @@ TextButton::TextButton(FormGroup* parent, const rect_t& rect, std::string text, lv_obj_set_style_text_color(label, makeLvColor(COLOR_THEME_PRIMARY2), LV_PART_MAIN | LV_STATE_FOCUSED); } -TextButton::~TextButton() -{ -} - -void TextButton::paint(BitmapBuffer * dc) -{ - // auto textColor = getTextFlags(); - // auto bgColor = COLOR_THEME_SECONDARY2; - - // if (bgColorHandler) { - // bgColor = bgColorHandler(); - // } else if (checked()) { - // bgColor = COLOR_THEME_ACTIVE; - // } else if (hasFocus()) { - // bgColor = COLOR_THEME_FOCUS; - // textColor = COLOR_THEME_PRIMARY2; - // } - - // if (checked()) { - // if (hasFocus()) { - // dc->drawSolidRect(0, 0, rect.w, rect.h, 2, COLOR_THEME_FOCUS); - // dc->drawSolidFilledRect(3, 3, rect.w - 6, rect.h - 6, bgColor); - // } else { - // dc->drawSolidFilledRect(0, 0, rect.w, rect.h, bgColor); - // } - // } - // else { - // dc->drawSolidFilledRect(0, 0, rect.w, rect.h, bgColor); - // if (windowFlags & BUTTON_BACKGROUND) { - // if (hasFocus()) { - // textColor = COLOR_THEME_PRIMARY2; - // } - // } else if (hasFocus()) { - // dc->drawSolidRect(0, 0, rect.w, rect.h, 2, COLOR_THEME_FOCUS); - // } - // else { - // dc->drawSolidRect(0, 0, rect.w, rect.h, 1, COLOR_THEME_SECONDARY2); - // } - // } - - // dc->drawText(rect.w / 2, 1 + (rect.h - getFontHeight(textFlags)) / 2, - // text.c_str(), CENTERED | textColor); -} - void IconButton::paint(BitmapBuffer * dc) { dc->drawBitmap(0, 0, theme->getIcon(icon, checked() ? STATE_PRESSED : STATE_DEFAULT)); diff --git a/radio/src/thirdparty/libopenui/src/button.h b/radio/src/thirdparty/libopenui/src/button.h index 286068959..1f11a9a4c 100644 --- a/radio/src/thirdparty/libopenui/src/button.h +++ b/radio/src/thirdparty/libopenui/src/button.h @@ -88,8 +88,6 @@ class Button: public FormField }; -extern void my_btn_event_cb(lv_event_t * e); - class TextButton: public Button { public: @@ -97,7 +95,6 @@ class TextButton: public Button std::function pressHandler = nullptr, WindowFlags windowFlags = BUTTON_BACKGROUND | OPAQUE, LcdFlags textFlags = 0); - ~TextButton(); #if defined(DEBUG_WINDOWS) std::string getName() const override @@ -111,7 +108,6 @@ class TextButton: public Button if (value != text) { text = std::move(value); lv_label_set_text(label, text.c_str()); - invalidate(); } } @@ -120,8 +116,6 @@ class TextButton: public Button bgColorHandler = std::move(handler); } - void paint(BitmapBuffer* dc) override; - protected: lv_obj_t * label = nullptr; diff --git a/radio/src/thirdparty/libopenui/src/menu.cpp b/radio/src/thirdparty/libopenui/src/menu.cpp index 950e411ee..3ec5a384d 100644 --- a/radio/src/thirdparty/libopenui/src/menu.cpp +++ b/radio/src/thirdparty/libopenui/src/menu.cpp @@ -92,11 +92,17 @@ int MenuBody::rangeCheck(int index) void MenuBody::setIndex(int index) { if (index < (int)lines.size()) { - selectedIndex = index; - lv_obj_t *btn = lv_obj_get_child(lvobj, selectedIndex); + if (btn != nullptr) { + lv_obj_clear_state(btn, LV_STATE_CHECKED); + } + + selectedIndex = index; + + btn = lv_obj_get_child(lvobj, selectedIndex); if (btn != nullptr) { lv_obj_add_state(btn, LV_STATE_CHECKED); + lv_obj_scroll_to_view(btn, LV_ANIM_ON); } } } @@ -263,6 +269,7 @@ MenuWindowContent::MenuWindowContent(Menu* parent) : body(this, {0, 0, width(), height()}) { body.setFocus(SET_FOCUS_DEFAULT); + lv_obj_set_style_bg_opa(lvobj, LV_OPA_100, LV_PART_MAIN); } void MenuWindowContent::paint(BitmapBuffer * dc) diff --git a/radio/src/thirdparty/libopenui/src/menutoolbar.h b/radio/src/thirdparty/libopenui/src/menutoolbar.h index 49e37817c..37c6b8a01 100644 --- a/radio/src/thirdparty/libopenui/src/menutoolbar.h +++ b/radio/src/thirdparty/libopenui/src/menutoolbar.h @@ -53,11 +53,12 @@ class MenuToolbar: public FormGroup { choice(choice), menu(menu) { + lv_obj_set_style_bg_opa(lvobj, LV_OPA_100, LV_PART_MAIN); } void paint(BitmapBuffer * dc) override { - dc->clear(COLOR_THEME_SECONDARY3); +// dc->clear(COLOR_THEME_SECONDARY3); } #if defined(HARDWARE_KEYS)