mirror of https://github.com/mgba-emu/mgba.git
GUI: Add scrolling
This commit is contained in:
parent
94e329a58c
commit
74c4cbe33e
|
@ -56,6 +56,7 @@ bool selectFile(const struct GUIParams* params, const char* basePath, char* outP
|
||||||
strncpy(currentPath, basePath, sizeof(currentPath));
|
strncpy(currentPath, basePath, sizeof(currentPath));
|
||||||
int oldInput = -1;
|
int oldInput = -1;
|
||||||
size_t fileIndex = 0;
|
size_t fileIndex = 0;
|
||||||
|
size_t start = 0;
|
||||||
|
|
||||||
struct FileList currentFiles;
|
struct FileList currentFiles;
|
||||||
FileListInit(¤tFiles, 0);
|
FileListInit(¤tFiles, 0);
|
||||||
|
@ -72,6 +73,12 @@ bool selectFile(const struct GUIParams* params, const char* basePath, char* outP
|
||||||
if (newInput & (1 << GUI_INPUT_DOWN) && fileIndex < FileListSize(¤tFiles) - 1) {
|
if (newInput & (1 << GUI_INPUT_DOWN) && fileIndex < FileListSize(¤tFiles) - 1) {
|
||||||
++fileIndex;
|
++fileIndex;
|
||||||
}
|
}
|
||||||
|
if (fileIndex < start) {
|
||||||
|
start = fileIndex;
|
||||||
|
}
|
||||||
|
while ((fileIndex - start + 4) * GUIFontHeight(params->font) > params->height) {
|
||||||
|
++start;
|
||||||
|
}
|
||||||
if (newInput & (1 << GUI_INPUT_CANCEL)) {
|
if (newInput & (1 << GUI_INPUT_CANCEL)) {
|
||||||
_cleanFiles(¤tFiles);
|
_cleanFiles(¤tFiles);
|
||||||
FileListDeinit(¤tFiles);
|
FileListDeinit(¤tFiles);
|
||||||
|
@ -101,7 +108,7 @@ bool selectFile(const struct GUIParams* params, const char* basePath, char* outP
|
||||||
GUIFontPrintf(params->font, 0, y, GUI_TEXT_LEFT, 0xFFFFFFFF, "Current directory: %s", currentPath);
|
GUIFontPrintf(params->font, 0, y, GUI_TEXT_LEFT, 0xFFFFFFFF, "Current directory: %s", currentPath);
|
||||||
y += 2 * GUIFontHeight(params->font);
|
y += 2 * GUIFontHeight(params->font);
|
||||||
size_t i;
|
size_t i;
|
||||||
for (i = 0; i < FileListSize(¤tFiles); ++i) {
|
for (i = start; i < FileListSize(¤tFiles); ++i) {
|
||||||
int color = 0xE0A0A0A0;
|
int color = 0xE0A0A0A0;
|
||||||
char bullet = ' ';
|
char bullet = ' ';
|
||||||
if (i == fileIndex) {
|
if (i == fileIndex) {
|
||||||
|
|
Loading…
Reference in New Issue