Exemplo n.º 1
0
        public static bool MenuBeginText(this NuklearContext ctx, string title, nk_text_align align, Vector2 size)
        {
            nk_window win;
            nk_input  _in_;
            var       header     = new RectangleF();
            var       is_clicked = false;
            uint      state;

            if (ctx == null || ctx.current == null || ctx.current.Layout == null)
            {
                return(false);
            }
            win   = ctx.current;
            state = (uint)ctx.Widget(ref header);
            if (state == 0)
            {
                return(false);
            }
            _in_ = state == NK_WIDGET_ROM || (win.Flags & NK_WINDOW_ROM) != 0 ? null : ctx.input;
            if (DoButtonText(ref ctx.last_widget_state, win.Buffer, header, title, align,
                             NK_BUTTON_DEFAULT, ctx.style.menu_button, _in_, ctx.style.font))
            {
                is_clicked = true;
            }
            return(MenuBegin(ctx, win, title, is_clicked, header, size));
        }
Exemplo n.º 2
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_));
        }
Exemplo n.º 3
0
 public static void Label(string Txt, nk_text_align TextAlign = (nk_text_align)nk_text_alignment.NK_TEXT_LEFT)
 {
     unsafe
     {
         Nuklear.nk_label(_nuklearContext, Txt, (uint)TextAlign);
     }
 }
Exemplo n.º 4
0
        public static bool nk_selectable_image_text(this NuklearContext ctx, nk_image img, string str,
                                                    nk_text_align align, ref bool value)
        {
            nk_window win;
            nk_panel  layout;
            nk_input  _in_;
            nk_style  style;
            int       state;
            var       bounds = new RectangleF();

            if (ctx == null || ctx.current == null || ctx.current.Layout == null)
            {
                return(false);
            }
            win    = ctx.current;
            layout = win.Layout;
            style  = ctx.style;
            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
                (nk_do_selectable_image(ref ctx.last_widget_state, win.Buffer, bounds, str, align,
                                        ref value, img, style.selectable, _in_, style.font));
        }
Exemplo n.º 5
0
        public static bool ContextualItemSymbolText(this NuklearContext ctx, nk_symbol_type symbol, string text,
                                                    nk_text_align align)
        {
            nk_window win;
            nk_input  _in_;
            nk_style  style;
            var       bounds = new RectangleF();
            int       state;

            if (ctx == null || ctx.current == null || ctx.current.Layout == null)
            {
                return(false);
            }
            win   = ctx.current;
            style = ctx.style;
            state = ctx.WidgetFitting(ref bounds, style.contextual_button.padding);
            if (state == 0)
            {
                return(false);
            }
            _in_ = state == NK_WIDGET_ROM || (win.Layout.Flags & NK_WINDOW_ROM) != 0 ? null : ctx.input;
            if (
                DoButtonTextSymbol(ref ctx.last_widget_state, win.Buffer, bounds, symbol, text,
                                   align, NK_BUTTON_DEFAULT, style.contextual_button, style.font, _in_))
            {
                ctx.ContextualClose();
                return(true);
            }

            return(false);
        }
Exemplo n.º 6
0
 public static extern int nk_button_symbol_text(
     nk_context *ctx,
     nk_symbol_type stype,
     string text,
     int length,
     nk_text_align alignment_nkflags
     );
Exemplo n.º 7
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);
        }
Exemplo n.º 8
0
        public static bool nk_do_selectable(ref uint state, CommandBuffer _out_, RectangleF bounds, string str,
                                            nk_text_align align, ref bool value, nk_style_selectable style, nk_input _in_, nk_font font)
        {
            bool old_value;
            var  touch = new RectangleF();

            if (_out_ == null || str == null || style == null ||
                font == null)
            {
                return(false);
            }
            old_value    = value;
            touch.X      = bounds.X - style.touch_padding.X;
            touch.Y      = bounds.Y - style.touch_padding.Y;
            touch.Width  = bounds.Width + style.touch_padding.X * 2;
            touch.Height = bounds.Height + style.touch_padding.Y * 2;
            if (ButtonBehavior(ref state, touch, _in_, NK_BUTTON_DEFAULT))
            {
                value = !value;
            }
            if (style.draw_begin != null)
            {
                style.draw_begin(_out_);
            }
            _out_.DrawSelectable(state, style, value, &bounds, null, null, str, align,
                                 font);
            if (style.draw_end != null)
            {
                style.draw_end(_out_);
            }
            return(old_value != value);
        }
