Merge pull request #436 from crazyBaboon/ImproveFileBrowser

Further improve file_browser.c
This commit is contained in:
Rob Loach 2022-04-02 23:07:01 -04:00 committed by GitHub
commit 64c6f73630
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -372,9 +372,12 @@ file_browser_run(struct file_browser *browser, struct nk_context *ctx)
int ret = 0;
struct media *media = browser->media;
struct nk_rect total_space;
static nk_bool file_browser_is_open = nk_true;
if (file_browser_is_open)
{
if (nk_begin(ctx, "File Browser", nk_rect(50, 50, 600, 400),
NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_SCALABLE|
NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_SCALABLE|NK_WINDOW_NO_SCROLLBAR|
NK_WINDOW_CLOSABLE|NK_WINDOW_MINIMIZABLE|NK_WINDOW_TITLE))
{
static float ratio[] = {0.25f, NK_UNDEFINED};
@ -405,7 +408,7 @@ file_browser_run(struct file_browser *browser, struct nk_context *ctx)
/* window layout */
total_space = nk_window_get_content_region(ctx);
nk_layout_row(ctx, NK_DYNAMIC, total_space.h, 2, ratio);
nk_layout_row(ctx, NK_DYNAMIC, total_space.h - 40, 2, ratio);
nk_group_begin(ctx, "Special", NK_WINDOW_NO_SCROLLBAR);
{
@ -424,7 +427,7 @@ file_browser_run(struct file_browser *browser, struct nk_context *ctx)
}
/* output directory content window */
nk_group_begin(ctx, "Content", 0);
nk_group_begin(ctx, "Content", NK_WINDOW_BORDER);
{
int index = -1;
size_t i = 0, j = 0;
@ -478,8 +481,20 @@ file_browser_run(struct file_browser *browser, struct nk_context *ctx)
}
nk_group_end(ctx);
}
nk_layout_row_dynamic(ctx, 30, 5);
nk_label(ctx,"",NK_TEXT_LEFT);
nk_label(ctx,"",NK_TEXT_LEFT);
nk_label(ctx,"",NK_TEXT_LEFT);
if(nk_button_label(ctx, "Cancel"))
{
fprintf(stdout, "File dialog has been closed!\n");
file_browser_is_open = nk_false;
}
if(nk_button_label(ctx, "Open"))
fprintf(stdout, "Insert routine to open/save the file!\n");
}
nk_end(ctx);
}
return ret;
}