From 64b530f89c63ffce7c8e72005f5f1af41ac40d20 Mon Sep 17 00:00:00 2001 From: Robert Lemmens Date: Fri, 17 Jun 2022 13:03:31 +0200 Subject: [PATCH 01/10] update checkbox and radio look and feel --- nuklear.h | 14 ++++++++------ src/nuklear_toggle.c | 14 ++++++++------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/nuklear.h b/nuklear.h index aef8f7fe9..f2dafd3f1 100644 --- a/nuklear.h +++ b/nuklear.h @@ -24434,13 +24434,14 @@ nk_draw_checkbox(struct nk_command_buffer *out, /* draw background and cursor */ if (background->type == NK_STYLE_ITEM_COLOR) { - nk_fill_rect(out, *selector, 0, style->border_color); - nk_fill_rect(out, nk_shrink_rect(*selector, style->border), 0, background->data.color); +// nk_fill_rect(out, *selector, 0, style->border_color); +// nk_fill_rect(out, nk_shrink_rect(*selector, style->border), 0, background->data.color); + nk_stroke_rect(out, *selector, 2, 2, background->data.color); } else nk_draw_image(out, *selector, &background->data.image, nk_white); if (active) { if (cursor->type == NK_STYLE_ITEM_IMAGE) nk_draw_image(out, *cursors, &cursor->data.image, nk_white); - else nk_fill_rect(out, *cursors, 0, cursor->data.color); + else nk_fill_rect(out, *cursors, 0, background->data.color); } text.padding.x = 0; @@ -24476,13 +24477,14 @@ nk_draw_option(struct nk_command_buffer *out, /* draw background and cursor */ if (background->type == NK_STYLE_ITEM_COLOR) { - nk_fill_circle(out, *selector, style->border_color); - nk_fill_circle(out, nk_shrink_rect(*selector, style->border), background->data.color); +// nk_fill_circle(out, *selector, style->border_color); +// nk_fill_circle(out, nk_shrink_rect(*selector, style->border), background->data.color); + nk_stroke_circle(out, *selector, 2, background->data.color); } else nk_draw_image(out, *selector, &background->data.image, nk_white); if (active) { if (cursor->type == NK_STYLE_ITEM_IMAGE) nk_draw_image(out, *cursors, &cursor->data.image, nk_white); - else nk_fill_circle(out, *cursors, cursor->data.color); + else nk_fill_circle(out, *cursors, background->data.color); } text.padding.x = 0; diff --git a/src/nuklear_toggle.c b/src/nuklear_toggle.c index 0644a8078..123a40d64 100644 --- a/src/nuklear_toggle.c +++ b/src/nuklear_toggle.c @@ -49,13 +49,14 @@ nk_draw_checkbox(struct nk_command_buffer *out, /* draw background and cursor */ if (background->type == NK_STYLE_ITEM_COLOR) { - nk_fill_rect(out, *selector, 0, style->border_color); - nk_fill_rect(out, nk_shrink_rect(*selector, style->border), 0, background->data.color); +// nk_fill_rect(out, *selector, 0, style->border_color); +// nk_fill_rect(out, nk_shrink_rect(*selector, style->border), 0, background->data.color); + nk_stroke_rect(out, *selector, 2, 2, background->data.color); } else nk_draw_image(out, *selector, &background->data.image, nk_white); if (active) { if (cursor->type == NK_STYLE_ITEM_IMAGE) nk_draw_image(out, *cursors, &cursor->data.image, nk_white); - else nk_fill_rect(out, *cursors, 0, cursor->data.color); + else nk_fill_rect(out, *cursors, 0, background->data.color); } text.padding.x = 0; @@ -91,13 +92,14 @@ nk_draw_option(struct nk_command_buffer *out, /* draw background and cursor */ if (background->type == NK_STYLE_ITEM_COLOR) { - nk_fill_circle(out, *selector, style->border_color); - nk_fill_circle(out, nk_shrink_rect(*selector, style->border), background->data.color); +// nk_fill_circle(out, *selector, style->border_color); +// nk_fill_circle(out, nk_shrink_rect(*selector, style->border), background->data.color); + nk_stroke_circle(out, *selector, 2, background->data.color); } else nk_draw_image(out, *selector, &background->data.image, nk_white); if (active) { if (cursor->type == NK_STYLE_ITEM_IMAGE) nk_draw_image(out, *cursors, &cursor->data.image, nk_white); - else nk_fill_circle(out, *cursors, cursor->data.color); + else nk_fill_circle(out, *cursors, background->data.color); } text.padding.x = 0; From 8491451f34862d532b9dc200ecbcf22a3160bbf8 Mon Sep 17 00:00:00 2001 From: Robert Lemmens Date: Fri, 17 Jun 2022 13:25:08 +0200 Subject: [PATCH 02/10] cleanup commented code --- nuklear.h | 4 ---- src/nuklear_toggle.c | 4 ---- 2 files changed, 8 deletions(-) diff --git a/nuklear.h b/nuklear.h index f2dafd3f1..421047107 100644 --- a/nuklear.h +++ b/nuklear.h @@ -24434,8 +24434,6 @@ nk_draw_checkbox(struct nk_command_buffer *out, /* draw background and cursor */ if (background->type == NK_STYLE_ITEM_COLOR) { -// nk_fill_rect(out, *selector, 0, style->border_color); -// nk_fill_rect(out, nk_shrink_rect(*selector, style->border), 0, background->data.color); nk_stroke_rect(out, *selector, 2, 2, background->data.color); } else nk_draw_image(out, *selector, &background->data.image, nk_white); if (active) { @@ -24477,8 +24475,6 @@ nk_draw_option(struct nk_command_buffer *out, /* draw background and cursor */ if (background->type == NK_STYLE_ITEM_COLOR) { -// nk_fill_circle(out, *selector, style->border_color); -// nk_fill_circle(out, nk_shrink_rect(*selector, style->border), background->data.color); nk_stroke_circle(out, *selector, 2, background->data.color); } else nk_draw_image(out, *selector, &background->data.image, nk_white); if (active) { diff --git a/src/nuklear_toggle.c b/src/nuklear_toggle.c index 123a40d64..f03adda8f 100644 --- a/src/nuklear_toggle.c +++ b/src/nuklear_toggle.c @@ -49,8 +49,6 @@ nk_draw_checkbox(struct nk_command_buffer *out, /* draw background and cursor */ if (background->type == NK_STYLE_ITEM_COLOR) { -// nk_fill_rect(out, *selector, 0, style->border_color); -// nk_fill_rect(out, nk_shrink_rect(*selector, style->border), 0, background->data.color); nk_stroke_rect(out, *selector, 2, 2, background->data.color); } else nk_draw_image(out, *selector, &background->data.image, nk_white); if (active) { @@ -92,8 +90,6 @@ nk_draw_option(struct nk_command_buffer *out, /* draw background and cursor */ if (background->type == NK_STYLE_ITEM_COLOR) { -// nk_fill_circle(out, *selector, style->border_color); -// nk_fill_circle(out, nk_shrink_rect(*selector, style->border), background->data.color); nk_stroke_circle(out, *selector, 2, background->data.color); } else nk_draw_image(out, *selector, &background->data.image, nk_white); if (active) { From 481b77df5202814216b64d5a099e0eeac152ad81 Mon Sep 17 00:00:00 2001 From: Robert Lemmens Date: Fri, 17 Jun 2022 13:30:01 +0200 Subject: [PATCH 03/10] update the indentation --- nuklear.h | 4 ++-- src/nuklear_toggle.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/nuklear.h b/nuklear.h index 421047107..60ab0d59f 100644 --- a/nuklear.h +++ b/nuklear.h @@ -24434,7 +24434,7 @@ nk_draw_checkbox(struct nk_command_buffer *out, /* draw background and cursor */ if (background->type == NK_STYLE_ITEM_COLOR) { - nk_stroke_rect(out, *selector, 2, 2, background->data.color); + nk_stroke_rect(out, *selector, 2, 2, background->data.color); } else nk_draw_image(out, *selector, &background->data.image, nk_white); if (active) { if (cursor->type == NK_STYLE_ITEM_IMAGE) @@ -24475,7 +24475,7 @@ nk_draw_option(struct nk_command_buffer *out, /* draw background and cursor */ if (background->type == NK_STYLE_ITEM_COLOR) { - nk_stroke_circle(out, *selector, 2, background->data.color); + nk_stroke_circle(out, *selector, 2, background->data.color); } else nk_draw_image(out, *selector, &background->data.image, nk_white); if (active) { if (cursor->type == NK_STYLE_ITEM_IMAGE) diff --git a/src/nuklear_toggle.c b/src/nuklear_toggle.c index f03adda8f..94af497b0 100644 --- a/src/nuklear_toggle.c +++ b/src/nuklear_toggle.c @@ -49,7 +49,7 @@ nk_draw_checkbox(struct nk_command_buffer *out, /* draw background and cursor */ if (background->type == NK_STYLE_ITEM_COLOR) { - nk_stroke_rect(out, *selector, 2, 2, background->data.color); + nk_stroke_rect(out, *selector, 2, 2, background->data.color); } else nk_draw_image(out, *selector, &background->data.image, nk_white); if (active) { if (cursor->type == NK_STYLE_ITEM_IMAGE) @@ -90,7 +90,7 @@ nk_draw_option(struct nk_command_buffer *out, /* draw background and cursor */ if (background->type == NK_STYLE_ITEM_COLOR) { - nk_stroke_circle(out, *selector, 2, background->data.color); + nk_stroke_circle(out, *selector, 2, background->data.color); } else nk_draw_image(out, *selector, &background->data.image, nk_white); if (active) { if (cursor->type == NK_STYLE_ITEM_IMAGE) From b82119178534ff9121f0552a4ad0950d4b1cdad0 Mon Sep 17 00:00:00 2001 From: Robert Lemmens Date: Fri, 17 Jun 2022 13:36:54 +0200 Subject: [PATCH 04/10] update changelog --- src/CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CHANGELOG b/src/CHANGELOG index 44223af14..c2b148cde 100644 --- a/src/CHANGELOG +++ b/src/CHANGELOG @@ -7,6 +7,7 @@ /// - [y]: Minor version with non-breaking API and library changes /// - [z]: Patch version with no direct changes to the API /// +/// - 2022/06/17 (4.10.1) - Updated the look and feel of checkboxes and radio buttons to be more distinguishable /// - 2022/05/27 (4.10.0) - Add nk_input_has_mouse_click_in_button_rect() to fix window move bug /// - 2022/04/18 (4.9.7) - Change button behavior when NK_BUTTON_TRIGGER_ON_RELEASE is defined to /// only trigger when the mouse position was inside the same button on down From 204888fb3beb5fa7908d5a3fd27e2417d3cbf5be Mon Sep 17 00:00:00 2001 From: "Alexander W. Schultz" Date: Mon, 2 Sep 2024 15:06:20 -0400 Subject: [PATCH 05/10] fixes minor issue with repeat lines from the merge --- src/nuklear_toggle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nuklear_toggle.c b/src/nuklear_toggle.c index dafbe9f85..28839f613 100644 --- a/src/nuklear_toggle.c +++ b/src/nuklear_toggle.c @@ -47,10 +47,10 @@ nk_draw_checkbox(struct nk_command_buffer *out, text.text = style->text_normal; } - text.text = nk_rgb_factor(text.text, style->color_factor); text.text = nk_rgb_factor(text.text, style->color_factor); text.padding.x = 0; text.padding.y = 0; + text.background = style->text_background; nk_widget_text(out, *label, string, len, &text, text_alignment, font); /* draw background and cursor */ From 7a87b4a11eb595fbe9f18d8ba264c63d295b76e6 Mon Sep 17 00:00:00 2001 From: "Alexander W. Schultz" Date: Mon, 2 Sep 2024 15:29:59 -0400 Subject: [PATCH 06/10] updates Nuklear.h Verified that toggle boxes and buttons look good for all SDL, X11, and GLFW demos. Also respects different styles, which is the biggest change with the recent merge with master. --- nuklear.h | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/nuklear.h b/nuklear.h index 3b14a74b4..7d5503e4f 100644 --- a/nuklear.h +++ b/nuklear.h @@ -24907,16 +24907,18 @@ nk_draw_checkbox(struct nk_command_buffer *out, text.padding.y = 0; text.background = style->text_background; nk_widget_text(out, *label, string, len, &text, text_alignment, font); + /* draw background and cursor */ if (background->type == NK_STYLE_ITEM_COLOR) { - nk_stroke_rect(out, *selector, 2, 2, background->data.color); - } else nk_draw_image(out, *selector, &background->data.image, nk_white); + nk_stroke_rect(out, *selector, 2, 2, nk_rgb_factor(background->data.color, style->color_factor)); + } else nk_draw_image(out, *selector, &background->data.image, nk_rgb_factor(nk_white, style->color_factor)); if (active) { if (cursor->type == NK_STYLE_ITEM_IMAGE) - nk_draw_image(out, *cursors, &cursor->data.image, nk_white); - else nk_fill_rect(out, *cursors, 0, background->data.color); + nk_draw_image(out, *cursors, &cursor->data.image, nk_rgb_factor(nk_white, style->color_factor)); + else nk_fill_rect(out, *cursors, 0, nk_rgb_factor(background->data.color, style->color_factor)); } + } NK_LIB void nk_draw_option(struct nk_command_buffer *out, @@ -24944,20 +24946,21 @@ nk_draw_option(struct nk_command_buffer *out, text.text = style->text_normal; } + text.text = nk_rgb_factor(text.text, style->color_factor); + text.padding.x = 0; + text.padding.y = 0; + text.background = style->text_background; + nk_widget_text(out, *label, string, len, &text, text_alignment, font); + /* draw background and cursor */ if (background->type == NK_STYLE_ITEM_COLOR) { - nk_stroke_circle(out, *selector, 2, background->data.color); - } else nk_draw_image(out, *selector, &background->data.image, nk_rgb_factor(nk_white, style->color_factor))); + nk_stroke_circle(out, *selector, 2, nk_rgb_factor(background->data.color, style->color_factor)); + } else nk_draw_image(out, *selector, &background->data.image, nk_rgb_factor(nk_white, style->color_factor)); if (active) { if (cursor->type == NK_STYLE_ITEM_IMAGE) - nk_draw_image(out, *cursors, &cursor->data.image, nk_rgb_factor(nk_white, style->color_factor))); + nk_draw_image(out, *cursors, &cursor->data.image, nk_rgb_factor(nk_white, style->color_factor)); else nk_fill_circle(out, *cursors, background->data.color); } - - text.padding.x = 0; - text.padding.y = 0; - text.background = style->text_background; - nk_widget_text(out, *label, string, len, &text, NK_TEXT_LEFT, font); } NK_LIB nk_bool nk_do_toggle(nk_flags *state, @@ -30539,6 +30542,7 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args) /// - 2022/12/23 (4.10.6) - Fix incorrect glyph index in nk_font_bake() /// - 2022/12/17 (4.10.5) - Fix nk_font_bake_pack() using TTC font offset incorrectly /// - 2022/10/24 (4.10.4) - Fix nk_str_{append,insert}_str_utf8 always returning 0 +/// - 2022/10/03 (4.10.4) - Updated the look and feel of checkboxes and radio buttons to be more distinguishable /// - 2022/09/03 (4.10.3) - Renamed the `null` texture variable to `tex_null` /// - 2022/08/01 (4.10.2) - Fix Apple Silicon with incorrect NK_SITE_TYPE and NK_POINTER_TYPE /// - 2022/08/01 (4.10.1) - Fix cursor jumping back to beginning of text when typing more than From bc40ecc00fcc297fe38843b5e661e532ab872903 Mon Sep 17 00:00:00 2001 From: awschult002 <73046001+awschult002@users.noreply.github.com> Date: Tue, 17 Sep 2024 09:44:02 -0400 Subject: [PATCH 07/10] fixes toggle rectangle overlap The new checkbox toggle look was off by a couple of pixels. This commit fixes that by removing the "line thickness" operation performed on its width before drawing. --- demo/x11/nuklear_xlib.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/demo/x11/nuklear_xlib.h b/demo/x11/nuklear_xlib.h index 0a80ab49e..0d025c791 100644 --- a/demo/x11/nuklear_xlib.h +++ b/demo/x11/nuklear_xlib.h @@ -927,8 +927,8 @@ nk_xlib_render(Drawable screen, struct nk_color clear) } break; case NK_COMMAND_RECT: { const struct nk_command_rect *r = (const struct nk_command_rect *)cmd; - nk_xsurf_stroke_rect(surf, r->x, r->y, NK_MAX(r->w -r->line_thickness, 0), - NK_MAX(r->h - r->line_thickness, 0), (unsigned short)r->rounding, + nk_xsurf_stroke_rect(surf, r->x, r->y, r->w, + r->h, (unsigned short)r->rounding, r->line_thickness, r->color); } break; case NK_COMMAND_RECT_FILLED: { From 1b8b90e0b9fc9ae60f41fc01ded9955191a2207b Mon Sep 17 00:00:00 2001 From: awschult002 <73046001+awschult002@users.noreply.github.com> Date: Tue, 17 Sep 2024 09:44:35 -0400 Subject: [PATCH 08/10] Update nuklear_xlib.h The new checkbox toggle look was off by a couple of pixels. This commit fixes that by removing the "line thickness" operation performed on its width before drawing. --- demo/x11_xft/nuklear_xlib.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/demo/x11_xft/nuklear_xlib.h b/demo/x11_xft/nuklear_xlib.h index 1931828b0..481c3cc48 100644 --- a/demo/x11_xft/nuklear_xlib.h +++ b/demo/x11_xft/nuklear_xlib.h @@ -1012,8 +1012,8 @@ nk_xlib_render(Drawable screen, struct nk_color clear) } break; case NK_COMMAND_RECT: { const struct nk_command_rect *r = (const struct nk_command_rect *)cmd; - nk_xsurf_stroke_rect(surf, r->x, r->y, NK_MAX(r->w -r->line_thickness, 0), - NK_MAX(r->h - r->line_thickness, 0), (unsigned short)r->rounding, + nk_xsurf_stroke_rect(surf, r->x, r->y, r->w, + r->h, (unsigned short)r->rounding, r->line_thickness, r->color); } break; case NK_COMMAND_RECT_FILLED: { From 66c5d1166787922007ccd2a1b10bd37929bb8d62 Mon Sep 17 00:00:00 2001 From: awschult002 <73046001+awschult002@users.noreply.github.com> Date: Thu, 17 Oct 2024 20:24:49 -0400 Subject: [PATCH 09/10] removes rounded corners from checkboxes the rounded corners on the checkboxes looked terrible with the X11 and rawfb demos. This was also in-congruent with the previous look. Reverting to sharp corners keeps the previous look while also removing the issue of the X11 looking terrible. This commit also shrinks the select toggle box inside the checkbox by a couple pixels to better match the radio button's look and feel --- src/nuklear_toggle.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/nuklear_toggle.c b/src/nuklear_toggle.c index 28839f613..188e44129 100644 --- a/src/nuklear_toggle.c +++ b/src/nuklear_toggle.c @@ -31,6 +31,12 @@ nk_draw_checkbox(struct nk_command_buffer *out, const struct nk_style_item *background; const struct nk_style_item *cursor; struct nk_text text; + struct nk_rect toggle_active_box = *cursors; + toggle_active_box.x += 1; + toggle_active_box.y += 1; + toggle_active_box.w -= 2; + toggle_active_box.h -= 2; + /* select correct colors/images */ if (state & NK_WIDGET_STATE_HOVER) { @@ -55,12 +61,12 @@ nk_draw_checkbox(struct nk_command_buffer *out, /* draw background and cursor */ if (background->type == NK_STYLE_ITEM_COLOR) { - nk_stroke_rect(out, *selector, 2, 2, nk_rgb_factor(background->data.color, style->color_factor)); + nk_stroke_rect(out, *selector, 2, 0, nk_rgb_factor(background->data.color, style->color_factor)); } else nk_draw_image(out, *selector, &background->data.image, nk_rgb_factor(nk_white, style->color_factor)); if (active) { if (cursor->type == NK_STYLE_ITEM_IMAGE) nk_draw_image(out, *cursors, &cursor->data.image, nk_rgb_factor(nk_white, style->color_factor)); - else nk_fill_rect(out, *cursors, 0, nk_rgb_factor(background->data.color, style->color_factor)); + else nk_fill_rect(out, toggle_active_box, 0, nk_rgb_factor(background->data.color, style->color_factor)); } From ff26938657407a7b7d60c748ebf878d396b34310 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Sun, 17 Nov 2024 18:00:48 -0500 Subject: [PATCH 10/10] Follow up on checkbox --- nuklear.h | 20 +++++++++++--------- src/nuklear_style.c | 8 ++++---- src/nuklear_toggle.c | 20 ++++++++------------ 3 files changed, 23 insertions(+), 25 deletions(-) diff --git a/nuklear.h b/nuklear.h index e47785a3a..0e8c255f3 100644 --- a/nuklear.h +++ b/nuklear.h @@ -18669,10 +18669,10 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table) 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->padding = nk_vec2(1.0f, 1.0f); toggle->touch_padding = nk_vec2(0,0); toggle->border_color = nk_rgba(0,0,0,0); - toggle->border = 0.0f; + toggle->border = 1.0f; toggle->spacing = 4; toggle->color_factor = 1.0f; toggle->disabled_factor = NK_WIDGET_DISABLED_FACTOR; @@ -18690,10 +18690,10 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table) 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(3.0f, 3.0f); + toggle->padding = nk_vec2(1.0f, 1.0f); toggle->touch_padding = nk_vec2(0,0); toggle->border_color = nk_rgba(0,0,0,0); - toggle->border = 0.0f; + toggle->border = 1.0f; toggle->spacing = 4; toggle->color_factor = 1.0f; toggle->disabled_factor = NK_WIDGET_DISABLED_FACTOR; @@ -25070,18 +25070,18 @@ nk_draw_checkbox(struct nk_command_buffer *out, text.padding.y = 0; text.background = style->text_background; nk_widget_text(out, *label, string, len, &text, text_alignment, font); - + /* draw background and cursor */ if (background->type == NK_STYLE_ITEM_COLOR) { - nk_stroke_rect(out, *selector, 2, 2, nk_rgb_factor(background->data.color, style->color_factor)); + nk_stroke_rect(out, *selector, 0, style->border, nk_rgb_factor(background->data.color, style->color_factor)); } else nk_draw_image(out, *selector, &background->data.image, nk_rgb_factor(nk_white, style->color_factor)); + + /* active state */ if (active) { if (cursor->type == NK_STYLE_ITEM_IMAGE) nk_draw_image(out, *cursors, &cursor->data.image, nk_rgb_factor(nk_white, style->color_factor)); else nk_fill_rect(out, *cursors, 0, nk_rgb_factor(background->data.color, style->color_factor)); } - - } NK_LIB void nk_draw_option(struct nk_command_buffer *out, @@ -25117,8 +25117,10 @@ nk_draw_option(struct nk_command_buffer *out, /* draw background and cursor */ if (background->type == NK_STYLE_ITEM_COLOR) { - nk_stroke_circle(out, *selector, 2, nk_rgb_factor(background->data.color, style->color_factor)); + nk_stroke_circle(out, *selector, style->border, nk_rgb_factor(background->data.color, style->color_factor)); } else nk_draw_image(out, *selector, &background->data.image, nk_rgb_factor(nk_white, style->color_factor)); + + /* active state */ if (active) { if (cursor->type == NK_STYLE_ITEM_IMAGE) nk_draw_image(out, *cursors, &cursor->data.image, nk_rgb_factor(nk_white, style->color_factor)); diff --git a/src/nuklear_style.c b/src/nuklear_style.c index 377836a4a..89e8338e4 100644 --- a/src/nuklear_style.c +++ b/src/nuklear_style.c @@ -204,10 +204,10 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table) 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->padding = nk_vec2(1.0f, 1.0f); toggle->touch_padding = nk_vec2(0,0); toggle->border_color = nk_rgba(0,0,0,0); - toggle->border = 0.0f; + toggle->border = 1.0f; toggle->spacing = 4; toggle->color_factor = 1.0f; toggle->disabled_factor = NK_WIDGET_DISABLED_FACTOR; @@ -225,10 +225,10 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table) 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(3.0f, 3.0f); + toggle->padding = nk_vec2(1.0f, 1.0f); toggle->touch_padding = nk_vec2(0,0); toggle->border_color = nk_rgba(0,0,0,0); - toggle->border = 0.0f; + toggle->border = 1.0f; toggle->spacing = 4; toggle->color_factor = 1.0f; toggle->disabled_factor = NK_WIDGET_DISABLED_FACTOR; diff --git a/src/nuklear_toggle.c b/src/nuklear_toggle.c index 188e44129..5e1824b8b 100644 --- a/src/nuklear_toggle.c +++ b/src/nuklear_toggle.c @@ -31,12 +31,6 @@ nk_draw_checkbox(struct nk_command_buffer *out, const struct nk_style_item *background; const struct nk_style_item *cursor; struct nk_text text; - struct nk_rect toggle_active_box = *cursors; - toggle_active_box.x += 1; - toggle_active_box.y += 1; - toggle_active_box.w -= 2; - toggle_active_box.h -= 2; - /* select correct colors/images */ if (state & NK_WIDGET_STATE_HOVER) { @@ -58,18 +52,18 @@ nk_draw_checkbox(struct nk_command_buffer *out, text.padding.y = 0; text.background = style->text_background; nk_widget_text(out, *label, string, len, &text, text_alignment, font); - + /* draw background and cursor */ if (background->type == NK_STYLE_ITEM_COLOR) { - nk_stroke_rect(out, *selector, 2, 0, nk_rgb_factor(background->data.color, style->color_factor)); + nk_stroke_rect(out, *selector, 0, style->border, nk_rgb_factor(background->data.color, style->color_factor)); } else nk_draw_image(out, *selector, &background->data.image, nk_rgb_factor(nk_white, style->color_factor)); + + /* active state */ if (active) { if (cursor->type == NK_STYLE_ITEM_IMAGE) nk_draw_image(out, *cursors, &cursor->data.image, nk_rgb_factor(nk_white, style->color_factor)); - else nk_fill_rect(out, toggle_active_box, 0, nk_rgb_factor(background->data.color, style->color_factor)); + else nk_fill_rect(out, *cursors, 0, nk_rgb_factor(background->data.color, style->color_factor)); } - - } NK_LIB void nk_draw_option(struct nk_command_buffer *out, @@ -105,8 +99,10 @@ nk_draw_option(struct nk_command_buffer *out, /* draw background and cursor */ if (background->type == NK_STYLE_ITEM_COLOR) { - nk_stroke_circle(out, *selector, 2, nk_rgb_factor(background->data.color, style->color_factor)); + nk_stroke_circle(out, *selector, style->border, nk_rgb_factor(background->data.color, style->color_factor)); } else nk_draw_image(out, *selector, &background->data.image, nk_rgb_factor(nk_white, style->color_factor)); + + /* active state */ if (active) { if (cursor->type == NK_STYLE_ITEM_IMAGE) nk_draw_image(out, *cursors, &cursor->data.image, nk_rgb_factor(nk_white, style->color_factor));