public void WindowSetBounds(string name, NkRect bounds) { fixed(char *name_ptr = name) { Nk.nk_window_set_bounds(_ctx, name_ptr, bounds); } }
public static int nk_toggle_behavior(nk_input _in_, NkRect select, ref NkWidgetStates state, int active) { if (((state) & NkWidgetStates.MODIFIED) != 0) { (state) = (NkWidgetStates.INACTIVE | NkWidgetStates.MODIFIED); } else { (state) = (NkWidgetStates.INACTIVE); } if ((nk_button_behavior(ref state, select, _in_, NkButtonBehavior.Default)) != 0) { state = (NkWidgetStates.ACTIVE); active = active != 0 ? 0 : 1; } if (((state & NkWidgetStates.HOVER) != 0) && (nk_input_is_mouse_prev_hovering_rect(_in_, (NkRect)(select)) == 0)) { state |= (NkWidgetStates.ENTERED); } else if ((nk_input_is_mouse_prev_hovering_rect(_in_, (NkRect)(select))) != 0) { state |= (NkWidgetStates.LEFT); } return((int)(active)); }
public bool Begin(string title, NkRect bounds, PanelFlags flags) { fixed(char *title_ptr = title) { return(Nk.nk_begin(_ctx, title_ptr, bounds, flags) != 0); } }
public bool MenuBegin(NkWindow win, string id, int is_clicked, NkRect header, NkVec2 size) { fixed(char *id_ptr = id) { return(Nk.nk_menu_begin(_ctx, win, id_ptr, is_clicked, header, size) != 0); } }
public bool PopupBegin(NkPopupType type, string title, PanelFlags flags, NkRect rect) { fixed(char *title_ptr = title) { return(Nk.nk_popup_begin(_ctx, type, title_ptr, flags, rect) != 0); } }
public static NkVec2 nk_rect_size(NkRect r) { NkVec2 ret = new NkVec2(); ret.x = (float)(r.w); ret.y = (float)(r.h); return((NkVec2)(ret)); }
public static void nk_unify(ref NkRect clip, ref NkRect a, float x0, float y0, float x1, float y1) { clip.x = (float)((a.x) < (x0) ? (x0) : (a.x)); clip.y = (float)((a.y) < (y0) ? (y0) : (a.y)); clip.w = (float)(((a.x + a.w) < (x1) ? (a.x + a.w) : (x1)) - clip.x); clip.h = (float)(((a.y + a.h) < (y1) ? (a.y + a.h) : (y1)) - clip.y); clip.w = (float)((0) < (clip.w) ? (clip.w) : (0)); clip.h = (float)((0) < (clip.h) ? (clip.h) : (0)); }
public static NkVec2 nk_rect_pos(NkRect r) { NkVec2 ret = new NkVec2 { x = r.x, y = r.y }; return(ret); }
public bool BeginTitled(string name, string title, NkRect bounds, PanelFlags flags) { fixed(char *name_ptr = name) { fixed(char *title_ptr = title) { return(Nk.nk_begin_titled(_ctx, name_ptr, title_ptr, bounds, flags) != 0); } } }
public static NkRect nk_pad_rect(NkRect r, NkVec2 pad) { r.w = (float)((r.w) < (2 * pad.x) ? (2 * pad.x) : (r.w)); r.h = (float)((r.h) < (2 * pad.y) ? (2 * pad.y) : (r.h)); r.x += (float)(pad.x); r.y += (float)(pad.y); r.w -= (float)(2 * pad.x); r.h -= (float)(2 * pad.y); return((NkRect)(r)); }
public static int nk_input_is_mouse_prev_hovering_rect(nk_input i, NkRect rect) { if (i == null) { return((int)(nk_false)); } return((((rect.x) <= (i.mouse.Prev.x)) && ((i.mouse.Prev.x) < (rect.x + rect.w))) && (((rect.y) <= (i.mouse.Prev.y)) && ((i.mouse.Prev.y) < (rect.y + rect.h))) ? 1 : 0); }
public static int nk_input_any_mouse_click_in_rect(nk_input _in_, NkRect b) { int i; int down = (int)(0); for (i = (int)(0); (i) < ((int)NkButtons.MAX); ++i) { down = (int)(((down) != 0) || ((nk_input_is_mouse_click_in_rect(_in_, (NkButtons)(i), (NkRect)(b))) != 0) ? 1 : 0); } return((int)(down)); }
public static NkRect nk_shrink_rect_(NkRect r, float amount) { NkRect res = new NkRect(); r.w = (float)((r.w) < (2 * amount) ? (2 * amount) : (r.w)); r.h = (float)((r.h) < (2 * amount) ? (2 * amount) : (r.h)); res.x = (float)(r.x + amount); res.y = (float)(r.y + amount); res.w = (float)(r.w - 2 * amount); res.h = (float)(r.h - 2 * amount); return((NkRect)(res)); }
public static int nk_input_mouse_clicked(nk_input i, NkButtons id, NkRect rect) { if (i == null) { return((int)(nk_false)); } if (nk_input_is_mouse_hovering_rect(i, (NkRect)(rect)) == 0) { return((int)(nk_false)); } return((int)(nk_input_is_mouse_click_in_rect(i, (id), (NkRect)(rect)))); }
public static int nk_input_is_mouse_click_in_rect(nk_input i, NkButtons id, NkRect b) { nk_mouse_button *btn; if (i == null) { return((int)(nk_false)); } btn = (nk_mouse_button *)i.mouse.Buttons + (int)id; return ((int) ((((nk_input_has_mouse_click_down_in_rect(i, (id), (NkRect)(b), (int)(nk_false))) != 0) && ((btn->clicked) != 0)) ? nk_true : nk_false)); }
public static int nk_input_has_mouse_click_in_rect(nk_input i, NkButtons id, NkRect b) { nk_mouse_button *btn; if (i == null) { return((int)(nk_false)); } btn = (nk_mouse_button *)i.mouse.Buttons + (int)id; if ( !((((b.x) <= (btn->clicked_pos.x)) && ((btn->clicked_pos.x) < (b.x + b.w))) && (((b.y) <= (btn->clicked_pos.y)) && ((btn->clicked_pos.y) < (b.y + b.h))))) { return((int)(nk_false)); } return((int)(nk_true)); }
public static NkWidgetLayoutStates nk_widget(NkRect *bounds, NkContext ctx) { NkRect c = new NkRect(); NkRect v = new NkRect(); NkWindow win; NkPanel layout; nk_input _in_; if (((ctx == null) || (ctx.Current == null)) || (ctx.Current.Layout == null)) { return(NkWidgetLayoutStates.NK_WIDGET_INVALID); } nk_panel_alloc_space(bounds, ctx); win = ctx.Current; layout = win.Layout; _in_ = ctx.Input; c = (NkRect)(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(NkWidgetLayoutStates.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(NkWidgetLayoutStates.NK_WIDGET_ROM); } return(NkWidgetLayoutStates.NK_WIDGET_VALID); }
public static void nk_triangle_from_direction(NkVec2 *result, NkRect r, float pad_x, float pad_y, NkHeading direction) { float w_half; float h_half; r.w = (float)((2 * pad_x) < (r.w) ? (r.w) : (2 * pad_x)); r.h = (float)((2 * pad_y) < (r.h) ? (r.h) : (2 * pad_y)); r.w = (float)(r.w - 2 * pad_x); r.h = (float)(r.h - 2 * pad_y); r.x = (float)(r.x + pad_x); r.y = (float)(r.y + pad_y); w_half = (float)(r.w / 2.0f); h_half = (float)(r.h / 2.0f); if ((direction) == (NkHeading.NK_UP)) { result[0] = (NkVec2)(nk_vec2_((float)(r.x + w_half), (float)(r.y))); result[1] = (NkVec2)(nk_vec2_((float)(r.x + r.w), (float)(r.y + r.h))); result[2] = (NkVec2)(nk_vec2_((float)(r.x), (float)(r.y + r.h))); } else if ((direction) == (NkHeading.NK_RIGHT)) { result[0] = (NkVec2)(nk_vec2_((float)(r.x), (float)(r.y))); result[1] = (NkVec2)(nk_vec2_((float)(r.x + r.w), (float)(r.y + h_half))); result[2] = (NkVec2)(nk_vec2_((float)(r.x), (float)(r.y + r.h))); } else if ((direction) == (NkHeading.NK_DOWN)) { result[0] = (NkVec2)(nk_vec2_((float)(r.x), (float)(r.y))); result[1] = (NkVec2)(nk_vec2_((float)(r.x + r.w), (float)(r.y))); result[2] = (NkVec2)(nk_vec2_((float)(r.x + w_half), (float)(r.y + r.h))); } else { result[0] = (NkVec2)(nk_vec2_((float)(r.x), (float)(r.y + h_half))); result[1] = (NkVec2)(nk_vec2_((float)(r.x + r.w), (float)(r.y))); result[2] = (NkVec2)(nk_vec2_((float)(r.x + r.w), (float)(r.y + r.h))); } }
public static void nk_property_(NkContext ctx, char *name, NkPropertyVariant *variant, float incPerPixel, NkPropertyFilter filter) { var bounds = new NkRect(); uint hash; string dummyBuffer = null; NkPropertyStatus dummyState = NkPropertyStatus.NK_PROPERTY_DEFAULT; var dummyCursor = 0; var dummySelectBegin = 0; var dummySelectEnd = 0; if (ctx == null || ctx.Current == null || ctx.Current.Layout == null) { return; } var win = ctx.Current; var layout = win.Layout; var style = ctx.Style; var s = nk_widget(&bounds, ctx); if (s == 0) { return; } if (name[0] == '#') { hash = nk_murmur_hash(name, nk_strlen(name), win.Property.seq++); name++; } else { hash = nk_murmur_hash(name, nk_strlen(name), 42); } var _in_ = s == NkWidgetLayoutStates.NK_WIDGET_ROM && win.Property.active == 0 || (layout.Flags & PanelFlags.ROM) != 0 ? null : ctx.Input; NkPropertyStatus oldState, state; string buffer; int cursor, selectBegin, selectEnd; if (win.Property.active != 0 && hash == win.Property.name) { oldState = win.Property.state; nk_do_property(ref ctx.LastWidgetState, win.Buffer, bounds, name, variant, incPerPixel, ref win.Property.buffer, ref win.Property.state, ref win.Property.cursor, ref win.Property.select_start, ref win.Property.select_end, style.Property, filter, _in_, style.Font, ctx.TextEdit, ctx.ButtonBehavior); state = win.Property.state; buffer = win.Property.buffer; cursor = win.Property.cursor; selectBegin = win.Property.select_start; selectEnd = win.Property.select_end; } else { oldState = dummyState; nk_do_property(ref ctx.LastWidgetState, win.Buffer, bounds, name, variant, incPerPixel, ref dummyBuffer, ref dummyState, ref dummyCursor, ref dummySelectBegin, ref dummySelectEnd, style.Property, filter, _in_, style.Font, ctx.TextEdit, ctx.ButtonBehavior); state = dummyState; buffer = dummyBuffer; cursor = dummyCursor; selectBegin = dummySelectBegin; selectEnd = dummySelectEnd; } ctx.TextEdit.clip = ctx.Clip; if (_in_ != null && state != NkPropertyStatus.NK_PROPERTY_DEFAULT && win.Property.active == 0) { win.Property.active = 1; win.Property.buffer = buffer; win.Property.cursor = cursor; win.Property.state = state; win.Property.name = hash; win.Property.select_start = selectBegin; win.Property.select_end = selectEnd; if (state == NkPropertyStatus.NK_PROPERTY_DRAG) { ctx.Input.mouse.Grab = nk_true; ctx.Input.mouse.Grabbed = nk_true; } } if (state == NkPropertyStatus.NK_PROPERTY_DEFAULT && oldState != NkPropertyStatus.NK_PROPERTY_DEFAULT) { if (oldState == NkPropertyStatus.NK_PROPERTY_DRAG) { ctx.Input.mouse.Grab = nk_false; ctx.Input.mouse.Grabbed = nk_false; ctx.Input.mouse.Ungrab = nk_true; } win.Property.select_start = 0; win.Property.select_end = 0; win.Property.active = 0; } }
public static NkImage nk_subimage_handle(NkHandle handle, ushort w, ushort h, NkRect r) { NkImage s = new NkImage(); s.handle = (NkHandle)(handle); s.w = (ushort)(w); s.h = (ushort)(h); s.region[0] = ((ushort)(r.x)); s.region[1] = ((ushort)(r.y)); s.region[2] = ((ushort)(r.w)); s.region[3] = ((ushort)(r.h)); return((NkImage)(s)); }
public bool ContextualBegin(PanelFlags flags, NkVec2 size, NkRect trigger_bounds) { return(Nk.nk_contextual_begin(_ctx, flags, size, trigger_bounds) != 0); }
public void LayoutSpacePush(NkRect rect) { Nk.nk_layout_space_push(_ctx, rect); }
public bool ComboBegin(NkWindow win, NkVec2 size, int is_clicked, NkRect header) { return(Nk.nk_combo_begin(_ctx, win, size, is_clicked, header) != 0); }
public NkRect LayoutSpaceRectToScreen(NkRect ret) { return(Nk.nk_layout_space_rect_to_screen(_ctx, ret)); }
public NkRect LayoutSpaceRectToLocal(NkRect ret) { return(Nk.nk_layout_space_rect_to_local(_ctx, ret)); }
public static void nk_build(NkContext ctx) { if (ctx.Style.CursorActive == null) { ctx.Style.CursorActive = ctx.Style.Cursors[(int)NkStyleCursor.ARROW]; } if (ctx.Style.CursorActive != null && ctx.Input.mouse.Grabbed == 0 && ctx.Style.CursorVisible != 0) { var mouseBounds = new NkRect(); var cursor = ctx.Style.CursorActive; nk_command_buffer_init(ctx.Overlay, false); nk_start_buffer(ctx, ctx.Overlay); mouseBounds.x = ctx.Input.mouse.Pos.x - cursor.offset.x; mouseBounds.y = ctx.Input.mouse.Pos.y - cursor.offset.y; mouseBounds.w = cursor.size.x; mouseBounds.h = cursor.size.y; nk_draw_image(ctx.Overlay, mouseBounds, cursor.img, nk_white); } var it = ctx.Begin; NkCommandBase cmd = null; for (; it != null;) { var next = it.Next; if ((it.Flags & PanelFlags.HIDDEN) != 0 || it.Seq != ctx.Seq) { goto cont; } cmd = it.Buffer.Last; while (next != null && (next.Buffer == null || next.Buffer.Count == 0 || (next.Flags & PanelFlags.HIDDEN) != 0)) { next = next.Next; } if (next != null) { cmd.Next = next.Buffer.First; } cont: it = next; } it = ctx.Begin; while (it != null) { var next = it.Next; if (it.Popup.buf.Buffer.Count == 0) { goto skip; } var buf = it.Popup.buf.Buffer; cmd.Next = buf.First; cmd = buf.Last; it.Popup.buf.Buffer.Count = 0; skip: it = next; } if (cmd != null) { cmd.Next = ctx.Overlay.Count > 0 ? ctx.Overlay.First : null; } }
public static int nk_popup_begin(NkContext ctx, NkPopupType type, string title, PanelFlags flags, NkRect rect) { fixed(char *ptr = title) { return(nk_popup_begin(ctx, type, ptr, flags, rect)); } }
public bool NonblockBegin(PanelFlags flags, NkRect body, NkRect header, NkPanelType panel_type) { return(Nk.nk_nonblock_begin(_ctx, flags, body, header, panel_type) != 0); }