Ejemplo n.º 1
0
        public static nk_style_item DrawButton(this CommandBuffer _out_, RectangleF *bounds, uint state,
                                               nk_style_button style)
        {
            nk_style_item background;

            if ((state & NK_WIDGET_STATE_HOVER) != 0)
            {
                background = style.hover;
            }
            else if ((state & NK_WIDGET_STATE_ACTIVED) != 0)
            {
                background = style.active;
            }
            else
            {
                background = style.normal;
            }
            if (background.type == NK_STYLE_ITEM_IMAGE)
            {
                _out_.DrawImage(*bounds, background.Image, nk_white);
            }
            else
            {
                _out_.FillRect(*bounds, style.Rounding, background.Color);
                _out_.StrokeRect(*bounds, style.Rounding, style.border,
                                 style.border_color);
            }

            return(background);
        }
Ejemplo n.º 2
0
 public bool ButtonTextStyled(nk_style_button style, string title)
 {
     fixed(char *title_ptr = title)
     {
         return(Nk.nk_button_text_styled(_ctx, style, title_ptr, title.Length) != 0);
     }
 }
Ejemplo n.º 3
0
 public bool ButtonSymbolLabelStyled(nk_style_button style, NkSymbolType symbol, string title, Alignment align)
 {
     fixed(char *title_ptr = title)
     {
         return(Nk.nk_button_symbol_label_styled(_ctx, style, symbol, title_ptr, align) != 0);
     }
 }
Ejemplo n.º 4
0
 public bool ButtonImageTextStyled(nk_style_button style, NkImage img, string text, Alignment align)
 {
     fixed(char *text_ptr = text)
     {
         return(Nk.nk_button_image_text_styled(_ctx, style, img, text_ptr, text.Length, align) != 0);
     }
 }
Ejemplo n.º 5
0
 public bool ButtonSymbolTextStyled(nk_style_button style, NkSymbolType symbol, string text, Alignment align)
 {
     fixed(char *text_ptr = text)
     {
         return(Nk.nk_button_symbol_text_styled(_ctx, style, symbol, text_ptr, text.Length, align) != 0);
     }
 }
Ejemplo n.º 6
0
 public bool ButtonLabelStyled(nk_style_button style, string title)
 {
     fixed(char *title_ptr = title)
     {
         return(Nk.nk_button_label_styled(_ctx, style, title_ptr) != 0);
     }
 }
Ejemplo n.º 7
0
        public static bool ButtonImageTextStyled(this NuklearContext ctx, nk_style_button style, nk_image img,
                                                 string text,
                                                 nk_text_align align)
        {
            nk_window win;
            nk_panel  layout;
            nk_input  _in_;
            var       bounds = new RectangleF();
            int       state;

            if (ctx == null || ctx.current == null || ctx.current.Layout == null)
            {
                return(false);
            }
            win    = ctx.current;
            layout = win.Layout;
            state  = ctx.Widget(ref bounds);
            if (state == 0)
            {
                return(false);
            }
            _in_ = state == NK_WIDGET_ROM || (layout.Flags & NK_WINDOW_ROM) != 0 ? null : ctx.input;
            return(DoButtonTextImage(ref ctx.last_widget_state, win.Buffer, bounds, img, text,
                                     align, ctx.button_behavior, style, ctx.style.font, _in_));
        }
Ejemplo n.º 8
0
        public static void DrawButtonTextImage(this CommandBuffer _out_, RectangleF *bounds, RectangleF *label,
                                               RectangleF *image, uint state, nk_style_button style, string str, nk_font font, nk_image img)
        {
            var           text = new nk_text();
            nk_style_item background;

            background = DrawButton(_out_, bounds, state, style);
            if (background.type == NK_STYLE_ITEM_COLOR)
            {
                text.Background = background.Color;
            }
            else
            {
                text.Background = style.text_background;
            }
            if ((state & NK_WIDGET_STATE_HOVER) != 0)
            {
                text.text = style.text_hover;
            }
            else if ((state & NK_WIDGET_STATE_ACTIVED) != 0)
            {
                text.text = style.text_active;
            }
            else
            {
                text.text = style.text_normal;
            }
            text.padding = new Vector2(0, 0);
            _out_.WidgetText(*label, str, &text, nk_text_align.NK_TEXT_CENTERED, font);
            _out_.DrawImage(*image, img, nk_white);
        }