Exemplo n.º 9
0
 public static bool nk_select_image_label(this NuklearContext ctx, nk_image img, string str,
                                          nk_text_align align,
                                          bool value)
 {
     nk_selectable_image_text(ctx, img, str, align, ref value);
     return(value);
 }
Exemplo n.º 10
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));
 }
Exemplo n.º 11
0
 public static void LabelColored(string text, nk_color color,
     nk_text_align alignment = (nk_text_align)nk_text_alignment.NK_TEXT_LEFT)
 {
     unsafe
     {
         Nuklear.nk_label_colored(_nuklearContext, text, alignment, color);
     }
 }
Exemplo n.º 12
0
		public static void WidgetText(this CommandBuffer o, RectangleF b, StringSegment _string_, nk_text* t,
			nk_text_align a, nk_font f)
		{
			var label = new RectangleF();
			float text_width;
			if (o == null || t == null)
				return;
			b.Height = b.Height < 2 * t->padding.Y ? 2 * t->padding.Y : b.Height;
			label.X = 0;
			label.Width = 0;
			label.Y = b.Y + t->padding.Y;
			label.Height = f.Size < b.Height - 2 * t->padding.Y ? f.Size : b.Height - 2 * t->padding.Y;
			text_width = f.width(_string_);
			text_width += 2.0f * t->padding.X;
			if ((a & nk_text_align.NK_TEXT_ALIGN_LEFT) != 0)
			{
				label.X = b.X + t->padding.X;
				label.Width = 0 < b.Width - 2 * t->padding.X ? b.Width - 2 * t->padding.X : 0;
			}
			else if ((a & nk_text_align.NK_TEXT_ALIGN_CENTERED) != 0)
			{
				label.Width = 1 < 2 * t->padding.X + text_width ? 2 * t->padding.X + text_width : 1;
				label.X = b.X + t->padding.X + (b.Width - 2 * t->padding.X - label.Width) / 2;
				label.X = b.X + t->padding.X < label.X ? label.X : b.X + t->padding.X;
				label.Width = b.X + b.Width < label.X + label.Width ? b.X + b.Width : label.X + label.Width;
				if (label.Width >= label.X)
					label.Width -= label.X;
			}
			else if ((a & nk_text_align.NK_TEXT_ALIGN_RIGHT) != 0)
			{
				label.X =
					b.X + t->padding.X < b.X + b.Width - (2 * t->padding.X + text_width)
						? b.X + b.Width - (2 * t->padding.X + text_width)
						: b.X + t->padding.X;
				label.Width = text_width + 2 * t->padding.X;
			}
			else
			{
				return;
			}

			if ((a & nk_text_align.NK_TEXT_ALIGN_MIDDLE) != 0)
			{
				label.Y = b.Y + b.Height / 2.0f - f.Size / 2.0f;
				label.Height =
					b.Height / 2.0f < b.Height - (b.Height / 2.0f + f.Size / 2.0f)
						? b.Height - (b.Height / 2.0f + f.Size / 2.0f)
						: b.Height / 2.0f;
			}
			else if ((a & nk_text_align.NK_TEXT_ALIGN_BOTTOM) != 0)
			{
				label.Y = b.Y + b.Height - f.Size;
				label.Height = f.Size;
			}

			o.DrawText(label, _string_, f, t->Background,
				t->text);
		}
Exemplo n.º 13
0
 public static bool ButtonSymbolText(this NuklearContext ctx, nk_symbol_type symbol, string text,
                                     nk_text_align align)
 {
     if (ctx == null)
     {
         return(false);
     }
     return(ButtonSymbolTextStyled(ctx, ctx.style.button, symbol, text, align));
 }
