From 41072b4260efb1fd85b45174bd6d059eb1cb4151 Mon Sep 17 00:00:00 2001 From: Dodzey <8467637+Dodzey@users.noreply.github.com> Date: Sat, 31 Aug 2024 18:05:17 +0100 Subject: [PATCH] Only apply image_padding to content position/width --- nuklear.h | 7 ++++--- src/nuklear_button.c | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/nuklear.h b/nuklear.h index eb2cf7ba3..891f7054b 100644 --- a/nuklear.h +++ b/nuklear.h @@ -24559,11 +24559,11 @@ nk_do_button_text_image(nk_flags *state, if (align & NK_TEXT_ALIGN_LEFT) { icon.x = (bounds.x + bounds.w) - (2 * style->padding.x + icon.w); icon.x = NK_MAX(icon.x, 0); - content.w -= (2 * style->padding.x + icon.w); + content.w -= icon.w; } else { icon.x = bounds.x + 2 * style->padding.x; - content.x += icon.w + 2 * style->padding.x; - content.w = NK_MAX(content.w - (2 * style->padding.x + icon.w), 0); + content.x += icon.w; + content.w = NK_MAX(content.w - icon.w, 0); } icon.x += style->image_padding.x; @@ -24572,6 +24572,7 @@ nk_do_button_text_image(nk_flags *state, icon.h -= 2 * style->image_padding.y; content.x += style->image_padding.x; + content.w -= style->image_padding.x; 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); diff --git a/src/nuklear_button.c b/src/nuklear_button.c index 8f3e7ee06..ebe740268 100644 --- a/src/nuklear_button.c +++ b/src/nuklear_button.c @@ -397,11 +397,11 @@ nk_do_button_text_image(nk_flags *state, if (align & NK_TEXT_ALIGN_LEFT) { icon.x = (bounds.x + bounds.w) - (2 * style->padding.x + icon.w); icon.x = NK_MAX(icon.x, 0); - content.w -= (2 * style->padding.x + icon.w); + content.w -= icon.w; } else { icon.x = bounds.x + 2 * style->padding.x; - content.x += icon.w + 2 * style->padding.x; - content.w = NK_MAX(content.w - (2 * style->padding.x + icon.w), 0); + content.x += icon.w; + content.w = NK_MAX(content.w - icon.w, 0); } icon.x += style->image_padding.x; @@ -410,6 +410,7 @@ nk_do_button_text_image(nk_flags *state, icon.h -= 2 * style->image_padding.y; content.x += style->image_padding.x; + content.w -= style->image_padding.x; 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);