Ejemplo n.º 9
0
 public static bool ButtonSymbolLabelStyled(this NuklearContext ctx, nk_style_button style,
                                            nk_symbol_type symbol, string title,
                                            nk_text_align align)
 {
     return
         (ButtonSymbolTextStyled(ctx, style, symbol, title, align));
 }
Ejemplo n.º 10
0
        public static bool ButtonColor(this NuklearContext ctx, Color color)
        {
            nk_window win;
            nk_panel  layout;
            nk_input  _in_;
            var       button  = new nk_style_button();
            var       ret     = false;
            var       bounds  = new RectangleF();
            var       content = new RectangleF();
            int       state;

            if (ctx == null || ctx.current == null || ctx.current.Layout == null)
            {
                return(false);
            }
            win    = ctx.current;
            layout = win.Layout;
            state  = ctx.Widget(ref bounds);
            if (state == 0)
            {
                return(false);
            }
            _in_          = state == NK_WIDGET_ROM || (layout.Flags & NK_WINDOW_ROM) != 0 ? null : ctx.input;
            button        = ctx.style.button;
            button.normal = new nk_style_item(color);
            button.hover  = new nk_style_item(color);
            button.active = new nk_style_item(color);
            ret           =
                DoButton(ref ctx.last_widget_state, win.Buffer, bounds, button, _in_, ctx.button_behavior,
                         &content);
            win.Buffer.DrawButton(&bounds, ctx.last_widget_state, button);
            return(ret);
        }
Ejemplo n.º 11
0
        public static bool DoButtonImage(ref uint state, CommandBuffer _out_, RectangleF bounds, nk_image img,
                                         int b,
                                         nk_style_button style, nk_input _in_)
        {
            bool ret;
            var  content = new RectangleF();

            if (_out_ == null || style == null)
            {
                return(false);
            }
            ret             = DoButton(ref state, _out_, bounds, style, _in_, b, &content);
            content.X      += style.image_padding.X;
            content.Y      += style.image_padding.Y;
            content.Width  -= 2 * style.image_padding.X;
            content.Height -= 2 * style.image_padding.Y;
            if (style.draw_begin != null)
            {
                style.draw_begin(_out_);
            }
            _out_.DrawButtonImage(&bounds, &content, state, style, img);
            if (style.draw_end != null)
            {
                style.draw_end(_out_);
            }
            return(ret);
        }
Ejemplo n.º 12
0
 public static void DrawButtonImage(this CommandBuffer _out_, RectangleF *bounds, RectangleF *content,
                                    uint state,
                                    nk_style_button style, nk_image img)
 {
     DrawButton(_out_, bounds, state, style);
     _out_.DrawImage(*content, img, nk_white);
 }
Ejemplo n.º 13
0
        public static void DrawButtonSymbol(this CommandBuffer _out_, RectangleF *bounds, RectangleF *content,
                                            uint state,
                                            nk_style_button style, nk_symbol_type type, nk_font font)
        {
            var           sym = new Color();
            var           bg  = new Color();
            nk_style_item background;

            background = DrawButton(_out_, bounds, state, style);
            if (background.type == NK_STYLE_ITEM_COLOR)
            {
                bg = background.Color;
            }
            else
            {
                bg = style.text_background;
            }
            if ((state & NK_WIDGET_STATE_HOVER) != 0)
            {
                sym = style.text_hover;
            }
            else if ((state & NK_WIDGET_STATE_ACTIVED) != 0)
            {
                sym = style.text_active;
            }
            else
            {
                sym = style.text_normal;
            }
            _out_.DrawSymbol(type, *content, bg, sym, 1,
                             font);
        }
