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); }
public static extern int nk_combo_begin_symbol_text( nk_context *ctx, char *selected, int i, nk_symbol_type stype, nk_vec2 size );
public static bool MenuBeginSymbolText(this NuklearContext ctx, string title, nk_text_align align, nk_symbol_type sym, Vector2 size) { nk_window win; var header = new RectangleF(); nk_input _in_; 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.Layout.Flags & NK_WINDOW_ROM) != 0 ? null : ctx.input; if ( DoButtonTextSymbol(ref ctx.last_widget_state, win.Buffer, header, sym, title, align, NK_BUTTON_DEFAULT, ctx.style.menu_button, ctx.style.font, _in_)) { is_clicked = true; } return(MenuBegin(ctx, win, title, is_clicked, header, size)); }
public static extern int nk_button_symbol_label_styled( nk_context *ctx, nk_style_button *bstyle, nk_symbol_type stype, byte *title, uint align_nkflags );
public static extern int nk_contextual_item_symbol_text( nk_context *ctx, nk_symbol_type stype, byte *s, int i, uint alignment_nkflags );
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)); }
public static extern int nk_menu_begin_symbol_label( nk_context *ctx, byte *s, uint align_nkflags, nk_symbol_type stype, nk_vec2 size );
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); }
public static bool ButtonSymbolTextStyled(this NuklearContext ctx, nk_style_button style, nk_symbol_type symbol, 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 (DoButtonTextSymbol(ref ctx.last_widget_state, win.Buffer, bounds, symbol, text, align, ctx.button_behavior, style, ctx.style.font, _in_)); }
public static extern int nk_button_symbol_text( nk_context *ctx, nk_symbol_type stype, string text, int length, nk_text_align alignment_nkflags );
public static extern int nk_button_symbol_text_styled( nk_context *ctx, nk_style_button *bstyle, nk_symbol_type stype, byte *s, int i, uint alignment_nkflags );
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)); }
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); }
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); }
public static bool ComboBeginSymbolLabel(this NuklearContext ctx, string selected, nk_symbol_type type, Vector2 size) { return(ComboBeginSymbolText(ctx, selected, type, size)); }
public static bool ComboBeginSymbolText(this NuklearContext ctx, string selected, nk_symbol_type symbol, Vector2 size) { nk_window win; nk_style style; nk_input _in_; var header = new RectangleF(); var is_clicked = false; int s; nk_style_item background; var symbol_color = new Color(); var text = new nk_text(); if (ctx == null || ctx.current == null || ctx.current.Layout == null) { return(false); } win = ctx.current; style = ctx.style; s = ctx.Widget(ref header); if (s == 0) { return(false); } _in_ = (win.Layout.Flags & NK_WINDOW_ROM) != 0 || s == NK_WIDGET_ROM ? null : ctx.input; if (ButtonBehavior(ref ctx.last_widget_state, header, _in_, NK_BUTTON_DEFAULT)) { is_clicked = true; } if ((ctx.last_widget_state & NK_WIDGET_STATE_ACTIVED) != 0) { background = style.combo.active; symbol_color = style.combo.symbol_active; text.text = style.combo.label_active; } else if ((ctx.last_widget_state & NK_WIDGET_STATE_HOVER) != 0) { background = style.combo.hover; symbol_color = style.combo.symbol_hover; text.text = style.combo.label_hover; } else { background = style.combo.normal; symbol_color = style.combo.symbol_normal; text.text = style.combo.label_normal; } if (background.type == NK_STYLE_ITEM_IMAGE) { text.Background = Color.Transparent; win.Buffer.DrawImage(header, background.Image, nk_white); } else { text.Background = background.Color; win.Buffer.FillRect(header, style.combo.Rounding, background.Color); win.Buffer.StrokeRect(header, style.combo.Rounding, style.combo.border, style.combo.border_color); } { var content = new RectangleF(); var button = new RectangleF(); var label = new RectangleF(); var image = new RectangleF(); nk_symbol_type sym; if ((ctx.last_widget_state & NK_WIDGET_STATE_HOVER) != 0) { sym = style.combo.sym_hover; } else if (is_clicked) { sym = style.combo.sym_active; } else { sym = style.combo.sym_normal; } button.Width = header.Height - 2 * style.combo.button_padding.Y; button.X = header.X + header.Width - header.Height - style.combo.button_padding.X; button.Y = header.Y + style.combo.button_padding.Y; button.Height = button.Width; content.X = button.X + style.combo.button.padding.X; content.Y = button.Y + style.combo.button.padding.Y; content.Width = button.Width - 2 * style.combo.button.padding.X; content.Height = button.Height - 2 * style.combo.button.padding.Y; win.Buffer.DrawButtonSymbol(&button, &content, ctx.last_widget_state, ctx.style.combo.button, sym, style.font); image.X = header.X + style.combo.content_padding.X; image.Y = header.Y + style.combo.content_padding.Y; image.Height = header.Height - 2 * style.combo.content_padding.Y; image.Width = image.Height; win.Buffer.DrawSymbol(symbol, image, text.Background, symbol_color, 1.0f, style.font); text.padding = new Vector2(0, 0); label.X = image.X + image.Width + style.combo.spacing.X + style.combo.content_padding.X; label.Y = header.Y + style.combo.content_padding.Y; label.Width = button.X - style.combo.content_padding.X - label.X; label.Height = header.Height - 2 * style.combo.content_padding.Y; win.Buffer.WidgetText(label, selected, &text, nk_text_align.NK_TEXT_LEFT, style.font); } return(ComboBegin(ctx, win, size, is_clicked, header)); }
public static bool ContextualItemSymbolLabel(this NuklearContext ctx, nk_symbol_type symbol, string text, nk_text_align align) { return(ctx.ContextualItemSymbolText(symbol, text, align)); }
public static bool ButtonSymbolLabel(this NuklearContext ctx, nk_symbol_type symbol, string label, nk_text_align align) { return(ButtonSymbolText(ctx, symbol, label, align)); }
public static void DrawSymbol(this CommandBuffer _out_, nk_symbol_type type, RectangleF content, Color background, Color foreground, float border_width, nk_font font) { switch (type) { case nk_symbol_type.NK_SYMBOL_X: case nk_symbol_type.NK_SYMBOL_UNDERSCORE: case nk_symbol_type.NK_SYMBOL_PLUS: case nk_symbol_type.NK_SYMBOL_MINUS: { var X = type == nk_symbol_type.NK_SYMBOL_X ? "x" : type == nk_symbol_type.NK_SYMBOL_UNDERSCORE ? "_" : type == nk_symbol_type.NK_SYMBOL_PLUS ? "+" : "-"; var text = new nk_text(); text.padding = new Vector2(0, 0); text.Background = background; text.text = foreground; _out_.WidgetText(content, X, &text, nk_text_align.NK_TEXT_CENTERED, font); } break; case nk_symbol_type.NK_SYMBOL_CIRCLE_SOLID: case nk_symbol_type.NK_SYMBOL_CIRCLE_OUTLINE: case nk_symbol_type.NK_SYMBOL_RECT_SOLID: case nk_symbol_type.NK_SYMBOL_RECT_OUTLINE: { if (type == nk_symbol_type.NK_SYMBOL_RECT_SOLID || type == nk_symbol_type.NK_SYMBOL_RECT_OUTLINE) { _out_.FillRect(content, 0, foreground); if (type == nk_symbol_type.NK_SYMBOL_RECT_OUTLINE) { _out_.FillRect(RectangleF.nk_shrink_rect_(content, border_width), 0, background); } } else { _out_.nk_fill_circle(content, foreground); if (type == nk_symbol_type.NK_SYMBOL_CIRCLE_OUTLINE) { _out_.nk_fill_circle(RectangleF.nk_shrink_rect_(content, 1), background); } } } break; case nk_symbol_type.NK_SYMBOL_TRIANGLE_UP: case nk_symbol_type.NK_SYMBOL_TRIANGLE_DOWN: case nk_symbol_type.NK_SYMBOL_TRIANGLE_LEFT: case nk_symbol_type.NK_SYMBOL_TRIANGLE_RIGHT: { int heading; var points = stackalloc Vector2[3]; heading = type == nk_symbol_type.NK_SYMBOL_TRIANGLE_RIGHT ? NK_RIGHT : type == nk_symbol_type.NK_SYMBOL_TRIANGLE_LEFT ? NK_LEFT : type == nk_symbol_type.NK_SYMBOL_TRIANGLE_UP ? NK_UP : NK_DOWN; RectangleF.nk_triangle_from_direction(points, content, 0, 0, heading); _out_.FillTriangle(points[0].X, points[0].Y, points[1].X, points[1].Y, points[2].X, points[2].Y, foreground); } break; default: case nk_symbol_type.NK_SYMBOL_NONE: case nk_symbol_type.NK_SYMBOL_MAX: break; } }
public static bool ButtonSymbol(this NuklearContext ctx, nk_symbol_type symbol) { return(ButtonSymbolStyled(ctx, ctx.style.button, symbol)); }
public static extern int nk_button_symbol(nk_context *ctx, nk_symbol_type symtype);
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)); }
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)); }
public static extern int nk_button_symbol_styled(nk_context *ctx, nk_style_button *bstyle, nk_symbol_type stype);
public static extern int nk_button_symbol_label(nk_context *ctx, nk_symbol_type stype, byte *s, uint text_alignment_nkflags);
public static extern int nk_menu_begin_symbol(nk_context *ctx, byte *s, nk_symbol_type stype, nk_vec2 size);
public static extern int nk_combo_begin_symbol(nk_context *ctx, nk_symbol_type stype, nk_vec2 size);
public static bool MenuItemSymbolLabel(this NuklearContext ctx, nk_symbol_type sym, string label, nk_text_align align) { return(ctx.ContextualItemSymbolLabel(sym, label, align)); }
public static extern int nk_menu_item_symbol_label(nk_context *ctx, nk_symbol_type stype, byte *s, uint alignment_nkflags);
public static void DrawButtonTextSymbol(this CommandBuffer _out_, RectangleF *bounds, RectangleF *label, RectangleF *symbol, uint state, nk_style_button style, string str, nk_symbol_type type, nk_font font) { var sym = new Color(); 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) { sym = style.text_hover; text.text = style.text_hover; } else if ((state & NK_WIDGET_STATE_ACTIVED) != 0) { sym = style.text_active; text.text = style.text_active; } else { sym = style.text_normal; text.text = style.text_normal; } text.padding = new Vector2(0, 0); _out_.DrawSymbol(type, *symbol, style.text_background, sym, 0, font); _out_.WidgetText(*label, str, &text, nk_text_align.NK_TEXT_CENTERED, font); }