diff --git a/radio/src/thirdparty/libopenui/src/menu.cpp b/radio/src/thirdparty/libopenui/src/menu.cpp index 31ee8f269..fe95e4010 100644 --- a/radio/src/thirdparty/libopenui/src/menu.cpp +++ b/radio/src/thirdparty/libopenui/src/menu.cpp @@ -106,7 +106,7 @@ void MenuBody::addLine(const std::string &text, std::function onPress, lines.emplace_back(std::move(onPress), std::move(isChecked), nullptr); auto idx = lines.size() - 1; - lv_table_set_cell_value_fmt(lvobj, idx, 0, text.c_str()); + lv_table_set_cell_value(lvobj, idx, 0, text.c_str()); } void MenuBody::addLine(const uint8_t *icon_mask, const std::string &text, @@ -200,29 +200,11 @@ void MenuBody::setIndex(int index) } } -void MenuBody::select(int index) -{ - // adjust the selection based on separators - for (int i = 0; i <= index; i++) { - if (lines[i].isSeparator) - index++; - index = rangeCheck(index); - } - - setIndex(index); -} - void MenuBody::selectNext(MENU_DIRECTION direction) { // look for the next non separator line int index = selectedIndex + direction; - index = rangeCheck(index); - while (lines[index].isSeparator) { - index += direction; - index = rangeCheck(index); - } - - setIndex(index); + setIndex(rangeCheck(index)); } @@ -247,7 +229,7 @@ void MenuBody::onEvent(event_t event) if (!lines.empty()) { onKeyPress(); if (selectedIndex < 0) { - select(0); + setIndex(0); } else { Menu * menu = getParentMenu(); @@ -348,12 +330,6 @@ void Menu::addLine(const uint8_t *icon_mask, const std::string &text, updatePosition(); } -void Menu::addSeparator() -{ - content->body.addSeparator(); - updatePosition(); -} - void Menu::removeLines() { content->body.removeLines(); diff --git a/radio/src/thirdparty/libopenui/src/menu.h b/radio/src/thirdparty/libopenui/src/menu.h index c923f9d13..e58555b62 100644 --- a/radio/src/thirdparty/libopenui/src/menu.h +++ b/radio/src/thirdparty/libopenui/src/menu.h @@ -57,14 +57,12 @@ class MenuBody: public Window { } - MenuLine(bool isSeparator) : isSeparator(true) {} MenuLine(MenuLine &) = delete; MenuLine(MenuLine &&) = default; lv_obj_t* getIcon() { return icon.get(); } protected: - bool isSeparator = false; std::function onPress; std::function isChecked; std::unique_ptr icon; @@ -80,16 +78,11 @@ class MenuBody: public Window } #endif - void select(int index); + void setIndex(int index); int selection() const { - int index = selectedIndex; - for (int i = 0; i < selectedIndex; i++) - if (lines[i].isSeparator) - index--; - - return index; + return selectedIndex; } int count() const @@ -108,11 +101,6 @@ class MenuBody: public Window std::function onPress, std::function isChecked); - void addSeparator() - { - lines.emplace_back(true); - } - void removeLines(); void setCancelHandler(std::function handler) @@ -130,7 +118,6 @@ class MenuBody: public Window void selectNext(MENU_DIRECTION direction); int rangeCheck(int); - void setIndex(int index); std::vector lines; int selectedIndex = 0; @@ -217,7 +204,7 @@ class Menu: public ModalWindow void select(int index) { - content->body.select(index); + content->body.setIndex(index); } #if defined(HARDWARE_KEYS)