Only handle scrolling if there are items to scroll

This commit is contained in:
Mikael Degerfält 2019-06-27 16:00:05 +02:00
parent 0e32077042
commit 73e6db7686

View file

@ -980,10 +980,11 @@ static bool updateMenuPage(const MenuPage *page, KeyState &input, uint32_t timeN
} }
if(newPos != cursorPos) { if(newPos != cursorPos) {
int offset = offsets[page->cursor];
int offset = offsets[page->cursor];
drawMenuCursor(cursorPos-offset, BLACK); // Clear old cursor drawMenuCursor(cursorPos-offset, BLACK); // Clear old cursor
if(page->numEntries >= MENU_NUM_ROWS) {
// Handle scrolling.. // Handle scrolling..
if((newPos - offset) > (MENU_NUM_ROWS-2) ) { if((newPos - offset) > (MENU_NUM_ROWS-2) ) {
offset = newPos - (MENU_NUM_ROWS-2); offset = newPos - (MENU_NUM_ROWS-2);
@ -997,6 +998,7 @@ static bool updateMenuPage(const MenuPage *page, KeyState &input, uint32_t timeN
offsets[page->cursor] = offset; offsets[page->cursor] = offset;
plotMenuEntries(page, true); plotMenuEntries(page, true);
} }
}
drawMenuCursor(newPos-offset, WHITE); drawMenuCursor(newPos-offset, WHITE);
cursorNow = BLACK; cursorNow = BLACK;