From 73e6db7686d16625afad85c463f388ee935e77bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikael=20Degerf=C3=A4lt?= Date: Thu, 27 Jun 2019 16:00:05 +0200 Subject: [PATCH] Only handle scrolling if there are items to scroll --- NuEVI/menu.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/NuEVI/menu.cpp b/NuEVI/menu.cpp index f404be6..4615983 100644 --- a/NuEVI/menu.cpp +++ b/NuEVI/menu.cpp @@ -980,22 +980,24 @@ static bool updateMenuPage(const MenuPage *page, KeyState &input, uint32_t timeN } if(newPos != cursorPos) { - int offset = offsets[page->cursor]; + int offset = offsets[page->cursor]; drawMenuCursor(cursorPos-offset, BLACK); // Clear old cursor - // Handle scrolling.. - if((newPos - offset) > (MENU_NUM_ROWS-2) ) { - offset = newPos - (MENU_NUM_ROWS-2); - } else if( (newPos - offset) < 1) { - offset = newPos - 1; - } + if(page->numEntries >= MENU_NUM_ROWS) { + // Handle scrolling.. + if((newPos - offset) > (MENU_NUM_ROWS-2) ) { + offset = newPos - (MENU_NUM_ROWS-2); + } else if( (newPos - offset) < 1) { + offset = newPos - 1; + } - offset = constrain(offset, 0, page->numEntries - MENU_NUM_ROWS); + offset = constrain(offset, 0, page->numEntries - MENU_NUM_ROWS); - if( offset != offsets[page->cursor]) { - offsets[page->cursor] = offset; - plotMenuEntries(page, true); + if( offset != offsets[page->cursor]) { + offsets[page->cursor] = offset; + plotMenuEntries(page, true); + } } drawMenuCursor(newPos-offset, WHITE);