Пример #1
0
        public static bool MenuBegin(this NuklearContext ctx, nk_window win, string id, bool is_clicked,
                                     RectangleF header, Vector2 size)
        {
            var       is_open   = 0;
            var       is_active = 0;
            var       body      = new RectangleF();
            nk_window popup;
            var       hash = nk_murmur_hash(id, NK_PANEL_MENU);

            if (ctx == null || ctx.current == null || ctx.current.Layout == null)
            {
                return(false);
            }
            body.X      = header.X;
            body.Width  = size.X;
            body.Y      = header.Y + header.Height;
            body.Height = size.Y;
            popup       = win.Popup.Window;
            is_open     = popup != null ? nk_true : nk_false;
            is_active   =
                popup != null && win.Popup.Name == hash && win.Popup.Type == NK_PANEL_MENU ? 1 : 0;
            if (is_clicked && is_open != 0 && is_active == 0 || is_open != 0 && is_active == 0 ||
                is_open == 0 && is_active == 0 && !is_clicked)
            {
                return(false);
            }
            if (!ctx.NonBlockBegin(NK_WINDOW_NO_SCROLLBAR, body, header, NK_PANEL_MENU))
            {
                return(false);
            }
            win.Popup.Type = NK_PANEL_MENU;
            win.Popup.Name = hash;
            return(true);
        }
Пример #2
0
        public static bool ComboBegin(this NuklearContext ctx, nk_window win, Vector2 size, bool is_clicked,
                                      RectangleF header)
        {
            nk_window popup;
            var       is_open   = false;
            var       is_active = false;
            var       body      = new RectangleF();

            if (ctx == null || ctx.current == null || ctx.current.Layout == null)
            {
                return(false);
            }
            popup       = win.Popup.Window;
            body.X      = header.X;
            body.Width  = size.X;
            body.Y      = header.Y + header.Height - ctx.style.window.combo_border;
            body.Height = size.Y;
            var hash = win.Popup.ComboCount++;

            is_open   = popup != null ? true : false;
            is_active =
                popup != null && win.Popup.Name == hash && win.Popup.Type == NK_PANEL_COMBO;
            if ((is_clicked && is_open && !is_active) ||
                (is_open && !is_active) ||
                (!is_open && !is_active && !is_clicked))
            {
                return(false);
            }

            if (!ctx.NonBlockBegin(0, body,
                                   is_clicked && is_open ? new RectangleF(0, 0, 0, 0) : header,
                                   NK_PANEL_COMBO))
            {
                return(false);
            }
            win.Popup.Type = NK_PANEL_COMBO;
            win.Popup.Name = hash;
            return(true);
        }
Пример #3
0
        public static bool ContextualBegin(this NuklearContext ctx, uint flags, Vector2 size, RectangleF trigger_bounds)
        {
            nk_window win;
            nk_window popup;
            var       body       = new RectangleF();
            var       null_rect  = new RectangleF();
            var       is_clicked = false;
            var       is_active  = false;
            var       is_open    = false;
            var       ret        = false;

            if (ctx == null || ctx.current == null || ctx.current.Layout == null)
            {
                return(false);
            }
            win = ctx.current;
            ++win.Popup.ConCount;
            popup      = win.Popup.Window;
            is_open    = popup != null && win.Popup.Type == NK_PANEL_CONTEXTUAL;
            is_clicked = nk_input_mouse_clicked(ctx.input, NK_BUTTON_RIGHT, trigger_bounds);
            if (win.Popup.ActiveCon != 0 && win.Popup.ConCount != win.Popup.ActiveCon)
            {
                return(false);
            }
            if (is_clicked && is_open && !is_active ||
                !is_open && !is_active && !is_clicked)
            {
                return(false);
            }
            win.Popup.ActiveCon = win.Popup.ConCount;
            if (is_clicked)
            {
                body.X = ctx.input.mouse.pos.X;
                body.Y = ctx.input.mouse.pos.Y;
            }
            else
            {
                body.X = popup.Bounds.X;
                body.Y = popup.Bounds.Y;
            }

            body.Width  = size.X;
            body.Height = size.Y;
            ret         = ctx.NonBlockBegin(flags | NK_WINDOW_NO_SCROLLBAR, body, null_rect,
                                            NK_PANEL_CONTEXTUAL);
            if (ret)
            {
                win.Popup.Type = NK_PANEL_CONTEXTUAL;
            }
            else
            {
                win.Popup.ActiveCon = 0;
                if (win.Popup.Window != null)
                {
                    win.Popup.Window.Flags = 0;
                }
            }

            return(ret);

            ;
        }