Update nuklear_layout.c
This commit is contained in:
parent
cac6ca59d7
commit
f9c0977f35
@ -605,21 +605,21 @@ nk_layout_widget_space(struct nk_rect *bounds, const struct nk_context *ctx,
|
|||||||
panel_space = nk_layout_row_calculate_usable_space(&ctx->style, layout->type,
|
panel_space = nk_layout_row_calculate_usable_space(&ctx->style, layout->type,
|
||||||
layout->bounds.w, layout->row.columns);
|
layout->bounds.w, layout->row.columns);
|
||||||
|
|
||||||
#define FRAC(x) (x - (int)x) /* will be used to remove fookin gaps */
|
#define NK_FRAC(x) (x - (int)x) /* will be used to remove fookin gaps */
|
||||||
/* calculate the width of one item inside the current layout space */
|
/* calculate the width of one item inside the current layout space */
|
||||||
switch (layout->row.type) {
|
switch (layout->row.type) {
|
||||||
case NK_LAYOUT_DYNAMIC_FIXED: {
|
case NK_LAYOUT_DYNAMIC_FIXED: {
|
||||||
/* scaling fixed size widgets item width */
|
/* scaling fixed size widgets item width */
|
||||||
float w = NK_MAX(1.0f,panel_space) / (float)layout->row.columns;
|
float w = NK_MAX(1.0f,panel_space) / (float)layout->row.columns;
|
||||||
item_offset = (float)layout->row.index * w;
|
item_offset = (float)layout->row.index * w;
|
||||||
item_width = w + FRAC(item_offset);
|
item_width = w + NK_FRAC(item_offset);
|
||||||
item_spacing = (float)layout->row.index * spacing.x;
|
item_spacing = (float)layout->row.index * spacing.x;
|
||||||
} break;
|
} break;
|
||||||
case NK_LAYOUT_DYNAMIC_ROW: {
|
case NK_LAYOUT_DYNAMIC_ROW: {
|
||||||
/* scaling single ratio widget width */
|
/* scaling single ratio widget width */
|
||||||
float w = layout->row.item_width * panel_space;
|
float w = layout->row.item_width * panel_space;
|
||||||
item_offset = layout->row.item_offset;
|
item_offset = layout->row.item_offset;
|
||||||
item_width = w + FRAC(item_offset);
|
item_width = w + NK_FRAC(item_offset);
|
||||||
item_spacing = 0;
|
item_spacing = 0;
|
||||||
|
|
||||||
if (modify) {
|
if (modify) {
|
||||||
@ -634,8 +634,8 @@ nk_layout_widget_space(struct nk_rect *bounds, const struct nk_context *ctx,
|
|||||||
bounds->x -= (float)*layout->offset_x;
|
bounds->x -= (float)*layout->offset_x;
|
||||||
bounds->y = layout->at_y + (layout->row.height * layout->row.item.y);
|
bounds->y = layout->at_y + (layout->row.height * layout->row.item.y);
|
||||||
bounds->y -= (float)*layout->offset_y;
|
bounds->y -= (float)*layout->offset_y;
|
||||||
bounds->w = layout->bounds.w * layout->row.item.w + FRAC(bounds->x);
|
bounds->w = layout->bounds.w * layout->row.item.w + NK_FRAC(bounds->x);
|
||||||
bounds->h = layout->row.height * layout->row.item.h + FRAC(bounds->y);
|
bounds->h = layout->row.height * layout->row.item.h + NK_FRAC(bounds->y);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case NK_LAYOUT_DYNAMIC: {
|
case NK_LAYOUT_DYNAMIC: {
|
||||||
@ -648,7 +648,7 @@ nk_layout_widget_space(struct nk_rect *bounds, const struct nk_context *ctx,
|
|||||||
w = (ratio * panel_space);
|
w = (ratio * panel_space);
|
||||||
item_spacing = (float)layout->row.index * spacing.x;
|
item_spacing = (float)layout->row.index * spacing.x;
|
||||||
item_offset = layout->row.item_offset;
|
item_offset = layout->row.item_offset;
|
||||||
item_width = w + FRAC(item_offset);
|
item_width = w + NK_FRAC(item_offset);
|
||||||
|
|
||||||
if (modify) {
|
if (modify) {
|
||||||
layout->row.item_offset += w;
|
layout->row.item_offset += w;
|
||||||
@ -694,11 +694,11 @@ nk_layout_widget_space(struct nk_rect *bounds, const struct nk_context *ctx,
|
|||||||
NK_ASSERT(layout->row.index < NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS);
|
NK_ASSERT(layout->row.index < NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS);
|
||||||
w = layout->row.templates[layout->row.index];
|
w = layout->row.templates[layout->row.index];
|
||||||
item_offset = layout->row.item_offset;
|
item_offset = layout->row.item_offset;
|
||||||
item_width = w + FRAC(item_offset);
|
item_width = w + NK_FRAC(item_offset);
|
||||||
item_spacing = (float)layout->row.index * spacing.x;
|
item_spacing = (float)layout->row.index * spacing.x;
|
||||||
if (modify) layout->row.item_offset += w;
|
if (modify) layout->row.item_offset += w;
|
||||||
} break;
|
} break;
|
||||||
#undef FRAC
|
#undef NK_FRAC
|
||||||
default: NK_ASSERT(0); break;
|
default: NK_ASSERT(0); break;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user