@@ -526,6 +526,11 @@ enum nk_symbol_type {
526526 NK_SYMBOL_TRIANGLE_DOWN_OUTLINE,
527527 NK_SYMBOL_TRIANGLE_LEFT_OUTLINE,
528528 NK_SYMBOL_TRIANGLE_RIGHT_OUTLINE,
529+ NK_SYMBOL_CHEVRON_UP,
530+ NK_SYMBOL_CHEVRON_RIGHT,
531+ NK_SYMBOL_CHEVRON_DOWN,
532+ NK_SYMBOL_CHEVRON_LEFT,
533+ NK_SYMBOL_HAMBURGER, /** Three horizontal lines. */
529534 NK_SYMBOL_MAX
530535};
531536/* =============================================================================
@@ -24531,20 +24536,32 @@ nk_draw_symbol(struct nk_command_buffer *out, enum nk_symbol_type type,
2453124536 struct nk_rect content, struct nk_color background, struct nk_color foreground,
2453224537 float border_width, const struct nk_user_font *font)
2453324538{
24539+ /* Use the border_width as the line thickness. */
24540+ if (border_width <= 0.0f) {
24541+ border_width = 1.0f;
24542+ }
2453424543 switch (type) {
24535- case NK_SYMBOL_X:
24544+ case NK_SYMBOL_X: {
24545+ float pad_x = content.w * 0.2f;
24546+ float pad_y = content.h * 0.2f;
24547+ float x0 = content.x + pad_x;
24548+ float y0 = content.y + pad_y;
24549+ float x1 = content.x + content.w - pad_x;
24550+ float y1 = content.y + content.h - pad_y;
24551+ nk_stroke_line(out, x0, y0, x1, y1, border_width, foreground);
24552+ nk_stroke_line(out, x1, y0, x0, y1, border_width, foreground);
24553+ } break;
2453624554 case NK_SYMBOL_UNDERSCORE:
2453724555 case NK_SYMBOL_PLUS:
2453824556 case NK_SYMBOL_MINUS: {
2453924557 /* single character text symbol */
24540- const char *X = (type == NK_SYMBOL_X) ? "x":
24541- (type == NK_SYMBOL_UNDERSCORE) ? "_":
24558+ const char *character = (type == NK_SYMBOL_UNDERSCORE) ? "_":
2454224559 (type == NK_SYMBOL_PLUS) ? "+": "-";
2454324560 struct nk_text text;
2454424561 text.padding = nk_vec2(0,0);
2454524562 text.background = background;
2454624563 text.text = foreground;
24547- nk_widget_text(out, content, X , 1, &text, NK_TEXT_CENTERED, font);
24564+ nk_widget_text(out, content, character , 1, &text, NK_TEXT_CENTERED, font);
2454824565 } break;
2454924566 case NK_SYMBOL_CIRCLE_SOLID:
2455024567 case NK_SYMBOL_CIRCLE_OUTLINE:
@@ -24558,7 +24575,7 @@ nk_draw_symbol(struct nk_command_buffer *out, enum nk_symbol_type type,
2455824575 } else {
2455924576 nk_fill_circle(out, content, foreground);
2456024577 if (type == NK_SYMBOL_CIRCLE_OUTLINE)
24561- nk_fill_circle(out, nk_shrink_rect(content, 1 ), background);
24578+ nk_fill_circle(out, nk_shrink_rect(content, border_width ), background);
2456224579 }
2456324580 } break;
2456424581 case NK_SYMBOL_TRIANGLE_UP:
@@ -24587,6 +24604,58 @@ nk_draw_symbol(struct nk_command_buffer *out, enum nk_symbol_type type,
2458724604 nk_stroke_triangle(out, points[0].x, points[0].y, points[1].x, points[1].y,
2458824605 points[2].x, points[2].y, border_width, foreground);
2458924606 } break;
24607+ case NK_SYMBOL_CHEVRON_UP:
24608+ case NK_SYMBOL_CHEVRON_RIGHT:
24609+ case NK_SYMBOL_CHEVRON_DOWN:
24610+ case NK_SYMBOL_CHEVRON_LEFT: {
24611+ struct nk_vec2 points[3];
24612+ switch (type) {
24613+ case NK_SYMBOL_CHEVRON_RIGHT:
24614+ points[0].x = content.x;
24615+ points[0].y = content.y;
24616+ points[1].x = content.x + content.w;
24617+ points[1].y = content.y + content.h * 0.5f;
24618+ points[2].x = content.x;
24619+ points[2].y = content.y + content.h;
24620+ break;
24621+ case NK_SYMBOL_CHEVRON_LEFT:
24622+ points[0].x = content.x + content.w;
24623+ points[0].y = content.y;
24624+ points[1].x = content.x;
24625+ points[1].y = content.y + content.h * 0.5f;
24626+ points[2].x = content.x + content.w;
24627+ points[2].y = content.y + content.h;
24628+ break;
24629+ case NK_SYMBOL_CHEVRON_UP:
24630+ points[0].x = content.x;
24631+ points[0].y = content.y + content.h;
24632+ points[1].x = content.x + content.w * 0.5f;
24633+ points[1].y = content.y;
24634+ points[2].x = content.x + content.w;
24635+ points[2].y = content.y + content.h;
24636+ break;
24637+ case NK_SYMBOL_CHEVRON_DOWN:
24638+ points[0].x = content.x;
24639+ points[0].y = content.y;
24640+ points[1].x = content.x + content.w * 0.5f;
24641+ points[1].y = content.y + content.h;
24642+ points[2].x = content.x + content.w;
24643+ points[2].y = content.y;
24644+ break;
24645+ default:
24646+ break;
24647+ }
24648+ nk_stroke_line(out, points[0].x, points[0].y, points[1].x, points[1].y, border_width, foreground);
24649+ nk_stroke_line(out, points[1].x, points[1].y, points[2].x, points[2].y, border_width, foreground);
24650+ } break;
24651+ case NK_SYMBOL_HAMBURGER: {
24652+ float y2 = content.y + content.h * 0.5f;
24653+ float y3 = content.y + content.h - border_width;
24654+ float x1 = content.x + content.w;
24655+ nk_stroke_line(out, content.x, content.y, x1, content.y, border_width, foreground);
24656+ nk_stroke_line(out, content.x, y2, x1, y2, border_width, foreground);
24657+ nk_stroke_line(out, content.x, y3, x1, y3, border_width, foreground);
24658+ } break;
2459024659 default:
2459124660 case NK_SYMBOL_NONE:
2459224661 case NK_SYMBOL_MAX: break;
@@ -24741,7 +24810,7 @@ nk_draw_button_symbol(struct nk_command_buffer *out,
2474124810 else sym = style->text_normal;
2474224811
2474324812 sym = nk_rgb_factor(sym, style->color_factor_text);
24744- nk_draw_symbol(out, type, *content, bg, sym, 1 , font);
24813+ nk_draw_symbol(out, type, *content, bg, sym, style->border , font);
2474524814}
2474624815NK_LIB nk_bool
2474724816nk_do_button_symbol(nk_flags *state,
@@ -24832,7 +24901,7 @@ nk_draw_button_text_symbol(struct nk_command_buffer *out,
2483224901 sym = nk_rgb_factor(sym, style->color_factor_text);
2483324902 text.text = nk_rgb_factor(text.text, style->color_factor_text);
2483424903 text.padding = nk_vec2(0,0);
24835- nk_draw_symbol(out, type, *symbol, style->text_background, sym, 0 , font);
24904+ nk_draw_symbol(out, type, *symbol, style->text_background, sym, style->border , font);
2483624905 nk_widget_text(out, *label, str, len, &text, NK_TEXT_CENTERED, font);
2483724906}
2483824907NK_LIB nk_bool
@@ -30254,7 +30323,7 @@ nk_combo_begin_symbol(struct nk_context *ctx, enum nk_symbol_type symbol, struct
3025430323 bounds.x = header.x + style->combo.content_padding.x;
3025530324 bounds.w = (button.x - style->combo.content_padding.y) - bounds.x;
3025630325 nk_draw_symbol(&win->buffer, symbol, bounds, sym_background, symbol_color,
30257- 1.0f , style->font);
30326+ style->combo.border , style->font);
3025830327
3025930328 /* draw open/close button */
3026030329 nk_draw_button_symbol(&win->buffer, &bounds, &content, ctx->last_widget_state,
@@ -30357,7 +30426,7 @@ nk_combo_begin_symbol_text(struct nk_context *ctx, const char *selected, int len
3035730426 image.h = header.h - 2 * style->combo.content_padding.y;
3035830427 image.w = image.h;
3035930428 nk_draw_symbol(&win->buffer, symbol, image, text.background, symbol_color,
30360- 1.0f , style->font);
30429+ style->combo.border , style->font);
3036130430
3036230431 /* draw label */
3036330432 text.padding = nk_vec2(0,0);
0 commit comments