Ejemplo n.º 14
0
        public static void DrawButtonText(this CommandBuffer _out_, RectangleF *bounds, RectangleF *content, uint state,
                                          nk_style_button style, StringSegment txt, nk_text_align text_alignment, nk_font font)
        {
            var           text = new nk_text();
            nk_style_item background;

            background = DrawButton(_out_, bounds, state, style);
            if (background.type == NK_STYLE_ITEM_COLOR)
            {
                text.Background = background.Color;
            }
            else
            {
                text.Background = style.text_background;
            }
            if ((state & NK_WIDGET_STATE_HOVER) != 0)
            {
                text.text = style.text_hover;
            }
            else if ((state & NK_WIDGET_STATE_ACTIVED) != 0)
            {
                text.text = style.text_active;
            }
            else
            {
                text.text = style.text_normal;
            }
            text.padding = new Vector2(0, 0);
            _out_.WidgetText(*content, txt, &text, text_alignment, font);
        }
Ejemplo n.º 15
0
 public bool ButtonImageLabelStyled(nk_style_button style, NkImage img, string label,
                                    Alignment text_alignment)
 {
     fixed(char *label_ptr = label)
     {
         return(Nk.nk_button_image_label_styled(_ctx, style, img, label_ptr, text_alignment) != 0);
     }
 }
Ejemplo n.º 16
0
        public static bool DoButtonText(ref uint state, CommandBuffer _out_, RectangleF bounds, StringSegment _string_,
                                        nk_text_align align, int behavior, nk_style_button style, nk_input _in_, nk_font font)
        {
            var content = new RectangleF();
            var ret     = false;

            if (_out_ == null || style == null || font == null || _string_ == null)
            {
                return(false);
            }
            ret = DoButton(ref state, _out_, bounds, style, _in_, behavior, &content);
            if (style.draw_begin != null)
            {
                style.draw_begin(_out_);
            }
            _out_.DrawButtonText(&bounds, &content, state, style, _string_, align, font);
            if (style.draw_end != null)
            {
                style.draw_end(_out_);
            }
            return(ret);
        }
Ejemplo n.º 17
0
        public static bool DoButtonSymbol(ref uint state, CommandBuffer _out_, RectangleF bounds,
                                          nk_symbol_type symbol,
                                          int behavior, nk_style_button style, nk_input _in_, nk_font font)
        {
            bool ret;
            var  content = new RectangleF();

            if (_out_ == null || style == null || font == null)
            {
                return(false);
            }
            ret = DoButton(ref state, _out_, bounds, style, _in_, behavior, &content);
            if (style.draw_begin != null)
            {
                style.draw_begin(_out_);
            }
            _out_.DrawButtonSymbol(&bounds, &content, state, style, symbol, font);
            if (style.draw_end != null)
            {
                style.draw_end(_out_);
            }
            return(ret);
        }
Ejemplo n.º 18
0
        public static bool ButtonSymbolStyled(this NuklearContext ctx, nk_style_button style, nk_symbol_type symbol)
        {
            nk_window win;
            nk_panel  layout;
            nk_input  _in_;
            var       bounds = new RectangleF();
            int       state;

            if (ctx == null || ctx.current == null || ctx.current.Layout == null)
            {
                return(false);
            }
            win    = ctx.current;
            layout = win.Layout;
            state  = ctx.Widget(ref bounds);
            if (state == 0)
            {
                return(false);
            }
            _in_ = state == NK_WIDGET_ROM || (layout.Flags & NK_WINDOW_ROM) != 0 ? null : ctx.input;
            return
                (DoButtonSymbol(ref ctx.last_widget_state, win.Buffer, bounds, symbol,
                                ctx.button_behavior, style, _in_, ctx.style.font));
        }
Ejemplo n.º 19
0
 public static bool ButtonLabelStyled(this NuklearContext ctx, nk_style_button style, string title)
 {
     return(ButtonTextStyled(ctx, style, title));
 }
