From e8fe41584d5b2e7c2e519489a0ecd3509fc4d222 Mon Sep 17 00:00:00 2001 From: vurtun Date: Sun, 1 May 2016 19:15:19 +0200 Subject: [PATCH] Added color picker into x11 opengl demos --- demo/x11_opengl2/main.c | 15 +++++++++++++++ demo/x11_opengl3/main.c | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/demo/x11_opengl2/main.c b/demo/x11_opengl2/main.c index df675cd..7b26326 100644 --- a/demo/x11_opengl2/main.c +++ b/demo/x11_opengl2/main.c @@ -266,6 +266,21 @@ int main(int argc, char **argv) if (nk_option_label(ctx, "hard", op == HARD)) op = HARD; nk_layout_row_dynamic(ctx, 25, 1); nk_property_int(ctx, "Compression:", 0, &property, 100, 10, 1); + + {struct nk_panel combo; + nk_layout_row_dynamic(ctx, 20, 1); + nk_label(ctx, "background:", NK_TEXT_LEFT); + nk_layout_row_dynamic(ctx, 25, 1); + if (nk_combo_begin_color(ctx, &combo, background, 400)) { + nk_layout_row_dynamic(ctx, 120, 1); + background = nk_color_picker(ctx, background, NK_RGBA); + nk_layout_row_dynamic(ctx, 25, 1); + background.r = (nk_byte)nk_propertyi(ctx, "#R:", 0, background.r, 255, 1,1); + background.g = (nk_byte)nk_propertyi(ctx, "#G:", 0, background.g, 255, 1,1); + background.b = (nk_byte)nk_propertyi(ctx, "#B:", 0, background.b, 255, 1,1); + background.a = (nk_byte)nk_propertyi(ctx, "#A:", 0, background.a, 255, 1,1); + nk_combo_end(ctx); + }} } nk_end(ctx);} if (nk_window_is_closed(ctx, "Demo")) break; diff --git a/demo/x11_opengl3/main.c b/demo/x11_opengl3/main.c index a7795a8..d9121c0 100644 --- a/demo/x11_opengl3/main.c +++ b/demo/x11_opengl3/main.c @@ -264,6 +264,21 @@ int main(int argc, char **argv) if (nk_option_label(ctx, "hard", op == HARD)) op = HARD; nk_layout_row_dynamic(ctx, 25, 1); nk_property_int(ctx, "Compression:", 0, &property, 100, 10, 1); + + {struct nk_panel combo; + nk_layout_row_dynamic(ctx, 20, 1); + nk_label(ctx, "background:", NK_TEXT_LEFT); + nk_layout_row_dynamic(ctx, 25, 1); + if (nk_combo_begin_color(ctx, &combo, background, 400)) { + nk_layout_row_dynamic(ctx, 120, 1); + background = nk_color_picker(ctx, background, NK_RGBA); + nk_layout_row_dynamic(ctx, 25, 1); + background.r = (nk_byte)nk_propertyi(ctx, "#R:", 0, background.r, 255, 1,1); + background.g = (nk_byte)nk_propertyi(ctx, "#G:", 0, background.g, 255, 1,1); + background.b = (nk_byte)nk_propertyi(ctx, "#B:", 0, background.b, 255, 1,1); + background.a = (nk_byte)nk_propertyi(ctx, "#A:", 0, background.a, 255, 1,1); + nk_combo_end(ctx); + }} } nk_end(ctx);} if (nk_window_is_closed(ctx, "Demo")) break;