Exemplo n.º 14
0
        public static bool nk_do_selectable_image(ref uint state, CommandBuffer _out_, RectangleF bounds,
                                                  string str,
                                                  nk_text_align align, ref bool value, nk_image img, nk_style_selectable style, nk_input _in_,
                                                  nk_font font)
        {
            bool old_value;
            var  touch = new RectangleF();
            var  icon  = new RectangleF();

            if (_out_ == null || str == null || style == null ||
                font == null)
            {
                return(false);
            }
            old_value    = value;
            touch.X      = bounds.X - style.touch_padding.X;
            touch.Y      = bounds.Y - style.touch_padding.Y;
            touch.Width  = bounds.Width + style.touch_padding.X * 2;
            touch.Height = bounds.Height + style.touch_padding.Y * 2;
            if (ButtonBehavior(ref state, touch, _in_, NK_BUTTON_DEFAULT))
            {
                value = !value;
            }
            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_.DrawSelectable(state, style, value, &bounds, &icon, img, str, align,
                                 font);
            if (style.draw_end != null)
            {
                style.draw_end(_out_);
            }
            return(old_value != value);
        }
Exemplo n.º 15
0
		public static void nk_text_colored(this NuklearContext ctx, StringSegment str, nk_text_align alignment,
			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.WidgetText(bounds, str, &text, alignment, style.font);
		}
Exemplo n.º 16
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);
        }
Exemplo n.º 17
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);
        }
Exemplo n.º 18
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);
        }
Exemplo n.º 19
0
 public static bool ContextualItemSymbolLabel(this NuklearContext ctx, nk_symbol_type symbol, string text,
                                              nk_text_align align)
 {
     return(ctx.ContextualItemSymbolText(symbol, text, align));
 }
Exemplo n.º 20
0
 public static bool ContextualItemImageLabel(this NuklearContext ctx, nk_image img, string label,
                                             nk_text_align align)
 {
     return(ctx.ContextualItemImageText(img, label, align));
 }
Exemplo n.º 21
0
 public static extern void nk_label_colored(
     nk_context *ctx,
     string s,
     nk_text_align align_nkflags,
     nk_color color
     );
Exemplo n.º 22
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));
 }
Exemplo n.º 23
0
		public static void nk_text_(this NuklearContext ctx, StringSegment str, nk_text_align alignment)
		{
			if (ctx == null) return;
			nk_text_colored(ctx, str, alignment, ctx.style.text.Color);
		}
Exemplo n.º 24
0
 public static bool ComboItemLabel(this NuklearContext ctx, string label, nk_text_align align)
 {
     return(ctx.ContextualItemLabel(label, align));
 }
Exemplo n.º 25
0
 public static bool ComboItemText(this NuklearContext ctx, StringSegment text, nk_text_align align)
 {
     return(ctx.ContextualItemText(text, align));
 }
Exemplo n.º 26
0
 public static bool nk_combo_item_symbol_text(this NuklearContext ctx, nk_symbol_type sym, string text,
                                              nk_text_align alignment)
 {
     return(ctx.ContextualItemSymbolText(sym, text, alignment));
 }
Exemplo n.º 27
0
 public static bool ComboItemImageLabel(this NuklearContext ctx, nk_image img, string text,
                                        nk_text_align alignment)
 {
     return(ctx.ContextualItemImageLabel(img, text, alignment));
 }
Exemplo n.º 28
0
 public static bool ButtonImageText(this NuklearContext ctx, nk_image img, string text,
                                    nk_text_align align)
 {
     return
         (ButtonImageTextStyled(ctx, ctx.style.button, img, text, align));
 }
Exemplo n.º 29
0
 public static bool nk_combo_item_symbol_label(this NuklearContext ctx, nk_symbol_type sym, string label,
                                               nk_text_align alignment)
 {
     return(ctx.ContextualItemSymbolLabel(sym, label, alignment));
 }
Exemplo n.º 30
0
 public static bool ButtonImageLabel(this NuklearContext ctx, nk_image img, string label, nk_text_align align)
 {
     return(ButtonImageText(ctx, img, label, align));
 }