mirror of
https://git.planet-casio.com/Lephenixnoir/JustUI.git
synced 2025-06-06 21:35:05 +02:00
jfileselect: improve behavior for empty listings
This commit is contained in:
parent
d9c18117c5
commit
4c44b3e413
1 changed files with 9 additions and 4 deletions
|
@ -226,7 +226,7 @@ static bool load_folder_switch(jfileselect *fs, char *path)
|
||||||
|
|
||||||
/* Allocate memory for the fileinfo structures */
|
/* Allocate memory for the fileinfo structures */
|
||||||
struct fileinfo *finfo = malloc(n * sizeof *finfo);
|
struct fileinfo *finfo = malloc(n * sizeof *finfo);
|
||||||
if(!finfo) {
|
if(n && !finfo) {
|
||||||
closedir(dp);
|
closedir(dp);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -379,7 +379,7 @@ static void generate_info_string(char *str, bool isfolder, int size)
|
||||||
static void jfileselect_poly_render(void *fs0, int x, int y)
|
static void jfileselect_poly_render(void *fs0, int x, int y)
|
||||||
{
|
{
|
||||||
jfileselect *fs = fs0;
|
jfileselect *fs = fs0;
|
||||||
if(!fs->path || !fs->entries)
|
if(!fs->path)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
font_t const *old_font = dfont(fs->font);
|
font_t const *old_font = dfont(fs->font);
|
||||||
|
@ -393,6 +393,11 @@ static void jfileselect_poly_render(void *fs0, int x, int y)
|
||||||
&& fs->scrollbar_width > 0;
|
&& fs->scrollbar_width > 0;
|
||||||
int entry_width = cw - (scrollbar ? 2 * fs->scrollbar_width : 0);
|
int entry_width = cw - (scrollbar ? 2 * fs->scrollbar_width : 0);
|
||||||
|
|
||||||
|
if(!fs->entries || fs->entry_count == 0) {
|
||||||
|
int text_y = y + (fs->line_spacing + 0) / 2;
|
||||||
|
dprint(x+2, text_y, C_BLACK, "(No entries)");
|
||||||
|
}
|
||||||
|
|
||||||
for(int i = 0; i < fs->visible_lines && i < fs->entry_count; i++) {
|
for(int i = 0; i < fs->visible_lines && i < fs->entry_count; i++) {
|
||||||
bool selected = (fs->cursor == fs->scroll + i);
|
bool selected = (fs->cursor == fs->scroll + i);
|
||||||
struct fileinfo *info = &finfo[fs->scroll + i];
|
struct fileinfo *info = &finfo[fs->scroll + i];
|
||||||
|
@ -440,7 +445,7 @@ static void jfileselect_poly_render(void *fs0, int x, int y)
|
||||||
static bool jfileselect_poly_event(void *fs0, jevent e)
|
static bool jfileselect_poly_event(void *fs0, jevent e)
|
||||||
{
|
{
|
||||||
jfileselect *fs = fs0;
|
jfileselect *fs = fs0;
|
||||||
if(!fs->path || !fs->entries)
|
if(!fs->path)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(e.type == JINPUT_CANCELED && e.source == fs->saveas_input) {
|
if(e.type == JINPUT_CANCELED && e.source == fs->saveas_input) {
|
||||||
|
@ -510,7 +515,7 @@ static bool jfileselect_poly_event(void *fs0, jevent e)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(key == KEY_EXE) {
|
else if(key == KEY_EXE && fs->entries) {
|
||||||
struct fileinfo *finfo = fs->entries;
|
struct fileinfo *finfo = fs->entries;
|
||||||
struct fileinfo *i = &finfo[fs->cursor];
|
struct fileinfo *i = &finfo[fs->cursor];
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue