Skip to content

Commit b6e261b

Browse files
committed
Round layout widget position to nearest 0
1 parent 964cc81 commit b6e261b

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

src/nuklear_internal.h

+1
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ NK_LIB int nk_ifloord(double x);
118118
NK_LIB int nk_ifloorf(float x);
119119
NK_LIB int nk_iceilf(float x);
120120
NK_LIB int nk_log10(double n);
121+
NK_LIB float nk_roundf(float x);
121122

122123
/* util */
123124
enum {NK_DO_NOT_STOP_ON_NEW_LINE, NK_STOP_ON_NEW_LINE};

src/nuklear_layout.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ nk_layout_widget_space(struct nk_rect *bounds, const struct nk_context *ctx,
601601
panel_space = nk_layout_row_calculate_usable_space(&ctx->style, layout->type,
602602
layout->bounds.w, layout->row.columns);
603603

604-
#define NK_FRAC(x) (x - (float)(int)x) /* will be used to remove fookin gaps */
604+
#define NK_FRAC(x) (x - (float)(int)nk_roundf(x)) /* will be used to remove fookin gaps */
605605
/* calculate the width of one item inside the current layout space */
606606
switch (layout->row.type) {
607607
case NK_LAYOUT_DYNAMIC_FIXED: {

src/nuklear_math.c

+5
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,11 @@ nk_log10(double n)
197197
if (neg) exp = -exp;
198198
return exp;
199199
}
200+
NK_LIB float
201+
nk_roundf(float x)
202+
{
203+
return (x >= 0.0) ? nk_ifloorf(x + 0.5) : nk_iceilf(x - 0.5);
204+
}
200205
NK_API struct nk_rect
201206
nk_get_null_rect(void)
202207
{

0 commit comments

Comments
 (0)