Skip to content

Commit 64e0a50

Browse files
committed
Revert "Fix bug where width padding was applied twice"
This reverts commit 14dd68e.
1 parent e5e4270 commit 64e0a50

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

nuklear.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22034,14 +22034,16 @@ nk_layout_row_calculate_usable_space(const struct nk_style *style, enum nk_panel
2203422034
float panel_space;
2203522035

2203622036
struct nk_vec2 spacing;
22037+
struct nk_vec2 padding;
2203722038

2203822039
NK_UNUSED(type);
2203922040

2204022041
spacing = style->window.spacing;
22042+
padding = nk_panel_get_padding(style, type);
2204122043

2204222044
/* calculate the usable panel space */
2204322045
panel_spacing = (float)NK_MAX(columns - 1, 0) * spacing.x;
22044-
panel_space = total_space - panel_spacing;
22046+
panel_space = total_space - (2 * padding.x) - panel_spacing;
2204522047
return panel_space;
2204622048
}
2204722049
NK_LIB void
@@ -22565,6 +22567,7 @@ nk_layout_widget_space(struct nk_rect *bounds, const struct nk_context *ctx,
2256522567
struct nk_panel *layout;
2256622568
const struct nk_style *style;
2256722569

22570+
struct nk_vec2 padding;
2256822571
struct nk_vec2 spacing;
2256922572

2257022573
float item_offset = 0;
@@ -22584,6 +22587,7 @@ nk_layout_widget_space(struct nk_rect *bounds, const struct nk_context *ctx,
2258422587
NK_ASSERT(bounds);
2258522588

2258622589
spacing = style->window.spacing;
22590+
padding = nk_panel_get_padding(style, layout->type);
2258722591
panel_space = nk_layout_row_calculate_usable_space(&ctx->style, layout->type,
2258822592
layout->bounds.w, layout->row.columns);
2258922593

@@ -22688,7 +22692,7 @@ nk_layout_widget_space(struct nk_rect *bounds, const struct nk_context *ctx,
2268822692
bounds->w = item_width;
2268922693
bounds->h = layout->row.height - spacing.y;
2269022694
bounds->y = layout->at_y - (float)*layout->offset_y;
22691-
bounds->x = layout->at_x + item_offset + item_spacing;
22695+
bounds->x = layout->at_x + item_offset + item_spacing + padding.x;
2269222696
if (((bounds->x + bounds->w) > layout->max_x) && modify)
2269322697
layout->max_x = bounds->x + bounds->w;
2269422698
bounds->x -= (float)*layout->offset_x;

src/nuklear_layout.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,16 @@ nk_layout_row_calculate_usable_space(const struct nk_style *style, enum nk_panel
4848
float panel_space;
4949

5050
struct nk_vec2 spacing;
51+
struct nk_vec2 padding;
5152

5253
NK_UNUSED(type);
5354

5455
spacing = style->window.spacing;
56+
padding = nk_panel_get_padding(style, type);
5557

5658
/* calculate the usable panel space */
5759
panel_spacing = (float)NK_MAX(columns - 1, 0) * spacing.x;
58-
panel_space = total_space - panel_spacing;
60+
panel_space = total_space - (2 * padding.x) - panel_spacing;
5961
return panel_space;
6062
}
6163
NK_LIB void
@@ -579,6 +581,7 @@ nk_layout_widget_space(struct nk_rect *bounds, const struct nk_context *ctx,
579581
struct nk_panel *layout;
580582
const struct nk_style *style;
581583

584+
struct nk_vec2 padding;
582585
struct nk_vec2 spacing;
583586

584587
float item_offset = 0;
@@ -598,6 +601,7 @@ nk_layout_widget_space(struct nk_rect *bounds, const struct nk_context *ctx,
598601
NK_ASSERT(bounds);
599602

600603
spacing = style->window.spacing;
604+
padding = nk_panel_get_padding(style, layout->type);
601605
panel_space = nk_layout_row_calculate_usable_space(&ctx->style, layout->type,
602606
layout->bounds.w, layout->row.columns);
603607

@@ -702,7 +706,7 @@ nk_layout_widget_space(struct nk_rect *bounds, const struct nk_context *ctx,
702706
bounds->w = item_width;
703707
bounds->h = layout->row.height - spacing.y;
704708
bounds->y = layout->at_y - (float)*layout->offset_y;
705-
bounds->x = layout->at_x + item_offset + item_spacing;
709+
bounds->x = layout->at_x + item_offset + item_spacing + padding.x;
706710
if (((bounds->x + bounds->w) > layout->max_x) && modify)
707711
layout->max_x = bounds->x + bounds->w;
708712
bounds->x -= (float)*layout->offset_x;

0 commit comments

Comments
 (0)