public static void nk_panel_end(this NuklearContext ctx) { nk_input _in_; nk_window window; nk_panel layout; nk_style style; CommandBuffer _out_; var scrollbar_size = new Vector2(); var panel_padding = new Vector2(); if (ctx == null || ctx.current == null || ctx.current.Layout == null) { return; } window = ctx.current; layout = window.Layout; style = ctx.style; _out_ = window.Buffer; _in_ = (layout.Flags & NK_WINDOW_ROM) != 0 || (layout.Flags & NK_WINDOW_NO_INPUT) != 0 ? null : ctx.input; if (nk_panel_is_sub(layout.Type) == 0) { _out_.Scissor(RectangleF.Null); } scrollbar_size = style.window.scrollbar_size; panel_padding = nk_panel_get_padding(style, layout.Type); layout.At_y += layout.Row.height; if ((layout.Flags & NK_WINDOW_DYNAMIC) != 0 && (layout.Flags & NK_WINDOW_MINIMIZED) == 0) { var empty_space = new RectangleF(); if (layout.At_y < layout.Bounds.Y + layout.Bounds.Height) { layout.Bounds.Height = layout.At_y - layout.Bounds.Y; } empty_space.X = window.Bounds.X; empty_space.Y = layout.Bounds.Y; empty_space.Height = panel_padding.Y; empty_space.Width = window.Bounds.Width; _out_.FillRect(empty_space, 0, style.window.background); empty_space.X = window.Bounds.X; empty_space.Y = layout.Bounds.Y; empty_space.Width = panel_padding.X + layout.Border; empty_space.Height = layout.Bounds.Height; _out_.FillRect(empty_space, 0, style.window.background); empty_space.X = layout.Bounds.X + layout.Bounds.Width - layout.Border; empty_space.Y = layout.Bounds.Y; empty_space.Width = panel_padding.X + layout.Border; empty_space.Height = layout.Bounds.Height; if (layout.Offset.Y == 0 && (layout.Flags & NK_WINDOW_NO_SCROLLBAR) == 0) { empty_space.Width += scrollbar_size.X; } _out_.FillRect(empty_space, 0, style.window.background); if (layout.Offset.X != 0 && (layout.Flags & NK_WINDOW_NO_SCROLLBAR) == 0) { empty_space.X = window.Bounds.X; empty_space.Y = layout.Bounds.Y + layout.Bounds.Height; empty_space.Width = window.Bounds.Width; empty_space.Height = scrollbar_size.Y; _out_.FillRect(empty_space, 0, style.window.background); } } if ((layout.Flags & NK_WINDOW_NO_SCROLLBAR) == 0 && (layout.Flags & NK_WINDOW_MINIMIZED) == 0 && window.ScrollbarHidingTimer < 4.0f) { var scroll = new RectangleF(); bool scroll_has_scrolling; float scroll_target; float scroll_offset; float scroll_step; float scroll_inc; if (nk_panel_is_sub(layout.Type) != 0) { var root_window = window; var root_panel = window.Layout; while (root_panel.Parent != null) { root_panel = root_panel.Parent; } while (root_window.Parent != null) { root_window = root_window.Parent; } scroll_has_scrolling = false; if (root_window == ctx.active && layout.Has_scrolling != 0) { if (nk_input_is_mouse_hovering_rect(_in_, layout.Bounds) && !(root_panel.Clip.X > layout.Bounds.X + layout.Bounds.Width || root_panel.Clip.X + root_panel.Clip.Width < layout.Bounds.X || root_panel.Clip.Y > layout.Bounds.Y + layout.Bounds.Height || root_panel.Clip.Y + root_panel.Clip.Height < layout.Bounds.Y)) { root_panel = window.Layout; while (root_panel.Parent != null) { root_panel.Has_scrolling = nk_false; root_panel = root_panel.Parent; } root_panel.Has_scrolling = nk_false; scroll_has_scrolling = true; } } } else if (nk_panel_is_sub(layout.Type) == 0) { scroll_has_scrolling = window == ctx.active && layout.Has_scrolling != 0; if (_in_ != null && (_in_.mouse.scroll_delta.Y > 0 || _in_.mouse.scroll_delta.X > 0) && scroll_has_scrolling) { window.Scrolled = nk_true; } else { window.Scrolled = nk_false; } } else { scroll_has_scrolling = false; } { var state = (uint)0; scroll.X = layout.Bounds.X + layout.Bounds.Width + panel_padding.X; scroll.Y = layout.Bounds.Y; scroll.Width = scrollbar_size.X; scroll.Height = layout.Bounds.Height; scroll_offset = layout.Offset.Y; scroll_step = scroll.Height * 0.10f; scroll_inc = scroll.Height * 0.01f; scroll_target = (int)(layout.At_y - scroll.Y); scroll_offset = nk_do_scrollbarv(ref state, _out_, scroll, scroll_has_scrolling, scroll_offset, scroll_target, scroll_step, scroll_inc, ctx.style.scrollv, _in_, style.font); layout.Offset.Y = (int)scroll_offset; if (_in_ != null && scroll_has_scrolling) { _in_.mouse.scroll_delta.Y = 0; } } { var state = (uint)0; scroll.X = layout.Bounds.X; scroll.Y = layout.Bounds.Y + layout.Bounds.Height; scroll.Width = layout.Bounds.Width; scroll.Height = scrollbar_size.Y; scroll_offset = layout.Offset.X; scroll_target = (int)(layout.Max_x - scroll.X); scroll_step = layout.Max_x * 0.05f; scroll_inc = layout.Max_x * 0.005f; scroll_offset = nk_do_scrollbarh(ref state, _out_, scroll, scroll_has_scrolling, scroll_offset, scroll_target, scroll_step, scroll_inc, ctx.style.scrollh, _in_, style.font); layout.Offset.X = (int)scroll_offset; } } if ((window.Flags & NK_WINDOW_SCROLL_AUTO_HIDE) != 0) { var has_input = ctx.input.mouse.delta.X != 0 || ctx.input.mouse.delta.Y != 0 || ctx.input.mouse.scroll_delta.Y != 0 ? 1 : 0; var is_window_hovered = ctx.nk_window_is_hovered(); var any_item_active = (ctx.last_widget_state & NK_WIDGET_STATE_MODIFIED) != 0; if (has_input == 0 && is_window_hovered || !is_window_hovered && !any_item_active) { window.ScrollbarHidingTimer += ctx.delta_time_seconds; } else { window.ScrollbarHidingTimer = 0; } } else { window.ScrollbarHidingTimer = 0; } if ((layout.Flags & NK_WINDOW_BORDER) != 0) { var border_color = nk_panel_get_border_color(style, layout.Type); var padding_y = (layout.Flags & NK_WINDOW_MINIMIZED) != 0 ? style.window.border + window.Bounds.Y + layout.Header_height : (layout.Flags & NK_WINDOW_DYNAMIC) != 0 ? layout.Bounds.Y + layout.Bounds.Height + layout.Footer_height : window.Bounds.Y + window.Bounds.Height; var b = window.Bounds; b.Height = padding_y - window.Bounds.Y; _out_.StrokeRect(b, 0, layout.Border, border_color); } if ((layout.Flags & NK_WINDOW_SCALABLE) != 0 && _in_ != null && (layout.Flags & NK_WINDOW_MINIMIZED) == 0) { var scaler = new RectangleF(); scaler.Width = scrollbar_size.X; scaler.Height = scrollbar_size.Y; scaler.Y = layout.Bounds.Y + layout.Bounds.Height; if ((layout.Flags & NK_WINDOW_SCALE_LEFT) != 0) { scaler.X = layout.Bounds.X - panel_padding.X * 0.5f; } else { scaler.X = layout.Bounds.X + layout.Bounds.Width + panel_padding.X; } if ((layout.Flags & NK_WINDOW_NO_SCROLLBAR) != 0) { scaler.X -= scaler.Width; } { var item = style.window.scaler; if (item.type == NK_STYLE_ITEM_IMAGE) { _out_.DrawImage(scaler, item.Image, nk_white); } else { if ((layout.Flags & NK_WINDOW_SCALE_LEFT) != 0) { _out_.FillTriangle(scaler.X, scaler.Y, scaler.X, scaler.Y + scaler.Height, scaler.X + scaler.Width, scaler.Y + scaler.Height, item.Color); } else { _out_.FillTriangle(scaler.X + scaler.Width, scaler.Y, scaler.X + scaler.Width, scaler.Y + scaler.Height, scaler.X, scaler.Y + scaler.Height, item.Color); } } } if ((window.Flags & NK_WINDOW_ROM) == 0) { var window_size = style.window.min_size; var left_mouse_down = _in_.mouse.buttons[NK_BUTTON_LEFT].down; var left_mouse_click_in_scaler = nk_input_has_mouse_click_down_in_rect(_in_, NK_BUTTON_LEFT, scaler, true); if (left_mouse_down && left_mouse_click_in_scaler) { var delta_x = _in_.mouse.delta.X; if ((layout.Flags & NK_WINDOW_SCALE_LEFT) != 0) { delta_x = -delta_x; window.Bounds.X += _in_.mouse.delta.X; } if (window.Bounds.Width + delta_x >= window_size.X) { if (delta_x < 0 || delta_x > 0 && _in_.mouse.pos.X >= scaler.X) { window.Bounds.Width = window.Bounds.Width + delta_x; scaler.X += _in_.mouse.delta.X; } } if ((layout.Flags & NK_WINDOW_DYNAMIC) == 0) { if (window_size.Y < window.Bounds.Height + _in_.mouse.delta.Y) { if (_in_.mouse.delta.Y < 0 || _in_.mouse.delta.Y > 0 && _in_.mouse.pos.Y >= scaler.Y) { window.Bounds.Height = window.Bounds.Height + _in_.mouse.delta.Y; scaler.Y += _in_.mouse.delta.Y; } } } ctx.style.cursor_active = ctx.style.cursors[NK_CURSOR_RESIZE_TOP_RIGHT_DOWN_LEFT]; _in_.mouse.buttons[NK_BUTTON_LEFT].clicked_pos.X = scaler.X + scaler.Width / 2.0f; _in_.mouse.buttons[NK_BUTTON_LEFT].clicked_pos.Y = scaler.Y + scaler.Height / 2.0f; } } } if (nk_panel_is_sub(layout.Type) == 0) { if ((layout.Flags & NK_WINDOW_HIDDEN) != 0) { window.Buffer.Reset(); } } if ((layout.Flags & NK_WINDOW_REMOVE_ROM) != 0) { layout.Flags &= ~(uint)NK_WINDOW_ROM; layout.Flags &= ~(uint)NK_WINDOW_REMOVE_ROM; } window.Flags = layout.Flags; if (window.Property.active != 0 && window.Property.old != window.Property.seq && window.Property.active == window.Property.prev) { } else { window.Property.old = window.Property.seq; window.Property.prev = window.Property.active; window.Property.seq = 0; } if (window.Edit.Active && window.Edit.Old != window.Edit.Seq && window.Edit.Active == window.Edit.Prev) { } else { window.Edit.Old = window.Edit.Seq; window.Edit.Prev = window.Edit.Active; window.Edit.Seq = 0; } if (window.Popup.ActiveCon != 0 && window.Popup.ConOld != window.Popup.ConCount) { window.Popup.ConCount = 0; window.Popup.ConOld = 0; window.Popup.ActiveCon = 0; } else { window.Popup.ConOld = window.Popup.ConCount; window.Popup.ConCount = 0; } window.Popup.ComboCount = 0; }