GUI: Use the real page size for page scrolling
Jeffrey Pfau jeffrey@endrift.com
Wed, 26 Aug 2015 21:45:55 -0700
1 files changed,
10 insertions(+),
4 deletions(-)
jump to
M
src/util/gui/file-select.c
→
src/util/gui/file-select.c
@@ -85,6 +85,12 @@ strncpy(currentPath, basePath, outLen);
} size_t fileIndex = 0; size_t start = 0; + size_t pageSize = params->height / GUIFontHeight(params->font); + if (pageSize > 4) { + pageSize -= 4; + } else { + pageSize = 1; + } struct FileList currentFiles; FileListInit(¤tFiles, 0);@@ -113,15 +119,15 @@ if (newInput & (1 << GUI_INPUT_DOWN) && fileIndex < FileListSize(¤tFiles) - 1) {
++fileIndex; } if (newInput & (1 << GUI_INPUT_LEFT)) { - if (fileIndex >= ITERATION_SIZE) { - fileIndex -= ITERATION_SIZE; + if (fileIndex >= pageSize) { + fileIndex -= pageSize; } else { fileIndex = 0; } } if (newInput & (1 << GUI_INPUT_RIGHT)) { - if (fileIndex + ITERATION_SIZE < FileListSize(¤tFiles)) { - fileIndex += ITERATION_SIZE; + if (fileIndex + pageSize < FileListSize(¤tFiles)) { + fileIndex += pageSize; } else { fileIndex = FileListSize(¤tFiles) - 1; }