Skip to content

Commit

Permalink
Only apply image_padding to content position/width
Browse files Browse the repository at this point in the history
  • Loading branch information
Dodzey committed Aug 31, 2024
1 parent 11a165f commit 41072b4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions nuklear.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
7 changes: 4 additions & 3 deletions src/nuklear_button.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit 41072b4

Please sign in to comment.