public static nk_style_item nk_style_item_color(nk_color col) { nk_style_item i = new nk_style_item(); i.type = (int)(NK_STYLE_ITEM_COLOR); i.data.color = (nk_color)(col); return((nk_style_item)(i)); }
public static nk_style_item nk_style_item_image(nk_image img) { nk_style_item i = new nk_style_item(); i.type = (int)(NK_STYLE_ITEM_IMAGE); i.data.image = (nk_image)(img); return((nk_style_item)(i)); }
public static nk_style_item nk_style_item_hide() { nk_style_item i = new nk_style_item(); i.type = (int)(NK_STYLE_ITEM_COLOR); i.Color = (Color)(new Color((int)(0), (int)(0), (int)(0), (int)(0))); return((nk_style_item)(i)); }
public static bool nk_panel_begin(this NuklearContext ctx, string title, int panel_type) { nk_input _in_; nk_window win; nk_panel layout; CommandBuffer _out_; nk_style style; nk_font font; var scrollbar_size = new Vector2(); var panel_padding = new Vector2(); if (ctx == null || ctx.current == null || ctx.current.Layout == null) { return(false); } if ((ctx.current.Flags & NK_WINDOW_HIDDEN) != 0 || (ctx.current.Flags & NK_WINDOW_CLOSED) != 0) { ctx.current.Layout.Type = panel_type; return(false); } style = ctx.style; font = style.font; win = ctx.current; layout = win.Layout; _out_ = win.Buffer; _in_ = (win.Flags & NK_WINDOW_NO_INPUT) != 0 ? null : ctx.input; scrollbar_size = style.window.scrollbar_size; panel_padding = nk_panel_get_padding(style, panel_type); if ((win.Flags & NK_WINDOW_MOVABLE) != 0 && (win.Flags & NK_WINDOW_ROM) == 0) { bool left_mouse_down; bool left_mouse_click_in_cursor; var header = new RectangleF(); header.X = win.Bounds.X; header.Y = win.Bounds.Y; header.Width = win.Bounds.Width; if (nk_panel_has_header(win.Flags, title) != 0) { header.Height = font.Size + 2.0f * style.window.header.padding.Y; header.Height += 2.0f * style.window.header.label_padding.Y; } else { header.Height = panel_padding.Y; } left_mouse_down = _in_.mouse.buttons[NK_BUTTON_LEFT].down; left_mouse_click_in_cursor = nk_input_has_mouse_click_down_in_rect(_in_, NK_BUTTON_LEFT, header, true); if (left_mouse_down && left_mouse_click_in_cursor) { win.Bounds.X = win.Bounds.X + _in_.mouse.delta.X; win.Bounds.Y = win.Bounds.Y + _in_.mouse.delta.Y; _in_.mouse.buttons[NK_BUTTON_LEFT].clicked_pos.X += _in_.mouse.delta.X; _in_.mouse.buttons[NK_BUTTON_LEFT].clicked_pos.Y += _in_.mouse.delta.Y; ctx.style.cursor_active = ctx.style.cursors[NK_CURSOR_MOVE]; } } layout.Type = panel_type; layout.Flags = win.Flags; layout.Bounds = win.Bounds; layout.Bounds.X += panel_padding.X; layout.Bounds.Width -= 2 * panel_padding.X; if ((win.Flags & NK_WINDOW_BORDER) != 0) { layout.Border = nk_panel_get_border(style, win.Flags, panel_type); layout.Bounds = RectangleF.nk_shrink_rect_(layout.Bounds, layout.Border); } else { layout.Border = 0; } layout.At_y = layout.Bounds.Y; layout.At_x = layout.Bounds.X; layout.Max_x = 0; layout.Header_height = 0; layout.Footer_height = 0; ctx.LayoutResetMinRowHeight(); layout.Row.index = 0; layout.Row.columns = 0; layout.Row.ratio = null; layout.Row.item_width = 0; layout.Row.tree_depth = 0; layout.Row.height = panel_padding.Y; layout.Has_scrolling = nk_true; if ((win.Flags & NK_WINDOW_NO_SCROLLBAR) == 0) { layout.Bounds.Width -= scrollbar_size.X; } if (nk_panel_is_nonblock(panel_type) == 0) { layout.Footer_height = 0; if ((win.Flags & NK_WINDOW_NO_SCROLLBAR) == 0 || (win.Flags & NK_WINDOW_SCALABLE) != 0) { layout.Footer_height = scrollbar_size.Y; } layout.Bounds.Height -= layout.Footer_height; } if (nk_panel_has_header(win.Flags, title) != 0) { var text = new nk_text(); var header = new RectangleF(); nk_style_item background = null; header.X = win.Bounds.X; header.Y = win.Bounds.Y; header.Width = win.Bounds.Width; header.Height = font.Size + 2.0f * style.window.header.padding.Y; header.Height += 2.0f * style.window.header.label_padding.Y; layout.Header_height = header.Height; layout.Bounds.Y += header.Height; layout.Bounds.Height -= header.Height; layout.At_y += header.Height; if (ctx.active == win) { background = style.window.header.active; text.text = style.window.header.label_active; } else if (nk_input_is_mouse_hovering_rect(ctx.input, header)) { background = style.window.header.hover; text.text = style.window.header.label_hover; } else { background = style.window.header.normal; text.text = style.window.header.label_normal; } header.Height += 1.0f; if (background.type == NK_STYLE_ITEM_IMAGE) { text.Background = Color.Transparent; win.Buffer.DrawImage(header, background.Image, nk_white); } else { text.Background = background.Color; _out_.FillRect(header, 0, background.Color); } { var button = new RectangleF(); button.Y = header.Y + style.window.header.padding.Y; button.Height = header.Height - 2 * style.window.header.padding.Y; button.Width = button.Height; if ((win.Flags & NK_WINDOW_CLOSABLE) != 0) { var ws = (uint)0; if (style.window.header.align == NK_HEADER_RIGHT) { button.X = header.Width + header.X - (button.Width + style.window.header.padding.X); header.Width -= button.Width + style.window.header.spacing.X + style.window.header.padding.X; } else { button.X = header.X + style.window.header.padding.X; header.X += button.Width + style.window.header.spacing.X + style.window.header.padding.X; } if ( DoButtonSymbol(ref ws, win.Buffer, button, style.window.header.close_symbol, NK_BUTTON_DEFAULT, style.window.header.close_button, _in_, style.font) && (win.Flags & NK_WINDOW_ROM) == 0) { layout.Flags |= NK_WINDOW_HIDDEN; layout.Flags &= ~(uint)NK_WINDOW_MINIMIZED; } } if ((win.Flags & NK_WINDOW_MINIMIZABLE) != 0) { var ws = (uint)0; if (style.window.header.align == NK_HEADER_RIGHT) { button.X = header.Width + header.X - button.Width; if ((win.Flags & NK_WINDOW_CLOSABLE) == 0) { button.X -= style.window.header.padding.X; header.Width -= style.window.header.padding.X; } header.Width -= button.Width + style.window.header.spacing.X; } else { button.X = header.X; header.X += button.Width + style.window.header.spacing.X + style.window.header.padding.X; } if ( DoButtonSymbol(ref ws, win.Buffer, button, (layout.Flags & NK_WINDOW_MINIMIZED) != 0 ? style.window.header.maximize_symbol : style.window.header.minimize_symbol, NK_BUTTON_DEFAULT, style.window.header.minimize_button, _in_, style.font) && (win.Flags & NK_WINDOW_ROM) == 0) { layout.Flags = (layout.Flags & NK_WINDOW_MINIMIZED) != 0 ? layout.Flags & ~(uint)NK_WINDOW_MINIMIZED : layout.Flags | NK_WINDOW_MINIMIZED; } } } { var label = new RectangleF(); var t = font.width(title); text.padding = new Vector2(0, 0); label.X = header.X + style.window.header.padding.X; label.X += style.window.header.label_padding.X; label.Y = header.Y + style.window.header.label_padding.Y; label.Height = font.Size + 2 * style.window.header.label_padding.Y; label.Width = t + 2 * style.window.header.spacing.X; label.Width = (label.Width < header.X + header.Width - label.X ? label.Width : header.X + header.Width - label.X) < 0 ? 0 : label.Width < header.X + header.Width - label.X ? label.Width : header.X + header.Width - label.X; _out_.WidgetText(label, title, &text, nk_text_align.NK_TEXT_LEFT, font); } } if ((layout.Flags & NK_WINDOW_MINIMIZED) == 0 && (layout.Flags & NK_WINDOW_DYNAMIC) == 0) { var body = new RectangleF(); body.X = win.Bounds.X; body.Width = win.Bounds.Width; body.Y = win.Bounds.Y + layout.Header_height; body.Height = win.Bounds.Height - layout.Header_height; if (style.window.fixed_background.type == NK_STYLE_ITEM_IMAGE) { _out_.DrawImage(body, style.window.fixed_background.Image, nk_white); } else { _out_.FillRect(body, 0, style.window.fixed_background.Color); } } { var clip = new RectangleF(); layout.Clip = layout.Bounds; RectangleF.nk_unify(ref clip, ref win.Buffer.Clip, layout.Clip.X, layout.Clip.Y, layout.Clip.X + layout.Clip.Width, layout.Clip.Y + layout.Clip.Height); _out_.Scissor(clip); layout.Clip = clip; } return((layout.Flags & NK_WINDOW_HIDDEN) == 0 && (layout.Flags & NK_WINDOW_MINIMIZED) == 0); }
public static int nk_style_push_style_item(nk_context *ctx, nk_style_item *sitem, nk_style_item sitem2) => _nk_style_push_style_item(ctx, sitem, sitem2);