all repos — mgba @ d5697971a93a22ecc90a25e969fae05b91437617

mGBA Game Boy Advance Emulator

GUI: Use the real page size for page scrolling
Jeffrey Pfau jeffrey@endrift.com
Wed, 26 Aug 2015 21:45:55 -0700
commit

d5697971a93a22ecc90a25e969fae05b91437617

parent

87a05e3ed1828cea1ac54e9397f5e69825e92efc

1 files changed, 10 insertions(+), 4 deletions(-)

jump to
M src/util/gui/file-select.csrc/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(&currentFiles, 0);

@@ -113,15 +119,15 @@ if (newInput & (1 << GUI_INPUT_DOWN) && fileIndex < FileListSize(&currentFiles) - 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(&currentFiles)) { - fileIndex += ITERATION_SIZE; + if (fileIndex + pageSize < FileListSize(&currentFiles)) { + fileIndex += pageSize; } else { fileIndex = FileListSize(&currentFiles) - 1; }