From 21e3c4df7bd2979bbbf5a21e61288ae9f4ec8342 Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 6 Mar 2023 17:20:57 +0100 Subject: [PATCH] add nk_flags alignment to draw_button_text_* functions as the flags was not being used for the text --- src/nuklear_button.c | 12 ++++++------ src/nuklear_internal.h | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/nuklear_button.c b/src/nuklear_button.c index 2636b608d..b1f41dc86 100644 --- a/src/nuklear_button.c +++ b/src/nuklear_button.c @@ -268,7 +268,7 @@ nk_draw_button_text_symbol(struct nk_command_buffer *out, const struct nk_rect *bounds, const struct nk_rect *label, const struct nk_rect *symbol, nk_flags state, const struct nk_style_button *style, const char *str, int len, enum nk_symbol_type type, - const struct nk_user_font *font) + const struct nk_user_font *font, nk_flags align) { struct nk_color sym; struct nk_text text; @@ -294,7 +294,7 @@ nk_draw_button_text_symbol(struct nk_command_buffer *out, text.padding = nk_vec2(0,0); nk_draw_symbol(out, type, *symbol, style->text_background, sym, 0, font); - nk_widget_text(out, *label, str, len, &text, NK_TEXT_CENTERED, font); + nk_widget_text(out, *label, str, len, &text, align, font); } NK_LIB nk_bool nk_do_button_text_symbol(nk_flags *state, @@ -324,7 +324,7 @@ nk_do_button_text_symbol(nk_flags *state, /* draw button */ if (style->draw_begin) style->draw_begin(out, style->userdata); nk_draw_button_text_symbol(out, &bounds, &content, &tri, - *state, style, str, len, symbol, font); + *state, style, str, len, symbol, font, align); if (style->draw_end) style->draw_end(out, style->userdata); return ret; } @@ -333,7 +333,7 @@ nk_draw_button_text_image(struct nk_command_buffer *out, const struct nk_rect *bounds, const struct nk_rect *label, const struct nk_rect *image, nk_flags state, const struct nk_style_button *style, const char *str, int len, const struct nk_user_font *font, - const struct nk_image *img) + const struct nk_image *img, nk_flags align) { struct nk_text text; const struct nk_style_item *background; @@ -350,7 +350,7 @@ nk_draw_button_text_image(struct nk_command_buffer *out, else text.text = style->text_normal; text.padding = nk_vec2(0,0); - nk_widget_text(out, *label, str, len, &text, NK_TEXT_CENTERED, font); + nk_widget_text(out, *label, str, len, &text, align, font); nk_draw_image(out, *image, img, nk_white); } NK_LIB nk_bool @@ -385,7 +385,7 @@ nk_do_button_text_image(nk_flags *state, icon.h -= 2 * style->image_padding.y; if (style->draw_begin) style->draw_begin(out, style->userdata); - nk_draw_button_text_image(out, &bounds, &content, &icon, *state, style, str, len, font, &img); + nk_draw_button_text_image(out, &bounds, &content, &icon, *state, style, str, len, font, &img, align); if (style->draw_end) style->draw_end(out, style->userdata); return ret; } diff --git a/src/nuklear_internal.h b/src/nuklear_internal.h index 8d1b785b9..a4dcf81db 100644 --- a/src/nuklear_internal.h +++ b/src/nuklear_internal.h @@ -244,9 +244,9 @@ NK_LIB void nk_draw_button_symbol(struct nk_command_buffer *out, const struct nk NK_LIB nk_bool nk_do_button_symbol(nk_flags *state, struct nk_command_buffer *out, struct nk_rect bounds, enum nk_symbol_type symbol, enum nk_button_behavior behavior, const struct nk_style_button *style, const struct nk_input *in, const struct nk_user_font *font); NK_LIB void nk_draw_button_image(struct nk_command_buffer *out, const struct nk_rect *bounds, const struct nk_rect *content, nk_flags state, const struct nk_style_button *style, const struct nk_image *img); NK_LIB nk_bool nk_do_button_image(nk_flags *state, struct nk_command_buffer *out, struct nk_rect bounds, struct nk_image img, enum nk_button_behavior b, const struct nk_style_button *style, const struct nk_input *in); -NK_LIB void nk_draw_button_text_symbol(struct nk_command_buffer *out, const struct nk_rect *bounds, const struct nk_rect *label, const struct nk_rect *symbol, nk_flags state, const struct nk_style_button *style, const char *str, int len, enum nk_symbol_type type, const struct nk_user_font *font); +NK_LIB void nk_draw_button_text_symbol(struct nk_command_buffer *out, const struct nk_rect *bounds, const struct nk_rect *label, const struct nk_rect *symbol, nk_flags state, const struct nk_style_button *style, const char *str, int len, enum nk_symbol_type type, const struct nk_user_font *font, nk_flags align); NK_LIB nk_bool nk_do_button_text_symbol(nk_flags *state, struct nk_command_buffer *out, struct nk_rect bounds, enum nk_symbol_type symbol, const char *str, int len, nk_flags align, enum nk_button_behavior behavior, const struct nk_style_button *style, const struct nk_user_font *font, const struct nk_input *in); -NK_LIB void nk_draw_button_text_image(struct nk_command_buffer *out, const struct nk_rect *bounds, const struct nk_rect *label, const struct nk_rect *image, nk_flags state, const struct nk_style_button *style, const char *str, int len, const struct nk_user_font *font, const struct nk_image *img); +NK_LIB void nk_draw_button_text_image(struct nk_command_buffer *out, const struct nk_rect *bounds, const struct nk_rect *label, const struct nk_rect *image, nk_flags state, const struct nk_style_button *style, const char *str, int len, const struct nk_user_font *font, const struct nk_image *img, nk_flags align); NK_LIB nk_bool nk_do_button_text_image(nk_flags *state, struct nk_command_buffer *out, struct nk_rect bounds, struct nk_image img, const char* str, int len, nk_flags align, enum nk_button_behavior behavior, const struct nk_style_button *style, const struct nk_user_font *font, const struct nk_input *in); /* toggle */