From ec430918d51db15c7fe4ad8c45c2040858384bd8 Mon Sep 17 00:00:00 2001 From: Robert Winkler Date: Sat, 7 Mar 2020 12:53:38 -0700 Subject: [PATCH 01/13] First draft --- demo/sdl_opengl3/main.c | 10 +- demo/style_configurator.c | 2822 +++++++++++++++++++++++++++++++++++++ 2 files changed, 2831 insertions(+), 1 deletion(-) create mode 100644 demo/style_configurator.c diff --git a/demo/sdl_opengl3/main.c b/demo/sdl_opengl3/main.c index 0e49cfc0f..2b5604f70 100644 --- a/demo/sdl_opengl3/main.c +++ b/demo/sdl_opengl3/main.c @@ -43,6 +43,7 @@ /*#define INCLUDE_CALCULATOR */ /*#define INCLUDE_CANVAS */ #define INCLUDE_OVERVIEW +#define INCLUDE_CONFIGURATOR /*#define INCLUDE_NODE_EDITOR */ #ifdef INCLUDE_ALL @@ -50,6 +51,7 @@ #define INCLUDE_CALCULATOR #define INCLUDE_CANVAS #define INCLUDE_OVERVIEW + #define INCLUDE_CONFIGURATOR #define INCLUDE_NODE_EDITOR #endif @@ -65,6 +67,9 @@ #ifdef INCLUDE_OVERVIEW #include "../../demo/common/overview.c" #endif +#ifdef INCLUDE_OVERVIEW + #include "../style_configurator.c" +#endif #ifdef INCLUDE_NODE_EDITOR #include "../../demo/common/node_editor.c" #endif @@ -74,7 +79,7 @@ * DEMO * * ===============================================================*/ -int main(int argc, char *argv[]) +int main(void) { /* Platform */ SDL_Window *win; @@ -183,6 +188,9 @@ int main(int argc, char *argv[]) #ifdef INCLUDE_OVERVIEW overview(ctx); #endif + #ifdef INCLUDE_OVERVIEW + style_configurator(ctx); + #endif #ifdef INCLUDE_NODE_EDITOR node_editor(ctx); #endif diff --git a/demo/style_configurator.c b/demo/style_configurator.c new file mode 100644 index 000000000..44553dd50 --- /dev/null +++ b/demo/style_configurator.c @@ -0,0 +1,2822 @@ + +// TODO design decisions +// plural or not? ie style_button or style_buttons? +// use the duplicate array method, or just yet the user +// manually set those after calling the function by accessing ctx->style->*? + +// style_general? pass array in instead of static? +static void +style_colors(struct nk_context* ctx, struct nk_color color_table[NK_COLOR_COUNT]) +{ + const char* color_labels[NK_COLOR_COUNT] = + { + "COLOR_TEXT:", + "COLOR_WINDOW:", + "COLOR_HEADER:", + "COLOR_BORDER:", + "COLOR_BUTTON:", + "COLOR_BUTTON_HOVER:", + "COLOR_BUTTON_ACTIVE:", + "COLOR_TOGGLE:", + "COLOR_TOGGLE_HOVER:", + "COLOR_TOGGLE_CURSOR:", + "COLOR_SELECT:", + "COLOR_SELECT_ACTIVE:", + "COLOR_SLIDER:", + "COLOR_SLIDER_CURSOR:", + "COLOR_SLIDER_CURSOR_HOVER:", + "COLOR_SLIDER_CURSOR_ACTIVE:", + "COLOR_PROPERTY:", + "COLOR_EDIT:", + "COLOR_EDIT_CURSOR:", + "COLOR_COMBO:", + "COLOR_CHART:", + "COLOR_CHART_COLOR:", + "COLOR_CHART_COLOR_HIGHLIGHT:", + "COLOR_SCROLLBAR:", + "COLOR_SCROLLBAR_CURSOR:", + "COLOR_SCROLLBAR_CURSOR_HOVER:", + "COLOR_SCROLLBAR_CURSOR_ACTIVE:", + "COLOR_TAB_HEADER:" + }; + + nk_layout_row_dynamic(ctx, 30, 2); + for (int i=0; itext; + //text->color = table[NK_COLOR_TEXT]; + //text->padding = nk_vec2(0,0); + + char buffer[64]; + + nk_layout_row_dynamic(ctx, 30, 2); + nk_label(ctx, "Color:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, text.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(text.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + text.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Padding:", NK_TEXT_LEFT); + sprintf(buffer, "%.2f, %.2f", text.padding.x, text.padding.y); + if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { + nk_layout_row_dynamic(ctx, 25, 1); + nk_property_float(ctx, "#X:", -100.0f, &text.padding.x, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Y:", -100.0f, &text.padding.y, 100.0f, 1,0.5f); + nk_combo_end(ctx); + } + + *out_style = text; +} + +static void +style_button(struct nk_context* ctx, struct nk_style_button* out_style, struct nk_style_button** duplicate_styles, int n_dups) +{ + struct nk_style_button button = *out_style; + //button = &style->button; + //nk_zero_struct(*button); + //button->normal = nk_style_item_color(table[NK_COLOR_BUTTON]); + //button->hover = nk_style_item_color(table[NK_COLOR_BUTTON_HOVER]); + //button->active = nk_style_item_color(table[NK_COLOR_BUTTON_ACTIVE]); + //button->border_color = table[NK_COLOR_BORDER]; + //button->text_background = table[NK_COLOR_BUTTON]; + //button->text_normal = table[NK_COLOR_TEXT]; + //button->text_hover = table[NK_COLOR_TEXT]; + //button->text_active = table[NK_COLOR_TEXT]; + //button->padding = nk_vec2(2.0f,2.0f); + //button->image_padding = nk_vec2(0.0f,0.0f); + //button->touch_padding = nk_vec2(0.0f, 0.0f); + //button->userdata = nk_handle_ptr(0); + //button->text_alignment = NK_TEXT_CENTERED; + //button->border = 1.0f; + //button->rounding = 4.0f; + //button->draw_begin = 0; + //button->draw_end = 0; + + + char buffer[64]; + + // Assumes all the style items are colors not images + nk_layout_row_dynamic(ctx, 30, 2); + nk_label(ctx, "Normal:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, button.normal.data.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(button.normal.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + button.normal.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Hover:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, button.hover.data.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(button.hover.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + button.hover.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Active:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, button.active.data.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(button.active.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + button.active.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Border:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, button.border_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(button.border_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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + button.border_color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Text Background:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, button.text_background, 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(button.text_background), 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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + button.text_background = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Text Normal:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, button.text_normal, 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(button.text_normal), 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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + button.text_normal = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Text Hover:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, button.text_hover, 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(button.text_hover), 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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + button.text_hover = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Text Active:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, button.text_active, 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(button.text_active), 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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + button.text_active = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Padding:", NK_TEXT_LEFT); + sprintf(buffer, "%.2f, %.2f", button.padding.x, button.padding.y); + if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { + nk_layout_row_dynamic(ctx, 25, 1); + nk_property_float(ctx, "#X:", -100.0f, &button.padding.x, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Y:", -100.0f, &button.padding.y, 100.0f, 1,0.5f); + nk_combo_end(ctx); + } + + nk_label(ctx, "Image Padding:", NK_TEXT_LEFT); + sprintf(buffer, "%.2f, %.2f", button.image_padding.x, button.image_padding.y); + if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { + nk_layout_row_dynamic(ctx, 25, 1); + nk_property_float(ctx, "#X:", -100.0f, &button.image_padding.x, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Y:", -100.0f, &button.image_padding.y, 100.0f, 1,0.5f); + nk_combo_end(ctx); + } + + nk_label(ctx, "Touch Padding:", NK_TEXT_LEFT); + sprintf(buffer, "%.2f, %.2f", button.touch_padding.x, button.touch_padding.y); + if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { + nk_layout_row_dynamic(ctx, 25, 1); + nk_property_float(ctx, "#X:", -100.0f, &button.touch_padding.x, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Y:", -100.0f, &button.touch_padding.y, 100.0f, 1,0.5f); + nk_combo_end(ctx); + } + + + /* +enum nk_text_align { +NK_TEXT_ALIGN_LEFT = 0x01, +NK_TEXT_ALIGN_CENTERED = 0x02, +NK_TEXT_ALIGN_RIGHT = 0x04, +NK_TEXT_ALIGN_TOP = 0x08, +NK_TEXT_ALIGN_MIDDLE = 0x10, +NK_TEXT_ALIGN_BOTTOM = 0x20 +}; +enum nk_text_alignment { +NK_TEXT_LEFT = NK_TEXT_ALIGN_MIDDLE|NK_TEXT_ALIGN_LEFT, +NK_TEXT_CENTERED = NK_TEXT_ALIGN_MIDDLE|NK_TEXT_ALIGN_CENTERED, +NK_TEXT_RIGHT = NK_TEXT_ALIGN_MIDDLE|NK_TEXT_ALIGN_RIGHT +}; +*/ + // TODO support combining with TOP/MIDDLE/BOTTOM .. separate combo? + const char* alignments[] = { "LEFT", "CENTERED", "RIGHT" }; + int aligns[3] = { NK_TEXT_LEFT, NK_TEXT_CENTERED, NK_TEXT_RIGHT }; + int cur_align; + if (button.text_alignment == NK_TEXT_LEFT) { + cur_align = 0; + } else if (button.text_alignment == NK_TEXT_CENTERED) { + cur_align = 1; + } else { + cur_align = 2; + } + nk_label(ctx, "Text Alignment:", NK_TEXT_LEFT); + cur_align = nk_combo(ctx, alignments, NK_LEN(alignments), cur_align, 25, nk_vec2(200,200)); + button.text_alignment = aligns[cur_align]; + + nk_property_float(ctx, "#Border:", -100.0f, &button.border, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Rounding:", -100.0f, &button.rounding, 100.0f, 1,0.5f); + + // + // optional user callback stuff + //button->userdata = nk_handle_ptr(0); + //button->draw_begin = 0; + //button->draw_end = 0; + + + *out_style = button; + if (duplicate_styles) { + for (int i=0; icheckbox; + //nk_zero_struct(*toggle); + //toggle->normal = nk_style_item_color(table[NK_COLOR_TOGGLE]); + //toggle->hover = nk_style_item_color(table[NK_COLOR_TOGGLE_HOVER]); + //toggle->active = nk_style_item_color(table[NK_COLOR_TOGGLE_HOVER]); + //toggle->cursor_normal = nk_style_item_color(table[NK_COLOR_TOGGLE_CURSOR]); + //toggle->cursor_hover = nk_style_item_color(table[NK_COLOR_TOGGLE_CURSOR]); + //toggle->userdata = nk_handle_ptr(0); + //toggle->text_background = table[NK_COLOR_WINDOW]; + //toggle->text_normal = table[NK_COLOR_TEXT]; + //toggle->text_hover = table[NK_COLOR_TEXT]; + //toggle->text_active = table[NK_COLOR_TEXT]; + //toggle->padding = nk_vec2(2.0f, 2.0f); + //toggle->touch_padding = nk_vec2(0,0); + //toggle->border_color = nk_rgba(0,0,0,0); + //toggle->border = 0.0f; + //toggle->spacing = 4; + // + + char buffer[64]; + + // Assumes all the style items are colors not images + nk_layout_row_dynamic(ctx, 30, 2); + + nk_label(ctx, "Normal:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, toggle.normal.data.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(toggle.normal.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + toggle.normal.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Hover:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, toggle.hover.data.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(toggle.hover.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + toggle.hover.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Active:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, toggle.active.data.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(toggle.active.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + toggle.active.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Cursor Normal:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, toggle.cursor_normal.data.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(toggle.cursor_normal.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + toggle.cursor_normal.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Cursor Hover:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, toggle.cursor_hover.data.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(toggle.cursor_hover.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + toggle.cursor_hover.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Text Background:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, toggle.text_background, 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(toggle.text_background), 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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + toggle.text_background = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Text Normal:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, toggle.text_normal, 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(toggle.text_normal), 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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + toggle.text_normal = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Text Hover:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, toggle.text_hover, 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(toggle.text_hover), 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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + toggle.text_hover = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Text Active:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, toggle.text_active, 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(toggle.text_active), 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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + toggle.text_active = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Padding:", NK_TEXT_LEFT); + sprintf(buffer, "%.2f, %.2f", toggle.padding.x, toggle.padding.y); + if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { + nk_layout_row_dynamic(ctx, 25, 1); + nk_property_float(ctx, "#X:", -100.0f, &toggle.padding.x, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Y:", -100.0f, &toggle.padding.y, 100.0f, 1,0.5f); + nk_combo_end(ctx); + } + + nk_label(ctx, "Touch Padding:", NK_TEXT_LEFT); + sprintf(buffer, "%.2f, %.2f", toggle.touch_padding.x, toggle.touch_padding.y); + if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { + nk_layout_row_dynamic(ctx, 25, 1); + nk_property_float(ctx, "#X:", -100.0f, &toggle.touch_padding.x, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Y:", -100.0f, &toggle.touch_padding.y, 100.0f, 1,0.5f); + nk_combo_end(ctx); + } + + nk_label(ctx, "Border Color:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, toggle.border_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(toggle.border_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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + toggle.border_color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_property_float(ctx, "#Border:", -100.0f, &toggle.border, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Spacing:", -100.0f, &toggle.spacing, 100.0f, 1,0.5f); + + + *out_style = toggle; + +} + +static void +style_selectable(struct nk_context* ctx, struct nk_style_selectable* out_style) +{ + struct nk_style_selectable select = *out_style; + //select = &style->selectable; + //nk_zero_struct(*select); + //select->normal = nk_style_item_color(table[NK_COLOR_SELECT]); + //select->hover = nk_style_item_color(table[NK_COLOR_SELECT]); + //select->pressed = nk_style_item_color(table[NK_COLOR_SELECT]); + //select->normal_active = nk_style_item_color(table[NK_COLOR_SELECT_ACTIVE]); + //select->hover_active = nk_style_item_color(table[NK_COLOR_SELECT_ACTIVE]); + //select->pressed_active = nk_style_item_color(table[NK_COLOR_SELECT_ACTIVE]); + //select->text_normal = table[NK_COLOR_TEXT]; + //select->text_hover = table[NK_COLOR_TEXT]; + //select->text_pressed = table[NK_COLOR_TEXT]; + //select->text_normal_active = table[NK_COLOR_TEXT]; + //select->text_hover_active = table[NK_COLOR_TEXT]; + //select->text_pressed_active = table[NK_COLOR_TEXT]; + //select->padding = nk_vec2(2.0f,2.0f); + //select->image_padding = nk_vec2(2.0f,2.0f); + //select->touch_padding = nk_vec2(0,0); + //select->userdata = nk_handle_ptr(0); + //select->rounding = 0.0f; + //select->draw_begin = 0; + //select->draw_end = 0; + + char buffer[64]; + + // Assumes all the style items are colors not images + nk_layout_row_dynamic(ctx, 30, 2); + nk_label(ctx, "Normal:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, select.normal.data.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(select.normal.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + select.normal.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Hover:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, select.hover.data.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(select.hover.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + select.hover.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Pressed:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, select.pressed.data.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(select.pressed.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + select.pressed.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Normal Active:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, select.normal_active.data.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(select.normal_active.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + select.normal_active.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Hover Active:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, select.hover_active.data.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(select.hover_active.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + select.hover_active.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Pressed Active:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, select.pressed_active.data.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(select.pressed_active.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + select.pressed_active.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Text Normal:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, select.text_normal, 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(select.text_normal), 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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + select.text_normal = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Text Hover:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, select.text_hover, 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(select.text_hover), 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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + select.text_hover = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Text Pressed:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, select.text_pressed, 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(select.text_pressed), 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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + select.text_pressed = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Text Normal Active:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, select.text_normal_active, 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(select.text_normal_active), 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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + select.text_normal_active = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Text Hover Active:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, select.text_hover_active, 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(select.text_hover_active), 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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + select.text_hover_active = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Text Pressed Active:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, select.text_pressed_active, 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(select.text_pressed_active), 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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + select.text_pressed_active = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Padding:", NK_TEXT_LEFT); + sprintf(buffer, "%.2f, %.2f", select.padding.x, select.padding.y); + if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { + nk_layout_row_dynamic(ctx, 25, 1); + nk_property_float(ctx, "#X:", -100.0f, &select.padding.x, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Y:", -100.0f, &select.padding.y, 100.0f, 1,0.5f); + nk_combo_end(ctx); + } + + nk_label(ctx, "Image Padding:", NK_TEXT_LEFT); + sprintf(buffer, "%.2f, %.2f", select.image_padding.x, select.image_padding.y); + if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { + nk_layout_row_dynamic(ctx, 25, 1); + nk_property_float(ctx, "#X:", -100.0f, &select.image_padding.x, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Y:", -100.0f, &select.image_padding.y, 100.0f, 1,0.5f); + nk_combo_end(ctx); + } + + nk_label(ctx, "Touch Padding:", NK_TEXT_LEFT); + sprintf(buffer, "%.2f, %.2f", select.touch_padding.x, select.touch_padding.y); + if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { + nk_layout_row_dynamic(ctx, 25, 1); + nk_property_float(ctx, "#X:", -100.0f, &select.touch_padding.x, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Y:", -100.0f, &select.touch_padding.y, 100.0f, 1,0.5f); + nk_combo_end(ctx); + } + + nk_property_float(ctx, "#Rounding:", -100.0f, &select.rounding, 100.0f, 1,0.5f); + + + *out_style = select; +} + +static void +style_slider(struct nk_context* ctx, struct nk_style_slider* out_style) +{ + struct nk_style_slider slider = *out_style; + //slider = &style->slider; + //nk_zero_struct(*slider); + //slider->normal = nk_style_item_hide(); + //slider->hover = nk_style_item_hide(); + //slider->active = nk_style_item_hide(); + //slider->bar_normal = table[NK_COLOR_SLIDER]; + //slider->bar_hover = table[NK_COLOR_SLIDER]; + //slider->bar_active = table[NK_COLOR_SLIDER]; + //slider->bar_filled = table[NK_COLOR_SLIDER_CURSOR]; + //slider->cursor_normal = nk_style_item_color(table[NK_COLOR_SLIDER_CURSOR]); + //slider->cursor_hover = nk_style_item_color(table[NK_COLOR_SLIDER_CURSOR_HOVER]); + //slider->cursor_active = nk_style_item_color(table[NK_COLOR_SLIDER_CURSOR_ACTIVE]); + //slider->inc_symbol = NK_SYMBOL_TRIANGLE_RIGHT; + //slider->dec_symbol = NK_SYMBOL_TRIANGLE_LEFT; + //slider->cursor_size = nk_vec2(16,16); + //slider->padding = nk_vec2(2,2); + //slider->spacing = nk_vec2(2,2); + //slider->userdata = nk_handle_ptr(0); + //slider->show_buttons = nk_false; + //slider->bar_height = 8; + //slider->rounding = 0; + //slider->draw_begin = 0; + //slider->draw_end = 0; + + char buffer[64]; + + // Assumes all the style items are colors not images + nk_layout_row_dynamic(ctx, 30, 2); + + nk_label(ctx, "Normal:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, slider.normal.data.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(slider.normal.data.color), NK_RGBA); + 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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + colorf.a = nk_propertyf(ctx, "#A:", 0, colorf.a, 1.0f, 0.01f,0.005f); + + slider.normal.data.color = nk_rgba_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Hover:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, slider.hover.data.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(slider.hover.data.color), NK_RGBA); + 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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + colorf.a = nk_propertyf(ctx, "#A:", 0, colorf.a, 1.0f, 0.01f,0.005f); + + slider.hover.data.color = nk_rgba_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Active:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, slider.active.data.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(slider.active.data.color), NK_RGBA); + 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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + colorf.a = nk_propertyf(ctx, "#A:", 0, colorf.a, 1.0f, 0.01f,0.005f); + + slider.active.data.color = nk_rgba_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Bar Normal:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, slider.bar_normal, 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(slider.bar_normal), 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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + slider.bar_normal = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Bar Hover:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, slider.bar_hover, 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(slider.bar_hover), 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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + slider.bar_hover = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Bar Active:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, slider.bar_active, 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(slider.bar_active), 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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + slider.bar_active = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Bar Filled:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, slider.bar_filled, 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(slider.bar_filled), 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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + slider.bar_filled = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Cursor Normal:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, slider.cursor_normal.data.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(slider.cursor_normal.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + slider.cursor_normal.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Cursor Hover:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, slider.cursor_hover.data.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(slider.cursor_hover.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + slider.cursor_hover.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Cursor Active:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, slider.cursor_active.data.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(slider.cursor_active.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + slider.cursor_active.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + + nk_label(ctx, "Cursor Size:", NK_TEXT_LEFT); + sprintf(buffer, "%.2f, %.2f", slider.cursor_size.x, slider.cursor_size.y); + if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { + nk_layout_row_dynamic(ctx, 25, 1); + nk_property_float(ctx, "#X:", -100.0f, &slider.cursor_size.x, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Y:", -100.0f, &slider.cursor_size.y, 100.0f, 1,0.5f); + nk_combo_end(ctx); + } + + nk_label(ctx, "Padding:", NK_TEXT_LEFT); + sprintf(buffer, "%.2f, %.2f", slider.padding.x, slider.padding.y); + if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { + nk_layout_row_dynamic(ctx, 25, 1); + nk_property_float(ctx, "#X:", -100.0f, &slider.padding.x, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Y:", -100.0f, &slider.padding.y, 100.0f, 1,0.5f); + nk_combo_end(ctx); + } + + nk_label(ctx, "Spacing:", NK_TEXT_LEFT); + sprintf(buffer, "%.2f, %.2f", slider.spacing.x, slider.spacing.y); + if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { + nk_layout_row_dynamic(ctx, 25, 1); + nk_property_float(ctx, "#X:", -100.0f, &slider.spacing.x, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Y:", -100.0f, &slider.spacing.y, 100.0f, 1,0.5f); + nk_combo_end(ctx); + } + + nk_property_float(ctx, "#Bar Height:", -100.0f, &slider.bar_height, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Rounding:", -100.0f, &slider.rounding, 100.0f, 1,0.5f); + + const char* symbols[NK_SYMBOL_MAX] = +{ + "NONE", + "X", + "UNDERSCORE", + "CIRCLE_SOLID", + "CIRCLE_OUTLINE", + "RECT_SOLID", + "RECT_OUTLINE", + "TRIANGLE_UP", + "TRIANGLE_DOWN", + "TRIANGLE_LEFT", + "TRIANGLE_RIGHT", + "PLUS", + "MINUS" +}; + + nk_layout_row_dynamic(ctx, 30, 1); + nk_checkbox_label(ctx, "Show Buttons", &slider.show_buttons); + + if (slider.show_buttons) { + nk_layout_row_dynamic(ctx, 30, 2); + nk_label(ctx, "Inc Symbol:", NK_TEXT_LEFT); + slider.inc_symbol = nk_combo(ctx, symbols, NK_SYMBOL_MAX, slider.inc_symbol, 25, nk_vec2(200,200)); + nk_label(ctx, "Dec Symbol:", NK_TEXT_LEFT); + slider.dec_symbol = nk_combo(ctx, symbols, NK_SYMBOL_MAX, slider.dec_symbol, 25, nk_vec2(200,200)); + + // necessary or do tree's always take the whole width? + //nk_layout_row_dynamic(ctx, 30, 1); + if (nk_tree_push(ctx, NK_TREE_TAB, "Slider Buttons", NK_MINIMIZED)) { + struct nk_style_button* dups[1] = { &ctx->style.slider.dec_button }; + style_button(ctx, &ctx->style.slider.inc_button, dups, 1); + nk_tree_pop(ctx); + } + + } + + *out_style = slider; +} + +static void +style_progress(struct nk_context* ctx, struct nk_style_progress* out_style) +{ + struct nk_style_progress prog = *out_style; + //prog = &style->progress; + //nk_zero_struct(*prog); + //prog->normal = nk_style_item_color(table[NK_COLOR_SLIDER]); + //prog->hover = nk_style_item_color(table[NK_COLOR_SLIDER]); + //prog->active = nk_style_item_color(table[NK_COLOR_SLIDER]); + //prog->cursor_normal = nk_style_item_color(table[NK_COLOR_SLIDER_CURSOR]); + //prog->cursor_hover = nk_style_item_color(table[NK_COLOR_SLIDER_CURSOR_HOVER]); + //prog->cursor_active = nk_style_item_color(table[NK_COLOR_SLIDER_CURSOR_ACTIVE]); + //prog->border_color = nk_rgba(0,0,0,0); + //prog->cursor_border_color = nk_rgba(0,0,0,0); + //prog->userdata = nk_handle_ptr(0); + //prog->padding = nk_vec2(4,4); + //prog->rounding = 0; + //prog->border = 0; + //prog->cursor_rounding = 0; + //prog->cursor_border = 0; + //prog->draw_begin = 0; + //prog->draw_end = 0; + + char buffer[64]; + + // Assumes all the style items are colors not images + nk_layout_row_dynamic(ctx, 30, 2); + + nk_label(ctx, "Normal:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, prog.normal.data.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(prog.normal.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + prog.normal.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Hover:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, prog.hover.data.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(prog.hover.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + prog.hover.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Active:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, prog.active.data.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(prog.active.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + prog.active.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + + nk_label(ctx, "Cursor Normal:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, prog.cursor_normal.data.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(prog.cursor_normal.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + prog.cursor_normal.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Cursor Hover:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, prog.cursor_hover.data.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(prog.cursor_hover.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + prog.cursor_hover.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Cursor Active:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, prog.cursor_active.data.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(prog.cursor_active.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + prog.cursor_active.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Border Color:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, prog.border_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(prog.border_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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + prog.border_color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Cursor Border Color:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, prog.cursor_border_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(prog.cursor_border_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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + prog.cursor_border_color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Padding:", NK_TEXT_LEFT); + sprintf(buffer, "%.2f, %.2f", prog.padding.x, prog.padding.y); + if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { + nk_layout_row_dynamic(ctx, 25, 1); + nk_property_float(ctx, "#X:", -100.0f, &prog.padding.x, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Y:", -100.0f, &prog.padding.y, 100.0f, 1,0.5f); + nk_combo_end(ctx); + } + + nk_property_float(ctx, "#Rounding:", -100.0f, &prog.rounding, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Border:", -100.0f, &prog.border, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Cursor Rounding:", -100.0f, &prog.cursor_rounding, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Cursor Border:", -100.0f, &prog.cursor_border, 100.0f, 1,0.5f); + + + *out_style = prog; +} + +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; + //scroll = &style->scrollh; + //nk_zero_struct(*scroll); + //scroll->normal = nk_style_item_color(table[NK_COLOR_SCROLLBAR]); + //scroll->hover = nk_style_item_color(table[NK_COLOR_SCROLLBAR]); + //scroll->active = nk_style_item_color(table[NK_COLOR_SCROLLBAR]); + //scroll->cursor_normal = nk_style_item_color(table[NK_COLOR_SCROLLBAR_CURSOR]); + //scroll->cursor_hover = nk_style_item_color(table[NK_COLOR_SCROLLBAR_CURSOR_HOVER]); + //scroll->cursor_active = nk_style_item_color(table[NK_COLOR_SCROLLBAR_CURSOR_ACTIVE]); + //scroll->dec_symbol = NK_SYMBOL_CIRCLE_SOLID; + //scroll->inc_symbol = NK_SYMBOL_CIRCLE_SOLID; + //scroll->userdata = nk_handle_ptr(0); + //scroll->border_color = table[NK_COLOR_SCROLLBAR]; + //scroll->cursor_border_color = table[NK_COLOR_SCROLLBAR]; + //scroll->padding = nk_vec2(0,0); + //scroll->show_buttons = nk_false; + //scroll->border = 0; + //scroll->rounding = 0; + //scroll->border_cursor = 0; + //scroll->rounding_cursor = 0; + //scroll->draw_begin = 0; + //scroll->draw_end = 0; + //style->scrollv = style->scrollh; + + char buffer[64]; + + // Assumes all the style items are colors not images + nk_layout_row_dynamic(ctx, 30, 2); + + nk_label(ctx, "Normal:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, scroll.normal.data.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(scroll.normal.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + scroll.normal.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Hover:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, scroll.hover.data.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(scroll.hover.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + scroll.hover.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Active:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, scroll.active.data.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(scroll.active.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + scroll.active.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + + nk_label(ctx, "Cursor Normal:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, scroll.cursor_normal.data.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(scroll.cursor_normal.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + scroll.cursor_normal.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Cursor Hover:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, scroll.cursor_hover.data.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(scroll.cursor_hover.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + scroll.cursor_hover.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Cursor Active:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, scroll.cursor_active.data.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(scroll.cursor_active.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + scroll.cursor_active.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Border Color:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, scroll.border_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(scroll.border_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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + scroll.border_color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Cursor Border Color:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, scroll.cursor_border_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(scroll.cursor_border_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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + scroll.cursor_border_color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Padding:", NK_TEXT_LEFT); + sprintf(buffer, "%.2f, %.2f", scroll.padding.x, scroll.padding.y); + if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { + nk_layout_row_dynamic(ctx, 25, 1); + nk_property_float(ctx, "#X:", -100.0f, &scroll.padding.x, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Y:", -100.0f, &scroll.padding.y, 100.0f, 1,0.5f); + nk_combo_end(ctx); + } + + 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? + 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); + + + const char* symbols[NK_SYMBOL_MAX] = +{ + "NONE", + "X", + "UNDERSCORE", + "CIRCLE_SOLID", + "CIRCLE_OUTLINE", + "RECT_SOLID", + "RECT_OUTLINE", + "TRIANGLE_UP", + "TRIANGLE_DOWN", + "TRIANGLE_LEFT", + "TRIANGLE_RIGHT", + "PLUS", + "MINUS" +}; + + // 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); + + if (scroll.show_buttons) { + nk_layout_row_dynamic(ctx, 30, 2); + nk_label(ctx, "Inc Symbol:", NK_TEXT_LEFT); + scroll.inc_symbol = nk_combo(ctx, symbols, NK_SYMBOL_MAX, scroll.inc_symbol, 25, nk_vec2(200,200)); + 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); + if (nk_tree_push(ctx, NK_TREE_TAB, "Scrollbar Buttons", NK_MINIMIZED)) { + // TODO best way to handle correctly with duplicate styles + struct nk_style_button* dups[3] = { &ctx->style.scrollh.dec_button, + &ctx->style.scrollv.inc_button, + &ctx->style.scrollv.dec_button }; + style_button(ctx, &ctx->style.scrollh.inc_button, dups, 3); + nk_tree_pop(ctx); + } + } + + + //style->scrollv = style->scrollh; + + *out_style = scroll; + if (duplicate_styles) { + for (int i=0; iedit; + //nk_zero_struct(*edit); + //edit->normal = nk_style_item_color(table[NK_COLOR_EDIT]); + //edit->hover = nk_style_item_color(table[NK_COLOR_EDIT]); + //edit->active = nk_style_item_color(table[NK_COLOR_EDIT]); + //edit->cursor_normal = table[NK_COLOR_TEXT]; + //edit->cursor_hover = table[NK_COLOR_TEXT]; + //edit->cursor_text_normal= table[NK_COLOR_EDIT]; + //edit->cursor_text_hover = table[NK_COLOR_EDIT]; + //edit->border_color = table[NK_COLOR_BORDER]; + //edit->text_normal = table[NK_COLOR_TEXT]; + //edit->text_hover = table[NK_COLOR_TEXT]; + //edit->text_active = table[NK_COLOR_TEXT]; + //edit->selected_normal = table[NK_COLOR_TEXT]; + //edit->selected_hover = table[NK_COLOR_TEXT]; + //edit->selected_text_normal = table[NK_COLOR_EDIT]; + //edit->selected_text_hover = table[NK_COLOR_EDIT]; + //edit->scrollbar_size = nk_vec2(10,10); + //edit->scrollbar = style->scrollv; + //edit->padding = nk_vec2(4,4); + //edit->row_padding = 2; + //edit->cursor_size = 4; + //edit->border = 1; + //edit->rounding = 0; + + char buffer[64]; + + // Assumes all the style items are colors not images + nk_layout_row_dynamic(ctx, 30, 2); + + nk_label(ctx, "Normal:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, edit.normal.data.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(edit.normal.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + edit.normal.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Hover:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, edit.hover.data.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(edit.hover.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + edit.hover.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Active:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, edit.active.data.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(edit.active.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + edit.active.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Cursor Normal:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, edit.cursor_normal, 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(edit.cursor_normal), 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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + edit.cursor_normal = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Cursor Hover:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, edit.cursor_hover, 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(edit.cursor_hover), 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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + edit.cursor_hover = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Cursor Text Normal:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, edit.cursor_text_normal, 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(edit.cursor_text_normal), 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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + edit.cursor_text_normal = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Cursor Text Hover:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, edit.cursor_text_hover, 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(edit.cursor_text_hover), 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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + edit.cursor_text_hover = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Border Color:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, edit.border_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(edit.border_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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + edit.border_color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Text Normal:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, edit.text_normal, 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(edit.text_normal), 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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + edit.text_normal = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Text Hover:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, edit.text_hover, 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(edit.text_hover), 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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + edit.text_hover = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Text Active:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, edit.text_active, 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(edit.text_active), 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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + edit.text_active = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Selected Normal:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, edit.selected_normal, 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(edit.selected_normal), 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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + edit.selected_normal = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Selected Hover:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, edit.selected_hover, 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(edit.selected_hover), 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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + edit.selected_hover = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Selected Text Normal:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, edit.selected_text_normal, 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(edit.selected_text_normal), 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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + edit.selected_text_normal = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Selected Text Hover:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, edit.selected_text_hover, 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(edit.selected_text_hover), 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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + edit.selected_text_hover = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Scrollbar Size:", NK_TEXT_LEFT); + sprintf(buffer, "%.2f, %.2f", edit.scrollbar_size.x, edit.scrollbar_size.y); + if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { + nk_layout_row_dynamic(ctx, 25, 1); + nk_property_float(ctx, "#X:", -100.0f, &edit.scrollbar_size.x, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Y:", -100.0f, &edit.scrollbar_size.y, 100.0f, 1,0.5f); + nk_combo_end(ctx); + } + + nk_label(ctx, "Padding:", NK_TEXT_LEFT); + sprintf(buffer, "%.2f, %.2f", edit.padding.x, edit.padding.y); + if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { + nk_layout_row_dynamic(ctx, 25, 1); + nk_property_float(ctx, "#X:", -100.0f, &edit.padding.x, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Y:", -100.0f, &edit.padding.y, 100.0f, 1,0.5f); + nk_combo_end(ctx); + } + + // TODO subtree? + //edit->scrollbar = style->scrollv; + + nk_property_float(ctx, "#Row Padding:", -100.0f, &edit.row_padding, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Cursor Size:", -100.0f, &edit.cursor_size, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Border:", -100.0f, &edit.border, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Rounding:", -100.0f, &edit.rounding, 100.0f, 1,0.5f); + + + *out_style = edit; +} + +static void +style_property(struct nk_context* ctx, struct nk_style_property* out_style) +{ + struct nk_style_property property = *out_style; + + //property = &style->property; + //nk_zero_struct(*property); + //property->normal = nk_style_item_color(table[NK_COLOR_PROPERTY]); + //property->hover = nk_style_item_color(table[NK_COLOR_PROPERTY]); + //property->active = nk_style_item_color(table[NK_COLOR_PROPERTY]); + //property->border_color = table[NK_COLOR_BORDER]; + //property->label_normal = table[NK_COLOR_TEXT]; + //property->label_hover = table[NK_COLOR_TEXT]; + //property->label_active = table[NK_COLOR_TEXT]; + //property->sym_left = NK_SYMBOL_TRIANGLE_LEFT; + //property->sym_right = NK_SYMBOL_TRIANGLE_RIGHT; + //property->userdata = nk_handle_ptr(0); + //property->padding = nk_vec2(4,4); + //property->border = 1; + //property->rounding = 10; + //property->draw_begin = 0; + //property->draw_end = 0; + + char buffer[64]; + + nk_layout_row_dynamic(ctx, 30, 2); + + nk_label(ctx, "Normal:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, property.normal.data.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(property.normal.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + property.normal.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Hover:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, property.hover.data.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(property.hover.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + property.hover.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Active:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, property.active.data.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(property.active.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + property.active.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Border Color:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, property.border_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(property.border_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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + property.border_color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Label Normal:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, property.label_normal, 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(property.label_normal), 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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + property.label_normal = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Label Hover:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, property.label_hover, 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(property.label_hover), 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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + property.label_hover = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Label Active:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, property.label_active, 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(property.label_active), 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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + property.label_active = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Padding:", NK_TEXT_LEFT); + sprintf(buffer, "%.2f, %.2f", property.padding.x, property.padding.y); + if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { + nk_layout_row_dynamic(ctx, 25, 1); + nk_property_float(ctx, "#X:", -100.0f, &property.padding.x, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Y:", -100.0f, &property.padding.y, 100.0f, 1,0.5f); + nk_combo_end(ctx); + } + + // TODO check weird hover bug with properties, happens in overview basic section too + nk_property_float(ctx, "#Border:", -100.0f, &property.border, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Rounding:", -100.0f, &property.rounding, 100.0f, 1,0.5f); + + // there is no property.show_buttons, they're always there + const char* symbols[NK_SYMBOL_MAX] = +{ + "NONE", + "X", + "UNDERSCORE", + "CIRCLE_SOLID", + "CIRCLE_OUTLINE", + "RECT_SOLID", + "RECT_OUTLINE", + "TRIANGLE_UP", + "TRIANGLE_DOWN", + "TRIANGLE_LEFT", + "TRIANGLE_RIGHT", + "PLUS", + "MINUS" +}; + + nk_label(ctx, "Left Symbol:", NK_TEXT_LEFT); + property.sym_left = nk_combo(ctx, symbols, NK_SYMBOL_MAX, property.sym_left, 25, nk_vec2(200,200)); + nk_label(ctx, "Right Symbol:", NK_TEXT_LEFT); + property.sym_right = nk_combo(ctx, symbols, NK_SYMBOL_MAX, property.sym_right, 25, nk_vec2(200,200)); + + if (nk_tree_push(ctx, NK_TREE_TAB, "Property Buttons", NK_MINIMIZED)) { + struct nk_style_button* dups[1] = { &property.dec_button }; + style_button(ctx, &property.inc_button, dups, 1); + nk_tree_pop(ctx); + } + + if (nk_tree_push(ctx, NK_TREE_TAB, "Property Edit", NK_MINIMIZED)) { + style_edit(ctx, &ctx->style.property.edit); + nk_tree_pop(ctx); + } + + *out_style = property; +} + +static void +style_chart(struct nk_context* ctx, struct nk_style_chart* out_style) +{ + struct nk_style_chart chart = *out_style; + //chart = &style->chart; + //nk_zero_struct(*chart); + //chart->background = nk_style_item_color(table[NK_COLOR_CHART]); + //chart->border_color = table[NK_COLOR_BORDER]; + //chart->selected_color = table[NK_COLOR_CHART_COLOR_HIGHLIGHT]; + //chart->color = table[NK_COLOR_CHART_COLOR]; + //chart->padding = nk_vec2(4,4); + //chart->border = 0; + //chart->rounding = 0; + + char buffer[64]; + + nk_layout_row_dynamic(ctx, 30, 2); + + nk_label(ctx, "Background:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, chart.background.data.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(chart.background.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + chart.background.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Border Color:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, chart.border_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(chart.border_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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + chart.border_color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Selected Color:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, chart.selected_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(chart.selected_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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + chart.selected_color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Color:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, chart.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(chart.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + chart.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Padding:", NK_TEXT_LEFT); + sprintf(buffer, "%.2f, %.2f", chart.padding.x, chart.padding.y); + if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { + nk_layout_row_dynamic(ctx, 25, 1); + nk_property_float(ctx, "#X:", -100.0f, &chart.padding.x, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Y:", -100.0f, &chart.padding.y, 100.0f, 1,0.5f); + nk_combo_end(ctx); + } + + nk_property_float(ctx, "#Border:", -100.0f, &chart.border, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Rounding:", -100.0f, &chart.rounding, 100.0f, 1,0.5f); + + + *out_style = chart; +} + +static void +style_combo(struct nk_context* ctx, struct nk_style_combo* out_style) +{ + struct nk_style_combo combo = *out_style; + //combo = &style->combo; + //combo->normal = nk_style_item_color(table[NK_COLOR_COMBO]); + //combo->hover = nk_style_item_color(table[NK_COLOR_COMBO]); + //combo->active = nk_style_item_color(table[NK_COLOR_COMBO]); + //combo->border_color = table[NK_COLOR_BORDER]; + //combo->label_normal = table[NK_COLOR_TEXT]; + //combo->label_hover = table[NK_COLOR_TEXT]; + //combo->label_active = table[NK_COLOR_TEXT]; + //combo->sym_normal = NK_SYMBOL_TRIANGLE_DOWN; + //combo->sym_hover = NK_SYMBOL_TRIANGLE_DOWN; + //combo->sym_active = NK_SYMBOL_TRIANGLE_DOWN; + //combo->content_padding = nk_vec2(4,4); + //combo->button_padding = nk_vec2(0,4); + //combo->spacing = nk_vec2(4,0); + //combo->border = 1; + //combo->rounding = 0; + + char buffer[64]; + + nk_layout_row_dynamic(ctx, 30, 2); + + nk_label(ctx, "Normal:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, combo.normal.data.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(combo.normal.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + combo.normal.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Hover:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, combo.hover.data.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(combo.hover.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + combo.hover.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Active:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, combo.active.data.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(combo.active.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + combo.active.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Border Color:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, combo.border_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(combo.border_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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + combo.border_color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Label Normal:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, combo.label_normal, 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(combo.label_normal), 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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + combo.label_normal = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Label Hover:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, combo.label_hover, 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(combo.label_hover), 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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + combo.label_hover = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Label Active:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, combo.label_active, 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(combo.label_active), 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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + combo.label_active = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + const char* symbols[NK_SYMBOL_MAX] = +{ + "NONE", + "X", + "UNDERSCORE", + "CIRCLE_SOLID", + "CIRCLE_OUTLINE", + "RECT_SOLID", + "RECT_OUTLINE", + "TRIANGLE_UP", + "TRIANGLE_DOWN", + "TRIANGLE_LEFT", + "TRIANGLE_RIGHT", + "PLUS", + "MINUS" +}; + + nk_label(ctx, "Normal Symbol:", NK_TEXT_LEFT); + combo.sym_normal = nk_combo(ctx, symbols, NK_SYMBOL_MAX, combo.sym_normal, 25, nk_vec2(200,200)); + nk_label(ctx, "Hover Symbol:", NK_TEXT_LEFT); + combo.sym_hover = nk_combo(ctx, symbols, NK_SYMBOL_MAX, combo.sym_hover, 25, nk_vec2(200,200)); + nk_label(ctx, "Active Symbol:", NK_TEXT_LEFT); + combo.sym_active = nk_combo(ctx, symbols, NK_SYMBOL_MAX, combo.sym_active, 25, nk_vec2(200,200)); + + + nk_label(ctx, "Content Padding:", NK_TEXT_LEFT); + sprintf(buffer, "%.2f, %.2f", combo.content_padding.x, combo.content_padding.y); + if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { + nk_layout_row_dynamic(ctx, 25, 1); + nk_property_float(ctx, "#X:", -100.0f, &combo.content_padding.x, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Y:", -100.0f, &combo.content_padding.y, 100.0f, 1,0.5f); + nk_combo_end(ctx); + } + + nk_label(ctx, "Button Padding:", NK_TEXT_LEFT); + sprintf(buffer, "%.2f, %.2f", combo.button_padding.x, combo.button_padding.y); + if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { + nk_layout_row_dynamic(ctx, 25, 1); + nk_property_float(ctx, "#X:", -100.0f, &combo.button_padding.x, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Y:", -100.0f, &combo.button_padding.y, 100.0f, 1,0.5f); + nk_combo_end(ctx); + } + + nk_label(ctx, "Spacing:", NK_TEXT_LEFT); + sprintf(buffer, "%.2f, %.2f", combo.spacing.x, combo.spacing.y); + if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { + nk_layout_row_dynamic(ctx, 25, 1); + nk_property_float(ctx, "#X:", -100.0f, &combo.spacing.x, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Y:", -100.0f, &combo.spacing.y, 100.0f, 1,0.5f); + nk_combo_end(ctx); + } + + nk_property_float(ctx, "#Border:", -100.0f, &combo.border, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Rounding:", -100.0f, &combo.rounding, 100.0f, 1,0.5f); + + *out_style = combo; +} + +static void +style_tab(struct nk_context* ctx, struct nk_style_tab* out_style) +{ + struct nk_style_tab tab = *out_style; + //tab = &style->tab; + //tab->background = nk_style_item_color(table[NK_COLOR_TAB_HEADER]); + //tab->border_color = table[NK_COLOR_BORDER]; + //tab->text = table[NK_COLOR_TEXT]; + //tab->sym_minimize = NK_SYMBOL_TRIANGLE_RIGHT; + //tab->sym_maximize = NK_SYMBOL_TRIANGLE_DOWN; + //tab->padding = nk_vec2(4,4); + //tab->spacing = nk_vec2(4,4); + //tab->indent = 10.0f; + //tab->border = 1; + //tab->rounding = 0; + + char buffer[64]; + + nk_layout_row_dynamic(ctx, 30, 2); + + nk_label(ctx, "Background:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, tab.background.data.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(tab.background.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + tab.background.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Border Color:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, tab.border_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(tab.border_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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + tab.border_color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Text:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, tab.text, 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(tab.text), 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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + tab.text = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + // putting these in matching order instead of at bottom because we have an odd number of float properties + const char* symbols[NK_SYMBOL_MAX] = +{ + "NONE", + "X", + "UNDERSCORE", + "CIRCLE_SOLID", + "CIRCLE_OUTLINE", + "RECT_SOLID", + "RECT_OUTLINE", + "TRIANGLE_UP", + "TRIANGLE_DOWN", + "TRIANGLE_LEFT", + "TRIANGLE_RIGHT", + "PLUS", + "MINUS" +}; + + nk_label(ctx, "Minimize Symbol:", NK_TEXT_LEFT); + tab.sym_minimize = nk_combo(ctx, symbols, NK_SYMBOL_MAX, tab.sym_minimize, 25, nk_vec2(200,200)); + nk_label(ctx, "Maxmize Symbol:", NK_TEXT_LEFT); + tab.sym_maximize = nk_combo(ctx, symbols, NK_SYMBOL_MAX, tab.sym_maximize, 25, nk_vec2(200,200)); + + nk_label(ctx, "Padding:", NK_TEXT_LEFT); + sprintf(buffer, "%.2f, %.2f", tab.padding.x, tab.padding.y); + if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { + nk_layout_row_dynamic(ctx, 25, 1); + nk_property_float(ctx, "#X:", -100.0f, &tab.padding.x, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Y:", -100.0f, &tab.padding.y, 100.0f, 1,0.5f); + nk_combo_end(ctx); + } + + nk_label(ctx, "Spacing:", NK_TEXT_LEFT); + sprintf(buffer, "%.2f, %.2f", tab.spacing.x, tab.spacing.y); + if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { + nk_layout_row_dynamic(ctx, 25, 1); + nk_property_float(ctx, "#X:", -100.0f, &tab.spacing.x, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Y:", -100.0f, &tab.spacing.y, 100.0f, 1,0.5f); + nk_combo_end(ctx); + } + + nk_property_float(ctx, "#Indent:", -100.0f, &tab.indent, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Border:", -100.0f, &tab.border, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Rounding:", -100.0f, &tab.rounding, 100.0f, 1,0.5f); + + + + *out_style = tab; +} + +static void +style_window_header(struct nk_context* ctx, struct nk_style_window_header* out_style) +{ + struct nk_style_window_header header = *out_style; + //win->header.align = NK_HEADER_RIGHT; + //win->header.close_symbol = NK_SYMBOL_X; + //win->header.minimize_symbol = NK_SYMBOL_MINUS; + //win->header.maximize_symbol = NK_SYMBOL_PLUS; + //win->header.normal = nk_style_item_color(table[NK_COLOR_HEADER]); + //win->header.hover = nk_style_item_color(table[NK_COLOR_HEADER]); + //win->header.active = nk_style_item_color(table[NK_COLOR_HEADER]); + //win->header.label_normal = table[NK_COLOR_TEXT]; + //win->header.label_hover = table[NK_COLOR_TEXT]; + //win->header.label_active = table[NK_COLOR_TEXT]; + //win->header.label_padding = nk_vec2(4,4); + //win->header.padding = nk_vec2(4,4); + //win->header.spacing = nk_vec2(0,0); + + char buffer[64]; + + nk_layout_row_dynamic(ctx, 30, 2); + + nk_label(ctx, "Normal:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, header.normal.data.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(header.normal.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + header.normal.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Hover:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, header.hover.data.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(header.hover.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + header.hover.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Active:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, header.active.data.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(header.active.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + header.active.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Label Normal:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, header.label_normal, 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(header.label_normal), 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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + header.label_normal = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Label Hover:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, header.label_hover, 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(header.label_hover), 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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + header.label_hover = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Label Active:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, header.label_active, 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(header.label_active), 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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + header.label_active = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Label Padding:", NK_TEXT_LEFT); + sprintf(buffer, "%.2f, %.2f", header.label_padding.x, header.padding.y); + if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { + nk_layout_row_dynamic(ctx, 25, 1); + nk_property_float(ctx, "#X:", -100.0f, &header.label_padding.x, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Y:", -100.0f, &header.label_padding.y, 100.0f, 1,0.5f); + nk_combo_end(ctx); + } + + nk_label(ctx, "Padding:", NK_TEXT_LEFT); + sprintf(buffer, "%.2f, %.2f", header.padding.x, header.padding.y); + if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { + nk_layout_row_dynamic(ctx, 25, 1); + nk_property_float(ctx, "#X:", -100.0f, &header.padding.x, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Y:", -100.0f, &header.padding.y, 100.0f, 1,0.5f); + nk_combo_end(ctx); + } + + nk_label(ctx, "Spacing:", NK_TEXT_LEFT); + sprintf(buffer, "%.2f, %.2f", header.spacing.x, header.spacing.y); + if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { + nk_layout_row_dynamic(ctx, 25, 1); + nk_property_float(ctx, "#X:", -100.0f, &header.spacing.x, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Y:", -100.0f, &header.spacing.y, 100.0f, 1,0.5f); + nk_combo_end(ctx); + } + + const char* symbols[NK_SYMBOL_MAX] = +{ + "NONE", + "X", + "UNDERSCORE", + "CIRCLE_SOLID", + "CIRCLE_OUTLINE", + "RECT_SOLID", + "RECT_OUTLINE", + "TRIANGLE_UP", + "TRIANGLE_DOWN", + "TRIANGLE_LEFT", + "TRIANGLE_RIGHT", + "PLUS", + "MINUS" +}; + +#define NUM_ALIGNS 2 + const char* alignments[NUM_ALIGNS] = { "LEFT", "RIGHT" }; + + nk_layout_row_dynamic(ctx, 30, 2); + nk_label(ctx, "Button Alignment:", NK_TEXT_LEFT); + header.align = nk_combo(ctx, alignments, NUM_ALIGNS, header.align, 25, nk_vec2(200,200)); + + nk_label(ctx, "Close Symbol:", NK_TEXT_LEFT); + header.close_symbol = nk_combo(ctx, symbols, NK_SYMBOL_MAX, header.close_symbol, 25, nk_vec2(200,200)); + nk_label(ctx, "Minimize Symbol:", NK_TEXT_LEFT); + header.minimize_symbol = nk_combo(ctx, symbols, NK_SYMBOL_MAX, header.minimize_symbol, 25, nk_vec2(200,200)); + nk_label(ctx, "Maximize Symbol:", NK_TEXT_LEFT); + header.maximize_symbol = nk_combo(ctx, symbols, NK_SYMBOL_MAX, header.maximize_symbol, 25, nk_vec2(200,200)); + + // necessary or do tree's always take the whole width? + //nk_layout_row_dynamic(ctx, 30, 1); + if (nk_tree_push(ctx, NK_TREE_TAB, "Close and Minimize Button", NK_MINIMIZED)) { + struct nk_style_button* dups[1] = { &header.minimize_button }; + style_button(ctx, &header.close_button, dups, 1); + nk_tree_pop(ctx); + } + + + *out_style = header; +} + +static void +style_window(struct nk_context* ctx, struct nk_style_window* out_style) +{ + struct nk_style_window win = *out_style; + //win->background = table[NK_COLOR_WINDOW]; + //win->fixed_background = nk_style_item_color(table[NK_COLOR_WINDOW]); + //win->border_color = table[NK_COLOR_BORDER]; + //win->popup_border_color = table[NK_COLOR_BORDER]; + //win->combo_border_color = table[NK_COLOR_BORDER]; + //win->contextual_border_color = table[NK_COLOR_BORDER]; + //win->menu_border_color = table[NK_COLOR_BORDER]; + //win->group_border_color = table[NK_COLOR_BORDER]; + //win->tooltip_border_color = table[NK_COLOR_BORDER]; + //win->scaler = nk_style_item_color(table[NK_COLOR_TEXT]); + // + //win->rounding = 0.0f; + //win->spacing = nk_vec2(4,4); + //win->scrollbar_size = nk_vec2(10,10); + //win->min_size = nk_vec2(64,64); + // + //win->combo_border = 1.0f; + //win->contextual_border = 1.0f; + //win->menu_border = 1.0f; + //win->group_border = 1.0f; + //win->tooltip_border = 1.0f; + //win->popup_border = 1.0f; + //win->border = 2.0f; + //win->min_row_height_padding = 8; + // + //win->padding = nk_vec2(4,4); + //win->group_padding = nk_vec2(4,4); + //win->popup_padding = nk_vec2(4,4); + //win->combo_padding = nk_vec2(4,4); + //win->contextual_padding = nk_vec2(4,4); + //win->menu_padding = nk_vec2(4,4); + //win->tooltip_padding = nk_vec2(4,4); + + char buffer[64]; + + nk_layout_row_dynamic(ctx, 30, 2); + + nk_label(ctx, "Background:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, win.background, 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(win.background), 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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + win.background = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Fixed Background:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, win.fixed_background.data.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(win.fixed_background.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + win.fixed_background.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Border:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, win.border_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(win.border_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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + win.border_color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Popup Border:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, win.popup_border_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(win.popup_border_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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + win.popup_border_color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Combo Border:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, win.combo_border_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(win.combo_border_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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + win.combo_border_color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Contextual Border:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, win.contextual_border_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(win.contextual_border_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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + win.contextual_border_color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Menu Border:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, win.menu_border_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(win.menu_border_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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + win.menu_border_color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Group Border:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, win.group_border_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(win.group_border_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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + win.group_border_color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Tooltip Border:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, win.tooltip_border_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(win.tooltip_border_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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + win.tooltip_border_color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Scaler:", NK_TEXT_LEFT); + if (nk_combo_begin_color(ctx, win.scaler.data.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(win.scaler.data.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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + win.scaler.data.color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } + + nk_label(ctx, "Spacing:", NK_TEXT_LEFT); + sprintf(buffer, "%.2f, %.2f", win.spacing.x, win.spacing.y); + if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { + nk_layout_row_dynamic(ctx, 25, 1); + nk_property_float(ctx, "#X:", -100.0f, &win.spacing.x, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Y:", -100.0f, &win.spacing.y, 100.0f, 1,0.5f); + nk_combo_end(ctx); + } + + nk_label(ctx, "Scrollbar Size:", NK_TEXT_LEFT); + sprintf(buffer, "%.2f, %.2f", win.scrollbar_size.x, win.scrollbar_size.y); + if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { + nk_layout_row_dynamic(ctx, 25, 1); + nk_property_float(ctx, "#X:", -100.0f, &win.scrollbar_size.x, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Y:", -100.0f, &win.scrollbar_size.y, 100.0f, 1,0.5f); + nk_combo_end(ctx); + } + + nk_label(ctx, "Min Size:", NK_TEXT_LEFT); + sprintf(buffer, "%.2f, %.2f", win.min_size.x, win.min_size.y); + if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { + nk_layout_row_dynamic(ctx, 25, 1); + nk_property_float(ctx, "#X:", 10.0f, &win.min_size.x, 10000.0f, 1,1.0f); + nk_property_float(ctx, "#Y:", 10.0f, &win.min_size.y, 10000.0f, 1,1.0f); + nk_combo_end(ctx); + } + + nk_label(ctx, "Padding:", NK_TEXT_LEFT); + sprintf(buffer, "%.2f, %.2f", win.padding.x, win.padding.y); + if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { + nk_layout_row_dynamic(ctx, 25, 1); + nk_property_float(ctx, "#X:", -100.0f, &win.padding.x, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Y:", -100.0f, &win.padding.y, 100.0f, 1,0.5f); + nk_combo_end(ctx); + } + + nk_label(ctx, "Group Padding:", NK_TEXT_LEFT); + sprintf(buffer, "%.2f, %.2f", win.group_padding.x, win.group_padding.y); + if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { + nk_layout_row_dynamic(ctx, 25, 1); + nk_property_float(ctx, "#X:", -100.0f, &win.group_padding.x, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Y:", -100.0f, &win.group_padding.y, 100.0f, 1,0.5f); + nk_combo_end(ctx); + } + + nk_label(ctx, "Popup Padding:", NK_TEXT_LEFT); + sprintf(buffer, "%.2f, %.2f", win.popup_padding.x, win.popup_padding.y); + if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { + nk_layout_row_dynamic(ctx, 25, 1); + nk_property_float(ctx, "#X:", -100.0f, &win.popup_padding.x, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Y:", -100.0f, &win.popup_padding.y, 100.0f, 1,0.5f); + nk_combo_end(ctx); + } + + nk_label(ctx, "Combo Padding:", NK_TEXT_LEFT); + sprintf(buffer, "%.2f, %.2f", win.combo_padding.x, win.combo_padding.y); + if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { + nk_layout_row_dynamic(ctx, 25, 1); + nk_property_float(ctx, "#X:", -100.0f, &win.combo_padding.x, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Y:", -100.0f, &win.combo_padding.y, 100.0f, 1,0.5f); + nk_combo_end(ctx); + } + + nk_label(ctx, "Contextual Padding:", NK_TEXT_LEFT); + sprintf(buffer, "%.2f, %.2f", win.contextual_padding.x, win.contextual_padding.y); + if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { + nk_layout_row_dynamic(ctx, 25, 1); + nk_property_float(ctx, "#X:", -100.0f, &win.contextual_padding.x, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Y:", -100.0f, &win.contextual_padding.y, 100.0f, 1,0.5f); + nk_combo_end(ctx); + } + + nk_label(ctx, "Menu Padding:", NK_TEXT_LEFT); + sprintf(buffer, "%.2f, %.2f", win.menu_padding.x, win.menu_padding.y); + if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { + nk_layout_row_dynamic(ctx, 25, 1); + nk_property_float(ctx, "#X:", -100.0f, &win.menu_padding.x, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Y:", -100.0f, &win.menu_padding.y, 100.0f, 1,0.5f); + nk_combo_end(ctx); + } + + nk_label(ctx, "Tooltip Padding:", NK_TEXT_LEFT); + sprintf(buffer, "%.2f, %.2f", win.tooltip_padding.x, win.tooltip_padding.y); + if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { + nk_layout_row_dynamic(ctx, 25, 1); + nk_property_float(ctx, "#X:", -100.0f, &win.tooltip_padding.x, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Y:", -100.0f, &win.tooltip_padding.y, 100.0f, 1,0.5f); + nk_combo_end(ctx); + } + + nk_property_float(ctx, "#Rounding:", -100.0f, &win.rounding, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Combo Border:", -100.0f, &win.combo_border, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Contextual Border:", -100.0f, &win.contextual_border, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Menu Border:", -100.0f, &win.menu_border, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Group Border:", -100.0f, &win.group_border, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Tooltip Border:", -100.0f, &win.tooltip_border, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Popup Border:", -100.0f, &win.popup_border, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Border:", -100.0f, &win.border, 100.0f, 1,0.5f); + + nk_layout_row_dynamic(ctx, 30, 1); + nk_property_float(ctx, "#Min Row Height Padding:", -100.0f, &win.min_row_height_padding, 100.0f, 1,0.5f); + + if (nk_tree_push(ctx, NK_TREE_TAB, "Window Header", NK_MINIMIZED)) { + style_window_header(ctx, &win.header); + nk_tree_pop(ctx); + } + + *out_style = win; +} + +static int +style_configurator(struct nk_context *ctx) +{ + /* window flags */ + int border = nk_true; + int resize = nk_true; + int movable = nk_true; + int no_scrollbar = nk_false; + int scale_left = nk_false; + nk_flags window_flags = 0; + int minimizable = nk_true; + + + /* window flags */ + window_flags = 0; + if (border) window_flags |= NK_WINDOW_BORDER; + if (resize) window_flags |= NK_WINDOW_SCALABLE; + if (movable) window_flags |= NK_WINDOW_MOVABLE; + if (no_scrollbar) window_flags |= NK_WINDOW_NO_SCROLLBAR; + if (scale_left) window_flags |= NK_WINDOW_SCALE_LEFT; + if (minimizable) window_flags |= NK_WINDOW_MINIMIZABLE; + + + struct nk_style *style = &ctx->style; + + struct nk_style_tab *tab; + struct nk_style_window *win; + + // TODO better way? + static int initialized = nk_false; + static struct nk_color color_table[NK_COLOR_COUNT]; + + if (!initialized) { + memcpy(color_table, nk_default_color_style, sizeof(color_table)); + initialized = nk_true; + } + + + if (nk_begin(ctx, "Configurator", nk_rect(10, 10, 400, 600), window_flags)) + { + if (nk_tree_push(ctx, NK_TREE_TAB, "Colors", NK_MINIMIZED)) { + style_colors(ctx, color_table); + nk_tree_pop(ctx); + } + + if (nk_tree_push(ctx, NK_TREE_TAB, "Text", NK_MINIMIZED)) { + style_text(ctx, &style->text); + nk_tree_pop(ctx); + } + + if (nk_tree_push(ctx, NK_TREE_TAB, "Button", NK_MINIMIZED)) { + style_button(ctx, &style->button, NULL, 0); + nk_tree_pop(ctx); + } + + if (nk_tree_push(ctx, NK_TREE_TAB, "Contextual Button", NK_MINIMIZED)) { + style_button(ctx, &style->contextual_button, NULL, 0); + nk_tree_pop(ctx); + } + + if (nk_tree_push(ctx, NK_TREE_TAB, "Menu Button", NK_MINIMIZED)) { + style_button(ctx, &style->menu_button, NULL, 0); + nk_tree_pop(ctx); + } + + if (nk_tree_push(ctx, NK_TREE_TAB, "Combo Buttons", NK_MINIMIZED)) { + style_button(ctx, &style->combo.button, NULL, 0); + nk_tree_pop(ctx); + } + + 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 }; + 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 }; + style_button(ctx, &style->tab.node_minimize_button, dups, 1); + nk_tree_pop(ctx); + } + + if (nk_tree_push(ctx, NK_TREE_TAB, "Window Header Close Buttons", NK_MINIMIZED)) { + style_button(ctx, &style->window.header.close_button, NULL, 0); + nk_tree_pop(ctx); + } + + if (nk_tree_push(ctx, NK_TREE_TAB, "Window Header Minimize Buttons", NK_MINIMIZED)) { + style_button(ctx, &style->window.header.minimize_button, NULL, 0); + nk_tree_pop(ctx); + } + + if (nk_tree_push(ctx, NK_TREE_TAB, "Checkbox", NK_MINIMIZED)) { + style_toggle(ctx, &style->checkbox); + nk_tree_pop(ctx); + } + + if (nk_tree_push(ctx, NK_TREE_TAB, "Option", NK_MINIMIZED)) { + style_toggle(ctx, &style->option); + nk_tree_pop(ctx); + } + + if (nk_tree_push(ctx, NK_TREE_TAB, "Selectable", NK_MINIMIZED)) { + style_selectable(ctx, &style->selectable); + nk_tree_pop(ctx); + } + + if (nk_tree_push(ctx, NK_TREE_TAB, "Slider", NK_MINIMIZED)) { + style_slider(ctx, &style->slider); + nk_tree_pop(ctx); + } + + if (nk_tree_push(ctx, NK_TREE_TAB, "Progress", NK_MINIMIZED)) { + style_progress(ctx, &style->progress); + nk_tree_pop(ctx); + } + + + if (nk_tree_push(ctx, NK_TREE_TAB, "Scrollbars", NK_MINIMIZED)) { + struct nk_style_scrollbar* dups[1] = { &style->scrollv }; + style_scrollbars(ctx, &style->scrollh, dups, 1); + nk_tree_pop(ctx); + } + + if (nk_tree_push(ctx, NK_TREE_TAB, "Edit", NK_MINIMIZED)) { + style_edit(ctx, &style->edit); + nk_tree_pop(ctx); + } + + if (nk_tree_push(ctx, NK_TREE_TAB, "Property", NK_MINIMIZED)) { + style_property(ctx, &style->property); + nk_tree_pop(ctx); + } + + if (nk_tree_push(ctx, NK_TREE_TAB, "Chart", NK_MINIMIZED)) { + style_chart(ctx, &style->chart); + nk_tree_pop(ctx); + } + + if (nk_tree_push(ctx, NK_TREE_TAB, "Combo", NK_MINIMIZED)) { + style_combo(ctx, &style->combo); + nk_tree_pop(ctx); + } + + if (nk_tree_push(ctx, NK_TREE_TAB, "Tab", NK_MINIMIZED)) { + style_tab(ctx, &style->tab); + nk_tree_pop(ctx); + } + + if (nk_tree_push(ctx, NK_TREE_TAB, "Window", NK_MINIMIZED)) { + style_window(ctx, &style->window); + nk_tree_pop(ctx); + } + + nk_layout_row_dynamic(ctx, 30, 1); + if (nk_button_label(ctx, "Reset all styles to defaults")) { + nk_style_default(ctx); + } + + } + + nk_end(ctx); + return !nk_window_is_closed(ctx, "Configurator"); +} From d7d6280033e48c5020da47621caec2c457a4666c Mon Sep 17 00:00:00 2001 From: Robert Winkler Date: Sun, 8 Mar 2020 17:16:01 -0700 Subject: [PATCH 02/13] Finished using style_rgb, started style_item_color --- demo/sdl_opengl3/main.c | 2 +- demo/style_configurator.c | 950 ++++---------------------------------- 2 files changed, 97 insertions(+), 855 deletions(-) diff --git a/demo/sdl_opengl3/main.c b/demo/sdl_opengl3/main.c index 2b5604f70..b758c01e5 100644 --- a/demo/sdl_opengl3/main.c +++ b/demo/sdl_opengl3/main.c @@ -79,7 +79,7 @@ * DEMO * * ===============================================================*/ -int main(void) +int main(int argc, char *argv[]) { /* Platform */ SDL_Window *win; diff --git a/demo/style_configurator.c b/demo/style_configurator.c index 44553dd50..5bebc0999 100644 --- a/demo/style_configurator.c +++ b/demo/style_configurator.c @@ -1,9 +1,36 @@ // TODO design decisions // plural or not? ie style_button or style_buttons? -// use the duplicate array method, or just yet the user +// use the duplicate array method, or just let the user // manually set those after calling the function by accessing ctx->style->*? + + +static void +style_rgb(struct nk_context* ctx, const char* name, struct nk_color* color) +{ + 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); + 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); + colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); + + *color = nk_rgb_cf(colorf); + + nk_combo_end(ctx); + } +} + +// 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) +{ + style_rgb(ctx, name, &item->data.color); +} + // style_general? pass array in instead of static? static void style_colors(struct nk_context* ctx, struct nk_color color_table[NK_COLOR_COUNT]) @@ -42,20 +69,7 @@ style_colors(struct nk_context* ctx, struct nk_color color_table[NK_COLOR_COUNT] nk_layout_row_dynamic(ctx, 30, 2); for (int i=0; i Date: Sun, 8 Mar 2020 20:45:54 -0700 Subject: [PATCH 03/13] Finished style_item_color --- demo/style_configurator.c | 727 +++----------------------------------- 1 file changed, 47 insertions(+), 680 deletions(-) diff --git a/demo/style_configurator.c b/demo/style_configurator.c index 5bebc0999..ad7411364 100644 --- a/demo/style_configurator.c +++ b/demo/style_configurator.c @@ -105,7 +105,6 @@ style_button(struct nk_context* ctx, struct nk_style_button* out_style, struct n { struct nk_style_button button = *out_style; //button = &style->button; - //nk_zero_struct(*button); //button->normal = nk_style_item_color(table[NK_COLOR_BUTTON]); //button->hover = nk_style_item_color(table[NK_COLOR_BUTTON_HOVER]); //button->active = nk_style_item_color(table[NK_COLOR_BUTTON_ACTIVE]); @@ -130,49 +129,8 @@ style_button(struct nk_context* ctx, struct nk_style_button* out_style, struct n // Assumes all the style items are colors not images nk_layout_row_dynamic(ctx, 30, 2); style_item_color(ctx, "Normal:", &button.normal); - /* - nk_label(ctx, "Normal:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, button.normal.data.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(button.normal.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - - button.normal.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } - */ - - nk_label(ctx, "Hover:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, button.hover.data.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(button.hover.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - - button.hover.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } - - nk_label(ctx, "Active:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, button.active.data.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(button.active.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - - button.active.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } + style_item_color(ctx, "Hover:", &button.hover); + style_item_color(ctx, "Active:", &button.active); style_rgb(ctx, "Border:", &button.border_color); style_rgb(ctx, "Text Background:", &button.text_background); @@ -261,7 +219,6 @@ static void style_toggle(struct nk_context* ctx, struct nk_style_toggle* out_sty { struct nk_style_toggle toggle = *out_style; //toggle = &style->checkbox; - //nk_zero_struct(*toggle); //toggle->normal = nk_style_item_color(table[NK_COLOR_TOGGLE]); //toggle->hover = nk_style_item_color(table[NK_COLOR_TOGGLE_HOVER]); //toggle->active = nk_style_item_color(table[NK_COLOR_TOGGLE_HOVER]); @@ -281,78 +238,13 @@ static void style_toggle(struct nk_context* ctx, struct nk_style_toggle* out_sty char buffer[64]; - // Assumes all the style items are colors not images nk_layout_row_dynamic(ctx, 30, 2); - nk_label(ctx, "Normal:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, toggle.normal.data.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(toggle.normal.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - - toggle.normal.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } - - nk_label(ctx, "Hover:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, toggle.hover.data.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(toggle.hover.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - - toggle.hover.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } - - nk_label(ctx, "Active:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, toggle.active.data.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(toggle.active.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - - toggle.active.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } - - nk_label(ctx, "Cursor Normal:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, toggle.cursor_normal.data.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(toggle.cursor_normal.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - - toggle.cursor_normal.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } - - nk_label(ctx, "Cursor Hover:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, toggle.cursor_hover.data.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(toggle.cursor_hover.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - - toggle.cursor_hover.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } + style_item_color(ctx, "Normal:", &toggle.normal); + style_item_color(ctx, "Hover:", &toggle.hover); + style_item_color(ctx, "Active:", &toggle.active); + style_item_color(ctx, "Cursor Normal:", &toggle.cursor_normal); + style_item_color(ctx, "Cursor Hover:", &toggle.cursor_hover); style_rgb(ctx, "Border:", &toggle.border_color); style_rgb(ctx, "Text Background:", &toggle.text_background); @@ -391,7 +283,6 @@ style_selectable(struct nk_context* ctx, struct nk_style_selectable* out_style) { struct nk_style_selectable select = *out_style; //select = &style->selectable; - //nk_zero_struct(*select); //select->normal = nk_style_item_color(table[NK_COLOR_SELECT]); //select->hover = nk_style_item_color(table[NK_COLOR_SELECT]); //select->pressed = nk_style_item_color(table[NK_COLOR_SELECT]); @@ -414,91 +305,14 @@ style_selectable(struct nk_context* ctx, struct nk_style_selectable* out_style) char buffer[64]; - // Assumes all the style items are colors not images nk_layout_row_dynamic(ctx, 30, 2); - nk_label(ctx, "Normal:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, select.normal.data.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(select.normal.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - - select.normal.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } - - nk_label(ctx, "Hover:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, select.hover.data.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(select.hover.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - - select.hover.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } - - nk_label(ctx, "Pressed:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, select.pressed.data.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(select.pressed.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - - select.pressed.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } - - nk_label(ctx, "Normal Active:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, select.normal_active.data.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(select.normal_active.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - - select.normal_active.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } - - nk_label(ctx, "Hover Active:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, select.hover_active.data.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(select.hover_active.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - - select.hover_active.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } - - nk_label(ctx, "Pressed Active:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, select.pressed_active.data.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(select.pressed_active.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - select.pressed_active.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } + style_item_color(ctx, "Normal:", &select.normal); + style_item_color(ctx, "Hover:", &select.hover); + style_item_color(ctx, "Pressed:", &select.pressed); + style_item_color(ctx, "Normal Active:", &select.normal_active); + style_item_color(ctx, "Hover Active:", &select.hover_active); + style_item_color(ctx, "Pressed Active:", &select.pressed_active); style_rgb(ctx, "Text Normal:", &select.text_normal); style_rgb(ctx, "Text Hover:", &select.text_hover); @@ -545,7 +359,6 @@ style_slider(struct nk_context* ctx, struct nk_style_slider* out_style) { struct nk_style_slider slider = *out_style; //slider = &style->slider; - //nk_zero_struct(*slider); //slider->normal = nk_style_item_hide(); //slider->hover = nk_style_item_hide(); //slider->active = nk_style_item_hide(); @@ -570,101 +383,20 @@ style_slider(struct nk_context* ctx, struct nk_style_slider* out_style) char buffer[64]; - // Assumes all the style items are colors not images nk_layout_row_dynamic(ctx, 30, 2); - nk_label(ctx, "Normal:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, slider.normal.data.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(slider.normal.data.color), NK_RGBA); - 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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - colorf.a = nk_propertyf(ctx, "#A:", 0, colorf.a, 1.0f, 0.01f,0.005f); - - slider.normal.data.color = nk_rgba_cf(colorf); - - nk_combo_end(ctx); - } - - nk_label(ctx, "Hover:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, slider.hover.data.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(slider.hover.data.color), NK_RGBA); - 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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - colorf.a = nk_propertyf(ctx, "#A:", 0, colorf.a, 1.0f, 0.01f,0.005f); - - slider.hover.data.color = nk_rgba_cf(colorf); - - nk_combo_end(ctx); - } - - nk_label(ctx, "Active:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, slider.active.data.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(slider.active.data.color), NK_RGBA); - 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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - colorf.a = nk_propertyf(ctx, "#A:", 0, colorf.a, 1.0f, 0.01f,0.005f); - - slider.active.data.color = nk_rgba_cf(colorf); - - nk_combo_end(ctx); - } + style_item_color(ctx, "Normal:", &slider.normal); + style_item_color(ctx, "Hover:", &slider.hover); + style_item_color(ctx, "Active:", &slider.active); style_rgb(ctx, "Bar Normal:", &slider.bar_normal); style_rgb(ctx, "Bar Hover:", &slider.bar_hover); style_rgb(ctx, "Bar Active:", &slider.bar_active); style_rgb(ctx, "Bar Filled:", &slider.bar_filled); - nk_label(ctx, "Cursor Normal:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, slider.cursor_normal.data.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(slider.cursor_normal.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - - slider.cursor_normal.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } - - nk_label(ctx, "Cursor Hover:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, slider.cursor_hover.data.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(slider.cursor_hover.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - - slider.cursor_hover.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } - - nk_label(ctx, "Cursor Active:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, slider.cursor_active.data.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(slider.cursor_active.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - - slider.cursor_active.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } - + style_item_color(ctx, "Cursor Normal:", &slider.cursor_normal); + style_item_color(ctx, "Cursor Hover:", &slider.cursor_hover); + style_item_color(ctx, "Cursor Active:", &slider.cursor_active); nk_label(ctx, "Cursor Size:", NK_TEXT_LEFT); sprintf(buffer, "%.2f, %.2f", slider.cursor_size.x, slider.cursor_size.y); @@ -741,7 +473,6 @@ style_progress(struct nk_context* ctx, struct nk_style_progress* out_style) { struct nk_style_progress prog = *out_style; //prog = &style->progress; - //nk_zero_struct(*prog); //prog->normal = nk_style_item_color(table[NK_COLOR_SLIDER]); //prog->hover = nk_style_item_color(table[NK_COLOR_SLIDER]); //prog->active = nk_style_item_color(table[NK_COLOR_SLIDER]); @@ -761,93 +492,14 @@ style_progress(struct nk_context* ctx, struct nk_style_progress* out_style) char buffer[64]; - // Assumes all the style items are colors not images nk_layout_row_dynamic(ctx, 30, 2); - nk_label(ctx, "Normal:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, prog.normal.data.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(prog.normal.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - - prog.normal.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } - - nk_label(ctx, "Hover:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, prog.hover.data.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(prog.hover.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - - prog.hover.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } - - nk_label(ctx, "Active:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, prog.active.data.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(prog.active.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - - prog.active.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } - - - nk_label(ctx, "Cursor Normal:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, prog.cursor_normal.data.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(prog.cursor_normal.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - - prog.cursor_normal.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } - - nk_label(ctx, "Cursor Hover:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, prog.cursor_hover.data.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(prog.cursor_hover.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - - prog.cursor_hover.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } - - nk_label(ctx, "Cursor Active:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, prog.cursor_active.data.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(prog.cursor_active.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - - prog.cursor_active.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } + style_item_color(ctx, "Normal:", &prog.normal); + style_item_color(ctx, "Hover:", &prog.hover); + style_item_color(ctx, "Active:", &prog.active); + style_item_color(ctx, "Cursor Normal:", &prog.cursor_normal); + style_item_color(ctx, "Cursor Hover:", &prog.cursor_hover); + style_item_color(ctx, "Cursor Active:", &prog.cursor_active); // TODO rgba? style_rgb(ctx, "Border Color:", &prog.border_color); @@ -876,7 +528,6 @@ style_scrollbars(struct nk_context* ctx, struct nk_style_scrollbar* out_style, s { struct nk_style_scrollbar scroll = *out_style; //scroll = &style->scrollh; - //nk_zero_struct(*scroll); //scroll->normal = nk_style_item_color(table[NK_COLOR_SCROLLBAR]); //scroll->hover = nk_style_item_color(table[NK_COLOR_SCROLLBAR]); //scroll->active = nk_style_item_color(table[NK_COLOR_SCROLLBAR]); @@ -900,93 +551,14 @@ style_scrollbars(struct nk_context* ctx, struct nk_style_scrollbar* out_style, s char buffer[64]; - // Assumes all the style items are colors not images nk_layout_row_dynamic(ctx, 30, 2); - nk_label(ctx, "Normal:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, scroll.normal.data.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(scroll.normal.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - - scroll.normal.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } - - nk_label(ctx, "Hover:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, scroll.hover.data.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(scroll.hover.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - - scroll.hover.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } - - nk_label(ctx, "Active:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, scroll.active.data.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(scroll.active.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - - scroll.active.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } - - - nk_label(ctx, "Cursor Normal:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, scroll.cursor_normal.data.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(scroll.cursor_normal.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - - scroll.cursor_normal.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } - - nk_label(ctx, "Cursor Hover:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, scroll.cursor_hover.data.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(scroll.cursor_hover.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - - scroll.cursor_hover.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } - - nk_label(ctx, "Cursor Active:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, scroll.cursor_active.data.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(scroll.cursor_active.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - - scroll.cursor_active.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } + style_item_color(ctx, "Normal:", &scroll.normal); + style_item_color(ctx, "Hover:", &scroll.hover); + style_item_color(ctx, "Active:", &scroll.active); + style_item_color(ctx, "Cursor Normal:", &scroll.cursor_normal); + style_item_color(ctx, "Cursor Hover:", &scroll.cursor_hover); + style_item_color(ctx, "Cursor Active:", &scroll.cursor_active); // TODO rgba? style_rgb(ctx, "Border Color:", &scroll.border_color); @@ -1064,7 +636,6 @@ style_edit(struct nk_context* ctx, struct nk_style_edit* out_style) { struct nk_style_edit edit = *out_style; //edit = &style->edit; - //nk_zero_struct(*edit); //edit->normal = nk_style_item_color(table[NK_COLOR_EDIT]); //edit->hover = nk_style_item_color(table[NK_COLOR_EDIT]); //edit->active = nk_style_item_color(table[NK_COLOR_EDIT]); @@ -1090,50 +661,11 @@ style_edit(struct nk_context* ctx, struct nk_style_edit* out_style) char buffer[64]; - // Assumes all the style items are colors not images nk_layout_row_dynamic(ctx, 30, 2); - nk_label(ctx, "Normal:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, edit.normal.data.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(edit.normal.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - - edit.normal.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } - - nk_label(ctx, "Hover:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, edit.hover.data.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(edit.hover.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - - edit.hover.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } - - nk_label(ctx, "Active:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, edit.active.data.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(edit.active.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - - edit.active.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } + style_item_color(ctx, "Normal:", &edit.normal); + style_item_color(ctx, "Hover:", &edit.hover); + style_item_color(ctx, "Active:", &edit.active); style_rgb(ctx, "Cursor Normal:", &edit.cursor_normal); style_rgb(ctx, "Cursor Hover:", &edit.cursor_hover); @@ -1184,7 +716,6 @@ style_property(struct nk_context* ctx, struct nk_style_property* out_style) struct nk_style_property property = *out_style; //property = &style->property; - //nk_zero_struct(*property); //property->normal = nk_style_item_color(table[NK_COLOR_PROPERTY]); //property->hover = nk_style_item_color(table[NK_COLOR_PROPERTY]); //property->active = nk_style_item_color(table[NK_COLOR_PROPERTY]); @@ -1205,47 +736,9 @@ style_property(struct nk_context* ctx, struct nk_style_property* out_style) nk_layout_row_dynamic(ctx, 30, 2); - nk_label(ctx, "Normal:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, property.normal.data.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(property.normal.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - - property.normal.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } - - nk_label(ctx, "Hover:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, property.hover.data.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(property.hover.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - - property.hover.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } - - nk_label(ctx, "Active:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, property.active.data.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(property.active.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - - property.active.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } + style_item_color(ctx, "Normal:", &property.normal); + style_item_color(ctx, "Hover:", &property.hover); + style_item_color(ctx, "Active:", &property.active); style_rgb(ctx, "Border:", &property.border_color); style_rgb(ctx, "Label Normal:", &property.label_normal); @@ -1307,7 +800,6 @@ style_chart(struct nk_context* ctx, struct nk_style_chart* out_style) { struct nk_style_chart chart = *out_style; //chart = &style->chart; - //nk_zero_struct(*chart); //chart->background = nk_style_item_color(table[NK_COLOR_CHART]); //chart->border_color = table[NK_COLOR_BORDER]; //chart->selected_color = table[NK_COLOR_CHART_COLOR_HIGHLIGHT]; @@ -1320,19 +812,7 @@ style_chart(struct nk_context* ctx, struct nk_style_chart* out_style) nk_layout_row_dynamic(ctx, 30, 2); - nk_label(ctx, "Background:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, chart.background.data.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(chart.background.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - - chart.background.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } + style_item_color(ctx, "Background:", &chart.background); style_rgb(ctx, "Border:", &chart.border_color); style_rgb(ctx, "Selected Color:", &chart.selected_color); @@ -1350,7 +830,6 @@ style_chart(struct nk_context* ctx, struct nk_style_chart* out_style) nk_property_float(ctx, "#Border:", -100.0f, &chart.border, 100.0f, 1,0.5f); nk_property_float(ctx, "#Rounding:", -100.0f, &chart.rounding, 100.0f, 1,0.5f); - *out_style = chart; } @@ -1379,47 +858,9 @@ style_combo(struct nk_context* ctx, struct nk_style_combo* out_style) nk_layout_row_dynamic(ctx, 30, 2); - nk_label(ctx, "Normal:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, combo.normal.data.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(combo.normal.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - - combo.normal.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } - - nk_label(ctx, "Hover:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, combo.hover.data.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(combo.hover.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - - combo.hover.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } - - nk_label(ctx, "Active:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, combo.active.data.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(combo.active.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - - combo.active.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } + style_item_color(ctx, "Normal:", &combo.normal); + style_item_color(ctx, "Hover:", &combo.hover); + style_item_color(ctx, "Active:", &combo.active); style_rgb(ctx, "Border:", &combo.border_color); style_rgb(ctx, "Label Normal:", &combo.label_normal); @@ -1504,19 +945,7 @@ style_tab(struct nk_context* ctx, struct nk_style_tab* out_style) nk_layout_row_dynamic(ctx, 30, 2); - nk_label(ctx, "Background:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, tab.background.data.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(tab.background.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - - tab.background.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } + style_item_color(ctx, "Background:", &tab.background); style_rgb(ctx, "Border:", &tab.border_color); style_rgb(ctx, "Text:", &tab.text); @@ -1593,47 +1022,9 @@ style_window_header(struct nk_context* ctx, struct nk_style_window_header* out_s nk_layout_row_dynamic(ctx, 30, 2); - nk_label(ctx, "Normal:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, header.normal.data.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(header.normal.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - - header.normal.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } - - nk_label(ctx, "Hover:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, header.hover.data.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(header.hover.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - - header.hover.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } - - nk_label(ctx, "Active:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, header.active.data.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(header.active.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - - header.active.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } + style_item_color(ctx, "Normal:", &header.normal); + style_item_color(ctx, "Hover:", &header.hover); + style_item_color(ctx, "Active:", &header.active); style_rgb(ctx, "Label Normal:", &header.label_normal); style_rgb(ctx, "Label Hover:", &header.label_hover); @@ -1752,19 +1143,7 @@ style_window(struct nk_context* ctx, struct nk_style_window* out_style) style_rgb(ctx, "Background:", &win.background); - nk_label(ctx, "Fixed Background:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, win.fixed_background.data.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(win.fixed_background.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - - win.fixed_background.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } + style_item_color(ctx, "Fixed Background:", &win.fixed_background); style_rgb(ctx, "Border:", &win.border_color); style_rgb(ctx, "Popup Border:", &win.popup_border_color); @@ -1774,19 +1153,7 @@ style_window(struct nk_context* ctx, struct nk_style_window* out_style) style_rgb(ctx, "Group Border:", &win.group_border_color); style_rgb(ctx, "Tooltip Border:", &win.tooltip_border_color); - nk_label(ctx, "Scaler:", NK_TEXT_LEFT); - if (nk_combo_begin_color(ctx, win.scaler.data.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(win.scaler.data.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); - colorf.b = nk_propertyf(ctx, "#B:", 0, colorf.b, 1.0f, 0.01f,0.005f); - - win.scaler.data.color = nk_rgb_cf(colorf); - - nk_combo_end(ctx); - } + style_item_color(ctx, "Scaler:", &win.scaler); nk_label(ctx, "Spacing:", NK_TEXT_LEFT); sprintf(buffer, "%.2f, %.2f", win.spacing.x, win.spacing.y); From fb462a31e6f30b7b623cdb99129b4009ca88fc9a Mon Sep 17 00:00:00 2001 From: Robert Winkler Date: Mon, 9 Mar 2020 00:25:05 -0700 Subject: [PATCH 04/13] Finished style_vec2 --- demo/style_configurator.c | 399 +++++--------------------------------- 1 file changed, 50 insertions(+), 349 deletions(-) diff --git a/demo/style_configurator.c b/demo/style_configurator.c index ad7411364..e1bb670f1 100644 --- a/demo/style_configurator.c +++ b/demo/style_configurator.c @@ -31,6 +31,20 @@ style_item_color(struct nk_context* ctx, const char* name, struct nk_style_item* style_rgb(ctx, name, &item->data.color); } +static void +style_vec2(struct nk_context* ctx, const char* name, struct nk_vec2* vec) +{ + char buffer[64]; + nk_label(ctx, name, NK_TEXT_LEFT); + sprintf(buffer, "%.2f, %.2f", vec->x, vec->y); + if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { + nk_layout_row_dynamic(ctx, 25, 1); + nk_property_float(ctx, "#X:", -100.0f, &vec->x, 100.0f, 1,0.5f); + nk_property_float(ctx, "#Y:", -100.0f, &vec->y, 100.0f, 1,0.5f); + nk_combo_end(ctx); + } +} + // style_general? pass array in instead of static? static void style_colors(struct nk_context* ctx, struct nk_color color_table[NK_COLOR_COUNT]) @@ -83,19 +97,10 @@ style_text(struct nk_context* ctx, struct nk_style_text* out_style) //text->color = table[NK_COLOR_TEXT]; //text->padding = nk_vec2(0,0); - char buffer[64]; - nk_layout_row_dynamic(ctx, 30, 2); style_rgb(ctx, "Color:", &text.color); - nk_label(ctx, "Padding:", NK_TEXT_LEFT); - sprintf(buffer, "%.2f, %.2f", text.padding.x, text.padding.y); - if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { - nk_layout_row_dynamic(ctx, 25, 1); - nk_property_float(ctx, "#X:", -100.0f, &text.padding.x, 100.0f, 1,0.5f); - nk_property_float(ctx, "#Y:", -100.0f, &text.padding.y, 100.0f, 1,0.5f); - nk_combo_end(ctx); - } + style_vec2(ctx, "Padding:", &text.padding); *out_style = text; } @@ -123,10 +128,6 @@ style_button(struct nk_context* ctx, struct nk_style_button* out_style, struct n //button->draw_begin = 0; //button->draw_end = 0; - - char buffer[64]; - - // Assumes all the style items are colors not images nk_layout_row_dynamic(ctx, 30, 2); style_item_color(ctx, "Normal:", &button.normal); style_item_color(ctx, "Hover:", &button.hover); @@ -138,33 +139,9 @@ style_button(struct nk_context* ctx, struct nk_style_button* out_style, struct n style_rgb(ctx, "Text Hover:", &button.text_hover); style_rgb(ctx, "Text Active:", &button.text_active); - nk_label(ctx, "Padding:", NK_TEXT_LEFT); - sprintf(buffer, "%.2f, %.2f", button.padding.x, button.padding.y); - if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { - nk_layout_row_dynamic(ctx, 25, 1); - nk_property_float(ctx, "#X:", -100.0f, &button.padding.x, 100.0f, 1,0.5f); - nk_property_float(ctx, "#Y:", -100.0f, &button.padding.y, 100.0f, 1,0.5f); - nk_combo_end(ctx); - } - - nk_label(ctx, "Image Padding:", NK_TEXT_LEFT); - sprintf(buffer, "%.2f, %.2f", button.image_padding.x, button.image_padding.y); - if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { - nk_layout_row_dynamic(ctx, 25, 1); - nk_property_float(ctx, "#X:", -100.0f, &button.image_padding.x, 100.0f, 1,0.5f); - nk_property_float(ctx, "#Y:", -100.0f, &button.image_padding.y, 100.0f, 1,0.5f); - nk_combo_end(ctx); - } - - nk_label(ctx, "Touch Padding:", NK_TEXT_LEFT); - sprintf(buffer, "%.2f, %.2f", button.touch_padding.x, button.touch_padding.y); - if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { - nk_layout_row_dynamic(ctx, 25, 1); - nk_property_float(ctx, "#X:", -100.0f, &button.touch_padding.x, 100.0f, 1,0.5f); - nk_property_float(ctx, "#Y:", -100.0f, &button.touch_padding.y, 100.0f, 1,0.5f); - nk_combo_end(ctx); - } - + style_vec2(ctx, "Padding:", &button.padding); + style_vec2(ctx, "Image Padding:", &button.image_padding); + style_vec2(ctx, "Touch Padding:", &button.touch_padding); /* enum nk_text_align { @@ -205,7 +182,6 @@ NK_TEXT_RIGHT = NK_TEXT_ALIGN_MIDDLE|NK_TEXT_ALIGN_RIGHT //button->draw_begin = 0; //button->draw_end = 0; - *out_style = button; if (duplicate_styles) { for (int i=0; ispacing = 4; // - char buffer[64]; - nk_layout_row_dynamic(ctx, 30, 2); style_item_color(ctx, "Normal:", &toggle.normal); @@ -252,28 +226,12 @@ static void style_toggle(struct nk_context* ctx, struct nk_style_toggle* out_sty style_rgb(ctx, "Text Hover:", &toggle.text_hover); style_rgb(ctx, "Text Active:", &toggle.text_active); - nk_label(ctx, "Padding:", NK_TEXT_LEFT); - sprintf(buffer, "%.2f, %.2f", toggle.padding.x, toggle.padding.y); - if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { - nk_layout_row_dynamic(ctx, 25, 1); - nk_property_float(ctx, "#X:", -100.0f, &toggle.padding.x, 100.0f, 1,0.5f); - nk_property_float(ctx, "#Y:", -100.0f, &toggle.padding.y, 100.0f, 1,0.5f); - nk_combo_end(ctx); - } - - nk_label(ctx, "Touch Padding:", NK_TEXT_LEFT); - sprintf(buffer, "%.2f, %.2f", toggle.touch_padding.x, toggle.touch_padding.y); - if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { - nk_layout_row_dynamic(ctx, 25, 1); - nk_property_float(ctx, "#X:", -100.0f, &toggle.touch_padding.x, 100.0f, 1,0.5f); - nk_property_float(ctx, "#Y:", -100.0f, &toggle.touch_padding.y, 100.0f, 1,0.5f); - nk_combo_end(ctx); - } + style_vec2(ctx, "Padding:", &toggle.padding); + style_vec2(ctx, "Touch Padding:", &toggle.touch_padding); nk_property_float(ctx, "#Border:", -100.0f, &toggle.border, 100.0f, 1,0.5f); nk_property_float(ctx, "#Spacing:", -100.0f, &toggle.spacing, 100.0f, 1,0.5f); - *out_style = toggle; } @@ -303,8 +261,6 @@ style_selectable(struct nk_context* ctx, struct nk_style_selectable* out_style) //select->draw_begin = 0; //select->draw_end = 0; - char buffer[64]; - nk_layout_row_dynamic(ctx, 30, 2); style_item_color(ctx, "Normal:", &select.normal); @@ -321,32 +277,9 @@ style_selectable(struct nk_context* ctx, struct nk_style_selectable* out_style) style_rgb(ctx, "Text Hover Active:", &select.text_hover_active); style_rgb(ctx, "Text Pressed Active:", &select.text_pressed_active); - nk_label(ctx, "Padding:", NK_TEXT_LEFT); - sprintf(buffer, "%.2f, %.2f", select.padding.x, select.padding.y); - if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { - nk_layout_row_dynamic(ctx, 25, 1); - nk_property_float(ctx, "#X:", -100.0f, &select.padding.x, 100.0f, 1,0.5f); - nk_property_float(ctx, "#Y:", -100.0f, &select.padding.y, 100.0f, 1,0.5f); - nk_combo_end(ctx); - } - - nk_label(ctx, "Image Padding:", NK_TEXT_LEFT); - sprintf(buffer, "%.2f, %.2f", select.image_padding.x, select.image_padding.y); - if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { - nk_layout_row_dynamic(ctx, 25, 1); - nk_property_float(ctx, "#X:", -100.0f, &select.image_padding.x, 100.0f, 1,0.5f); - nk_property_float(ctx, "#Y:", -100.0f, &select.image_padding.y, 100.0f, 1,0.5f); - nk_combo_end(ctx); - } - - nk_label(ctx, "Touch Padding:", NK_TEXT_LEFT); - sprintf(buffer, "%.2f, %.2f", select.touch_padding.x, select.touch_padding.y); - if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { - nk_layout_row_dynamic(ctx, 25, 1); - nk_property_float(ctx, "#X:", -100.0f, &select.touch_padding.x, 100.0f, 1,0.5f); - nk_property_float(ctx, "#Y:", -100.0f, &select.touch_padding.y, 100.0f, 1,0.5f); - nk_combo_end(ctx); - } + style_vec2(ctx, "Padding:", &select.padding); + style_vec2(ctx, "Image Padding:", &select.image_padding); + style_vec2(ctx, "Touch Padding:", &select.touch_padding); nk_property_float(ctx, "#Rounding:", -100.0f, &select.rounding, 100.0f, 1,0.5f); @@ -381,8 +314,6 @@ style_slider(struct nk_context* ctx, struct nk_style_slider* out_style) //slider->draw_begin = 0; //slider->draw_end = 0; - char buffer[64]; - nk_layout_row_dynamic(ctx, 30, 2); style_item_color(ctx, "Normal:", &slider.normal); @@ -398,32 +329,9 @@ style_slider(struct nk_context* ctx, struct nk_style_slider* out_style) style_item_color(ctx, "Cursor Hover:", &slider.cursor_hover); style_item_color(ctx, "Cursor Active:", &slider.cursor_active); - nk_label(ctx, "Cursor Size:", NK_TEXT_LEFT); - sprintf(buffer, "%.2f, %.2f", slider.cursor_size.x, slider.cursor_size.y); - if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { - nk_layout_row_dynamic(ctx, 25, 1); - nk_property_float(ctx, "#X:", -100.0f, &slider.cursor_size.x, 100.0f, 1,0.5f); - nk_property_float(ctx, "#Y:", -100.0f, &slider.cursor_size.y, 100.0f, 1,0.5f); - nk_combo_end(ctx); - } - - nk_label(ctx, "Padding:", NK_TEXT_LEFT); - sprintf(buffer, "%.2f, %.2f", slider.padding.x, slider.padding.y); - if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { - nk_layout_row_dynamic(ctx, 25, 1); - nk_property_float(ctx, "#X:", -100.0f, &slider.padding.x, 100.0f, 1,0.5f); - nk_property_float(ctx, "#Y:", -100.0f, &slider.padding.y, 100.0f, 1,0.5f); - nk_combo_end(ctx); - } - - nk_label(ctx, "Spacing:", NK_TEXT_LEFT); - sprintf(buffer, "%.2f, %.2f", slider.spacing.x, slider.spacing.y); - if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { - nk_layout_row_dynamic(ctx, 25, 1); - nk_property_float(ctx, "#X:", -100.0f, &slider.spacing.x, 100.0f, 1,0.5f); - nk_property_float(ctx, "#Y:", -100.0f, &slider.spacing.y, 100.0f, 1,0.5f); - nk_combo_end(ctx); - } + style_vec2(ctx, "Cursor Size:", &slider.cursor_size); + style_vec2(ctx, "Padding:", &slider.padding); + style_vec2(ctx, "Spacing:", &slider.spacing); nk_property_float(ctx, "#Bar Height:", -100.0f, &slider.bar_height, 100.0f, 1,0.5f); nk_property_float(ctx, "#Rounding:", -100.0f, &slider.rounding, 100.0f, 1,0.5f); @@ -490,8 +398,6 @@ style_progress(struct nk_context* ctx, struct nk_style_progress* out_style) //prog->draw_begin = 0; //prog->draw_end = 0; - char buffer[64]; - nk_layout_row_dynamic(ctx, 30, 2); style_item_color(ctx, "Normal:", &prog.normal); @@ -505,14 +411,7 @@ style_progress(struct nk_context* ctx, struct nk_style_progress* out_style) style_rgb(ctx, "Border Color:", &prog.border_color); style_rgb(ctx, "Cursor Border Color:", &prog.cursor_border_color); - nk_label(ctx, "Padding:", NK_TEXT_LEFT); - sprintf(buffer, "%.2f, %.2f", prog.padding.x, prog.padding.y); - if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { - nk_layout_row_dynamic(ctx, 25, 1); - nk_property_float(ctx, "#X:", -100.0f, &prog.padding.x, 100.0f, 1,0.5f); - nk_property_float(ctx, "#Y:", -100.0f, &prog.padding.y, 100.0f, 1,0.5f); - nk_combo_end(ctx); - } + style_vec2(ctx, "Padding:", &prog.padding); nk_property_float(ctx, "#Rounding:", -100.0f, &prog.rounding, 100.0f, 1,0.5f); nk_property_float(ctx, "#Border:", -100.0f, &prog.border, 100.0f, 1,0.5f); @@ -549,8 +448,6 @@ style_scrollbars(struct nk_context* ctx, struct nk_style_scrollbar* out_style, s //scroll->draw_end = 0; //style->scrollv = style->scrollh; - char buffer[64]; - nk_layout_row_dynamic(ctx, 30, 2); style_item_color(ctx, "Normal:", &scroll.normal); @@ -564,14 +461,7 @@ style_scrollbars(struct nk_context* ctx, struct nk_style_scrollbar* out_style, s style_rgb(ctx, "Border Color:", &scroll.border_color); style_rgb(ctx, "Cursor Border Color:", &scroll.cursor_border_color); - nk_label(ctx, "Padding:", NK_TEXT_LEFT); - sprintf(buffer, "%.2f, %.2f", scroll.padding.x, scroll.padding.y); - if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { - nk_layout_row_dynamic(ctx, 25, 1); - nk_property_float(ctx, "#X:", -100.0f, &scroll.padding.x, 100.0f, 1,0.5f); - nk_property_float(ctx, "#Y:", -100.0f, &scroll.padding.y, 100.0f, 1,0.5f); - nk_combo_end(ctx); - } + style_vec2(ctx, "Padding:", &scroll.padding); 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); @@ -659,8 +549,6 @@ style_edit(struct nk_context* ctx, struct nk_style_edit* out_style) //edit->border = 1; //edit->rounding = 0; - char buffer[64]; - nk_layout_row_dynamic(ctx, 30, 2); style_item_color(ctx, "Normal:", &edit.normal); @@ -680,23 +568,8 @@ style_edit(struct nk_context* ctx, struct nk_style_edit* out_style) style_rgb(ctx, "Selected Text Normal:", &edit.selected_text_normal); style_rgb(ctx, "Selected Text Hover:", &edit.selected_text_hover); - nk_label(ctx, "Scrollbar Size:", NK_TEXT_LEFT); - sprintf(buffer, "%.2f, %.2f", edit.scrollbar_size.x, edit.scrollbar_size.y); - if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { - nk_layout_row_dynamic(ctx, 25, 1); - nk_property_float(ctx, "#X:", -100.0f, &edit.scrollbar_size.x, 100.0f, 1,0.5f); - nk_property_float(ctx, "#Y:", -100.0f, &edit.scrollbar_size.y, 100.0f, 1,0.5f); - nk_combo_end(ctx); - } - - nk_label(ctx, "Padding:", NK_TEXT_LEFT); - sprintf(buffer, "%.2f, %.2f", edit.padding.x, edit.padding.y); - if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { - nk_layout_row_dynamic(ctx, 25, 1); - nk_property_float(ctx, "#X:", -100.0f, &edit.padding.x, 100.0f, 1,0.5f); - nk_property_float(ctx, "#Y:", -100.0f, &edit.padding.y, 100.0f, 1,0.5f); - nk_combo_end(ctx); - } + style_vec2(ctx, "Scrollbar Size:", &edit.scrollbar_size); + style_vec2(ctx, "Padding:", &edit.padding); // TODO subtree? //edit->scrollbar = style->scrollv; @@ -732,8 +605,6 @@ style_property(struct nk_context* ctx, struct nk_style_property* out_style) //property->draw_begin = 0; //property->draw_end = 0; - char buffer[64]; - nk_layout_row_dynamic(ctx, 30, 2); style_item_color(ctx, "Normal:", &property.normal); @@ -745,14 +616,7 @@ style_property(struct nk_context* ctx, struct nk_style_property* out_style) style_rgb(ctx, "Label Hover:", &property.label_hover); style_rgb(ctx, "Label Active:", &property.label_active); - nk_label(ctx, "Padding:", NK_TEXT_LEFT); - sprintf(buffer, "%.2f, %.2f", property.padding.x, property.padding.y); - if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { - nk_layout_row_dynamic(ctx, 25, 1); - nk_property_float(ctx, "#X:", -100.0f, &property.padding.x, 100.0f, 1,0.5f); - nk_property_float(ctx, "#Y:", -100.0f, &property.padding.y, 100.0f, 1,0.5f); - nk_combo_end(ctx); - } + style_vec2(ctx, "Padding:", &property.padding); // TODO check weird hover bug with properties, happens in overview basic section too nk_property_float(ctx, "#Border:", -100.0f, &property.border, 100.0f, 1,0.5f); @@ -808,8 +672,6 @@ style_chart(struct nk_context* ctx, struct nk_style_chart* out_style) //chart->border = 0; //chart->rounding = 0; - char buffer[64]; - nk_layout_row_dynamic(ctx, 30, 2); style_item_color(ctx, "Background:", &chart.background); @@ -818,14 +680,7 @@ style_chart(struct nk_context* ctx, struct nk_style_chart* out_style) style_rgb(ctx, "Selected Color:", &chart.selected_color); style_rgb(ctx, "Color:", &chart.color); - nk_label(ctx, "Padding:", NK_TEXT_LEFT); - sprintf(buffer, "%.2f, %.2f", chart.padding.x, chart.padding.y); - if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { - nk_layout_row_dynamic(ctx, 25, 1); - nk_property_float(ctx, "#X:", -100.0f, &chart.padding.x, 100.0f, 1,0.5f); - nk_property_float(ctx, "#Y:", -100.0f, &chart.padding.y, 100.0f, 1,0.5f); - nk_combo_end(ctx); - } + style_vec2(ctx, "Padding:", &chart.padding); nk_property_float(ctx, "#Border:", -100.0f, &chart.border, 100.0f, 1,0.5f); nk_property_float(ctx, "#Rounding:", -100.0f, &chart.rounding, 100.0f, 1,0.5f); @@ -854,8 +709,6 @@ style_combo(struct nk_context* ctx, struct nk_style_combo* out_style) //combo->border = 1; //combo->rounding = 0; - char buffer[64]; - nk_layout_row_dynamic(ctx, 30, 2); style_item_color(ctx, "Normal:", &combo.normal); @@ -891,33 +744,9 @@ style_combo(struct nk_context* ctx, struct nk_style_combo* out_style) nk_label(ctx, "Active Symbol:", NK_TEXT_LEFT); combo.sym_active = nk_combo(ctx, symbols, NK_SYMBOL_MAX, combo.sym_active, 25, nk_vec2(200,200)); - - nk_label(ctx, "Content Padding:", NK_TEXT_LEFT); - sprintf(buffer, "%.2f, %.2f", combo.content_padding.x, combo.content_padding.y); - if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { - nk_layout_row_dynamic(ctx, 25, 1); - nk_property_float(ctx, "#X:", -100.0f, &combo.content_padding.x, 100.0f, 1,0.5f); - nk_property_float(ctx, "#Y:", -100.0f, &combo.content_padding.y, 100.0f, 1,0.5f); - nk_combo_end(ctx); - } - - nk_label(ctx, "Button Padding:", NK_TEXT_LEFT); - sprintf(buffer, "%.2f, %.2f", combo.button_padding.x, combo.button_padding.y); - if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { - nk_layout_row_dynamic(ctx, 25, 1); - nk_property_float(ctx, "#X:", -100.0f, &combo.button_padding.x, 100.0f, 1,0.5f); - nk_property_float(ctx, "#Y:", -100.0f, &combo.button_padding.y, 100.0f, 1,0.5f); - nk_combo_end(ctx); - } - - nk_label(ctx, "Spacing:", NK_TEXT_LEFT); - sprintf(buffer, "%.2f, %.2f", combo.spacing.x, combo.spacing.y); - if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { - nk_layout_row_dynamic(ctx, 25, 1); - nk_property_float(ctx, "#X:", -100.0f, &combo.spacing.x, 100.0f, 1,0.5f); - nk_property_float(ctx, "#Y:", -100.0f, &combo.spacing.y, 100.0f, 1,0.5f); - nk_combo_end(ctx); - } + style_vec2(ctx, "Content Padding:", &combo.content_padding); + style_vec2(ctx, "Button Padding:", &combo.button_padding); + style_vec2(ctx, "Spacing:", &combo.spacing); nk_property_float(ctx, "#Border:", -100.0f, &combo.border, 100.0f, 1,0.5f); nk_property_float(ctx, "#Rounding:", -100.0f, &combo.rounding, 100.0f, 1,0.5f); @@ -941,8 +770,6 @@ style_tab(struct nk_context* ctx, struct nk_style_tab* out_style) //tab->border = 1; //tab->rounding = 0; - char buffer[64]; - nk_layout_row_dynamic(ctx, 30, 2); style_item_color(ctx, "Background:", &tab.background); @@ -973,23 +800,8 @@ style_tab(struct nk_context* ctx, struct nk_style_tab* out_style) nk_label(ctx, "Maxmize Symbol:", NK_TEXT_LEFT); tab.sym_maximize = nk_combo(ctx, symbols, NK_SYMBOL_MAX, tab.sym_maximize, 25, nk_vec2(200,200)); - nk_label(ctx, "Padding:", NK_TEXT_LEFT); - sprintf(buffer, "%.2f, %.2f", tab.padding.x, tab.padding.y); - if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { - nk_layout_row_dynamic(ctx, 25, 1); - nk_property_float(ctx, "#X:", -100.0f, &tab.padding.x, 100.0f, 1,0.5f); - nk_property_float(ctx, "#Y:", -100.0f, &tab.padding.y, 100.0f, 1,0.5f); - nk_combo_end(ctx); - } - - nk_label(ctx, "Spacing:", NK_TEXT_LEFT); - sprintf(buffer, "%.2f, %.2f", tab.spacing.x, tab.spacing.y); - if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { - nk_layout_row_dynamic(ctx, 25, 1); - nk_property_float(ctx, "#X:", -100.0f, &tab.spacing.x, 100.0f, 1,0.5f); - nk_property_float(ctx, "#Y:", -100.0f, &tab.spacing.y, 100.0f, 1,0.5f); - nk_combo_end(ctx); - } + style_vec2(ctx, "Padding:", &tab.padding); + style_vec2(ctx, "Spacing:", &tab.spacing); nk_property_float(ctx, "#Indent:", -100.0f, &tab.indent, 100.0f, 1,0.5f); nk_property_float(ctx, "#Border:", -100.0f, &tab.border, 100.0f, 1,0.5f); @@ -1018,8 +830,6 @@ style_window_header(struct nk_context* ctx, struct nk_style_window_header* out_s //win->header.padding = nk_vec2(4,4); //win->header.spacing = nk_vec2(0,0); - char buffer[64]; - nk_layout_row_dynamic(ctx, 30, 2); style_item_color(ctx, "Normal:", &header.normal); @@ -1030,32 +840,9 @@ style_window_header(struct nk_context* ctx, struct nk_style_window_header* out_s style_rgb(ctx, "Label Hover:", &header.label_hover); style_rgb(ctx, "Label Active:", &header.label_active); - nk_label(ctx, "Label Padding:", NK_TEXT_LEFT); - sprintf(buffer, "%.2f, %.2f", header.label_padding.x, header.padding.y); - if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { - nk_layout_row_dynamic(ctx, 25, 1); - nk_property_float(ctx, "#X:", -100.0f, &header.label_padding.x, 100.0f, 1,0.5f); - nk_property_float(ctx, "#Y:", -100.0f, &header.label_padding.y, 100.0f, 1,0.5f); - nk_combo_end(ctx); - } - - nk_label(ctx, "Padding:", NK_TEXT_LEFT); - sprintf(buffer, "%.2f, %.2f", header.padding.x, header.padding.y); - if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { - nk_layout_row_dynamic(ctx, 25, 1); - nk_property_float(ctx, "#X:", -100.0f, &header.padding.x, 100.0f, 1,0.5f); - nk_property_float(ctx, "#Y:", -100.0f, &header.padding.y, 100.0f, 1,0.5f); - nk_combo_end(ctx); - } - - nk_label(ctx, "Spacing:", NK_TEXT_LEFT); - sprintf(buffer, "%.2f, %.2f", header.spacing.x, header.spacing.y); - if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { - nk_layout_row_dynamic(ctx, 25, 1); - nk_property_float(ctx, "#X:", -100.0f, &header.spacing.x, 100.0f, 1,0.5f); - nk_property_float(ctx, "#Y:", -100.0f, &header.spacing.y, 100.0f, 1,0.5f); - nk_combo_end(ctx); - } + style_vec2(ctx, "Label Padding:", &header.label_padding); + style_vec2(ctx, "Padding:", &header.padding); + style_vec2(ctx, "Spacing:", &header.spacing); const char* symbols[NK_SYMBOL_MAX] = { @@ -1137,8 +924,6 @@ style_window(struct nk_context* ctx, struct nk_style_window* out_style) //win->menu_padding = nk_vec2(4,4); //win->tooltip_padding = nk_vec2(4,4); - char buffer[64]; - nk_layout_row_dynamic(ctx, 30, 2); style_rgb(ctx, "Background:", &win.background); @@ -1155,95 +940,16 @@ style_window(struct nk_context* ctx, struct nk_style_window* out_style) style_item_color(ctx, "Scaler:", &win.scaler); - nk_label(ctx, "Spacing:", NK_TEXT_LEFT); - sprintf(buffer, "%.2f, %.2f", win.spacing.x, win.spacing.y); - if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { - nk_layout_row_dynamic(ctx, 25, 1); - nk_property_float(ctx, "#X:", -100.0f, &win.spacing.x, 100.0f, 1,0.5f); - nk_property_float(ctx, "#Y:", -100.0f, &win.spacing.y, 100.0f, 1,0.5f); - nk_combo_end(ctx); - } - - nk_label(ctx, "Scrollbar Size:", NK_TEXT_LEFT); - sprintf(buffer, "%.2f, %.2f", win.scrollbar_size.x, win.scrollbar_size.y); - if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { - nk_layout_row_dynamic(ctx, 25, 1); - nk_property_float(ctx, "#X:", -100.0f, &win.scrollbar_size.x, 100.0f, 1,0.5f); - nk_property_float(ctx, "#Y:", -100.0f, &win.scrollbar_size.y, 100.0f, 1,0.5f); - nk_combo_end(ctx); - } - - nk_label(ctx, "Min Size:", NK_TEXT_LEFT); - sprintf(buffer, "%.2f, %.2f", win.min_size.x, win.min_size.y); - if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { - nk_layout_row_dynamic(ctx, 25, 1); - nk_property_float(ctx, "#X:", 10.0f, &win.min_size.x, 10000.0f, 1,1.0f); - nk_property_float(ctx, "#Y:", 10.0f, &win.min_size.y, 10000.0f, 1,1.0f); - nk_combo_end(ctx); - } - - nk_label(ctx, "Padding:", NK_TEXT_LEFT); - sprintf(buffer, "%.2f, %.2f", win.padding.x, win.padding.y); - if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { - nk_layout_row_dynamic(ctx, 25, 1); - nk_property_float(ctx, "#X:", -100.0f, &win.padding.x, 100.0f, 1,0.5f); - nk_property_float(ctx, "#Y:", -100.0f, &win.padding.y, 100.0f, 1,0.5f); - nk_combo_end(ctx); - } - - nk_label(ctx, "Group Padding:", NK_TEXT_LEFT); - sprintf(buffer, "%.2f, %.2f", win.group_padding.x, win.group_padding.y); - if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { - nk_layout_row_dynamic(ctx, 25, 1); - nk_property_float(ctx, "#X:", -100.0f, &win.group_padding.x, 100.0f, 1,0.5f); - nk_property_float(ctx, "#Y:", -100.0f, &win.group_padding.y, 100.0f, 1,0.5f); - nk_combo_end(ctx); - } - - nk_label(ctx, "Popup Padding:", NK_TEXT_LEFT); - sprintf(buffer, "%.2f, %.2f", win.popup_padding.x, win.popup_padding.y); - if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { - nk_layout_row_dynamic(ctx, 25, 1); - nk_property_float(ctx, "#X:", -100.0f, &win.popup_padding.x, 100.0f, 1,0.5f); - nk_property_float(ctx, "#Y:", -100.0f, &win.popup_padding.y, 100.0f, 1,0.5f); - nk_combo_end(ctx); - } - - nk_label(ctx, "Combo Padding:", NK_TEXT_LEFT); - sprintf(buffer, "%.2f, %.2f", win.combo_padding.x, win.combo_padding.y); - if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { - nk_layout_row_dynamic(ctx, 25, 1); - nk_property_float(ctx, "#X:", -100.0f, &win.combo_padding.x, 100.0f, 1,0.5f); - nk_property_float(ctx, "#Y:", -100.0f, &win.combo_padding.y, 100.0f, 1,0.5f); - nk_combo_end(ctx); - } - - nk_label(ctx, "Contextual Padding:", NK_TEXT_LEFT); - sprintf(buffer, "%.2f, %.2f", win.contextual_padding.x, win.contextual_padding.y); - if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { - nk_layout_row_dynamic(ctx, 25, 1); - nk_property_float(ctx, "#X:", -100.0f, &win.contextual_padding.x, 100.0f, 1,0.5f); - nk_property_float(ctx, "#Y:", -100.0f, &win.contextual_padding.y, 100.0f, 1,0.5f); - nk_combo_end(ctx); - } - - nk_label(ctx, "Menu Padding:", NK_TEXT_LEFT); - sprintf(buffer, "%.2f, %.2f", win.menu_padding.x, win.menu_padding.y); - if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { - nk_layout_row_dynamic(ctx, 25, 1); - nk_property_float(ctx, "#X:", -100.0f, &win.menu_padding.x, 100.0f, 1,0.5f); - nk_property_float(ctx, "#Y:", -100.0f, &win.menu_padding.y, 100.0f, 1,0.5f); - nk_combo_end(ctx); - } - - nk_label(ctx, "Tooltip Padding:", NK_TEXT_LEFT); - sprintf(buffer, "%.2f, %.2f", win.tooltip_padding.x, win.tooltip_padding.y); - if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) { - nk_layout_row_dynamic(ctx, 25, 1); - nk_property_float(ctx, "#X:", -100.0f, &win.tooltip_padding.x, 100.0f, 1,0.5f); - nk_property_float(ctx, "#Y:", -100.0f, &win.tooltip_padding.y, 100.0f, 1,0.5f); - nk_combo_end(ctx); - } + style_vec2(ctx, "Spacing:", &win.spacing); + style_vec2(ctx, "Scrollbar Size:", &win.scrollbar_size); + style_vec2(ctx, "Min Size:", &win.min_size); + style_vec2(ctx, "Padding:", &win.padding); + style_vec2(ctx, "Group Padding:", &win.group_padding); + style_vec2(ctx, "Popup Padding:", &win.popup_padding); + style_vec2(ctx, "Combo Padding:", &win.combo_padding); + style_vec2(ctx, "Contextual Padding:", &win.contextual_padding); + style_vec2(ctx, "Menu Padding:", &win.menu_padding); + style_vec2(ctx, "Tooltip Padding:", &win.tooltip_padding); nk_property_float(ctx, "#Rounding:", -100.0f, &win.rounding, 100.0f, 1,0.5f); nk_property_float(ctx, "#Combo Border:", -100.0f, &win.combo_border, 100.0f, 1,0.5f); @@ -1287,12 +993,8 @@ style_configurator(struct nk_context *ctx) if (scale_left) window_flags |= NK_WINDOW_SCALE_LEFT; if (minimizable) window_flags |= NK_WINDOW_MINIMIZABLE; - struct nk_style *style = &ctx->style; - struct nk_style_tab *tab; - struct nk_style_window *win; - // TODO better way? static int initialized = nk_false; static struct nk_color color_table[NK_COLOR_COUNT]; @@ -1302,7 +1004,6 @@ style_configurator(struct nk_context *ctx) initialized = nk_true; } - if (nk_begin(ctx, "Configurator", nk_rect(10, 10, 400, 600), window_flags)) { if (nk_tree_push(ctx, NK_TREE_TAB, "Colors", NK_MINIMIZED)) { From b51d4ac564b9d846c629b6d89127893c8adadf80 Mon Sep 17 00:00:00 2001 From: Robert Winkler Date: Mon, 9 Mar 2020 00:39:03 -0700 Subject: [PATCH 05/13] Make symbols array static global --- demo/style_configurator.c | 122 ++++++-------------------------------- 1 file changed, 19 insertions(+), 103 deletions(-) diff --git a/demo/style_configurator.c b/demo/style_configurator.c index e1bb670f1..f150f9c04 100644 --- a/demo/style_configurator.c +++ b/demo/style_configurator.c @@ -4,6 +4,23 @@ // use the duplicate array method, or just let the user // manually set those after calling the function by accessing ctx->style->*? +static const char* symbols[NK_SYMBOL_MAX] = +{ + "NONE", + "X", + "UNDERSCORE", + "CIRCLE_SOLID", + "CIRCLE_OUTLINE", + "RECT_SOLID", + "RECT_OUTLINE", + "TRIANGLE_UP", + "TRIANGLE_DOWN", + "TRIANGLE_LEFT", + "TRIANGLE_RIGHT", + "PLUS", + "MINUS" +}; + static void @@ -336,23 +353,6 @@ style_slider(struct nk_context* ctx, struct nk_style_slider* out_style) nk_property_float(ctx, "#Bar Height:", -100.0f, &slider.bar_height, 100.0f, 1,0.5f); nk_property_float(ctx, "#Rounding:", -100.0f, &slider.rounding, 100.0f, 1,0.5f); - const char* symbols[NK_SYMBOL_MAX] = -{ - "NONE", - "X", - "UNDERSCORE", - "CIRCLE_SOLID", - "CIRCLE_OUTLINE", - "RECT_SOLID", - "RECT_OUTLINE", - "TRIANGLE_UP", - "TRIANGLE_DOWN", - "TRIANGLE_LEFT", - "TRIANGLE_RIGHT", - "PLUS", - "MINUS" -}; - nk_layout_row_dynamic(ctx, 30, 1); nk_checkbox_label(ctx, "Show Buttons", &slider.show_buttons); @@ -470,24 +470,6 @@ style_scrollbars(struct nk_context* ctx, struct nk_style_scrollbar* out_style, s 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); - - const char* symbols[NK_SYMBOL_MAX] = -{ - "NONE", - "X", - "UNDERSCORE", - "CIRCLE_SOLID", - "CIRCLE_OUTLINE", - "RECT_SOLID", - "RECT_OUTLINE", - "TRIANGLE_UP", - "TRIANGLE_DOWN", - "TRIANGLE_LEFT", - "TRIANGLE_RIGHT", - "PLUS", - "MINUS" -}; - // 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); @@ -623,22 +605,6 @@ style_property(struct nk_context* ctx, struct nk_style_property* out_style) nk_property_float(ctx, "#Rounding:", -100.0f, &property.rounding, 100.0f, 1,0.5f); // there is no property.show_buttons, they're always there - const char* symbols[NK_SYMBOL_MAX] = -{ - "NONE", - "X", - "UNDERSCORE", - "CIRCLE_SOLID", - "CIRCLE_OUTLINE", - "RECT_SOLID", - "RECT_OUTLINE", - "TRIANGLE_UP", - "TRIANGLE_DOWN", - "TRIANGLE_LEFT", - "TRIANGLE_RIGHT", - "PLUS", - "MINUS" -}; nk_label(ctx, "Left Symbol:", NK_TEXT_LEFT); property.sym_left = nk_combo(ctx, symbols, NK_SYMBOL_MAX, property.sym_left, 25, nk_vec2(200,200)); @@ -720,23 +686,6 @@ style_combo(struct nk_context* ctx, struct nk_style_combo* out_style) style_rgb(ctx, "Label Hover:", &combo.label_hover); style_rgb(ctx, "Label Active:", &combo.label_active); - const char* symbols[NK_SYMBOL_MAX] = -{ - "NONE", - "X", - "UNDERSCORE", - "CIRCLE_SOLID", - "CIRCLE_OUTLINE", - "RECT_SOLID", - "RECT_OUTLINE", - "TRIANGLE_UP", - "TRIANGLE_DOWN", - "TRIANGLE_LEFT", - "TRIANGLE_RIGHT", - "PLUS", - "MINUS" -}; - nk_label(ctx, "Normal Symbol:", NK_TEXT_LEFT); combo.sym_normal = nk_combo(ctx, symbols, NK_SYMBOL_MAX, combo.sym_normal, 25, nk_vec2(200,200)); nk_label(ctx, "Hover Symbol:", NK_TEXT_LEFT); @@ -777,24 +726,8 @@ style_tab(struct nk_context* ctx, struct nk_style_tab* out_style) style_rgb(ctx, "Border:", &tab.border_color); style_rgb(ctx, "Text:", &tab.text); - // putting these in matching order instead of at bottom because we have an odd number of float properties - const char* symbols[NK_SYMBOL_MAX] = -{ - "NONE", - "X", - "UNDERSCORE", - "CIRCLE_SOLID", - "CIRCLE_OUTLINE", - "RECT_SOLID", - "RECT_OUTLINE", - "TRIANGLE_UP", - "TRIANGLE_DOWN", - "TRIANGLE_LEFT", - "TRIANGLE_RIGHT", - "PLUS", - "MINUS" -}; - + // FTR, I feel these fields are misnamed and should be sym_minimized and sym_maximized since they are + // what show in that state, not the button to push to get to that state nk_label(ctx, "Minimize Symbol:", NK_TEXT_LEFT); tab.sym_minimize = nk_combo(ctx, symbols, NK_SYMBOL_MAX, tab.sym_minimize, 25, nk_vec2(200,200)); nk_label(ctx, "Maxmize Symbol:", NK_TEXT_LEFT); @@ -844,23 +777,6 @@ style_window_header(struct nk_context* ctx, struct nk_style_window_header* out_s style_vec2(ctx, "Padding:", &header.padding); style_vec2(ctx, "Spacing:", &header.spacing); - const char* symbols[NK_SYMBOL_MAX] = -{ - "NONE", - "X", - "UNDERSCORE", - "CIRCLE_SOLID", - "CIRCLE_OUTLINE", - "RECT_SOLID", - "RECT_OUTLINE", - "TRIANGLE_UP", - "TRIANGLE_DOWN", - "TRIANGLE_LEFT", - "TRIANGLE_RIGHT", - "PLUS", - "MINUS" -}; - #define NUM_ALIGNS 2 const char* alignments[NUM_ALIGNS] = { "LEFT", "RIGHT" }; From ab6aee42d8dabbc0dff201e88e3abc159d15a58c Mon Sep 17 00:00:00 2001 From: Robert Winkler Date: Mon, 9 Mar 2020 17:31:58 -0700 Subject: [PATCH 06/13] Remove unnecessary comments --- demo/style_configurator.c | 250 -------------------------------------- 1 file changed, 250 deletions(-) diff --git a/demo/style_configurator.c b/demo/style_configurator.c index f150f9c04..fc79aae07 100644 --- a/demo/style_configurator.c +++ b/demo/style_configurator.c @@ -21,8 +21,6 @@ static const char* symbols[NK_SYMBOL_MAX] = "MINUS" }; - - static void style_rgb(struct nk_context* ctx, const char* name, struct nk_color* color) { @@ -110,9 +108,6 @@ static void style_text(struct nk_context* ctx, struct nk_style_text* out_style) { struct nk_style_text text = *out_style; - //text = &style->text; - //text->color = table[NK_COLOR_TEXT]; - //text->padding = nk_vec2(0,0); nk_layout_row_dynamic(ctx, 30, 2); style_rgb(ctx, "Color:", &text.color); @@ -126,24 +121,6 @@ static void style_button(struct nk_context* ctx, struct nk_style_button* out_style, struct nk_style_button** duplicate_styles, int n_dups) { struct nk_style_button button = *out_style; - //button = &style->button; - //button->normal = nk_style_item_color(table[NK_COLOR_BUTTON]); - //button->hover = nk_style_item_color(table[NK_COLOR_BUTTON_HOVER]); - //button->active = nk_style_item_color(table[NK_COLOR_BUTTON_ACTIVE]); - //button->border_color = table[NK_COLOR_BORDER]; - //button->text_background = table[NK_COLOR_BUTTON]; - //button->text_normal = table[NK_COLOR_TEXT]; - //button->text_hover = table[NK_COLOR_TEXT]; - //button->text_active = table[NK_COLOR_TEXT]; - //button->padding = nk_vec2(2.0f,2.0f); - //button->image_padding = nk_vec2(0.0f,0.0f); - //button->touch_padding = nk_vec2(0.0f, 0.0f); - //button->userdata = nk_handle_ptr(0); - //button->text_alignment = NK_TEXT_CENTERED; - //button->border = 1.0f; - //button->rounding = 4.0f; - //button->draw_begin = 0; - //button->draw_end = 0; nk_layout_row_dynamic(ctx, 30, 2); style_item_color(ctx, "Normal:", &button.normal); @@ -193,12 +170,6 @@ NK_TEXT_RIGHT = NK_TEXT_ALIGN_MIDDLE|NK_TEXT_ALIGN_RIGHT nk_property_float(ctx, "#Border:", -100.0f, &button.border, 100.0f, 1,0.5f); nk_property_float(ctx, "#Rounding:", -100.0f, &button.rounding, 100.0f, 1,0.5f); - // - // optional user callback stuff - //button->userdata = nk_handle_ptr(0); - //button->draw_begin = 0; - //button->draw_end = 0; - *out_style = button; if (duplicate_styles) { for (int i=0; icheckbox; - //toggle->normal = nk_style_item_color(table[NK_COLOR_TOGGLE]); - //toggle->hover = nk_style_item_color(table[NK_COLOR_TOGGLE_HOVER]); - //toggle->active = nk_style_item_color(table[NK_COLOR_TOGGLE_HOVER]); - //toggle->cursor_normal = nk_style_item_color(table[NK_COLOR_TOGGLE_CURSOR]); - //toggle->cursor_hover = nk_style_item_color(table[NK_COLOR_TOGGLE_CURSOR]); - //toggle->userdata = nk_handle_ptr(0); - //toggle->text_background = table[NK_COLOR_WINDOW]; - //toggle->text_normal = table[NK_COLOR_TEXT]; - //toggle->text_hover = table[NK_COLOR_TEXT]; - //toggle->text_active = table[NK_COLOR_TEXT]; - //toggle->padding = nk_vec2(2.0f, 2.0f); - //toggle->touch_padding = nk_vec2(0,0); - //toggle->border_color = nk_rgba(0,0,0,0); - //toggle->border = 0.0f; - //toggle->spacing = 4; - // nk_layout_row_dynamic(ctx, 30, 2); @@ -257,26 +211,6 @@ static void style_selectable(struct nk_context* ctx, struct nk_style_selectable* out_style) { struct nk_style_selectable select = *out_style; - //select = &style->selectable; - //select->normal = nk_style_item_color(table[NK_COLOR_SELECT]); - //select->hover = nk_style_item_color(table[NK_COLOR_SELECT]); - //select->pressed = nk_style_item_color(table[NK_COLOR_SELECT]); - //select->normal_active = nk_style_item_color(table[NK_COLOR_SELECT_ACTIVE]); - //select->hover_active = nk_style_item_color(table[NK_COLOR_SELECT_ACTIVE]); - //select->pressed_active = nk_style_item_color(table[NK_COLOR_SELECT_ACTIVE]); - //select->text_normal = table[NK_COLOR_TEXT]; - //select->text_hover = table[NK_COLOR_TEXT]; - //select->text_pressed = table[NK_COLOR_TEXT]; - //select->text_normal_active = table[NK_COLOR_TEXT]; - //select->text_hover_active = table[NK_COLOR_TEXT]; - //select->text_pressed_active = table[NK_COLOR_TEXT]; - //select->padding = nk_vec2(2.0f,2.0f); - //select->image_padding = nk_vec2(2.0f,2.0f); - //select->touch_padding = nk_vec2(0,0); - //select->userdata = nk_handle_ptr(0); - //select->rounding = 0.0f; - //select->draw_begin = 0; - //select->draw_end = 0; nk_layout_row_dynamic(ctx, 30, 2); @@ -308,28 +242,6 @@ static void style_slider(struct nk_context* ctx, struct nk_style_slider* out_style) { struct nk_style_slider slider = *out_style; - //slider = &style->slider; - //slider->normal = nk_style_item_hide(); - //slider->hover = nk_style_item_hide(); - //slider->active = nk_style_item_hide(); - //slider->bar_normal = table[NK_COLOR_SLIDER]; - //slider->bar_hover = table[NK_COLOR_SLIDER]; - //slider->bar_active = table[NK_COLOR_SLIDER]; - //slider->bar_filled = table[NK_COLOR_SLIDER_CURSOR]; - //slider->cursor_normal = nk_style_item_color(table[NK_COLOR_SLIDER_CURSOR]); - //slider->cursor_hover = nk_style_item_color(table[NK_COLOR_SLIDER_CURSOR_HOVER]); - //slider->cursor_active = nk_style_item_color(table[NK_COLOR_SLIDER_CURSOR_ACTIVE]); - //slider->inc_symbol = NK_SYMBOL_TRIANGLE_RIGHT; - //slider->dec_symbol = NK_SYMBOL_TRIANGLE_LEFT; - //slider->cursor_size = nk_vec2(16,16); - //slider->padding = nk_vec2(2,2); - //slider->spacing = nk_vec2(2,2); - //slider->userdata = nk_handle_ptr(0); - //slider->show_buttons = nk_false; - //slider->bar_height = 8; - //slider->rounding = 0; - //slider->draw_begin = 0; - //slider->draw_end = 0; nk_layout_row_dynamic(ctx, 30, 2); @@ -380,23 +292,6 @@ static void style_progress(struct nk_context* ctx, struct nk_style_progress* out_style) { struct nk_style_progress prog = *out_style; - //prog = &style->progress; - //prog->normal = nk_style_item_color(table[NK_COLOR_SLIDER]); - //prog->hover = nk_style_item_color(table[NK_COLOR_SLIDER]); - //prog->active = nk_style_item_color(table[NK_COLOR_SLIDER]); - //prog->cursor_normal = nk_style_item_color(table[NK_COLOR_SLIDER_CURSOR]); - //prog->cursor_hover = nk_style_item_color(table[NK_COLOR_SLIDER_CURSOR_HOVER]); - //prog->cursor_active = nk_style_item_color(table[NK_COLOR_SLIDER_CURSOR_ACTIVE]); - //prog->border_color = nk_rgba(0,0,0,0); - //prog->cursor_border_color = nk_rgba(0,0,0,0); - //prog->userdata = nk_handle_ptr(0); - //prog->padding = nk_vec2(4,4); - //prog->rounding = 0; - //prog->border = 0; - //prog->cursor_rounding = 0; - //prog->cursor_border = 0; - //prog->draw_begin = 0; - //prog->draw_end = 0; nk_layout_row_dynamic(ctx, 30, 2); @@ -426,27 +321,6 @@ 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; - //scroll = &style->scrollh; - //scroll->normal = nk_style_item_color(table[NK_COLOR_SCROLLBAR]); - //scroll->hover = nk_style_item_color(table[NK_COLOR_SCROLLBAR]); - //scroll->active = nk_style_item_color(table[NK_COLOR_SCROLLBAR]); - //scroll->cursor_normal = nk_style_item_color(table[NK_COLOR_SCROLLBAR_CURSOR]); - //scroll->cursor_hover = nk_style_item_color(table[NK_COLOR_SCROLLBAR_CURSOR_HOVER]); - //scroll->cursor_active = nk_style_item_color(table[NK_COLOR_SCROLLBAR_CURSOR_ACTIVE]); - //scroll->dec_symbol = NK_SYMBOL_CIRCLE_SOLID; - //scroll->inc_symbol = NK_SYMBOL_CIRCLE_SOLID; - //scroll->userdata = nk_handle_ptr(0); - //scroll->border_color = table[NK_COLOR_SCROLLBAR]; - //scroll->cursor_border_color = table[NK_COLOR_SCROLLBAR]; - //scroll->padding = nk_vec2(0,0); - //scroll->show_buttons = nk_false; - //scroll->border = 0; - //scroll->rounding = 0; - //scroll->border_cursor = 0; - //scroll->rounding_cursor = 0; - //scroll->draw_begin = 0; - //scroll->draw_end = 0; - //style->scrollv = style->scrollh; nk_layout_row_dynamic(ctx, 30, 2); @@ -492,9 +366,6 @@ style_scrollbars(struct nk_context* ctx, struct nk_style_scrollbar* out_style, s } } - - //style->scrollv = style->scrollh; - *out_style = scroll; if (duplicate_styles) { for (int i=0; iedit; - //edit->normal = nk_style_item_color(table[NK_COLOR_EDIT]); - //edit->hover = nk_style_item_color(table[NK_COLOR_EDIT]); - //edit->active = nk_style_item_color(table[NK_COLOR_EDIT]); - //edit->cursor_normal = table[NK_COLOR_TEXT]; - //edit->cursor_hover = table[NK_COLOR_TEXT]; - //edit->cursor_text_normal= table[NK_COLOR_EDIT]; - //edit->cursor_text_hover = table[NK_COLOR_EDIT]; - //edit->border_color = table[NK_COLOR_BORDER]; - //edit->text_normal = table[NK_COLOR_TEXT]; - //edit->text_hover = table[NK_COLOR_TEXT]; - //edit->text_active = table[NK_COLOR_TEXT]; - //edit->selected_normal = table[NK_COLOR_TEXT]; - //edit->selected_hover = table[NK_COLOR_TEXT]; - //edit->selected_text_normal = table[NK_COLOR_EDIT]; - //edit->selected_text_hover = table[NK_COLOR_EDIT]; - //edit->scrollbar_size = nk_vec2(10,10); - //edit->scrollbar = style->scrollv; - //edit->padding = nk_vec2(4,4); - //edit->row_padding = 2; - //edit->cursor_size = 4; - //edit->border = 1; - //edit->rounding = 0; nk_layout_row_dynamic(ctx, 30, 2); @@ -570,23 +418,6 @@ style_property(struct nk_context* ctx, struct nk_style_property* out_style) { struct nk_style_property property = *out_style; - //property = &style->property; - //property->normal = nk_style_item_color(table[NK_COLOR_PROPERTY]); - //property->hover = nk_style_item_color(table[NK_COLOR_PROPERTY]); - //property->active = nk_style_item_color(table[NK_COLOR_PROPERTY]); - //property->border_color = table[NK_COLOR_BORDER]; - //property->label_normal = table[NK_COLOR_TEXT]; - //property->label_hover = table[NK_COLOR_TEXT]; - //property->label_active = table[NK_COLOR_TEXT]; - //property->sym_left = NK_SYMBOL_TRIANGLE_LEFT; - //property->sym_right = NK_SYMBOL_TRIANGLE_RIGHT; - //property->userdata = nk_handle_ptr(0); - //property->padding = nk_vec2(4,4); - //property->border = 1; - //property->rounding = 10; - //property->draw_begin = 0; - //property->draw_end = 0; - nk_layout_row_dynamic(ctx, 30, 2); style_item_color(ctx, "Normal:", &property.normal); @@ -629,14 +460,6 @@ static void style_chart(struct nk_context* ctx, struct nk_style_chart* out_style) { struct nk_style_chart chart = *out_style; - //chart = &style->chart; - //chart->background = nk_style_item_color(table[NK_COLOR_CHART]); - //chart->border_color = table[NK_COLOR_BORDER]; - //chart->selected_color = table[NK_COLOR_CHART_COLOR_HIGHLIGHT]; - //chart->color = table[NK_COLOR_CHART_COLOR]; - //chart->padding = nk_vec2(4,4); - //chart->border = 0; - //chart->rounding = 0; nk_layout_row_dynamic(ctx, 30, 2); @@ -658,22 +481,6 @@ static void style_combo(struct nk_context* ctx, struct nk_style_combo* out_style) { struct nk_style_combo combo = *out_style; - //combo = &style->combo; - //combo->normal = nk_style_item_color(table[NK_COLOR_COMBO]); - //combo->hover = nk_style_item_color(table[NK_COLOR_COMBO]); - //combo->active = nk_style_item_color(table[NK_COLOR_COMBO]); - //combo->border_color = table[NK_COLOR_BORDER]; - //combo->label_normal = table[NK_COLOR_TEXT]; - //combo->label_hover = table[NK_COLOR_TEXT]; - //combo->label_active = table[NK_COLOR_TEXT]; - //combo->sym_normal = NK_SYMBOL_TRIANGLE_DOWN; - //combo->sym_hover = NK_SYMBOL_TRIANGLE_DOWN; - //combo->sym_active = NK_SYMBOL_TRIANGLE_DOWN; - //combo->content_padding = nk_vec2(4,4); - //combo->button_padding = nk_vec2(0,4); - //combo->spacing = nk_vec2(4,0); - //combo->border = 1; - //combo->rounding = 0; nk_layout_row_dynamic(ctx, 30, 2); @@ -707,17 +514,6 @@ static void style_tab(struct nk_context* ctx, struct nk_style_tab* out_style) { struct nk_style_tab tab = *out_style; - //tab = &style->tab; - //tab->background = nk_style_item_color(table[NK_COLOR_TAB_HEADER]); - //tab->border_color = table[NK_COLOR_BORDER]; - //tab->text = table[NK_COLOR_TEXT]; - //tab->sym_minimize = NK_SYMBOL_TRIANGLE_RIGHT; - //tab->sym_maximize = NK_SYMBOL_TRIANGLE_DOWN; - //tab->padding = nk_vec2(4,4); - //tab->spacing = nk_vec2(4,4); - //tab->indent = 10.0f; - //tab->border = 1; - //tab->rounding = 0; nk_layout_row_dynamic(ctx, 30, 2); @@ -749,19 +545,6 @@ static void style_window_header(struct nk_context* ctx, struct nk_style_window_header* out_style) { struct nk_style_window_header header = *out_style; - //win->header.align = NK_HEADER_RIGHT; - //win->header.close_symbol = NK_SYMBOL_X; - //win->header.minimize_symbol = NK_SYMBOL_MINUS; - //win->header.maximize_symbol = NK_SYMBOL_PLUS; - //win->header.normal = nk_style_item_color(table[NK_COLOR_HEADER]); - //win->header.hover = nk_style_item_color(table[NK_COLOR_HEADER]); - //win->header.active = nk_style_item_color(table[NK_COLOR_HEADER]); - //win->header.label_normal = table[NK_COLOR_TEXT]; - //win->header.label_hover = table[NK_COLOR_TEXT]; - //win->header.label_active = table[NK_COLOR_TEXT]; - //win->header.label_padding = nk_vec2(4,4); - //win->header.padding = nk_vec2(4,4); - //win->header.spacing = nk_vec2(0,0); nk_layout_row_dynamic(ctx, 30, 2); @@ -807,38 +590,6 @@ static void style_window(struct nk_context* ctx, struct nk_style_window* out_style) { struct nk_style_window win = *out_style; - //win->background = table[NK_COLOR_WINDOW]; - //win->fixed_background = nk_style_item_color(table[NK_COLOR_WINDOW]); - //win->border_color = table[NK_COLOR_BORDER]; - //win->popup_border_color = table[NK_COLOR_BORDER]; - //win->combo_border_color = table[NK_COLOR_BORDER]; - //win->contextual_border_color = table[NK_COLOR_BORDER]; - //win->menu_border_color = table[NK_COLOR_BORDER]; - //win->group_border_color = table[NK_COLOR_BORDER]; - //win->tooltip_border_color = table[NK_COLOR_BORDER]; - //win->scaler = nk_style_item_color(table[NK_COLOR_TEXT]); - // - //win->rounding = 0.0f; - //win->spacing = nk_vec2(4,4); - //win->scrollbar_size = nk_vec2(10,10); - //win->min_size = nk_vec2(64,64); - // - //win->combo_border = 1.0f; - //win->contextual_border = 1.0f; - //win->menu_border = 1.0f; - //win->group_border = 1.0f; - //win->tooltip_border = 1.0f; - //win->popup_border = 1.0f; - //win->border = 2.0f; - //win->min_row_height_padding = 8; - // - //win->padding = nk_vec2(4,4); - //win->group_padding = nk_vec2(4,4); - //win->popup_padding = nk_vec2(4,4); - //win->combo_padding = nk_vec2(4,4); - //win->contextual_padding = nk_vec2(4,4); - //win->menu_padding = nk_vec2(4,4); - //win->tooltip_padding = nk_vec2(4,4); nk_layout_row_dynamic(ctx, 30, 2); @@ -899,7 +650,6 @@ style_configurator(struct nk_context *ctx) nk_flags window_flags = 0; int minimizable = nk_true; - /* window flags */ window_flags = 0; if (border) window_flags |= NK_WINDOW_BORDER; From e0685b656cff9fc9668d69ac693b21de0f240100 Mon Sep 17 00:00:00 2001 From: Robert Winkler Date: Mon, 9 Mar 2020 17:38:29 -0700 Subject: [PATCH 07/13] 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 Date: Tue, 10 Mar 2020 21:23:58 -0700 Subject: [PATCH 08/13] Added additional button text alignments --- demo/style_configurator.c | 63 +++++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 26 deletions(-) diff --git a/demo/style_configurator.c b/demo/style_configurator.c index c0c302a45..b6023795c 100644 --- a/demo/style_configurator.c +++ b/demo/style_configurator.c @@ -143,31 +143,45 @@ style_button(struct nk_context* ctx, struct nk_style_button* out_style, struct n style_vec2(ctx, "Image Padding:", &button.image_padding); style_vec2(ctx, "Touch Padding:", &button.touch_padding); - /* -enum nk_text_align { -NK_TEXT_ALIGN_LEFT = 0x01, -NK_TEXT_ALIGN_CENTERED = 0x02, -NK_TEXT_ALIGN_RIGHT = 0x04, -NK_TEXT_ALIGN_TOP = 0x08, -NK_TEXT_ALIGN_MIDDLE = 0x10, -NK_TEXT_ALIGN_BOTTOM = 0x20 + const char* alignments[] = +{ + "LEFT", + "CENTERED", + "RIGHT", + "TOP LEFT", + "TOP CENTERED", + "TOP_RIGHT", + "BOTTOM LEFT", + "BOTTOM CENTERED", + "BOTTOM RIGHT" }; -enum nk_text_alignment { -NK_TEXT_LEFT = NK_TEXT_ALIGN_MIDDLE|NK_TEXT_ALIGN_LEFT, -NK_TEXT_CENTERED = NK_TEXT_ALIGN_MIDDLE|NK_TEXT_ALIGN_CENTERED, -NK_TEXT_RIGHT = NK_TEXT_ALIGN_MIDDLE|NK_TEXT_ALIGN_RIGHT + +#define TOP_LEFT NK_TEXT_ALIGN_TOP|NK_TEXT_ALIGN_LEFT +#define TOP_CENTER NK_TEXT_ALIGN_TOP|NK_TEXT_ALIGN_CENTERED +#define TOP_RIGHT NK_TEXT_ALIGN_TOP|NK_TEXT_ALIGN_RIGHT +#define BOTTOM_LEFT NK_TEXT_ALIGN_BOTTOM|NK_TEXT_ALIGN_LEFT +#define BOTTOM_CENTER NK_TEXT_ALIGN_BOTTOM|NK_TEXT_ALIGN_CENTERED +#define BOTTOM_RIGHT NK_TEXT_ALIGN_BOTTOM|NK_TEXT_ALIGN_RIGHT + + int aligns[] = +{ + NK_TEXT_LEFT, + NK_TEXT_CENTERED, + NK_TEXT_RIGHT, + TOP_LEFT, + TOP_CENTER, + TOP_RIGHT, + BOTTOM_LEFT, + BOTTOM_CENTER, + BOTTOM_RIGHT }; -*/ - // TODO support combining with TOP/MIDDLE/BOTTOM .. separate combo? - const char* alignments[] = { "LEFT", "CENTERED", "RIGHT" }; - int aligns[3] = { NK_TEXT_LEFT, NK_TEXT_CENTERED, NK_TEXT_RIGHT }; + int cur_align; - if (button.text_alignment == NK_TEXT_LEFT) { - cur_align = 0; - } else if (button.text_alignment == NK_TEXT_CENTERED) { - cur_align = 1; - } else { - cur_align = 2; + for (int i=0; istyle.scrollh.dec_button, &ctx->style.scrollv.inc_button, &ctx->style.scrollv.dec_button }; @@ -407,9 +420,6 @@ style_edit(struct nk_context* ctx, struct nk_style_edit* out_style) style_vec2(ctx, "Scrollbar Size:", &edit.scrollbar_size); style_vec2(ctx, "Padding:", &edit.padding); - // TODO subtree? - //edit->scrollbar = style->scrollv; - nk_property_float(ctx, "#Row Padding:", -100.0f, &edit.row_padding, 100.0f, 1,0.5f); nk_property_float(ctx, "#Cursor Size:", -100.0f, &edit.cursor_size, 100.0f, 1,0.5f); nk_property_float(ctx, "#Border:", -100.0f, &edit.border, 100.0f, 1,0.5f); @@ -572,6 +582,7 @@ style_window_header(struct nk_context* ctx, struct nk_style_window_header* out_s nk_layout_row_dynamic(ctx, 30, 2); nk_label(ctx, "Button Alignment:", NK_TEXT_LEFT); header.align = nk_combo(ctx, alignments, NUM_ALIGNS, header.align, 25, nk_vec2(200,200)); +#undef NUM_ALIGNS nk_label(ctx, "Close Symbol:", NK_TEXT_LEFT); header.close_symbol = nk_combo(ctx, symbols, NK_SYMBOL_MAX, header.close_symbol, 25, nk_vec2(200,200)); From 2327f81a7db6f1484ea057032c4e3dc89053609a Mon Sep 17 00:00:00 2001 From: Robert Winkler Date: Mon, 30 Mar 2020 20:55:33 -0700 Subject: [PATCH 09/13] Pass color array in as a parameter --- demo/sdl_opengl3/main.c | 23 +++++++++++++++++++++-- demo/style_configurator.c | 13 ++----------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/demo/sdl_opengl3/main.c b/demo/sdl_opengl3/main.c index b758c01e5..9a1d941cb 100644 --- a/demo/sdl_opengl3/main.c +++ b/demo/sdl_opengl3/main.c @@ -131,6 +131,25 @@ int main(int argc, char *argv[]) /*nk_style_load_all_cursors(ctx, atlas->cursors);*/ /*nk_style_set_font(ctx, &roboto->handle);*/} + /* style.c */ + #ifdef INCLUDE_STYLE + /* ease regression testing during Nuklear release process; not needed for anything else */ + #ifdef STYLE_WHITE + set_style(ctx, THEME_WHITE); + #elif defined(STYLE_RED) + set_style(ctx, THEME_RED); + #elif defined(STYLE_BLUE) + set_style(ctx, THEME_BLUE); + #elif defined(STYLE_DARK) + set_style(ctx, THEME_DARK); + #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) { @@ -188,8 +207,8 @@ int main(int argc, char *argv[]) #ifdef INCLUDE_OVERVIEW overview(ctx); #endif - #ifdef INCLUDE_OVERVIEW - style_configurator(ctx); + #ifdef INCLUDE_CONFIGURATOR + style_configurator(ctx, color_table); #endif #ifdef INCLUDE_NODE_EDITOR node_editor(ctx); diff --git a/demo/style_configurator.c b/demo/style_configurator.c index b6023795c..cac536b61 100644 --- a/demo/style_configurator.c +++ b/demo/style_configurator.c @@ -656,7 +656,7 @@ style_window(struct nk_context* ctx, struct nk_style_window* out_style) } static int -style_configurator(struct nk_context *ctx) +style_configurator(struct nk_context *ctx, struct nk_color color_table[NK_COLOR_COUNT]) { /* window flags */ int border = nk_true; @@ -678,15 +678,6 @@ style_configurator(struct nk_context *ctx) struct nk_style *style = &ctx->style; - // TODO better way? - static int initialized = nk_false; - static struct nk_color color_table[NK_COLOR_COUNT]; - - if (!initialized) { - memcpy(color_table, nk_default_color_style, sizeof(color_table)); - initialized = nk_true; - } - if (nk_begin(ctx, "Configurator", nk_rect(10, 10, 400, 600), window_flags)) { if (nk_tree_push(ctx, NK_TREE_TAB, "Global Colors", NK_MINIMIZED)) { @@ -804,7 +795,7 @@ style_configurator(struct nk_context *ctx) nk_layout_row_dynamic(ctx, 30, 1); if (nk_button_label(ctx, "Reset all styles to defaults")) { - memcpy(color_table, nk_default_color_style, sizeof(color_table)); + memcpy(color_table, nk_default_color_style, sizeof(nk_default_color_style)); nk_style_default(ctx); } From cc9829028300845b3bfcd204b2671c215370e8b8 Mon Sep 17 00:00:00 2001 From: Robert Winkler Date: Tue, 28 Mar 2023 10:41:13 -0700 Subject: [PATCH 10/13] rebase --- demo/style_configurator.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/demo/style_configurator.c b/demo/style_configurator.c index cac536b61..a9a1b44f2 100644 --- a/demo/style_configurator.c +++ b/demo/style_configurator.c @@ -1,8 +1,10 @@ -// TODO design decisions -// plural or not? ie style_button or style_buttons? -// use the duplicate array method, or just let the user -// manually set those after calling the function by accessing ctx->style->*? +/* + TODO design decisions + plural or not? ie style_button or style_buttons? + use the duplicate array method, or just let the user + manually set those after calling the function by accessing ctx->style->*? +*/ static const char* symbols[NK_SYMBOL_MAX] = { @@ -176,7 +178,7 @@ style_button(struct nk_context* ctx, struct nk_style_button* out_style, struct n BOTTOM_RIGHT }; - int cur_align; + int cur_align = button.text_alignment-NK_TEXT_LEFT; for (int i=0; i Date: Wed, 29 Mar 2023 10:18:37 -0700 Subject: [PATCH 11/13] Compile as C89 -pedantic -Wall with no warnings --- demo/{ => common}/style_configurator.c | 85 +++++++++++++++----------- demo/sdl_opengl3/main.c | 12 ++-- 2 files changed, 57 insertions(+), 40 deletions(-) rename demo/{ => common}/style_configurator.c (93%) 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 a9a1b44f2..645df6e6c 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 9a1d941cb..51db13654 100644 --- a/demo/sdl_opengl3/main.c +++ b/demo/sdl_opengl3/main.c @@ -68,7 +68,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" @@ -91,6 +91,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); @@ -145,11 +150,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) { From 2282b6c4a559d4eb0df0bf95d04d050b27c13e05 Mon Sep 17 00:00:00 2001 From: Robert Winkler Date: Sun, 14 May 2023 23:19:27 -0700 Subject: [PATCH 12/13] Fix copy-paste error --- demo/sdl_opengl3/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/sdl_opengl3/main.c b/demo/sdl_opengl3/main.c index 51db13654..2041c4862 100644 --- a/demo/sdl_opengl3/main.c +++ b/demo/sdl_opengl3/main.c @@ -67,7 +67,7 @@ #ifdef INCLUDE_OVERVIEW #include "../../demo/common/overview.c" #endif -#ifdef INCLUDE_OVERVIEW +#ifdef INCLUDE_CONFIGURATOR #include "../../demo/common/style_configurator.c" #endif #ifdef INCLUDE_NODE_EDITOR From 0f909452146d7d690535ac8bef35f55c6f0d5f06 Mon Sep 17 00:00:00 2001 From: Robert Winkler Date: Mon, 25 Nov 2024 23:56:20 -0700 Subject: [PATCH 13/13] Fix/update --- demo/common/style_configurator.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/demo/common/style_configurator.c b/demo/common/style_configurator.c index 645df6e6c..6443c6844 100644 --- a/demo/common/style_configurator.c +++ b/demo/common/style_configurator.c @@ -98,7 +98,11 @@ style_global_colors(struct nk_context* ctx, struct nk_color color_table[NK_COLOR "COLOR_SCROLLBAR_CURSOR:", "COLOR_SCROLLBAR_CURSOR_HOVER:", "COLOR_SCROLLBAR_CURSOR_ACTIVE:", - "COLOR_TAB_HEADER:" + "COLOR_TAB_HEADER:", + "COLOR_KNOB:", + "COLOR_KNOB_CURSOR:", + "COLOR_KNOB_CURSOR_HOVER:", + "COLOR_KNOB_CURSOR_ACTIVE:" }; int clicked = 0;