1
0
forked from me/IronOS

Extract menu size calc

This commit is contained in:
Ben V. Brown
2021-12-29 17:03:05 +11:00
parent f13b7be3d9
commit 6d3a52e32b

View File

@@ -857,6 +857,17 @@ static bool settings_enterAdvancedMenu(void) {
return false;
}
uint8_t gui_getMenuLength(const menuitem *menu) {
uint8_t scrollContentSize = 0;
for (uint8_t i = 0; menu[i].draw != nullptr; i++) {
if (menu[i].isVisible == nullptr) {
scrollContentSize += 1; // Always visible
} else if (menu[i].isVisible()) {
scrollContentSize += 1; // Selectively visible and chosen to show
}
}
return scrollContentSize;
}
void gui_Menu(const menuitem *menu) {
// Draw the settings menu and provide iteration support etc
@@ -877,21 +888,13 @@ void gui_Menu(const menuitem *menu) {
bool earlyExit = false;
bool lcdRefresh = true;
ButtonState lastButtonState = BUTTON_NONE;
uint8_t scrollContentSize = 0;
uint8_t scrollContentSize = gui_getMenuLength(menu);
bool scrollBlink = false;
bool lastValue = false;
NavState navState = NavState::Entering;
ScrollMessage scrollMessage;
for (uint8_t i = 0; menu[i].draw != nullptr; i++) {
if (menu[i].isVisible == nullptr) {
scrollContentSize += 1; // Always visible
} else if (menu[i].isVisible()) {
scrollContentSize += 1; // Selectively visible and chosen to show
}
}
while ((menu[currentScreen].draw != nullptr) && earlyExit == false) {
// Handle menu transition: