diff --git a/demo/style_configurator.c b/demo/common/style_configurator.c similarity index 93% rename from demo/style_configurator.c rename to demo/common/style_configurator.c index a9a1b44..645df6e 100644 --- a/demo/style_configurator.c +++ b/demo/common/style_configurator.c @@ -26,10 +26,11 @@ static const char* symbols[NK_SYMBOL_MAX] = static int style_rgb(struct nk_context* ctx, const char* name, struct nk_color* color) { + struct nk_colorf colorf; nk_label(ctx, name, NK_TEXT_LEFT); if (nk_combo_begin_color(ctx, *color, nk_vec2(nk_widget_width(ctx), 400))) { nk_layout_row_dynamic(ctx, 120, 1); - struct nk_colorf colorf = nk_color_picker(ctx, nk_color_cf(*color), NK_RGB); + colorf = nk_color_picker(ctx, nk_color_cf(*color), NK_RGB); nk_layout_row_dynamic(ctx, 25, 1); colorf.r = nk_propertyf(ctx, "#R:", 0, colorf.r, 1.0f, 0.01f,0.005f); colorf.g = nk_propertyf(ctx, "#G:", 0, colorf.g, 1.0f, 0.01f,0.005f); @@ -43,7 +44,7 @@ style_rgb(struct nk_context* ctx, const char* name, struct nk_color* color) return 0; } -// TODO style_style_item? how to handle images if at all? +/* TODO style_style_item? how to handle images if at all? */ static void style_item_color(struct nk_context* ctx, const char* name, struct nk_style_item* item) { @@ -64,7 +65,7 @@ style_vec2(struct nk_context* ctx, const char* name, struct nk_vec2* vec) } } -// style_general? pass array in instead of static? +/* style_general? pass array in instead of static? */ static void style_global_colors(struct nk_context* ctx, struct nk_color color_table[NK_COLOR_COUNT]) { @@ -101,9 +102,10 @@ style_global_colors(struct nk_context* ctx, struct nk_color color_table[NK_COLOR }; int clicked = 0; + int i; nk_layout_row_dynamic(ctx, 30, 2); - for (int i=0; istyle.slider.dec_button }; + dups[0] = &ctx->style.slider.dec_button; style_button(ctx, &ctx->style.slider.inc_button, dups, 1); nk_tree_pop(ctx); } @@ -324,7 +331,7 @@ style_progress(struct nk_context* ctx, struct nk_style_progress* out_style) style_item_color(ctx, "Cursor Hover:", &prog.cursor_hover); style_item_color(ctx, "Cursor Active:", &prog.cursor_active); - // TODO rgba? + /* TODO rgba? */ style_rgb(ctx, "Border Color:", &prog.border_color); style_rgb(ctx, "Cursor Border Color:", &prog.cursor_border_color); @@ -343,6 +350,7 @@ static void style_scrollbars(struct nk_context* ctx, struct nk_style_scrollbar* out_style, struct nk_style_scrollbar** duplicate_styles, int n_dups) { struct nk_style_scrollbar scroll = *out_style; + struct nk_style_button* dups[3]; nk_layout_row_dynamic(ctx, 30, 2); @@ -353,7 +361,7 @@ style_scrollbars(struct nk_context* ctx, struct nk_style_scrollbar* out_style, s style_item_color(ctx, "Cursor Hover:", &scroll.cursor_hover); style_item_color(ctx, "Cursor Active:", &scroll.cursor_active); - // TODO rgba? + /* TODO rgba? */ style_rgb(ctx, "Border Color:", &scroll.border_color); style_rgb(ctx, "Cursor Border Color:", &scroll.cursor_border_color); @@ -362,11 +370,11 @@ style_scrollbars(struct nk_context* ctx, struct nk_style_scrollbar* out_style, s nk_property_float(ctx, "#Border:", -100.0f, &scroll.border, 100.0f, 1,0.5f); nk_property_float(ctx, "#Rounding:", -100.0f, &scroll.rounding, 100.0f, 1,0.5f); - // TODO naming inconsistency with style_scrollress? + /* TODO naming inconsistency with style_scrollress? */ nk_property_float(ctx, "#Cursor Border:", -100.0f, &scroll.border_cursor, 100.0f, 1,0.5f); nk_property_float(ctx, "#Cursor Rounding:", -100.0f, &scroll.rounding_cursor, 100.0f, 1,0.5f); - // TODO what is wrong with scrollbar buttons? Also look into controlling the total width (and height) of scrollbars + /* TODO what is wrong with scrollbar buttons? Also look into controlling the total width (and height) of scrollbars */ nk_layout_row_dynamic(ctx, 30, 1); nk_checkbox_label(ctx, "Show Buttons", &scroll.show_buttons); @@ -377,11 +385,11 @@ style_scrollbars(struct nk_context* ctx, struct nk_style_scrollbar* out_style, s nk_label(ctx, "Dec Symbol:", NK_TEXT_LEFT); scroll.dec_symbol = nk_combo(ctx, symbols, NK_SYMBOL_MAX, scroll.dec_symbol, 25, nk_vec2(200,200)); - //nk_layout_row_dynamic(ctx, 30, 1); + /* nk_layout_row_dynamic(ctx, 30, 1); */ if (nk_tree_push(ctx, NK_TREE_TAB, "Scrollbar Buttons", NK_MINIMIZED)) { - struct nk_style_button* dups[3] = { &ctx->style.scrollh.dec_button, - &ctx->style.scrollv.inc_button, - &ctx->style.scrollv.dec_button }; + dups[0] = &ctx->style.scrollh.dec_button; + dups[1] = &ctx->style.scrollv.inc_button; + dups[2] = &ctx->style.scrollv.dec_button; style_button(ctx, &ctx->style.scrollh.inc_button, dups, 3); nk_tree_pop(ctx); } @@ -389,7 +397,8 @@ style_scrollbars(struct nk_context* ctx, struct nk_style_scrollbar* out_style, s *out_style = scroll; if (duplicate_styles) { - for (int i=0; istyle; + style = &ctx->style; if (nk_begin(ctx, "Configurator", nk_rect(10, 10, 400, 600), window_flags)) { @@ -713,12 +729,12 @@ style_configurator(struct nk_context *ctx, struct nk_color color_table[NK_COLOR_ } if (nk_tree_push(ctx, NK_TREE_TAB, "Tab Min/Max Buttons", NK_MINIMIZED)) { - struct nk_style_button* dups[1] = { &style->tab.tab_maximize_button }; + dups[0] = &style->tab.tab_maximize_button; style_button(ctx, &style->tab.tab_minimize_button, dups, 1); nk_tree_pop(ctx); } if (nk_tree_push(ctx, NK_TREE_TAB, "Node Min/Max Buttons", NK_MINIMIZED)) { - struct nk_style_button* dups[1] = { &style->tab.node_maximize_button }; + dups[0] = &style->tab.node_maximize_button; style_button(ctx, &style->tab.node_minimize_button, dups, 1); nk_tree_pop(ctx); } @@ -760,7 +776,8 @@ style_configurator(struct nk_context *ctx, struct nk_color color_table[NK_COLOR_ if (nk_tree_push(ctx, NK_TREE_TAB, "Scrollbars", NK_MINIMIZED)) { - struct nk_style_scrollbar* dups[1] = { &style->scrollv }; + struct nk_style_scrollbar* dups[1]; + dups[0] = &style->scrollv; style_scrollbars(ctx, &style->scrollh, dups, 1); nk_tree_pop(ctx); } diff --git a/demo/sdl_opengl3/main.c b/demo/sdl_opengl3/main.c index 67ec8b6..715413b 100644 --- a/demo/sdl_opengl3/main.c +++ b/demo/sdl_opengl3/main.c @@ -69,7 +69,7 @@ #include "../../demo/common/overview.c" #endif #ifdef INCLUDE_OVERVIEW - #include "../style_configurator.c" + #include "../../demo/common/style_configurator.c" #endif #ifdef INCLUDE_NODE_EDITOR #include "../../demo/common/node_editor.c" @@ -92,6 +92,11 @@ int main(int argc, char *argv[]) struct nk_context *ctx; struct nk_colorf bg; + #ifdef INCLUDE_CONFIGURATOR + static struct nk_color color_table[NK_COLOR_COUNT]; + memcpy(color_table, nk_default_color_style, sizeof(color_table)); + #endif + NK_UNUSED(argc); NK_UNUSED(argv); @@ -146,11 +151,6 @@ int main(int argc, char *argv[]) #endif #endif - #ifdef INCLUDE_CONFIGURATOR - static struct nk_color color_table[NK_COLOR_COUNT]; - memcpy(color_table, nk_default_color_style, sizeof(color_table)); - #endif - bg.r = 0.10f, bg.g = 0.18f, bg.b = 0.24f, bg.a = 1.0f; while (running) {