Skip to content
Merged
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
60 changes: 47 additions & 13 deletions nuklear.h
Original file line number Diff line number Diff line change
Expand Up @@ -28262,13 +28262,18 @@ nk_combo_begin_text(struct nk_context *ctx, const char *selected, int len,
struct nk_rect label;
struct nk_rect button;
struct nk_rect content;
int draw_button_symbol;
Comment thread
dumblob marked this conversation as resolved.

enum nk_symbol_type sym;
if (ctx->last_widget_state & NK_WIDGET_STATE_HOVER)
sym = style->combo.sym_hover;
else if (is_clicked)
sym = style->combo.sym_active;
else sym = style->combo.sym_normal;
else
sym = style->combo.sym_normal;

/* represents whether or not the combo's button symbol should be drawn */
draw_button_symbol = sym != NK_SYMBOL_NONE;

/* calculate button */
button.w = header.h - 2 * style->combo.button_padding.y;
Expand All @@ -28285,14 +28290,18 @@ nk_combo_begin_text(struct nk_context *ctx, const char *selected, int len,
text.padding = nk_vec2(0,0);
label.x = header.x + style->combo.content_padding.x;
label.y = header.y + style->combo.content_padding.y;
label.w = button.x - (style->combo.content_padding.x + style->combo.spacing.x) - label.x;;
label.h = header.h - 2 * style->combo.content_padding.y;
if (draw_button_symbol)
label.w = button.x - (style->combo.content_padding.x + style->combo.spacing.x) - label.x;
else
label.w = header.w - 2 * style->combo.content_padding.x;
nk_widget_text(&win->buffer, label, selected, len, &text,
NK_TEXT_LEFT, ctx->style.font);

/* draw open/close button */
nk_draw_button_symbol(&win->buffer, &button, &content, ctx->last_widget_state,
&ctx->style.combo.button, sym, style->font);
if (draw_button_symbol)
nk_draw_button_symbol(&win->buffer, &button, &content, ctx->last_widget_state,
&ctx->style.combo.button, sym, style->font);
}
return nk_combo_begin(ctx, win, size, is_clicked, header);
}
Expand Down Expand Up @@ -28346,6 +28355,7 @@ nk_combo_begin_color(struct nk_context *ctx, struct nk_color color, struct nk_ve
struct nk_rect content;
struct nk_rect button;
struct nk_rect bounds;
int draw_button_symbol;

enum nk_symbol_type sym;
if (ctx->last_widget_state & NK_WIDGET_STATE_HOVER)
Expand All @@ -28354,6 +28364,9 @@ nk_combo_begin_color(struct nk_context *ctx, struct nk_color color, struct nk_ve
sym = style->combo.sym_active;
else sym = style->combo.sym_normal;

/* represents whether or not the combo's button symbol should be drawn */
draw_button_symbol = sym != NK_SYMBOL_NONE;

/* calculate button */
button.w = header.h - 2 * style->combo.button_padding.y;
button.x = (header.x + header.w - header.h) - style->combo.button_padding.x;
Expand All @@ -28369,12 +28382,16 @@ nk_combo_begin_color(struct nk_context *ctx, struct nk_color color, struct nk_ve
bounds.h = header.h - 4 * style->combo.content_padding.y;
bounds.y = header.y + 2 * style->combo.content_padding.y;
bounds.x = header.x + 2 * style->combo.content_padding.x;
bounds.w = (button.x - (style->combo.content_padding.x + style->combo.spacing.x)) - bounds.x;
if (draw_button_symbol)
bounds.w = (button.x - (style->combo.content_padding.x + style->combo.spacing.x)) - bounds.x;
else
bounds.w = header.w - 4 * style->combo.content_padding.x;
nk_fill_rect(&win->buffer, bounds, 0, color);

/* draw open/close button */
nk_draw_button_symbol(&win->buffer, &button, &content, ctx->last_widget_state,
&ctx->style.combo.button, sym, style->font);
if (draw_button_symbol)
nk_draw_button_symbol(&win->buffer, &button, &content, ctx->last_widget_state,
&ctx->style.combo.button, sym, style->font);
}
return nk_combo_begin(ctx, win, size, is_clicked, header);
}
Expand Down Expand Up @@ -28606,6 +28623,7 @@ nk_combo_begin_image(struct nk_context *ctx, struct nk_image img, struct nk_vec2
struct nk_rect bounds = {0,0,0,0};
struct nk_rect content;
struct nk_rect button;
int draw_button_symbol;

enum nk_symbol_type sym;
if (ctx->last_widget_state & NK_WIDGET_STATE_HOVER)
Expand All @@ -28614,6 +28632,9 @@ nk_combo_begin_image(struct nk_context *ctx, struct nk_image img, struct nk_vec2
sym = style->combo.sym_active;
else sym = style->combo.sym_normal;

/* represents whether or not the combo's button symbol should be drawn */
draw_button_symbol = sym != NK_SYMBOL_NONE;

/* calculate button */
button.w = header.h - 2 * style->combo.button_padding.y;
button.x = (header.x + header.w - header.h) - style->combo.button_padding.y;
Expand All @@ -28629,12 +28650,16 @@ nk_combo_begin_image(struct nk_context *ctx, struct nk_image img, struct nk_vec2
bounds.h = header.h - 2 * style->combo.content_padding.y;
bounds.y = header.y + style->combo.content_padding.y;
bounds.x = header.x + style->combo.content_padding.x;
bounds.w = (button.x - style->combo.content_padding.y) - bounds.x;
if (draw_button_symbol)
bounds.w = (button.x - style->combo.content_padding.y) - bounds.x;
else
bounds.w = header.w - 2 * style->combo.content_padding.x;
nk_draw_image(&win->buffer, bounds, &img, nk_white);

/* draw open/close button */
nk_draw_button_symbol(&win->buffer, &bounds, &content, ctx->last_widget_state,
&ctx->style.combo.button, sym, style->font);
if (draw_button_symbol)
nk_draw_button_symbol(&win->buffer, &bounds, &content, ctx->last_widget_state,
&ctx->style.combo.button, sym, style->font);
}
return nk_combo_begin(ctx, win, size, is_clicked, header);
}
Expand Down Expand Up @@ -28691,6 +28716,7 @@ nk_combo_begin_image_text(struct nk_context *ctx, const char *selected, int len,
struct nk_rect button;
struct nk_rect label;
struct nk_rect image;
int draw_button_symbol;

enum nk_symbol_type sym;
if (ctx->last_widget_state & NK_WIDGET_STATE_HOVER)
Expand All @@ -28699,6 +28725,9 @@ nk_combo_begin_image_text(struct nk_context *ctx, const char *selected, int len,
sym = style->combo.sym_active;
else sym = style->combo.sym_normal;

/* represents whether or not the combo's button symbol should be drawn */
draw_button_symbol = sym != NK_SYMBOL_NONE;

/* calculate button */
button.w = header.h - 2 * style->combo.button_padding.y;
button.x = (header.x + header.w - header.h) - style->combo.button_padding.x;
Expand All @@ -28709,8 +28738,9 @@ nk_combo_begin_image_text(struct nk_context *ctx, const char *selected, int len,
content.y = button.y + style->combo.button.padding.y;
content.w = button.w - 2 * style->combo.button.padding.x;
content.h = button.h - 2 * style->combo.button.padding.y;
nk_draw_button_symbol(&win->buffer, &button, &content, ctx->last_widget_state,
&ctx->style.combo.button, sym, style->font);
if (draw_button_symbol)
nk_draw_button_symbol(&win->buffer, &button, &content, ctx->last_widget_state,
&ctx->style.combo.button, sym, style->font);

/* draw image */
image.x = header.x + style->combo.content_padding.x;
Expand All @@ -28723,8 +28753,11 @@ nk_combo_begin_image_text(struct nk_context *ctx, const char *selected, int len,
text.padding = nk_vec2(0,0);
label.x = image.x + image.w + style->combo.spacing.x + style->combo.content_padding.x;
label.y = header.y + style->combo.content_padding.y;
label.w = (button.x - style->combo.content_padding.x) - label.x;
label.h = header.h - 2 * style->combo.content_padding.y;
if (draw_button_symbol)
label.w = (button.x - style->combo.content_padding.x) - label.x;
else
label.w = (header.x + header.w - style->combo.content_padding.x) - label.x;
nk_widget_text(&win->buffer, label, selected, len, &text, NK_TEXT_LEFT, style->font);
}
return nk_combo_begin(ctx, win, size, is_clicked, header);
Expand Down Expand Up @@ -29097,6 +29130,7 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
/// - [yy]: Minor version with non-breaking API and library changes
/// - [zz]: Bug fix version with no direct changes to API
///
/// - 2020/06/04 (4.03.0) - Made nk_combo header symbols optional.
/// - 2020/05/27 (4.02.5) - Fix nk_do_edit: Keep scroll position when re-activating edit widget.
/// - 2020/05/09 (4.02.4) - Fix nk_menubar height calculation bug
/// - 2020/05/08 (4.02.3) - Fix missing stdarg.h with NK_INCLUDE_STANDARD_VARARGS
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nuklear",
"version": "4.02.5",
"version": "4.03.0",
"repo": "Immediate-Mode-UI/Nuklear",
"description": "A small ANSI C gui toolkit",
"keywords": ["gl", "ui", "toolkit"],
Expand Down
1 change: 1 addition & 0 deletions src/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
/// - [yy]: Minor version with non-breaking API and library changes
/// - [zz]: Bug fix version with no direct changes to API
///
/// - 2020/06/04 (4.03.0) - Made nk_combo header symbols optional.
/// - 2020/05/27 (4.02.5) - Fix nk_do_edit: Keep scroll position when re-activating edit widget.
/// - 2020/05/09 (4.02.4) - Fix nk_menubar height calculation bug
/// - 2020/05/08 (4.02.3) - Fix missing stdarg.h with NK_INCLUDE_STANDARD_VARARGS
Expand Down
59 changes: 46 additions & 13 deletions src/nuklear_combo.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,18 @@ nk_combo_begin_text(struct nk_context *ctx, const char *selected, int len,
struct nk_rect label;
struct nk_rect button;
struct nk_rect content;
int draw_button_symbol;

enum nk_symbol_type sym;
if (ctx->last_widget_state & NK_WIDGET_STATE_HOVER)
sym = style->combo.sym_hover;
else if (is_clicked)
sym = style->combo.sym_active;
else sym = style->combo.sym_normal;
else
sym = style->combo.sym_normal;

/* represents whether or not the combo's button symbol should be drawn */
draw_button_symbol = sym != NK_SYMBOL_NONE;

/* calculate button */
button.w = header.h - 2 * style->combo.button_padding.y;
Expand All @@ -118,14 +123,18 @@ nk_combo_begin_text(struct nk_context *ctx, const char *selected, int len,
text.padding = nk_vec2(0,0);
label.x = header.x + style->combo.content_padding.x;
label.y = header.y + style->combo.content_padding.y;
label.w = button.x - (style->combo.content_padding.x + style->combo.spacing.x) - label.x;;
label.h = header.h - 2 * style->combo.content_padding.y;
if (draw_button_symbol)
label.w = button.x - (style->combo.content_padding.x + style->combo.spacing.x) - label.x;
else
label.w = header.w - 2 * style->combo.content_padding.x;
nk_widget_text(&win->buffer, label, selected, len, &text,
NK_TEXT_LEFT, ctx->style.font);

/* draw open/close button */
nk_draw_button_symbol(&win->buffer, &button, &content, ctx->last_widget_state,
&ctx->style.combo.button, sym, style->font);
if (draw_button_symbol)
nk_draw_button_symbol(&win->buffer, &button, &content, ctx->last_widget_state,
&ctx->style.combo.button, sym, style->font);
}
return nk_combo_begin(ctx, win, size, is_clicked, header);
}
Expand Down Expand Up @@ -179,6 +188,7 @@ nk_combo_begin_color(struct nk_context *ctx, struct nk_color color, struct nk_ve
struct nk_rect content;
struct nk_rect button;
struct nk_rect bounds;
int draw_button_symbol;

enum nk_symbol_type sym;
if (ctx->last_widget_state & NK_WIDGET_STATE_HOVER)
Expand All @@ -187,6 +197,9 @@ nk_combo_begin_color(struct nk_context *ctx, struct nk_color color, struct nk_ve
sym = style->combo.sym_active;
else sym = style->combo.sym_normal;

/* represents whether or not the combo's button symbol should be drawn */
draw_button_symbol = sym != NK_SYMBOL_NONE;

/* calculate button */
button.w = header.h - 2 * style->combo.button_padding.y;
button.x = (header.x + header.w - header.h) - style->combo.button_padding.x;
Expand All @@ -202,12 +215,16 @@ nk_combo_begin_color(struct nk_context *ctx, struct nk_color color, struct nk_ve
bounds.h = header.h - 4 * style->combo.content_padding.y;
bounds.y = header.y + 2 * style->combo.content_padding.y;
bounds.x = header.x + 2 * style->combo.content_padding.x;
bounds.w = (button.x - (style->combo.content_padding.x + style->combo.spacing.x)) - bounds.x;
if (draw_button_symbol)
bounds.w = (button.x - (style->combo.content_padding.x + style->combo.spacing.x)) - bounds.x;
else
bounds.w = header.w - 4 * style->combo.content_padding.x;
nk_fill_rect(&win->buffer, bounds, 0, color);

/* draw open/close button */
nk_draw_button_symbol(&win->buffer, &button, &content, ctx->last_widget_state,
&ctx->style.combo.button, sym, style->font);
if (draw_button_symbol)
nk_draw_button_symbol(&win->buffer, &button, &content, ctx->last_widget_state,
&ctx->style.combo.button, sym, style->font);
}
return nk_combo_begin(ctx, win, size, is_clicked, header);
}
Expand Down Expand Up @@ -439,6 +456,7 @@ nk_combo_begin_image(struct nk_context *ctx, struct nk_image img, struct nk_vec2
struct nk_rect bounds = {0,0,0,0};
struct nk_rect content;
struct nk_rect button;
int draw_button_symbol;

enum nk_symbol_type sym;
if (ctx->last_widget_state & NK_WIDGET_STATE_HOVER)
Expand All @@ -447,6 +465,9 @@ nk_combo_begin_image(struct nk_context *ctx, struct nk_image img, struct nk_vec2
sym = style->combo.sym_active;
else sym = style->combo.sym_normal;

/* represents whether or not the combo's button symbol should be drawn */
draw_button_symbol = sym != NK_SYMBOL_NONE;

/* calculate button */
button.w = header.h - 2 * style->combo.button_padding.y;
button.x = (header.x + header.w - header.h) - style->combo.button_padding.y;
Expand All @@ -462,12 +483,16 @@ nk_combo_begin_image(struct nk_context *ctx, struct nk_image img, struct nk_vec2
bounds.h = header.h - 2 * style->combo.content_padding.y;
bounds.y = header.y + style->combo.content_padding.y;
bounds.x = header.x + style->combo.content_padding.x;
bounds.w = (button.x - style->combo.content_padding.y) - bounds.x;
if (draw_button_symbol)
bounds.w = (button.x - style->combo.content_padding.y) - bounds.x;
else
bounds.w = header.w - 2 * style->combo.content_padding.x;
nk_draw_image(&win->buffer, bounds, &img, nk_white);

/* draw open/close button */
nk_draw_button_symbol(&win->buffer, &bounds, &content, ctx->last_widget_state,
&ctx->style.combo.button, sym, style->font);
if (draw_button_symbol)
nk_draw_button_symbol(&win->buffer, &bounds, &content, ctx->last_widget_state,
&ctx->style.combo.button, sym, style->font);
}
return nk_combo_begin(ctx, win, size, is_clicked, header);
}
Expand Down Expand Up @@ -524,6 +549,7 @@ nk_combo_begin_image_text(struct nk_context *ctx, const char *selected, int len,
struct nk_rect button;
struct nk_rect label;
struct nk_rect image;
int draw_button_symbol;

enum nk_symbol_type sym;
if (ctx->last_widget_state & NK_WIDGET_STATE_HOVER)
Expand All @@ -532,6 +558,9 @@ nk_combo_begin_image_text(struct nk_context *ctx, const char *selected, int len,
sym = style->combo.sym_active;
else sym = style->combo.sym_normal;

/* represents whether or not the combo's button symbol should be drawn */
draw_button_symbol = sym != NK_SYMBOL_NONE;

/* calculate button */
button.w = header.h - 2 * style->combo.button_padding.y;
button.x = (header.x + header.w - header.h) - style->combo.button_padding.x;
Expand All @@ -542,8 +571,9 @@ nk_combo_begin_image_text(struct nk_context *ctx, const char *selected, int len,
content.y = button.y + style->combo.button.padding.y;
content.w = button.w - 2 * style->combo.button.padding.x;
content.h = button.h - 2 * style->combo.button.padding.y;
nk_draw_button_symbol(&win->buffer, &button, &content, ctx->last_widget_state,
&ctx->style.combo.button, sym, style->font);
if (draw_button_symbol)
nk_draw_button_symbol(&win->buffer, &button, &content, ctx->last_widget_state,
&ctx->style.combo.button, sym, style->font);

/* draw image */
image.x = header.x + style->combo.content_padding.x;
Expand All @@ -556,8 +586,11 @@ nk_combo_begin_image_text(struct nk_context *ctx, const char *selected, int len,
text.padding = nk_vec2(0,0);
label.x = image.x + image.w + style->combo.spacing.x + style->combo.content_padding.x;
label.y = header.y + style->combo.content_padding.y;
label.w = (button.x - style->combo.content_padding.x) - label.x;
label.h = header.h - 2 * style->combo.content_padding.y;
if (draw_button_symbol)
label.w = (button.x - style->combo.content_padding.x) - label.x;
else
label.w = (header.x + header.w - style->combo.content_padding.x) - label.x;
nk_widget_text(&win->buffer, label, selected, len, &text, NK_TEXT_LEFT, style->font);
}
return nk_combo_begin(ctx, win, size, is_clicked, header);
Expand Down