public static int nk_group_scrolled_offset_begin(this NuklearContext ctx, Offset offset, string title, uint flags) { var bounds = new RectangleF(); var panel = ctx.nk_create_window(); nk_window win; win = ctx.current; ctx.PanelAllocSpace(ref bounds); { if ( !!(bounds.X > win.Layout.Clip.X + win.Layout.Clip.Width || bounds.X + bounds.Width < win.Layout.Clip.X || bounds.Y > win.Layout.Clip.Y + win.Layout.Clip.Height || bounds.Y + bounds.Height < win.Layout.Clip.Y) && (flags & NK_WINDOW_MOVABLE) == 0) { return(0); } } if ((win.Flags & NK_WINDOW_ROM) != 0) { flags |= NK_WINDOW_ROM; } panel.Bounds = bounds; panel.Flags = flags; panel.Scrollbar.X = offset.X; panel.Scrollbar.Y = offset.Y; panel.Buffer = win.Buffer; panel.Layout = new nk_panel(); ctx.current = panel; ctx.nk_panel_begin((flags & NK_WINDOW_TITLE) != 0 ? title : null, NK_PANEL_GROUP); win.Buffer = panel.Buffer; win.Buffer.Clip = panel.Layout.Clip; panel.Layout.Offset = offset; panel.Layout.Parent = win.Layout; win.Layout = panel.Layout; ctx.current = win; if ((panel.Layout.Flags & NK_WINDOW_CLOSED) != 0 || (panel.Layout.Flags & NK_WINDOW_MINIMIZED) != 0) { var f = panel.Layout.Flags; nk_group_scrolled_end(ctx); if ((f & NK_WINDOW_CLOSED) != 0) { return(NK_WINDOW_CLOSED); } if ((f & NK_WINDOW_MINIMIZED) != 0) { return(NK_WINDOW_MINIMIZED); } } return(1); }
public static void nk_text_wrap_colored(this NuklearContext ctx, StringSegment str, Color color) { nk_window win; nk_style style; var item_padding = new Vector2(); var bounds = new RectangleF(); var text = new nk_text(); if (ctx == null || ctx.current == null || ctx.current.Layout == null) return; win = ctx.current; style = ctx.style; ctx.PanelAllocSpace(ref bounds); item_padding = style.text.Padding; text.padding.X = item_padding.X; text.padding.Y = item_padding.Y; text.Background = style.window.background; text.text = color; win.Buffer.nk_widget_text_wrap(bounds, str, &text, style.font); }
public static int Widget(this NuklearContext ctx, ref RectangleF bounds) { var c = new RectangleF(); var v = new RectangleF(); nk_window win; nk_panel layout; nk_input _in_; if (ctx == null || ctx.current == null || ctx.current.Layout == null) { return(NK_WIDGET_INVALID); } ctx.PanelAllocSpace(ref bounds); win = ctx.current; layout = win.Layout; _in_ = ctx.input; c = layout.Clip; bounds.X = (int)bounds.X; bounds.Y = (int)bounds.Y; bounds.Width = (int)bounds.Width; bounds.Height = (int)bounds.Height; c.X = (int)c.X; c.Y = (int)c.Y; c.Width = (int)c.Width; c.Height = (int)c.Height; RectangleF.nk_unify(ref v, ref c, bounds.X, bounds.Y, bounds.X + bounds.Width, bounds.Y + bounds.Height); if ( !!(bounds.X > c.X + c.Width || bounds.X + bounds.Width < c.X || bounds.Y > c.Y + c.Height || bounds.Y + bounds.Height < c.Y)) { return(NK_WIDGET_INVALID); } if ( !(v.X <= _in_.mouse.pos.X && _in_.mouse.pos.X < v.X + v.Width && v.Y <= _in_.mouse.pos.Y && _in_.mouse.pos.Y < v.Y + v.Height)) { return(NK_WIDGET_ROM); } return(NK_WIDGET_VALID); }
public static void Spacing(this NuklearContext ctx, int cols) { nk_window win; nk_panel layout; var none = new RectangleF(); int i; int index; int rows; if (ctx == null || ctx.current == null || ctx.current.Layout == null) { return; } win = ctx.current; layout = win.Layout; index = (layout.Row.index + cols) % layout.Row.columns; rows = (layout.Row.index + cols) / layout.Row.columns; if (rows != 0) { for (i = 0; i < rows; ++i) { ctx.PanelAllocRow(win); } cols = index; } if (layout.Row.type != NK_LAYOUT_DYNAMIC_FIXED && layout.Row.type != NK_LAYOUT_STATIC_FIXED) { for (i = 0; i < cols; ++i) { ctx.PanelAllocSpace(ref none); } } layout.Row.index = index; }