diff options
author | Ben V. Brown <[email protected]> | 2021-12-29 17:16:58 +1100 |
---|---|---|
committer | Ben V. Brown <[email protected]> | 2021-12-29 17:16:58 +1100 |
commit | 07b692e33055fa2adccb6f03f8656311cd7924a1 (patch) | |
tree | eb4c42c34e7b927ace3b513dcc9418a2905155a3 | |
parent | 6d3a52e32b006c578a4d0474b0b086bae7ce83fd (diff) | |
download | IronOS-07b692e33055fa2adccb6f03f8656311cd7924a1.tar.gz IronOS-07b692e33055fa2adccb6f03f8656311cd7924a1.zip |
Recalculate scroll size on value change
-rw-r--r-- | source/Core/Src/gui.cpp | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/source/Core/Src/gui.cpp b/source/Core/Src/gui.cpp index bbae1d7c..d6390419 100644 --- a/source/Core/Src/gui.cpp +++ b/source/Core/Src/gui.cpp @@ -882,21 +882,22 @@ void gui_Menu(const menuitem *menu) { Exiting, }; - uint8_t currentScreen = 0; - TickType_t autoRepeatTimer = 0; - TickType_t autoRepeatAcceleration = 0; - bool earlyExit = false; - bool lcdRefresh = true; - ButtonState lastButtonState = BUTTON_NONE; - uint8_t scrollContentSize = gui_getMenuLength(menu); - bool scrollBlink = false; - bool lastValue = false; - NavState navState = NavState::Entering; + uint8_t currentScreen = 0; + TickType_t autoRepeatTimer = 0; + TickType_t autoRepeatAcceleration = 0; + bool earlyExit = false; + bool lcdRefresh = true; + + ButtonState lastButtonState = BUTTON_NONE; + uint8_t scrollContentSize = gui_getMenuLength(menu); + bool scrollBlink = false; + bool lastValue = false; + NavState navState = NavState::Entering; ScrollMessage scrollMessage; while ((menu[currentScreen].draw != nullptr) && earlyExit == false) { - + bool valueChanged = false; // Handle menu transition: if (navState != NavState::Idle) { // 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 = [&]() { wasInGuiMenu = false; + valueChanged = true; bool res = false; if ((int)menu[currentScreen].autoSettingOption < (int)SettingsOptions::SettingsOptionsLength) { res = nextSettingValue(menu[currentScreen].autoSettingOption); @@ -1046,6 +1048,10 @@ void gui_Menu(const menuitem *menu) { earlyExit = true; scrollMessage.reset(); } + if (valueChanged) { + // If user changed value, update the scroll content size + scrollContentSize = gui_getMenuLength(menu); + } } } |