Ejemplo n.º 1
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.º 2
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.º 3
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.º 4
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.º 5
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);
        }