Пример #1
0
        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);
        }
Пример #2
0
        public static void nk_group_scrolled_end(this NuklearContext ctx)
        {
            nk_window win;
            nk_panel  parent;
            nk_panel  g;
            var       clip          = new RectangleF();
            var       pan           = ctx.nk_create_window();
            var       panel_padding = new Vector2();

            if (ctx == null || ctx.current == null)
            {
                return;
            }
            win    = ctx.current;
            g      = win.Layout;
            parent = g.Parent;

            panel_padding     = nk_panel_get_padding(ctx.style, NK_PANEL_GROUP);
            pan.Bounds.Y      = g.Bounds.Y - (g.Header_height + g.Menu.Height);
            pan.Bounds.X      = g.Bounds.X - panel_padding.X;
            pan.Bounds.Width  = g.Bounds.Width + 2 * panel_padding.X;
            pan.Bounds.Height = g.Bounds.Height + g.Header_height + g.Menu.Height;
            if ((g.Flags & NK_WINDOW_BORDER) != 0)
            {
                pan.Bounds.X      -= g.Border;
                pan.Bounds.Y      -= g.Border;
                pan.Bounds.Width  += 2 * g.Border;
                pan.Bounds.Height += 2 * g.Border;
            }

            if ((g.Flags & NK_WINDOW_NO_SCROLLBAR) == 0)
            {
                pan.Bounds.Width  += ctx.style.window.scrollbar_size.X;
                pan.Bounds.Height += ctx.style.window.scrollbar_size.Y;
            }

            pan.Scrollbar = g.Offset.ToPoint();
            pan.Flags     = g.Flags;
            pan.Buffer    = win.Buffer;
            pan.Layout    = g;
            pan.Parent    = win;
            ctx.current   = pan;
            RectangleF.nk_unify(ref clip, ref parent.Clip, pan.Bounds.X, pan.Bounds.Y,
                                pan.Bounds.X + pan.Bounds.Width, pan.Bounds.Y + pan.Bounds.Height + panel_padding.X);
            pan.Buffer.Scissor(clip);
            ctx.End();
            win.Buffer = pan.Buffer;
            win.Buffer.Scissor(parent.Clip);
            ctx.current = win;
            win.Layout  = parent;
            g.Bounds    = pan.Bounds;
        }