GUI: Add scrolling
Jeffrey Pfau jeffrey@endrift.com
Thu, 06 Aug 2015 15:43:45 -0700
1 files changed,
8 insertions(+),
1 deletions(-)
jump to
M
src/util/gui/file-select.c
→
src/util/gui/file-select.c
@@ -56,6 +56,7 @@ char currentPath[256];
strncpy(currentPath, basePath, sizeof(currentPath)); int oldInput = -1; size_t fileIndex = 0; + size_t start = 0; struct FileList currentFiles; FileListInit(¤tFiles, 0);@@ -71,6 +72,12 @@ --fileIndex;
} if (newInput & (1 << GUI_INPUT_DOWN) && fileIndex < FileListSize(¤tFiles) - 1) { ++fileIndex; + } + if (fileIndex < start) { + start = fileIndex; + } + while ((fileIndex - start + 4) * GUIFontHeight(params->font) > params->height) { + ++start; } if (newInput & (1 << GUI_INPUT_CANCEL)) { _cleanFiles(¤tFiles);@@ -101,7 +108,7 @@ int y = GUIFontHeight(params->font);
GUIFontPrintf(params->font, 0, y, GUI_TEXT_LEFT, 0xFFFFFFFF, "Current directory: %s", currentPath); y += 2 * GUIFontHeight(params->font); size_t i; - for (i = 0; i < FileListSize(¤tFiles); ++i) { + for (i = start; i < FileListSize(¤tFiles); ++i) { int color = 0xE0A0A0A0; char bullet = ' '; if (i == fileIndex) {