Added extended submenus to overview.c

This commit is contained in:
vurtun 2017-12-07 11:50:27 +01:00
parent f7833d0379
commit a9e5e7299c

View File

@ -36,9 +36,10 @@ overview(struct nk_context *ctx)
static nk_size mprog = 60; static nk_size mprog = 60;
static int mslider = 10; static int mslider = 10;
static int mcheck = nk_true; static int mcheck = nk_true;
nk_menubar_begin(ctx); nk_menubar_begin(ctx);
nk_layout_row_begin(ctx, NK_STATIC, 25, 4);
/* menu #1 */
nk_layout_row_begin(ctx, NK_STATIC, 25, 5);
nk_layout_row_push(ctx, 45); nk_layout_row_push(ctx, 45);
if (nk_menu_begin_label(ctx, "MENU", NK_TEXT_LEFT, nk_vec2(120, 200))) if (nk_menu_begin_label(ctx, "MENU", NK_TEXT_LEFT, nk_vec2(120, 200)))
{ {
@ -55,6 +56,59 @@ overview(struct nk_context *ctx)
nk_checkbox_label(ctx, "check", &check); nk_checkbox_label(ctx, "check", &check);
nk_menu_end(ctx); nk_menu_end(ctx);
} }
/* menu #2 */
nk_layout_row_push(ctx, 60);
if (nk_menu_begin_label(ctx, "ADVANCED", NK_TEXT_LEFT, nk_vec2(200, 600)))
{
enum menu_state {MENU_NONE,MENU_FILE, MENU_EDIT,MENU_VIEW,MENU_CHART};
static enum menu_state menu_state = MENU_NONE;
enum nk_collapse_states state;
state = (menu_state == MENU_FILE) ? NK_MAXIMIZED: NK_MINIMIZED;
if (nk_tree_state_push(ctx, NK_TREE_TAB, "FILE", &state)) {
menu_state = MENU_FILE;
nk_menu_item_label(ctx, "New", NK_TEXT_LEFT);
nk_menu_item_label(ctx, "Open", NK_TEXT_LEFT);
nk_menu_item_label(ctx, "Save", NK_TEXT_LEFT);
nk_menu_item_label(ctx, "Close", NK_TEXT_LEFT);
nk_menu_item_label(ctx, "Exit", NK_TEXT_LEFT);
nk_tree_pop(ctx);
} else menu_state = (menu_state == MENU_FILE) ? MENU_NONE: menu_state;
state = (menu_state == MENU_EDIT) ? NK_MAXIMIZED: NK_MINIMIZED;
if (nk_tree_state_push(ctx, NK_TREE_TAB, "EDIT", &state)) {
menu_state = MENU_EDIT;
nk_menu_item_label(ctx, "Copy", NK_TEXT_LEFT);
nk_menu_item_label(ctx, "Delete", NK_TEXT_LEFT);
nk_menu_item_label(ctx, "Cut", NK_TEXT_LEFT);
nk_menu_item_label(ctx, "Paste", NK_TEXT_LEFT);
nk_tree_pop(ctx);
} else menu_state = (menu_state == MENU_EDIT) ? MENU_NONE: menu_state;
state = (menu_state == MENU_VIEW) ? NK_MAXIMIZED: NK_MINIMIZED;
if (nk_tree_state_push(ctx, NK_TREE_TAB, "VIEW", &state)) {
menu_state = MENU_VIEW;
nk_menu_item_label(ctx, "About", NK_TEXT_LEFT);
nk_menu_item_label(ctx, "Options", NK_TEXT_LEFT);
nk_menu_item_label(ctx, "Customize", NK_TEXT_LEFT);
nk_tree_pop(ctx);
} else menu_state = (menu_state == MENU_VIEW) ? MENU_NONE: menu_state;
state = (menu_state == MENU_CHART) ? NK_MAXIMIZED: NK_MINIMIZED;
if (nk_tree_state_push(ctx, NK_TREE_TAB, "CHART", &state)) {
size_t i = 0;
const float values[]={26.0f,13.0f,30.0f,15.0f,25.0f,10.0f,20.0f,40.0f,12.0f,8.0f,22.0f,28.0f};
menu_state = MENU_CHART;
nk_layout_row_dynamic(ctx, 150, 1);
nk_chart_begin(ctx, NK_CHART_COLUMN, LEN(values), 0, 50);
for (i = 0; i < LEN(values); ++i)
nk_chart_push(ctx, values[i]);
nk_chart_end(ctx);
nk_tree_pop(ctx);
} else menu_state = (menu_state == MENU_CHART) ? MENU_NONE: menu_state;
nk_menu_end(ctx);
}
/* menu widgets */
nk_layout_row_push(ctx, 70); nk_layout_row_push(ctx, 70);
nk_progress(ctx, &mprog, 100, NK_MODIFIABLE); nk_progress(ctx, &mprog, 100, NK_MODIFIABLE);
nk_slider_int(ctx, 0, &mslider, 16, 1); nk_slider_int(ctx, 0, &mslider, 16, 1);