Ejemplo n.º 20
0
        public static bool DoButtonTextImage(ref uint state, CommandBuffer _out_, RectangleF bounds, nk_image img,
                                             string str, nk_text_align align, int behavior, nk_style_button style, nk_font font,
                                             nk_input _in_)
        {
            bool ret;
            var  icon    = new RectangleF();
            var  content = new RectangleF();

            if (_out_ == null || font == null || style == null || str == null)
            {
                return(false);
            }
            ret        = DoButton(ref state, _out_, bounds, style, _in_, behavior, &content);
            icon.Y     = bounds.Y + style.padding.Y;
            icon.Width = icon.Height = bounds.Height - 2 * style.padding.Y;
            if ((align & nk_text_align.NK_TEXT_ALIGN_LEFT) != 0)
            {
                icon.X = bounds.X + bounds.Width - (2 * style.padding.X + icon.Width);
                icon.X = icon.X < 0 ? 0 : icon.X;
            }
            else
            {
                icon.X = bounds.X + 2 * style.padding.X;
            }

            icon.X      += style.image_padding.X;
            icon.Y      += style.image_padding.Y;
            icon.Width  -= 2 * style.image_padding.X;
            icon.Height -= 2 * style.image_padding.Y;
            if (style.draw_begin != null)
            {
                style.draw_begin(_out_);
            }
            _out_.DrawButtonTextImage(&bounds, &content, &icon, state, style, str, font, img);
            if (style.draw_end != null)
            {
                style.draw_end(_out_);
            }
            return(ret);
        }
Ejemplo n.º 21
0
        public static bool DoButtonTextSymbol(ref uint state, CommandBuffer _out_, RectangleF bounds,
                                              nk_symbol_type symbol,
                                              string str, nk_text_align align, int behavior, nk_style_button style, nk_font font,
                                              nk_input _in_)
        {
            bool ret;
            var  tri     = new RectangleF();
            var  content = new RectangleF();

            if (_out_ == null || style == null || font == null)
            {
                return(false);
            }
            ret        = DoButton(ref state, _out_, bounds, style, _in_, behavior, &content);
            tri.Y      = content.Y + content.Height / 2 - font.Size / 2;
            tri.Width  = font.Size;
            tri.Height = font.Size;
            if ((align & nk_text_align.NK_TEXT_ALIGN_LEFT) != 0)
            {
                tri.X = content.X + content.Width - (2 * style.padding.X + tri.Width);
                tri.X = tri.X < 0 ? 0 : tri.X;
            }
            else
            {
                tri.X = content.X + 2 * style.padding.X;
            }

            if (style.draw_begin != null)
            {
                style.draw_begin(_out_);
            }
            _out_.DrawButtonTextSymbol(&bounds, &content, &tri, state, style, str, symbol,
                                       font);
            if (style.draw_end != null)
            {
                style.draw_end(_out_);
            }
            return(ret);
        }
Ejemplo n.º 22
0
 public bool ButtonImageStyled(nk_style_button style, NkImage img)
 {
     return(Nk.nk_button_image_styled(_ctx, style, img) != 0);
 }
Ejemplo n.º 23
0
 public static bool ButtonImageLabelStyled(this NuklearContext ctx, nk_style_button style, nk_image img,
                                           string label, nk_text_align text_alignment)
 {
     return(ButtonImageTextStyled(ctx, style, img, label, text_alignment));
 }
Ejemplo n.º 24
0
        public static bool DoButton(ref uint state, CommandBuffer _out_, RectangleF r, nk_style_button style,
                                    nk_input _in_, int behavior, RectangleF *content)
        {
            var bounds = new RectangleF();

            if (_out_ == null || style == null)
            {
                return(false);
            }
            content->X      = r.X + style.padding.X + style.border + style.Rounding;
            content->Y      = r.Y + style.padding.Y + style.border + style.Rounding;
            content->Width  = r.Width - (2 * style.padding.X + style.border + style.Rounding * 2);
            content->Height = r.Height - (2 * style.padding.Y + style.border + style.Rounding * 2);
            bounds.X        = r.X - style.touch_padding.X;
            bounds.Y        = r.Y - style.touch_padding.Y;
            bounds.Width    = r.Width + 2 * style.touch_padding.X;
            bounds.Height   = r.Height + 2 * style.touch_padding.Y;
            return(ButtonBehavior(ref state, bounds, _in_, behavior));
        }
Ejemplo n.º 25
0
 public bool ButtonSymbolStyled(nk_style_button style, NkSymbolType symbol)
 {
     return(Nk.nk_button_symbol_styled(_ctx, style, symbol) != 0);
 }