From a668105390c10d7d906d4ecb44d1a5523a41450b Mon Sep 17 00:00:00 2001 From: David Reid Date: Tue, 14 Nov 2023 15:39:10 +1000 Subject: [PATCH 1/2] Fix button text alignment error. When calculating the width and height of the content rect of a button, only the border of one side is being taken into account. Instead the border width needs to be multiplied by two before subtracting from the bounds. This is being done for padding and rounding, but not border, which is resulting in text being misaligned, most notably when using buttons with thick borders. --- nuklear.h | 4 ++-- src/nuklear_button.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/nuklear.h b/nuklear.h index c2edb75a0..baac97fbf 100644 --- a/nuklear.h +++ b/nuklear.h @@ -23892,8 +23892,8 @@ nk_do_button(nk_flags *state, struct nk_command_buffer *out, struct nk_rect r, /* calculate button content space */ content->x = r.x + style->padding.x + style->border + style->rounding; content->y = r.y + style->padding.y + style->border + style->rounding; - content->w = r.w - (2 * style->padding.x + style->border + style->rounding*2); - content->h = r.h - (2 * style->padding.y + style->border + style->rounding*2); + content->w = r.w - (2 * (style->padding.x + style->border + style->rounding)); + content->h = r.h - (2 * (style->padding.y + style->border + style->rounding)); /* execute button behavior */ bounds.x = r.x - style->touch_padding.x; diff --git a/src/nuklear_button.c b/src/nuklear_button.c index 2636b608d..af80f931d 100644 --- a/src/nuklear_button.c +++ b/src/nuklear_button.c @@ -127,8 +127,8 @@ nk_do_button(nk_flags *state, struct nk_command_buffer *out, struct nk_rect r, /* calculate button content space */ content->x = r.x + style->padding.x + style->border + style->rounding; content->y = r.y + style->padding.y + style->border + style->rounding; - content->w = r.w - (2 * style->padding.x + style->border + style->rounding*2); - content->h = r.h - (2 * style->padding.y + style->border + style->rounding*2); + content->w = r.w - (2 * (style->padding.x + style->border + style->rounding)); + content->h = r.h - (2 * (style->padding.y + style->border + style->rounding)); /* execute button behavior */ bounds.x = r.x - style->touch_padding.x; From 42e4c54954c150577fc8e70a26195b2509f67017 Mon Sep 17 00:00:00 2001 From: David Reid Date: Tue, 14 Nov 2023 18:02:22 +1000 Subject: [PATCH 2/2] Bump patch version in clib.json. --- clib.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clib.json b/clib.json index cf690c789..e83c57bd8 100644 --- a/clib.json +++ b/clib.json @@ -1,6 +1,6 @@ { "name": "nuklear", - "version": "4.10.6", + "version": "4.10.7", "repo": "Immediate-Mode-UI/Nuklear", "description": "A small ANSI C gui toolkit", "keywords": ["gl", "ui", "toolkit"],