1
0
forked from me/IronOS

Recalculate scroll size on value change

This commit is contained in:
Ben V. Brown
2021-12-29 17:16:58 +11:00
parent 6d3a52e32b
commit 07b692e330

View File

@@ -887,6 +887,7 @@ void gui_Menu(const menuitem *menu) {
TickType_t autoRepeatAcceleration = 0; TickType_t autoRepeatAcceleration = 0;
bool earlyExit = false; bool earlyExit = false;
bool lcdRefresh = true; bool lcdRefresh = true;
ButtonState lastButtonState = BUTTON_NONE; ButtonState lastButtonState = BUTTON_NONE;
uint8_t scrollContentSize = gui_getMenuLength(menu); uint8_t scrollContentSize = gui_getMenuLength(menu);
bool scrollBlink = false; bool scrollBlink = false;
@@ -896,7 +897,7 @@ void gui_Menu(const menuitem *menu) {
ScrollMessage scrollMessage; ScrollMessage scrollMessage;
while ((menu[currentScreen].draw != nullptr) && earlyExit == false) { while ((menu[currentScreen].draw != nullptr) && earlyExit == false) {
bool valueChanged = false;
// Handle menu transition: // Handle menu transition:
if (navState != NavState::Idle) { if (navState != NavState::Idle) {
// Check if this menu item shall be skipped. If it shall be skipped, // Check if this menu item shall be skipped. If it shall be skipped,
@@ -971,6 +972,7 @@ void gui_Menu(const menuitem *menu) {
auto callIncrementHandler = [&]() { auto callIncrementHandler = [&]() {
wasInGuiMenu = false; wasInGuiMenu = false;
valueChanged = true;
bool res = false; bool res = false;
if ((int)menu[currentScreen].autoSettingOption < (int)SettingsOptions::SettingsOptionsLength) { if ((int)menu[currentScreen].autoSettingOption < (int)SettingsOptions::SettingsOptionsLength) {
res = nextSettingValue(menu[currentScreen].autoSettingOption); res = nextSettingValue(menu[currentScreen].autoSettingOption);
@@ -1046,6 +1048,10 @@ void gui_Menu(const menuitem *menu) {
earlyExit = true; earlyExit = true;
scrollMessage.reset(); scrollMessage.reset();
} }
if (valueChanged) {
// If user changed value, update the scroll content size
scrollContentSize = gui_getMenuLength(menu);
}
} }
} }