public static void nk_layout_peek(nk_rect *bounds, nk_context ctx) { float y; int index; nk_window win; nk_panel layout; if (((ctx == null) || (ctx.current == null)) || (ctx.current.layout == null)) { return; } win = ctx.current; layout = win.layout; y = (float)(layout.at_y); index = (int)(layout.row.index); if ((layout.row.index) >= (layout.row.columns)) { layout.at_y += (float)(layout.row.height); layout.row.index = (int)(0); } nk_layout_widget_space(bounds, ctx, win, (int)(nk_false)); if (layout.row.index == 0) { bounds->x -= (float)(layout.row.item_offset); } layout.at_y = (float)(y); layout.row.index = (int)(index); }
public static void nk_panel_alloc_space(nk_rect *bounds, nk_context ctx) { nk_window win; nk_panel layout; if (((ctx == null) || (ctx.current == null)) || (ctx.current.layout == null)) { return; } win = ctx.current; layout = win.layout; if ((layout.row.index) >= (layout.row.columns)) { nk_panel_alloc_row(ctx, win); } nk_layout_widget_space(bounds, ctx, win, (int)(nk_true)); layout.row.index++; }
public static int nk_widget(nk_rect *bounds, nk_context ctx) { nk_rect c = new nk_rect(); nk_rect v = new nk_rect(); nk_window win; nk_panel layout; nk_input _in_; if (((ctx == null) || (ctx.current == null)) || (ctx.current.layout == null)) { return((int)(NK_WIDGET_INVALID)); } nk_panel_alloc_space(bounds, ctx); win = ctx.current; layout = win.layout; _in_ = ctx.input; c = (nk_rect)(layout.clip); bounds->x = ((float)((int)(bounds->x))); bounds->y = ((float)((int)(bounds->y))); bounds->w = ((float)((int)(bounds->w))); bounds->h = ((float)((int)(bounds->h))); c.x = ((float)((int)(c.x))); c.y = ((float)((int)(c.y))); c.w = ((float)((int)(c.w))); c.h = ((float)((int)(c.h))); nk_unify(ref v, ref c, (float)(bounds->x), (float)(bounds->y), (float)(bounds->x + bounds->w), (float)(bounds->y + bounds->h)); if ( !(!(((((bounds->x) > (c.x + c.w)) || ((bounds->x + bounds->w) < (c.x))) || ((bounds->y) > (c.y + c.h))) || ((bounds->y + bounds->h) < (c.y))))) { return((int)(NK_WIDGET_INVALID)); } if ( !((((v.x) <= (_in_.mouse.pos.x)) && ((_in_.mouse.pos.x) < (v.x + v.w))) && (((v.y) <= (_in_.mouse.pos.y)) && ((_in_.mouse.pos.y) < (v.y + v.h))))) { return((int)(NK_WIDGET_ROM)); } return((int)(NK_WIDGET_VALID)); }
public static int nk_widget_fitting(nk_rect *bounds, nk_context ctx, nk_vec2 item_padding) { nk_window win; nk_style style; nk_panel layout; int state; nk_vec2 panel_padding = new nk_vec2(); if (((ctx == null) || (ctx.current == null)) || (ctx.current.layout == null)) { return((int)(NK_WIDGET_INVALID)); } win = ctx.current; style = ctx.style; layout = win.layout; state = (int)(nk_widget(bounds, ctx)); panel_padding = (nk_vec2)(nk_panel_get_padding(style, (int)(layout.type))); if ((layout.row.index) == (1)) { bounds->w += (float)(panel_padding.x); bounds->x -= (float)(panel_padding.x); } else { bounds->x -= (float)(item_padding.x); } if ((layout.row.index) == (layout.row.columns)) { bounds->w += (float)(panel_padding.x); } else { bounds->w += (float)(item_padding.x); } return((int)(state)); }
public static void nk_layout_widget_space(nk_rect *bounds, nk_context ctx, nk_window win, int modify) { nk_panel layout; nk_style style; nk_vec2 spacing = new nk_vec2(); nk_vec2 padding = new nk_vec2(); float item_offset = (float)(0); float item_width = (float)(0); float item_spacing = (float)(0); float panel_space = (float)(0); if (((ctx == null) || (ctx.current == null)) || (ctx.current.layout == null)) { return; } win = ctx.current; layout = win.layout; style = ctx.style; spacing = (nk_vec2)(style.window.spacing); padding = (nk_vec2)(nk_panel_get_padding(style, (int)(layout.type))); panel_space = (float) (nk_layout_row_calculate_usable_space(ctx.style, (int)(layout.type), (float)(layout.bounds.w), (int)(layout.row.columns))); switch (layout.row.type) { case NK_LAYOUT_DYNAMIC_FIXED: { item_width = (float)(((1.0f) < (panel_space - 1.0f) ? (panel_space - 1.0f) : (1.0f)) / (float)(layout.row.columns)); item_offset = (float)((float)(layout.row.index) * item_width); item_spacing = (float)((float)(layout.row.index) * spacing.x); } break; case NK_LAYOUT_DYNAMIC_ROW: { item_width = (float)(layout.row.item_width * panel_space); item_offset = (float)(layout.row.item_offset); item_spacing = (float)(0); if ((modify) != 0) { layout.row.item_offset += (float)(item_width + spacing.x); layout.row.filled += (float)(layout.row.item_width); layout.row.index = (int)(0); } } break; case NK_LAYOUT_DYNAMIC_FREE: { bounds->x = (float)(layout.at_x + (layout.bounds.w * layout.row.item.x)); bounds->x -= ((float)(layout.offset.x)); bounds->y = (float)(layout.at_y + (layout.row.height * layout.row.item.y)); bounds->y -= ((float)(layout.offset.y)); bounds->w = (float)(layout.bounds.w * layout.row.item.w); bounds->h = (float)(layout.row.height * layout.row.item.h); return; } case NK_LAYOUT_DYNAMIC: { float ratio; ratio = (float) (((layout.row.ratio[layout.row.index]) < (0)) ? layout.row.item_width : layout.row.ratio[layout.row.index]); item_spacing = (float)((float)(layout.row.index) * spacing.x); item_width = (float)(ratio * panel_space); item_offset = (float)(layout.row.item_offset); if ((modify) != 0) { layout.row.item_offset += (float)(item_width); layout.row.filled += (float)(ratio); } } break; case NK_LAYOUT_STATIC_FIXED: { item_width = (float)(layout.row.item_width); item_offset = (float)((float)(layout.row.index) * item_width); item_spacing = (float)((float)(layout.row.index) * spacing.x); } break; case NK_LAYOUT_STATIC_ROW: { item_width = (float)(layout.row.item_width); item_offset = (float)(layout.row.item_offset); item_spacing = (float)((float)(layout.row.index) * spacing.x); if ((modify) != 0) { layout.row.item_offset += (float)(item_width); } } break; case NK_LAYOUT_STATIC_FREE: { bounds->x = (float)(layout.at_x + layout.row.item.x); bounds->w = (float)(layout.row.item.w); if (((bounds->x + bounds->w) > (layout.max_x)) && ((modify) != 0)) { layout.max_x = (float)(bounds->x + bounds->w); } bounds->x -= ((float)(layout.offset.x)); bounds->y = (float)(layout.at_y + layout.row.item.y); bounds->y -= ((float)(layout.offset.y)); bounds->h = (float)(layout.row.item.h); return; } case NK_LAYOUT_STATIC: { item_spacing = (float)((float)(layout.row.index) * spacing.x); item_width = (float)(layout.row.ratio[layout.row.index]); item_offset = (float)(layout.row.item_offset); if ((modify) != 0) { layout.row.item_offset += (float)(item_width); } } break; case NK_LAYOUT_TEMPLATE: { item_width = (float)(layout.row.templates[layout.row.index]); item_offset = (float)(layout.row.item_offset); item_spacing = (float)((float)(layout.row.index) * spacing.x); if ((modify) != 0) { layout.row.item_offset += (float)(item_width); } } break; default: ; break; } bounds->w = (float)(item_width); bounds->h = (float)(layout.row.height - spacing.y); bounds->y = (float)(layout.at_y - (float)(layout.offset.y)); bounds->x = (float)(layout.at_x + item_offset + item_spacing + padding.x); if (((bounds->x + bounds->w) > (layout.max_x)) && ((modify) != 0)) { layout.max_x = (float)(bounds->x + bounds->w); } bounds->x -= ((float)(layout.offset.x)); }
public static extern nk_widget_layout_states nk_widget_fitting(nk_rect *r, nk_context *ctx, nk_vec2 v);
public static extern nk_widget_layout_states nk_widget(nk_rect *r, nk_context *ctx);