added style selector in demo

This commit is contained in:
Richard Gill 2021-05-01 17:48:17 +02:00
parent 24594c8f75
commit 1ae558aa7f
2 changed files with 19 additions and 0 deletions

View File

@ -16,6 +16,11 @@ overview(struct nk_context *ctx)
static enum nk_style_header_align header_align = NK_HEADER_RIGHT;
static int show_app_about = nk_false;
#ifdef INCLUDE_STYLE
static const char* themes[] = {"Black", "White", "Red", "Blue", "Dark"};
static int current_theme = 0;
#endif
/* window flags */
window_flags = 0;
ctx->style.window.header.align = header_align;
@ -129,6 +134,18 @@ overview(struct nk_context *ctx)
} else show_app_about = nk_false;
}
#ifdef INCLUDE_STYLE
/* style selector */
nk_layout_row_static(ctx, 25, 200, 1);
{
int new_theme = nk_combo(ctx, themes, NK_LEN(themes), current_theme, 25, nk_vec2(200, 200));
if (new_theme != current_theme) {
current_theme = new_theme;
set_style(ctx, current_theme);
}
}
#endif
/* window flags */
if (nk_tree_push(ctx, NK_TREE_TAB, "Window", NK_MINIMIZED)) {
nk_layout_row_dynamic(ctx, 30, 2);

View File

@ -86,6 +86,8 @@ main(void)
nk_init_default(ctx, font);
#ifdef INCLUDE_STYLE
set_style(ctx, THEME_BLACK);
/*nk_style_push_float(ctx, &ctx->style.window.rounding, 20.0f);*/
/*set_style(ctx, THEME_WHITE);*/
/*set_style(ctx, THEME_RED);*/
/*set_style(ctx, THEME_BLUE);*/