Skip to content

Commit 82d85e9

Browse files
authored
Merge pull request #2 from Hejsil/fix-double-padding
Fix bug where width padding was applied twice
2 parents 0eb6187 + 14dd68e commit 82d85e9

4 files changed

Lines changed: 7 additions & 13 deletions

File tree

nuklear.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21264,15 +21264,12 @@ nk_layout_row_calculate_usable_space(const struct nk_style *style, enum nk_panel
2126421264
float panel_space;
2126521265

2126621266
struct nk_vec2 spacing;
21267-
struct nk_vec2 padding;
2126821267

2126921268
spacing = style->window.spacing;
21270-
padding = nk_panel_get_padding(style, type);
2127121269

2127221270
/* calculate the usable panel space */
21273-
panel_padding = 2 * padding.x;
2127421271
panel_spacing = (float)NK_MAX(columns - 1, 0) * spacing.x;
21275-
panel_space = total_space - panel_padding - panel_spacing;
21272+
panel_space = total_space - panel_spacing;
2127621273
return panel_space;
2127721274
}
2127821275
NK_LIB void
@@ -21816,7 +21813,6 @@ nk_layout_widget_space(struct nk_rect *bounds, const struct nk_context *ctx,
2181621813
NK_ASSERT(bounds);
2181721814

2181821815
spacing = style->window.spacing;
21819-
padding = nk_panel_get_padding(style, layout->type);
2182021816
panel_space = nk_layout_row_calculate_usable_space(&ctx->style, layout->type,
2182121817
layout->bounds.w, layout->row.columns);
2182221818

@@ -21921,7 +21917,7 @@ nk_layout_widget_space(struct nk_rect *bounds, const struct nk_context *ctx,
2192121917
bounds->w = item_width;
2192221918
bounds->h = layout->row.height - spacing.y;
2192321919
bounds->y = layout->at_y - (float)*layout->offset_y;
21924-
bounds->x = layout->at_x + item_offset + item_spacing + padding.x;
21920+
bounds->x = layout->at_x + item_offset + item_spacing;
2192521921
if (((bounds->x + bounds->w) > layout->max_x) && modify)
2192621922
layout->max_x = bounds->x + bounds->w;
2192721923
bounds->x -= (float)*layout->offset_x;
@@ -29114,6 +29110,7 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
2911429110
/// - [yy]: Minor version with non-breaking API and library changes
2911529111
/// - [zz]: Bug fix version with no direct changes to API
2911629112
///
29113+
/// - 2020/03/06 (4.01.7) - Fix bug where width padding was applied twice
2911729114
/// - 2020/02/06 (4.01.6) - Update stb_truetype.h and stb_rect_pack.h and separate them
2911829115
/// - 2019/12/10 (4.01.5) - Fix off-by-one error in NK_INTERSECT
2911929116
/// - 2019/10/09 (4.01.4) - Fix bug for autoscrolling in nk_do_edit

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nuklear",
3-
"version": "4.01.6",
3+
"version": "4.01.7",
44
"repo": "Immediate-Mode-UI/Nuklear",
55
"description": "A small ANSI C gui toolkit",
66
"keywords": ["gl", "ui", "toolkit"],

src/CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
/// - [yy]: Minor version with non-breaking API and library changes
99
/// - [zz]: Bug fix version with no direct changes to API
1010
///
11+
/// - 2020/03/06 (4.01.7) - Fix bug where width padding was applied twice
1112
/// - 2020/02/06 (4.01.6) - Update stb_truetype.h and stb_rect_pack.h and separate them
1213
/// - 2019/12/10 (4.01.5) - Fix off-by-one error in NK_INTERSECT
1314
/// - 2019/10/09 (4.01.4) - Fix bug for autoscrolling in nk_do_edit

src/nuklear_layout.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,12 @@ nk_layout_row_calculate_usable_space(const struct nk_style *style, enum nk_panel
4949
float panel_space;
5050

5151
struct nk_vec2 spacing;
52-
struct nk_vec2 padding;
5352

5453
spacing = style->window.spacing;
55-
padding = nk_panel_get_padding(style, type);
5654

5755
/* calculate the usable panel space */
58-
panel_padding = 2 * padding.x;
5956
panel_spacing = (float)NK_MAX(columns - 1, 0) * spacing.x;
60-
panel_space = total_space - panel_padding - panel_spacing;
57+
panel_space = total_space - panel_spacing;
6158
return panel_space;
6259
}
6360
NK_LIB void
@@ -601,7 +598,6 @@ nk_layout_widget_space(struct nk_rect *bounds, const struct nk_context *ctx,
601598
NK_ASSERT(bounds);
602599

603600
spacing = style->window.spacing;
604-
padding = nk_panel_get_padding(style, layout->type);
605601
panel_space = nk_layout_row_calculate_usable_space(&ctx->style, layout->type,
606602
layout->bounds.w, layout->row.columns);
607603

@@ -706,7 +702,7 @@ nk_layout_widget_space(struct nk_rect *bounds, const struct nk_context *ctx,
706702
bounds->w = item_width;
707703
bounds->h = layout->row.height - spacing.y;
708704
bounds->y = layout->at_y - (float)*layout->offset_y;
709-
bounds->x = layout->at_x + item_offset + item_spacing + padding.x;
705+
bounds->x = layout->at_x + item_offset + item_spacing;
710706
if (((bounds->x + bounds->w) > layout->max_x) && modify)
711707
layout->max_x = bounds->x + bounds->w;
712708
bounds->x -= (float)*layout->offset_x;

0 commit comments

Comments
 (0)