public static extern int nk_group_scrolled_offset_begin( nk_context *ctx, ref uint x_offset, ref uint y_offset, string title, nk_panel_flags flags );
public static bool Group(string name, string title, nk_panel_flags flags, Action action) { var result = true; unsafe { if (Nuklear.nk_group_begin_titled(_nuklearContext, name, title, flags) != 0) action?.Invoke(); else result = false; Nuklear.nk_group_end(_nuklearContext); } return result; }
public static bool Window(string name, string title, RectangleF rect, nk_panel_flags flags, Action action) { var result = true; unsafe { if (Nuklear.nk_begin_titled(_nuklearContext, name, title, rect, (uint)flags) != 0) action?.Invoke(); else result = false; Nuklear.nk_end(_nuklearContext); } return result; }
static void TestWindow(float X, float Y) { nk_panel_flags Flags = nk_panel_flags.NK_WINDOW_BORDER | nk_panel_flags.NK_WINDOW_MOVABLE | nk_panel_flags.NK_WINDOW_TITLE | nk_panel_flags.NK_WINDOW_MINIMIZABLE | nk_panel_flags.NK_WINDOW_SCALABLE | nk_panel_flags.NK_WINDOW_SCROLL_AUTO_HIDE; NuklearAPI.Window("Test Window", X, Y, 200, 200, Flags, () => { NuklearAPI.LayoutRowDynamic(35); for (int i = 0; i < 5; i++) { if (NuklearAPI.ButtonLabel("Some Button " + i)) { Console.WriteLine("You pressed button " + i); } } if (NuklearAPI.ButtonLabel("Exit")) { Environment.Exit(0); } }); }
public static bool Window(string Title, float X, float Y, float W, float H, nk_panel_flags Flags, Action A) => Window(Title, Title, X, Y, W, H, Flags, A);
public static bool Window(string Name, string Title, float X, float Y, float W, float H, nk_panel_flags Flags, Action A) { bool Res = true; if (Nuklear.nk_begin_titled(Ctx, Name, Title, new nk_rect(X, Y, W, H), (uint)Flags) != 0) { A?.Invoke(); } else { Res = false; } Nuklear.nk_end(Ctx); return(Res); }
public static extern int nk_group_scrolled_begin( nk_context *ctx, nk_scroll *scroll, string title, nk_panel_flags nkflags );
public static extern int nk_group_begin_titled(nk_context *ctx, string id, string title, nk_panel_flags flags);
public static bool Group(string name, nk_panel_flags flags, Action action) => Group(name, name, flags, action);
public static bool Window(string title, float x, float y, float w, float h, nk_panel_flags flags, Action action) => Window(title, title, new RectangleF(x, y, w, h), flags, action);
public void Calculator() { const string Numbers = "789456123"; const string Ops = "+-*/"; const nk_panel_flags F = nk_panel_flags.NK_WINDOW_BORDER | nk_panel_flags.NK_WINDOW_MOVABLE | nk_panel_flags.NK_WINDOW_NO_SCROLLBAR | nk_panel_flags.NK_WINDOW_TITLE | nk_panel_flags.NK_WINDOW_CLOSABLE | nk_panel_flags.NK_WINDOW_MINIMIZABLE; bool Solve = false; string BufferStr; NuklearAPI.Window(Name, X, Y, 180, 250, F, () => { NuklearAPI.LayoutRowDynamic(35, 1); Buffer.Clear(); Buffer.AppendFormat("{0:0.00}", Current); int Len = Buffer.Length; NuklearAPI.EditString(nk_edit_types.NK_EDIT_SIMPLE, Buffer, ref Len, (ref nk_text_edit TextBox, uint Rune) => { char C = (char)Rune; if (char.IsNumber(C)) { return(1); } return(0); }); BufferStr = Buffer.ToString().Trim(); if (BufferStr.Length > 0) { if (float.TryParse(BufferStr, out float CurFloat)) { Current = CurFloat; } } NuklearAPI.LayoutRowDynamic(35, 4); for (int i = 0; i < 16; i++) { if (i == 12) { if (NuklearAPI.ButtonLabel("C")) { A = B = 0; Op = ' '; Set = false; CurrentThingy = CurrentThing.A; } if (NuklearAPI.ButtonLabel("0")) { Current = Current * 10; Op = ' '; } if (NuklearAPI.ButtonLabel("=")) { Solve = true; Prev = Op; Op = ' '; } } else if (((i + 1) % 4) != 0) { int NumIdx = (i / 4) * 3 + i % 4; if (NumIdx < Numbers.Length && NuklearAPI.ButtonText(Numbers[NumIdx])) { Current = Current * 10 + int.Parse(Numbers[NumIdx].ToString()); Set = false; } } else if (NuklearAPI.ButtonText(Ops[i / 4])) { if (!Set) { if (CurrentThingy != CurrentThing.B) { CurrentThingy = CurrentThing.B; } else { Prev = Op; Solve = true; } } Op = Ops[i / 4]; Set = true; } } if (Solve) { if (Prev == '+') { A = A + B; } else if (Prev == '-') { A = A - B; } else if (Prev == '*') { A = A * B; } else if (Prev == '/') { A = A / B; } CurrentThingy = CurrentThing.A; if (Set) { CurrentThingy = CurrentThing.B; } B = 0; Set = false; } }); if (NuklearAPI.WindowIsClosed(Name) || NuklearAPI.WindowIsHidden(Name)) { Open = false; } }