Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checkbox Appearance #2 #733

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions demo/x11/nuklear_xlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
4 changes: 2 additions & 2 deletions demo/x11_xft/nuklear_xlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
23 changes: 13 additions & 10 deletions nuklear.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -25073,13 +25073,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, nk_rgb_factor(style->border_color, style->color_factor));
nk_fill_rect(out, nk_shrink_rect(*selector, style->border), 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, *cursors, 0, cursor->data.color);
else nk_fill_rect(out, *cursors, 0, nk_rgb_factor(background->data.color, style->color_factor));
}
}
NK_LIB void
Expand Down Expand Up @@ -25116,13 +25117,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, nk_rgb_factor(style->border_color, style->color_factor));
nk_fill_circle(out, nk_shrink_rect(*selector, style->border), 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));
else nk_fill_circle(out, *cursors, cursor->data.color);
else nk_fill_circle(out, *cursors, background->data.color);
}
}
NK_LIB nk_bool
Expand Down Expand Up @@ -30704,6 +30706,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
Expand Down
1 change: 1 addition & 0 deletions src/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
/// - 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
Expand Down
8 changes: 4 additions & 4 deletions src/nuklear_style.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
14 changes: 8 additions & 6 deletions src/nuklear_toggle.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,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, nk_rgb_factor(style->border_color, style->color_factor));
nk_fill_rect(out, nk_shrink_rect(*selector, style->border), 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, *cursors, 0, cursor->data.color);
else nk_fill_rect(out, *cursors, 0, nk_rgb_factor(background->data.color, style->color_factor));
}
}
NK_LIB void
Expand Down Expand Up @@ -98,13 +99,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, nk_rgb_factor(style->border_color, style->color_factor));
nk_fill_circle(out, nk_shrink_rect(*selector, style->border), 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));
else nk_fill_circle(out, *cursors, cursor->data.color);
else nk_fill_circle(out, *cursors, background->data.color);
}
}
NK_LIB nk_bool
Expand Down