Skip to content

Commit 73fcb94

Browse files
committed
Fix bug where width padding was applied twice
1 parent adc52d7 commit 73fcb94

3 files changed

Lines changed: 7 additions & 14 deletions

File tree

nuklear.h

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

1762717627
struct nk_vec2 spacing;
17628-
struct nk_vec2 padding;
1762917628

1763017629
spacing = style->window.spacing;
17631-
padding = nk_panel_get_padding(style, type);
1763217630

1763317631
/* calculate the usable panel space */
17634-
panel_padding = 2 * padding.x;
1763517632
panel_spacing = (float)NK_MAX(columns - 1, 0) * spacing.x;
17636-
panel_space = total_space - panel_padding - panel_spacing;
17633+
panel_space = total_space - panel_spacing;
1763717634
return panel_space;
1763817635
}
1763917636
NK_LIB void
@@ -18177,7 +18174,6 @@ nk_layout_widget_space(struct nk_rect *bounds, const struct nk_context *ctx,
1817718174
NK_ASSERT(bounds);
1817818175

1817918176
spacing = style->window.spacing;
18180-
padding = nk_panel_get_padding(style, layout->type);
1818118177
panel_space = nk_layout_row_calculate_usable_space(&ctx->style, layout->type,
1818218178
layout->bounds.w, layout->row.columns);
1818318179

@@ -18282,7 +18278,7 @@ nk_layout_widget_space(struct nk_rect *bounds, const struct nk_context *ctx,
1828218278
bounds->w = item_width;
1828318279
bounds->h = layout->row.height - spacing.y;
1828418280
bounds->y = layout->at_y - (float)*layout->offset_y;
18285-
bounds->x = layout->at_x + item_offset + item_spacing + padding.x;
18281+
bounds->x = layout->at_x + item_offset + item_spacing;
1828618282
if (((bounds->x + bounds->w) > layout->max_x) && modify)
1828718283
layout->max_x = bounds->x + bounds->w;
1828818284
bounds->x -= (float)*layout->offset_x;
@@ -25475,6 +25471,7 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
2547525471
/// - [yy]: Minor version with non-breaking API and library changes
2547625472
/// - [zz]: Bug fix version with no direct changes to API
2547725473
///
25474+
/// - 2019/11/09 (4.01.4) - Fix bug where width padding was applied twice
2547825475
/// - 2019/09/20 (4.01.3) - Fixed a bug wherein combobox cannot be closed by clicking the header
2547925476
/// when NK_BUTTON_TRIGGER_ON_RELEASE is defined.
2548025477
/// - 2019/09/10 (4.01.2) - Fixed the nk_cos function, which deviated significantly.

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;

src/nuklear_math.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ nk_sin(float x)
6666
NK_LIB float
6767
nk_cos(float x)
6868
{
69-
// New implementation. Also generated using lolremez.
70-
// Old version significantly deviated from expected results.
69+
/* New implementation. Also generated using lolremez. */
70+
/* Old version significantly deviated from expected results. */
7171
NK_STORAGE const float a0 = 9.9995999154986614e-1f;
7272
NK_STORAGE const float a1 = 1.2548995793001028e-3f;
7373
NK_STORAGE const float a2 = -5.0648546280678015e-1f;

0 commit comments

Comments
 (0)