Skip to content

Commit

Permalink
account for padding offsets
Browse files Browse the repository at this point in the history
  • Loading branch information
Dodzey committed Aug 31, 2024
1 parent e9f3d60 commit 11a165f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 5 additions & 3 deletions nuklear.h
Original file line number Diff line number Diff line change
Expand Up @@ -24559,18 +24559,20 @@ 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 -= icon.w;
content.w -= (2 * style->padding.x + icon.w);
} else {
icon.x = bounds.x + 2 * style->padding.x;
content.x += icon.w;
content.w = NK_MAX(content.w - icon.w, 0);
content.x += icon.w + 2 * style->padding.x;
content.w = NK_MAX(content.w - (2 * style->padding.x + icon.w), 0);
}

icon.x += style->image_padding.x;
icon.y += style->image_padding.y;
icon.w -= 2 * style->image_padding.x;
icon.h -= 2 * style->image_padding.y;

content.x += 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);
if (style->draw_end) style->draw_end(out, style->userdata);
Expand Down
8 changes: 5 additions & 3 deletions src/nuklear_button.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,18 +397,20 @@ 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 -= icon.w;
content.w -= (2 * style->padding.x + icon.w);
} else {
icon.x = bounds.x + 2 * style->padding.x;
content.x += icon.w;
content.w = NK_MAX(content.w - icon.w, 0);
content.x += icon.w + 2 * style->padding.x;
content.w = NK_MAX(content.w - (2 * style->padding.x + icon.w), 0);
}

icon.x += style->image_padding.x;
icon.y += style->image_padding.y;
icon.w -= 2 * style->image_padding.x;
icon.h -= 2 * style->image_padding.y;

content.x += 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);
if (style->draw_end) style->draw_end(out, style->userdata);
Expand Down

0 comments on commit 11a165f

Please sign in to comment.