private InternalBounds GetInternalBounds(Rect bounds) { var internalBounds = new InternalBounds { MinX = Mathf.Max(0, (int)((bounds.xMin - _bottomLeft.x) * CellWidthBackwards /*/ CellWidth*/)), MinY = Mathf.Max(0, (int)((bounds.yMin - _bottomLeft.y) * CellHeightBackwards /*/ CellHeight*/)), MaxX = Mathf.Min(Width - 1, (int)((bounds.xMax - _bottomLeft.x) * CellWidthBackwards /*/ CellWidth*/)), MaxY = Mathf.Min(Height - 1, (int)((bounds.yMax - _bottomLeft.y) * CellHeightBackwards /*/ CellHeight*/)) }; return(internalBounds); }
private InternalBounds GetInternalBounds(Rect bounds) { var internalBounds = new InternalBounds { MinX = Mathf.Max(0, (int)(bounds.xMin / CellWidth)), MinY = Mathf.Max(0, (int)(bounds.yMin / CellHeight)), MaxX = Mathf.Min(Width - 1, (int)(bounds.xMax / CellWidth)), MaxY = Mathf.Min(Height - 1, (int)(bounds.yMax / CellHeight)) }; return(internalBounds); }
public static void ShowContextMenu(Widget menu, Point position) { if (menu == null) { throw new ArgumentNullException("menu"); } HideContextMenu(); ContextMenu = menu; if (ContextMenu == null) { return; } ContextMenu.HorizontalAlignment = HorizontalAlignment.Left; ContextMenu.VerticalAlignment = VerticalAlignment.Top; var measure = ContextMenu.Measure(InternalBounds.Size()); if (position.X + measure.X > InternalBounds.Right) { position.X = InternalBounds.Right - measure.X; } if (position.Y + measure.Y > InternalBounds.Bottom) { position.Y = InternalBounds.Bottom - measure.Y; } ContextMenu.Left = position.X; ContextMenu.Top = position.Y; ContextMenu.Visible = true; Widgets.Add(ContextMenu); if (ContextMenu.AcceptsKeyboardFocus) { _previousKeyboardFocus = FocusedKeyboardWidget; FocusedKeyboardWidget = ContextMenu; } _scheduleMouseWheelFocus = ContextMenu; _contextMenuShown = true; }
private InternalBounds GetInternalBounds(Bounds bounds) { var min = bounds.min - _bottomLeftFront; var max = bounds.max - _bottomLeftFront; var internalBounds = new InternalBounds { MinX = Mathf.Max(0, (int)(min.x / CellWidth)), MinY = Mathf.Max(0, (int)(min.y / CellHeight)), MinZ = Mathf.Max(0, (int)(min.z / CellDepth)), MaxX = Mathf.Min(Width - 1, (int)(max.x / CellWidth)), MaxY = Mathf.Min(Height - 1, (int)(max.y / CellHeight)), MaxZ = Mathf.Min(Depth - 1, (int)(max.z / CellDepth)) }; return(internalBounds); }