From 291e0a44caf24e93d7afb9ae05e81bb39678c346 Mon Sep 17 00:00:00 2001 From: Robert Winkler Date: Mon, 9 Mar 2020 17:38:29 -0700 Subject: [PATCH] rename and improve style_colors to style_global_colors Now it only updates the colors after one of the dropdowns has been clicked, not every frame that the tree/tab is expanded --- demo/style_configurator.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/demo/style_configurator.c b/demo/style_configurator.c index fc79aae07..c0c302a45 100644 --- a/demo/style_configurator.c +++ b/demo/style_configurator.c @@ -21,7 +21,7 @@ static const char* symbols[NK_SYMBOL_MAX] = "MINUS" }; -static void +static int style_rgb(struct nk_context* ctx, const char* name, struct nk_color* color) { nk_label(ctx, name, NK_TEXT_LEFT); @@ -36,7 +36,9 @@ style_rgb(struct nk_context* ctx, const char* name, struct nk_color* color) *color = nk_rgb_cf(colorf); nk_combo_end(ctx); + return 1; } + return 0; } // TODO style_style_item? how to handle images if at all? @@ -62,7 +64,7 @@ style_vec2(struct nk_context* ctx, const char* name, struct nk_vec2* vec) // style_general? pass array in instead of static? static void -style_colors(struct nk_context* ctx, struct nk_color color_table[NK_COLOR_COUNT]) +style_global_colors(struct nk_context* ctx, struct nk_color color_table[NK_COLOR_COUNT]) { const char* color_labels[NK_COLOR_COUNT] = { @@ -96,12 +98,16 @@ style_colors(struct nk_context* ctx, struct nk_color color_table[NK_COLOR_COUNT] "COLOR_TAB_HEADER:" }; + int clicked = 0; + nk_layout_row_dynamic(ctx, 30, 2); for (int i=0; i