void Xceed.Wpf.AvalonDock.Controls.IOverlayWindow.DragLeave(IDropArea area) { FrameworkElement frameworkElement; this._visibleAreas.Remove(area); switch (area.Type) { case DropAreaType.DockingManager: { frameworkElement = this._gridDockingManagerDropTargets; break; } case DropAreaType.DocumentPane: { if (!(this._floatingWindow.Model is LayoutAnchorableFloatingWindow) || this._gridDocumentPaneFullDropTargets == null) { frameworkElement = this._gridDocumentPaneDropTargets; break; } else { frameworkElement = this._gridDocumentPaneFullDropTargets; break; } } case DropAreaType.DocumentPaneGroup: { frameworkElement = this._gridDocumentPaneDropTargets; break; } case DropAreaType.AnchorablePane: { frameworkElement = this._gridAnchorablePaneDropTargets; break; } default: { goto case DropAreaType.DocumentPane; } } frameworkElement.Visibility = System.Windows.Visibility.Hidden; }
/// <inheritdoc cref="IOverlayWindow"/> void IOverlayWindow.DragLeave(IDropArea area) { _visibleAreas.Remove(area); FrameworkElement areaElement; switch (area.Type) { case DropAreaType.DockingManager: areaElement = _gridDockingManagerDropTargets; break; case DropAreaType.AnchorablePane: areaElement = _gridAnchorablePaneDropTargets; break; case DropAreaType.DocumentPaneGroup: areaElement = _gridDocumentPaneDropTargets; break; case DropAreaType.DocumentPane: default: { bool isDraggingAnchorables = _floatingWindow.Model is LayoutAnchorableFloatingWindow; if (isDraggingAnchorables && _gridDocumentPaneFullDropTargets != null) { areaElement = _gridDocumentPaneFullDropTargets; } else { areaElement = _gridDocumentPaneDropTargets; } } break; } areaElement.Visibility = System.Windows.Visibility.Hidden; }
void IOverlayWindow.DragLeave(IDropArea area) { _visibleAreas.Remove(area); FrameworkElement areaElement; switch (area.Type) { case DropAreaType.DockingManager: areaElement = _gridDockingManagerDropTargets; break; case DropAreaType.AnchorablePane: areaElement = _gridAnchorablePaneDropTargets; break; case DropAreaType.DocumentPaneGroup: areaElement = _gridDocumentPaneDropTargets; break; case DropAreaType.DocumentPane: default: { bool isDraggingAnchorables = _floatingWindow.Model is LayoutAnchorableFloatingWindow; if (isDraggingAnchorables && _gridDocumentPaneFullDropTargets != null) areaElement = _gridDocumentPaneFullDropTargets; else areaElement = _gridDocumentPaneDropTargets; } break; } areaElement.Visibility = System.Windows.Visibility.Hidden; }
void IOverlayWindow.DragEnter(IDropArea area) { _visibleAreas.Add(area); FrameworkElement areaElement; switch (area.Type) { case DropAreaType.DockingManager: areaElement = _gridDockingManagerDropTargets; break; case DropAreaType.AnchorablePane: areaElement = _gridAnchorablePaneDropTargets; break; case DropAreaType.DocumentPaneGroup: { areaElement = _gridDocumentPaneDropTargets; var dropAreaDocumentPaneGroup = area as DropArea<LayoutDocumentPaneGroupControl>; var layoutDocumentPane = (dropAreaDocumentPaneGroup.AreaElement.Model as LayoutDocumentPaneGroup).Children.First() as LayoutDocumentPane; var parentDocumentPaneGroup = layoutDocumentPane.Parent as LayoutDocumentPaneGroup; _documentPaneDropTargetLeft.Visibility = Visibility.Hidden; _documentPaneDropTargetRight.Visibility = Visibility.Hidden; _documentPaneDropTargetTop.Visibility = Visibility.Hidden; _documentPaneDropTargetBottom.Visibility = Visibility.Hidden; } break; case DropAreaType.DocumentPane: default: { bool isDraggingAnchorables = _floatingWindow.Model is LayoutAnchorableFloatingWindow; if (isDraggingAnchorables && _gridDocumentPaneFullDropTargets != null) { areaElement = _gridDocumentPaneFullDropTargets; var dropAreaDocumentPaneGroup = area as DropArea<LayoutDocumentPaneControl>; var layoutDocumentPane = dropAreaDocumentPaneGroup.AreaElement.Model as LayoutDocumentPane; var parentDocumentPaneGroup = layoutDocumentPane.Parent as LayoutDocumentPaneGroup; if (parentDocumentPaneGroup != null && parentDocumentPaneGroup.Children.Where(c => c.IsVisible).Count() > 1) { var manager = parentDocumentPaneGroup.Root.Manager; if (!manager.AllowMixedOrientation) { _documentPaneFullDropTargetLeft.Visibility = parentDocumentPaneGroup.Orientation == Orientation.Horizontal ? Visibility.Visible : Visibility.Hidden; _documentPaneFullDropTargetRight.Visibility = parentDocumentPaneGroup.Orientation == Orientation.Horizontal ? Visibility.Visible : Visibility.Hidden; _documentPaneFullDropTargetTop.Visibility = parentDocumentPaneGroup.Orientation == Orientation.Vertical ? Visibility.Visible : Visibility.Hidden; _documentPaneFullDropTargetBottom.Visibility = parentDocumentPaneGroup.Orientation == Orientation.Vertical ? Visibility.Visible : Visibility.Hidden; } else { _documentPaneFullDropTargetLeft.Visibility = Visibility.Visible; _documentPaneFullDropTargetRight.Visibility = Visibility.Visible; _documentPaneFullDropTargetTop.Visibility = Visibility.Visible; _documentPaneFullDropTargetBottom.Visibility = Visibility.Visible; } } else if (parentDocumentPaneGroup == null && layoutDocumentPane != null && layoutDocumentPane.ChildrenCount == 0) { _documentPaneFullDropTargetLeft.Visibility = Visibility.Hidden; _documentPaneFullDropTargetRight.Visibility = Visibility.Hidden; _documentPaneFullDropTargetTop.Visibility = Visibility.Hidden; _documentPaneFullDropTargetBottom.Visibility = Visibility.Hidden; } else { _documentPaneFullDropTargetLeft.Visibility = Visibility.Visible; _documentPaneFullDropTargetRight.Visibility = Visibility.Visible; _documentPaneFullDropTargetTop.Visibility = Visibility.Visible; _documentPaneFullDropTargetBottom.Visibility = Visibility.Visible; } if (parentDocumentPaneGroup != null && parentDocumentPaneGroup.Children.Where(c => c.IsVisible).Count() > 1) { int indexOfDocumentPane = parentDocumentPaneGroup.Children.Where(ch => ch.IsVisible).ToList().IndexOf(layoutDocumentPane); bool isFirstChild = indexOfDocumentPane == 0; bool isLastChild = indexOfDocumentPane == parentDocumentPaneGroup.ChildrenCount - 1; var manager = parentDocumentPaneGroup.Root.Manager; if (!manager.AllowMixedOrientation) { _documentPaneDropTargetBottomAsAnchorablePane.Visibility = parentDocumentPaneGroup.Orientation == Orientation.Vertical ? (isLastChild ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden) : System.Windows.Visibility.Hidden; _documentPaneDropTargetTopAsAnchorablePane.Visibility = parentDocumentPaneGroup.Orientation == Orientation.Vertical ? (isFirstChild ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden) : System.Windows.Visibility.Hidden; _documentPaneDropTargetLeftAsAnchorablePane.Visibility = parentDocumentPaneGroup.Orientation == Orientation.Horizontal ? (isFirstChild ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden) : System.Windows.Visibility.Hidden; _documentPaneDropTargetRightAsAnchorablePane.Visibility = parentDocumentPaneGroup.Orientation == Orientation.Horizontal ? (isLastChild ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden) : System.Windows.Visibility.Hidden; } else { _documentPaneDropTargetBottomAsAnchorablePane.Visibility = System.Windows.Visibility.Visible; _documentPaneDropTargetLeftAsAnchorablePane.Visibility = System.Windows.Visibility.Visible; _documentPaneDropTargetRightAsAnchorablePane.Visibility = System.Windows.Visibility.Visible; _documentPaneDropTargetTopAsAnchorablePane.Visibility = System.Windows.Visibility.Visible; } } else { _documentPaneDropTargetBottomAsAnchorablePane.Visibility = System.Windows.Visibility.Visible; _documentPaneDropTargetLeftAsAnchorablePane.Visibility = System.Windows.Visibility.Visible; _documentPaneDropTargetRightAsAnchorablePane.Visibility = System.Windows.Visibility.Visible; _documentPaneDropTargetTopAsAnchorablePane.Visibility = System.Windows.Visibility.Visible; } } else { areaElement = _gridDocumentPaneDropTargets; var dropAreaDocumentPaneGroup = area as DropArea<LayoutDocumentPaneControl>; var layoutDocumentPane = dropAreaDocumentPaneGroup.AreaElement.Model as LayoutDocumentPane; var parentDocumentPaneGroup = layoutDocumentPane.Parent as LayoutDocumentPaneGroup; if (parentDocumentPaneGroup != null && parentDocumentPaneGroup.Children.Where(c => c.IsVisible).Count() > 1) { var manager = parentDocumentPaneGroup.Root.Manager; if (!manager.AllowMixedOrientation) { _documentPaneDropTargetLeft.Visibility = parentDocumentPaneGroup.Orientation == Orientation.Horizontal ? Visibility.Visible : Visibility.Hidden; _documentPaneDropTargetRight.Visibility = parentDocumentPaneGroup.Orientation == Orientation.Horizontal ? Visibility.Visible : Visibility.Hidden; _documentPaneDropTargetTop.Visibility = parentDocumentPaneGroup.Orientation == Orientation.Vertical ? Visibility.Visible : Visibility.Hidden; _documentPaneDropTargetBottom.Visibility = parentDocumentPaneGroup.Orientation == Orientation.Vertical ? Visibility.Visible : Visibility.Hidden; } else { _documentPaneDropTargetLeft.Visibility = Visibility.Visible; _documentPaneDropTargetRight.Visibility = Visibility.Visible; _documentPaneDropTargetTop.Visibility = Visibility.Visible; _documentPaneDropTargetBottom.Visibility = Visibility.Visible; } } else if (parentDocumentPaneGroup == null && layoutDocumentPane != null && layoutDocumentPane.ChildrenCount == 0) { _documentPaneDropTargetLeft.Visibility = Visibility.Hidden; _documentPaneDropTargetRight.Visibility = Visibility.Hidden; _documentPaneDropTargetTop.Visibility = Visibility.Hidden; _documentPaneDropTargetBottom.Visibility = Visibility.Hidden; } else { _documentPaneDropTargetLeft.Visibility = Visibility.Visible; _documentPaneDropTargetRight.Visibility = Visibility.Visible; _documentPaneDropTargetTop.Visibility = Visibility.Visible; _documentPaneDropTargetBottom.Visibility = Visibility.Visible; } } } break; } Canvas.SetLeft(areaElement, area.DetectionRect.Left - Left); Canvas.SetTop(areaElement, area.DetectionRect.Top - Top); areaElement.Width = area.DetectionRect.Width; areaElement.Height = area.DetectionRect.Height; areaElement.Visibility = System.Windows.Visibility.Visible; }
private void DragTab(Rect pos, GUIStyle tabStyle) { int controlID = GUIUtility.GetControlID(FocusType.Passive); float tabWidth = this.GetTabWidth(pos.width); Event current = Event.current; if (DockArea.s_DragMode != 0 && GUIUtility.hotControl == 0) { PaneDragTab.get.Close(); DockArea.ResetDragVars(); } EventType typeForControl = current.GetTypeForControl(controlID); switch (typeForControl) { case EventType.MouseDown: if (pos.Contains(current.mousePosition) && GUIUtility.hotControl == 0) { int tabAtMousePos = this.GetTabAtMousePos(current.mousePosition, pos); if (tabAtMousePos < this.m_Panes.Count) { switch (current.button) { case 0: if (tabAtMousePos != this.selected) { this.selected = tabAtMousePos; } GUIUtility.hotControl = controlID; DockArea.s_StartDragPosition = current.mousePosition; DockArea.s_DragMode = 0; current.Use(); break; case 2: this.m_Panes[tabAtMousePos].Close(); current.Use(); break; } } } goto IL_6B9; case EventType.MouseUp: if (GUIUtility.hotControl == controlID) { Vector2 vector = GUIUtility.GUIToScreenPoint(current.mousePosition); if (DockArea.s_DragMode != 0) { DockArea.s_DragMode = 0; PaneDragTab.get.Close(); EditorApplication.update = (EditorApplication.CallbackFunction)Delegate.Remove(EditorApplication.update, new EditorApplication.CallbackFunction(DockArea.CheckDragWindowExists)); if (DockArea.s_DropInfo != null && DockArea.s_DropInfo.dropArea != null) { DockArea.s_DropInfo.dropArea.PerformDrop(DockArea.s_DragPane, DockArea.s_DropInfo, vector); } else { EditorWindow editorWindow = DockArea.s_DragPane; DockArea.ResetDragVars(); this.RemoveTab(editorWindow); Rect position = editorWindow.position; position.x = vector.x - position.width * 0.5f; position.y = vector.y - position.height * 0.5f; if (Application.platform == RuntimePlatform.WindowsEditor) { position.y = Mathf.Max(InternalEditorUtility.GetBoundsOfDesktopAtPoint(vector).y, position.y); } EditorWindow.CreateNewWindowForEditorWindow(editorWindow, false, false); editorWindow.position = editorWindow.m_Parent.window.FitWindowRectToScreen(position, true, true); GUIUtility.hotControl = 0; GUIUtility.ExitGUI(); } DockArea.ResetDragVars(); } GUIUtility.hotControl = 0; current.Use(); } goto IL_6B9; case EventType.MouseMove: case EventType.KeyDown: case EventType.KeyUp: case EventType.ScrollWheel: IL_6E: if (typeForControl != EventType.ContextClick) { goto IL_6B9; } if (pos.Contains(current.mousePosition) && GUIUtility.hotControl == 0) { int tabAtMousePos2 = this.GetTabAtMousePos(current.mousePosition, pos); if (tabAtMousePos2 < this.m_Panes.Count) { base.PopupGenericMenu(this.m_Panes[tabAtMousePos2], new Rect(current.mousePosition.x, current.mousePosition.y, 0f, 0f)); } } goto IL_6B9; case EventType.MouseDrag: if (GUIUtility.hotControl == controlID) { Vector2 vector2 = current.mousePosition - DockArea.s_StartDragPosition; current.Use(); Rect screenPosition = base.screenPosition; if (DockArea.s_DragMode == 0 && vector2.sqrMagnitude > 99f) { DockArea.s_DragMode = 1; DockArea.s_PlaceholderPos = this.selected; DockArea.s_DragPane = this.m_Panes[this.selected]; if (this.m_Panes.Count == 1) { DockArea.s_IgnoreDockingForView = this; } else { DockArea.s_IgnoreDockingForView = null; } DockArea.s_OriginalDragSource = this; PaneDragTab.get.content = DockArea.s_DragPane.cachedTitleContent; base.Internal_SetAsActiveWindow(); PaneDragTab.get.GrabThumbnail(); PaneDragTab.get.Show(new Rect(pos.x + screenPosition.x + tabWidth * (float)this.selected, pos.y + screenPosition.y, tabWidth, pos.height), GUIUtility.GUIToScreenPoint(current.mousePosition)); EditorApplication.update = (EditorApplication.CallbackFunction)Delegate.Combine(EditorApplication.update, new EditorApplication.CallbackFunction(DockArea.CheckDragWindowExists)); GUIUtility.ExitGUI(); } if (DockArea.s_DragMode == 1) { DropInfo dropInfo = null; ContainerWindow[] windows = ContainerWindow.windows; Vector2 vector3 = GUIUtility.GUIToScreenPoint(current.mousePosition); ContainerWindow inFrontOf = null; ContainerWindow[] array = windows; for (int i = 0; i < array.Length; i++) { ContainerWindow containerWindow = array[i]; View[] allChildren = containerWindow.mainView.allChildren; for (int j = 0; j < allChildren.Length; j++) { View view = allChildren[j]; IDropArea dropArea = view as IDropArea; if (dropArea != null) { dropInfo = dropArea.DragOver(DockArea.s_DragPane, vector3); } if (dropInfo != null) { break; } } if (dropInfo != null) { inFrontOf = containerWindow; break; } } if (dropInfo == null) { dropInfo = new DropInfo(null); } if (dropInfo.type != DropInfo.Type.Tab) { DockArea.s_PlaceholderPos = -1; } DockArea.s_DropInfo = dropInfo; if (PaneDragTab.get.m_Window) { PaneDragTab.get.SetDropInfo(dropInfo, vector3, inFrontOf); } } } goto IL_6B9; case EventType.Repaint: { float num = pos.xMin; int num2 = 0; if (base.actualView) { for (int k = 0; k < this.m_Panes.Count; k++) { if (!(DockArea.s_DragPane == this.m_Panes[k])) { if (DockArea.s_DropInfo != null && object.ReferenceEquals(DockArea.s_DropInfo.dropArea, this) && DockArea.s_PlaceholderPos == num2) { num += tabWidth; } Rect rect = new Rect(num, pos.yMin, tabWidth, pos.height); float num3 = Mathf.Round(rect.x); Rect position2 = new Rect(num3, rect.y, Mathf.Round(rect.x + rect.width) - num3, rect.height); tabStyle.Draw(position2, this.m_Panes[k].cachedTitleContent, false, false, k == this.selected, base.hasFocus); num += tabWidth; num2++; } } } else { Rect rect2 = new Rect(num, pos.yMin, tabWidth, pos.height); float num4 = Mathf.Round(rect2.x); Rect position3 = new Rect(num4, rect2.y, Mathf.Round(rect2.x + rect2.width) - num4, rect2.height); tabStyle.Draw(position3, "Failed to load", false, false, true, false); } goto IL_6B9; } } goto IL_6E; IL_6B9: this.selected = Mathf.Clamp(this.selected, 0, this.m_Panes.Count - 1); }
public DropInfo(IDropArea source) { this.dropArea = source; }
void IOverlayWindow.DragEnter(IDropArea area) { _visibleAreas.Add(area); FrameworkElement areaElement; switch (area.Type) { case DropAreaType.DockingManager: areaElement = _gridDockingManagerDropTargets; break; case DropAreaType.AnchorablePane: areaElement = _gridAnchorablePaneDropTargets; break; case DropAreaType.DocumentPaneGroup: { areaElement = _gridDocumentPaneDropTargets; _documentPaneDropTargetLeft.Visibility = Visibility.Hidden; _documentPaneDropTargetRight.Visibility = Visibility.Hidden; _documentPaneDropTargetTop.Visibility = Visibility.Hidden; _documentPaneDropTargetBottom.Visibility = Visibility.Hidden; } break; default: { bool isDraggingAnchorables = _floatingWindow.Model is LayoutAnchorableFloatingWindow; if (isDraggingAnchorables && _gridDocumentPaneFullDropTargets != null) { areaElement = _gridDocumentPaneFullDropTargets; var dropAreaDocumentPaneGroup = area as DropArea <LayoutDocumentPaneControl>; var layoutDocumentPane = dropAreaDocumentPaneGroup?.AreaElement.Model as LayoutDocumentPane; if (layoutDocumentPane != null) { var parentDocumentPaneGroup = layoutDocumentPane.Parent as LayoutDocumentPaneGroup; if (parentDocumentPaneGroup != null && parentDocumentPaneGroup.Children.Count(c => c.IsVisible) > 1) { var manager = parentDocumentPaneGroup.Root.Manager; if (!manager.AllowMixedOrientation) { _documentPaneFullDropTargetLeft.Visibility = parentDocumentPaneGroup.Orientation == Orientation.Horizontal ? Visibility.Visible : Visibility.Hidden; _documentPaneFullDropTargetRight.Visibility = parentDocumentPaneGroup.Orientation == Orientation.Horizontal ? Visibility.Visible : Visibility.Hidden; _documentPaneFullDropTargetTop.Visibility = parentDocumentPaneGroup.Orientation == Orientation.Vertical ? Visibility.Visible : Visibility.Hidden; _documentPaneFullDropTargetBottom.Visibility = parentDocumentPaneGroup.Orientation == Orientation.Vertical ? Visibility.Visible : Visibility.Hidden; } else { _documentPaneFullDropTargetLeft.Visibility = Visibility.Visible; _documentPaneFullDropTargetRight.Visibility = Visibility.Visible; _documentPaneFullDropTargetTop.Visibility = Visibility.Visible; _documentPaneFullDropTargetBottom.Visibility = Visibility.Visible; } } else if (parentDocumentPaneGroup == null && layoutDocumentPane.ChildrenCount == 0) { _documentPaneFullDropTargetLeft.Visibility = Visibility.Hidden; _documentPaneFullDropTargetRight.Visibility = Visibility.Hidden; _documentPaneFullDropTargetTop.Visibility = Visibility.Hidden; _documentPaneFullDropTargetBottom.Visibility = Visibility.Hidden; } else { _documentPaneFullDropTargetLeft.Visibility = Visibility.Visible; _documentPaneFullDropTargetRight.Visibility = Visibility.Visible; _documentPaneFullDropTargetTop.Visibility = Visibility.Visible; _documentPaneFullDropTargetBottom.Visibility = Visibility.Visible; } if (parentDocumentPaneGroup != null && parentDocumentPaneGroup.Children.Count(c => c.IsVisible) > 1) { int indexOfDocumentPane = parentDocumentPaneGroup.Children.Where(ch => ch.IsVisible) .ToList() .IndexOf(layoutDocumentPane); bool isFirstChild = indexOfDocumentPane == 0; bool isLastChild = indexOfDocumentPane == parentDocumentPaneGroup.ChildrenCount - 1; var manager = parentDocumentPaneGroup.Root.Manager; if (!manager.AllowMixedOrientation) { _documentPaneDropTargetBottomAsAnchorablePane.Visibility = parentDocumentPaneGroup.Orientation == Orientation.Vertical ? (isLastChild ? Visibility.Visible : Visibility.Hidden) : Visibility.Hidden; _documentPaneDropTargetTopAsAnchorablePane.Visibility = parentDocumentPaneGroup.Orientation == Orientation.Vertical ? (isFirstChild ? Visibility.Visible : Visibility.Hidden) : Visibility.Hidden; _documentPaneDropTargetLeftAsAnchorablePane.Visibility = parentDocumentPaneGroup.Orientation == Orientation.Horizontal ? (isFirstChild ? Visibility.Visible : Visibility.Hidden) : Visibility.Hidden; _documentPaneDropTargetRightAsAnchorablePane.Visibility = parentDocumentPaneGroup.Orientation == Orientation.Horizontal ? (isLastChild ? Visibility.Visible : Visibility.Hidden) : Visibility.Hidden; } else { _documentPaneDropTargetBottomAsAnchorablePane.Visibility = Visibility.Visible; _documentPaneDropTargetLeftAsAnchorablePane.Visibility = Visibility.Visible; _documentPaneDropTargetRightAsAnchorablePane.Visibility = Visibility.Visible; _documentPaneDropTargetTopAsAnchorablePane.Visibility = Visibility.Visible; } } else { _documentPaneDropTargetBottomAsAnchorablePane.Visibility = Visibility.Visible; _documentPaneDropTargetLeftAsAnchorablePane.Visibility = Visibility.Visible; _documentPaneDropTargetRightAsAnchorablePane.Visibility = Visibility.Visible; _documentPaneDropTargetTopAsAnchorablePane.Visibility = Visibility.Visible; } } } else { areaElement = _gridDocumentPaneDropTargets; var dropAreaDocumentPaneGroup = area as DropArea <LayoutDocumentPaneControl>; var layoutDocumentPane = dropAreaDocumentPaneGroup?.AreaElement.Model as LayoutDocumentPane; if (layoutDocumentPane != null) { var parentDocumentPaneGroup = layoutDocumentPane.Parent as LayoutDocumentPaneGroup; if (parentDocumentPaneGroup != null && parentDocumentPaneGroup.Children.Count(c => c.IsVisible) > 1) { var manager = parentDocumentPaneGroup.Root.Manager; if (!manager.AllowMixedOrientation) { _documentPaneDropTargetLeft.Visibility = parentDocumentPaneGroup.Orientation == Orientation.Horizontal ? Visibility.Visible : Visibility.Hidden; _documentPaneDropTargetRight.Visibility = parentDocumentPaneGroup.Orientation == Orientation.Horizontal ? Visibility.Visible : Visibility.Hidden; _documentPaneDropTargetTop.Visibility = parentDocumentPaneGroup.Orientation == Orientation.Vertical ? Visibility.Visible : Visibility.Hidden; _documentPaneDropTargetBottom.Visibility = parentDocumentPaneGroup.Orientation == Orientation.Vertical ? Visibility.Visible : Visibility.Hidden; } else { _documentPaneDropTargetLeft.Visibility = Visibility.Visible; _documentPaneDropTargetRight.Visibility = Visibility.Visible; _documentPaneDropTargetTop.Visibility = Visibility.Visible; _documentPaneDropTargetBottom.Visibility = Visibility.Visible; } } else if (parentDocumentPaneGroup == null && layoutDocumentPane.ChildrenCount == 0) { _documentPaneDropTargetLeft.Visibility = Visibility.Hidden; _documentPaneDropTargetRight.Visibility = Visibility.Hidden; _documentPaneDropTargetTop.Visibility = Visibility.Hidden; _documentPaneDropTargetBottom.Visibility = Visibility.Hidden; } else { _documentPaneDropTargetLeft.Visibility = Visibility.Visible; _documentPaneDropTargetRight.Visibility = Visibility.Visible; _documentPaneDropTargetTop.Visibility = Visibility.Visible; _documentPaneDropTargetBottom.Visibility = Visibility.Visible; } } } } break; } Canvas.SetLeft(areaElement, area.DetectionRect.Left - Left); Canvas.SetTop(areaElement, area.DetectionRect.Top - Top); areaElement.Width = area.DetectionRect.Width; areaElement.Height = area.DetectionRect.Height; areaElement.Visibility = Visibility.Visible; }
/// <inheritdoc cref="IOverlayWindow"/> void IOverlayWindow.DragEnter(IDropArea area) { var floatingWindowManager = _floatingWindow.Model.Root.Manager; _visibleAreas.Add(area); FrameworkElement areaElement; switch (area.Type) { case DropAreaType.DockingManager: var dropAreaDockingManager = area as DropArea <DockingManager>; if (dropAreaDockingManager.AreaElement != floatingWindowManager) { _visibleAreas.Remove(area); return; } areaElement = _gridDockingManagerDropTargets; break; case DropAreaType.AnchorablePane: areaElement = _gridAnchorablePaneDropTargets; var dropAreaAnchorablePaneGroup = area as DropArea <LayoutAnchorablePaneControl>; var layoutAnchorablePane = dropAreaAnchorablePaneGroup.AreaElement.Model as LayoutAnchorablePane; if (layoutAnchorablePane.Root.Manager != floatingWindowManager) { _visibleAreas.Remove(area); return; } SetDropTargetIntoVisibility(layoutAnchorablePane); break; case DropAreaType.DocumentPaneGroup: { areaElement = _gridDocumentPaneDropTargets; var dropAreaDocumentPaneGroup = area as DropArea <LayoutDocumentPaneGroupControl>; var layoutDocumentPane = (dropAreaDocumentPaneGroup.AreaElement.Model as LayoutDocumentPaneGroup).Children.First() as LayoutDocumentPane; var parentDocumentPaneGroup = layoutDocumentPane.Parent as LayoutDocumentPaneGroup; if (parentDocumentPaneGroup.Root.Manager != floatingWindowManager) { _visibleAreas.Remove(area); return; } _documentPaneDropTargetLeft.Visibility = Visibility.Hidden; _documentPaneDropTargetRight.Visibility = Visibility.Hidden; _documentPaneDropTargetTop.Visibility = Visibility.Hidden; _documentPaneDropTargetBottom.Visibility = Visibility.Hidden; } break; case DropAreaType.DocumentPane: default: { bool isDraggingAnchorables = _floatingWindow.Model is LayoutAnchorableFloatingWindow; if (isDraggingAnchorables && _gridDocumentPaneFullDropTargets != null) { areaElement = _gridDocumentPaneFullDropTargets; var dropAreaDocumentPaneGroup = area as DropArea <LayoutDocumentPaneControl>; var layoutDocumentPane = dropAreaDocumentPaneGroup.AreaElement.Model as LayoutDocumentPane; var parentDocumentPaneGroup = layoutDocumentPane.Parent as LayoutDocumentPaneGroup; if (layoutDocumentPane.Root.Manager != floatingWindowManager) { _visibleAreas.Remove(area); return; } SetDropTargetIntoVisibility(layoutDocumentPane); if (parentDocumentPaneGroup != null && parentDocumentPaneGroup.Children.Where(c => c.IsVisible).Count() > 1) { var manager = parentDocumentPaneGroup.Root.Manager; if (!manager.AllowMixedOrientation) { _documentPaneFullDropTargetLeft.Visibility = parentDocumentPaneGroup.Orientation == Orientation.Horizontal ? Visibility.Visible : Visibility.Hidden; _documentPaneFullDropTargetRight.Visibility = parentDocumentPaneGroup.Orientation == Orientation.Horizontal ? Visibility.Visible : Visibility.Hidden; _documentPaneFullDropTargetTop.Visibility = parentDocumentPaneGroup.Orientation == Orientation.Vertical ? Visibility.Visible : Visibility.Hidden; _documentPaneFullDropTargetBottom.Visibility = parentDocumentPaneGroup.Orientation == Orientation.Vertical ? Visibility.Visible : Visibility.Hidden; } else { _documentPaneFullDropTargetLeft.Visibility = Visibility.Visible; _documentPaneFullDropTargetRight.Visibility = Visibility.Visible; _documentPaneFullDropTargetTop.Visibility = Visibility.Visible; _documentPaneFullDropTargetBottom.Visibility = Visibility.Visible; } } else if (parentDocumentPaneGroup == null && layoutDocumentPane != null && layoutDocumentPane.ChildrenCount == 0) { _documentPaneFullDropTargetLeft.Visibility = Visibility.Hidden; _documentPaneFullDropTargetRight.Visibility = Visibility.Hidden; _documentPaneFullDropTargetTop.Visibility = Visibility.Hidden; _documentPaneFullDropTargetBottom.Visibility = Visibility.Hidden; } else { _documentPaneFullDropTargetLeft.Visibility = Visibility.Visible; _documentPaneFullDropTargetRight.Visibility = Visibility.Visible; _documentPaneFullDropTargetTop.Visibility = Visibility.Visible; _documentPaneFullDropTargetBottom.Visibility = Visibility.Visible; } if (layoutDocumentPane.IsHostedInFloatingWindow) { // Hide outer buttons if drop area is a document floating window host // since these 4 drop area buttons are available over the DockingManager ONLY. _documentPaneDropTargetBottomAsAnchorablePane.Visibility = System.Windows.Visibility.Collapsed; _documentPaneDropTargetLeftAsAnchorablePane.Visibility = System.Windows.Visibility.Collapsed; _documentPaneDropTargetRightAsAnchorablePane.Visibility = System.Windows.Visibility.Collapsed; _documentPaneDropTargetTopAsAnchorablePane.Visibility = System.Windows.Visibility.Collapsed; } else if (parentDocumentPaneGroup != null && parentDocumentPaneGroup.Children.Where(c => c.IsVisible).Count() > 1) { int indexOfDocumentPane = parentDocumentPaneGroup.Children.Where(ch => ch.IsVisible).ToList().IndexOf(layoutDocumentPane); bool isFirstChild = indexOfDocumentPane == 0; bool isLastChild = indexOfDocumentPane == parentDocumentPaneGroup.ChildrenCount - 1; var manager = parentDocumentPaneGroup.Root.Manager; if (!manager.AllowMixedOrientation) { _documentPaneDropTargetBottomAsAnchorablePane.Visibility = parentDocumentPaneGroup.Orientation == Orientation.Vertical ? (isLastChild ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden) : System.Windows.Visibility.Hidden; _documentPaneDropTargetTopAsAnchorablePane.Visibility = parentDocumentPaneGroup.Orientation == Orientation.Vertical ? (isFirstChild ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden) : System.Windows.Visibility.Hidden; _documentPaneDropTargetLeftAsAnchorablePane.Visibility = parentDocumentPaneGroup.Orientation == Orientation.Horizontal ? (isFirstChild ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden) : System.Windows.Visibility.Hidden; _documentPaneDropTargetRightAsAnchorablePane.Visibility = parentDocumentPaneGroup.Orientation == Orientation.Horizontal ? (isLastChild ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden) : System.Windows.Visibility.Hidden; } else { _documentPaneDropTargetBottomAsAnchorablePane.Visibility = System.Windows.Visibility.Visible; _documentPaneDropTargetLeftAsAnchorablePane.Visibility = System.Windows.Visibility.Visible; _documentPaneDropTargetRightAsAnchorablePane.Visibility = System.Windows.Visibility.Visible; _documentPaneDropTargetTopAsAnchorablePane.Visibility = System.Windows.Visibility.Visible; } } else { _documentPaneDropTargetBottomAsAnchorablePane.Visibility = System.Windows.Visibility.Visible; _documentPaneDropTargetLeftAsAnchorablePane.Visibility = System.Windows.Visibility.Visible; _documentPaneDropTargetRightAsAnchorablePane.Visibility = System.Windows.Visibility.Visible; _documentPaneDropTargetTopAsAnchorablePane.Visibility = System.Windows.Visibility.Visible; } } else { // Showing a drop target structure with 5 centered star like buttons. areaElement = _gridDocumentPaneDropTargets; var dropAreaDocumentPaneGroup = area as DropArea <LayoutDocumentPaneControl>; var layoutDocumentPane = dropAreaDocumentPaneGroup.AreaElement.Model as LayoutDocumentPane; var parentDocumentPaneGroup = layoutDocumentPane.Parent as LayoutDocumentPaneGroup; if (layoutDocumentPane.Root.Manager != floatingWindowManager) { _visibleAreas.Remove(area); return; } SetDropTargetIntoVisibility(layoutDocumentPane); if (parentDocumentPaneGroup != null && parentDocumentPaneGroup.Children.Where(c => c.IsVisible).Count() > 1) { var manager = parentDocumentPaneGroup.Root.Manager; if (!manager.AllowMixedOrientation) { _documentPaneDropTargetLeft.Visibility = parentDocumentPaneGroup.Orientation == Orientation.Horizontal ? Visibility.Visible : Visibility.Hidden; _documentPaneDropTargetRight.Visibility = parentDocumentPaneGroup.Orientation == Orientation.Horizontal ? Visibility.Visible : Visibility.Hidden; _documentPaneDropTargetTop.Visibility = parentDocumentPaneGroup.Orientation == Orientation.Vertical ? Visibility.Visible : Visibility.Hidden; _documentPaneDropTargetBottom.Visibility = parentDocumentPaneGroup.Orientation == Orientation.Vertical ? Visibility.Visible : Visibility.Hidden; } else { _documentPaneDropTargetLeft.Visibility = Visibility.Visible; _documentPaneDropTargetRight.Visibility = Visibility.Visible; _documentPaneDropTargetTop.Visibility = Visibility.Visible; _documentPaneDropTargetBottom.Visibility = Visibility.Visible; } } else if (parentDocumentPaneGroup == null && layoutDocumentPane != null && layoutDocumentPane.ChildrenCount == 0) { _documentPaneDropTargetLeft.Visibility = Visibility.Hidden; _documentPaneDropTargetRight.Visibility = Visibility.Hidden; _documentPaneDropTargetTop.Visibility = Visibility.Hidden; _documentPaneDropTargetBottom.Visibility = Visibility.Hidden; } else { _documentPaneDropTargetLeft.Visibility = Visibility.Visible; _documentPaneDropTargetRight.Visibility = Visibility.Visible; _documentPaneDropTargetTop.Visibility = Visibility.Visible; _documentPaneDropTargetBottom.Visibility = Visibility.Visible; } } } break; } Canvas.SetLeft(areaElement, area.DetectionRect.Left - Left); Canvas.SetTop(areaElement, area.DetectionRect.Top - Top); areaElement.Width = area.DetectionRect.Width; areaElement.Height = area.DetectionRect.Height; areaElement.Visibility = System.Windows.Visibility.Visible; }
private void DragTab(Rect pos, GUIStyle tabStyle) { int controlId = GUIUtility.GetControlID(FocusType.Passive); float tabWidth = this.GetTabWidth(pos.width); Event current = Event.current; if (DockArea.s_DragMode != 0 && GUIUtility.hotControl == 0) { PaneDragTab.get.Close(); DockArea.ResetDragVars(); } EventType typeForControl = current.GetTypeForControl(controlId); switch (typeForControl) { case EventType.MouseDown: if (pos.Contains(current.mousePosition) && GUIUtility.hotControl == 0) { int tabAtMousePos = this.GetTabAtMousePos(current.mousePosition, pos); if (tabAtMousePos < this.m_Panes.Count) { switch (current.button) { case 0: if (tabAtMousePos != this.selected) { this.selected = tabAtMousePos; } GUIUtility.hotControl = controlId; DockArea.s_StartDragPosition = current.mousePosition; DockArea.s_DragMode = 0; current.Use(); break; case 2: this.m_Panes[tabAtMousePos].Close(); current.Use(); break; } } else { break; } } else { break; } case EventType.MouseUp: if (GUIUtility.hotControl == controlId) { Vector2 screenPoint = GUIUtility.GUIToScreenPoint(current.mousePosition); if (DockArea.s_DragMode != 0) { DockArea.s_DragMode = 0; PaneDragTab.get.Close(); EditorApplication.update -= new EditorApplication.CallbackFunction(DockArea.CheckDragWindowExists); if (DockArea.s_DropInfo != null && DockArea.s_DropInfo.dropArea != null) { DockArea.s_DropInfo.dropArea.PerformDrop(DockArea.s_DragPane, DockArea.s_DropInfo, screenPoint); } else { EditorWindow dragPane = DockArea.s_DragPane; DockArea.ResetDragVars(); this.RemoveTab(dragPane); Rect position = dragPane.position; position.x = screenPoint.x - position.width * 0.5f; position.y = screenPoint.y - position.height * 0.5f; if (Application.platform == RuntimePlatform.WindowsEditor) { position.y = Mathf.Max(InternalEditorUtility.GetBoundsOfDesktopAtPoint(screenPoint).y, position.y); } EditorWindow.CreateNewWindowForEditorWindow(dragPane, false, false); dragPane.position = dragPane.m_Parent.window.FitWindowRectToScreen(position, true, true); GUIUtility.hotControl = 0; GUIUtility.ExitGUI(); } DockArea.ResetDragVars(); } GUIUtility.hotControl = 0; current.Use(); break; } break; case EventType.MouseDrag: if (GUIUtility.hotControl == controlId) { Vector2 vector2 = current.mousePosition - DockArea.s_StartDragPosition; current.Use(); Rect screenPosition = this.screenPosition; if (DockArea.s_DragMode == 0 && (double)vector2.sqrMagnitude > 99.0) { DockArea.s_DragMode = 1; DockArea.s_PlaceholderPos = this.selected; DockArea.s_DragPane = this.m_Panes[this.selected]; DockArea.s_IgnoreDockingForView = this.m_Panes.Count != 1 ? (View)null : (View)this; DockArea.s_OriginalDragSource = this; PaneDragTab.get.content = DockArea.s_DragPane.titleContent; this.Internal_SetAsActiveWindow(); PaneDragTab.get.GrabThumbnail(); PaneDragTab.get.Show(new Rect((float)((double)pos.x + (double)screenPosition.x + (double)tabWidth * (double)this.selected), pos.y + screenPosition.y, tabWidth, pos.height), GUIUtility.GUIToScreenPoint(current.mousePosition)); EditorApplication.update += new EditorApplication.CallbackFunction(DockArea.CheckDragWindowExists); GUIUtility.ExitGUI(); } if (DockArea.s_DragMode == 1) { DropInfo di = (DropInfo)null; ContainerWindow[] windows = ContainerWindow.windows; Vector2 screenPoint = GUIUtility.GUIToScreenPoint(current.mousePosition); ContainerWindow inFrontOf = (ContainerWindow)null; foreach (ContainerWindow containerWindow in windows) { foreach (View allChild in containerWindow.mainView.allChildren) { IDropArea dropArea = allChild as IDropArea; if (dropArea != null) { di = dropArea.DragOver(DockArea.s_DragPane, screenPoint); } if (di != null) { break; } } if (di != null) { inFrontOf = containerWindow; break; } } if (di == null) { di = new DropInfo((IDropArea)null); } if (di.type != DropInfo.Type.Tab) { DockArea.s_PlaceholderPos = -1; } DockArea.s_DropInfo = di; if ((bool)((UnityEngine.Object)PaneDragTab.get.m_Window)) { PaneDragTab.get.SetDropInfo(di, screenPoint, inFrontOf); break; } break; } break; } break; case EventType.Repaint: float xMin = pos.xMin; int num = 0; if ((bool)((UnityEngine.Object) this.actualView)) { for (int index = 0; index < this.m_Panes.Count; ++index) { if (!((UnityEngine.Object)DockArea.s_DragPane == (UnityEngine.Object) this.m_Panes[index])) { if (DockArea.s_DropInfo != null && object.ReferenceEquals((object)DockArea.s_DropInfo.dropArea, (object)this) && DockArea.s_PlaceholderPos == num) { xMin += tabWidth; } Rect rect = new Rect(xMin, pos.yMin, tabWidth, pos.height); float x = Mathf.Round(rect.x); Rect position = new Rect(x, rect.y, Mathf.Round(rect.x + rect.width) - x, rect.height); tabStyle.Draw(position, this.m_Panes[index].titleContent, false, false, index == this.selected, this.hasFocus); xMin += tabWidth; ++num; } } break; } Rect rect1 = new Rect(xMin, pos.yMin, tabWidth, pos.height); float x1 = Mathf.Round(rect1.x); Rect position1 = new Rect(x1, rect1.y, Mathf.Round(rect1.x + rect1.width) - x1, rect1.height); tabStyle.Draw(position1, "Failed to load", false, false, true, false); break; default: if (typeForControl == EventType.ContextClick && pos.Contains(current.mousePosition) && GUIUtility.hotControl == 0) { int tabAtMousePos = this.GetTabAtMousePos(current.mousePosition, pos); if (tabAtMousePos < this.m_Panes.Count) { this.PopupGenericMenu(this.m_Panes[tabAtMousePos], new Rect(current.mousePosition.x, current.mousePosition.y, 0.0f, 0.0f)); break; } break; } break; } this.selected = Mathf.Clamp(this.selected, 0, this.m_Panes.Count - 1); }
private float DragTab(Rect tabAreaRect, float scrollOffset, GUIStyle tabStyle, GUIStyle firstTabStyle) { Event evt = Event.current; int id = GUIUtility.GetControlID(FocusType.Passive); // Detect if hotcontrol was cleared while dragging (happens when pressing Esc). // We do not listen for the Escape keydown event because it is sent to the dragged window (not this dockarea) if (s_DragMode != 0 && GUIUtility.hotControl == 0) { PaneDragTab.get.Close(); ResetDragVars(); } float xPos = 0f; switch (evt.GetTypeForControl(id)) { case EventType.MouseDown: if (GUIUtility.hotControl == 0) { int sel = GetTabAtMousePos(tabStyle, evt.mousePosition, scrollOffset, tabAreaRect); if (sel != -1 && sel < m_Panes.Count) { switch (evt.button) { case 0: if (selected != sel) { selected = sel; } GUIUtility.hotControl = id; s_StartDragPosition = evt.mousePosition; s_DragMode = 0; evt.Use(); break; case 2: m_Panes[sel].Close(); evt.Use(); break; } } } break; case EventType.ContextClick: if (GUIUtility.hotControl == 0) { int sel = GetTabAtMousePos(tabStyle, evt.mousePosition, scrollOffset, tabAreaRect); var menuPos = new Rect(evt.mousePosition.x, evt.mousePosition.y, 0, 0); if (sel != -1 && sel < m_Panes.Count && !ContainerWindow.s_Modal) { PopupGenericMenu(m_Panes[sel], menuPos); } else if (!ContainerWindow.s_Modal && m_Panes.Count == 0) // i.e. all panes have failed to load { PopupGenericMenu(null, menuPos); } } break; case EventType.MouseDrag: if (GUIUtility.hotControl == id) { Vector2 delta = evt.mousePosition - s_StartDragPosition; evt.Use(); Rect screenRect = screenPosition; // if we're not tab dragging yet, check to see if we should start // If modal window exists, disable all tab behavior if (ContainerWindow.s_Modal) { break; } // check if we're allowed to drag tab bool dragAllowed = (window.showMode != ShowMode.MainWindow || AllowTabAction()); if (s_DragMode == 0 && delta.sqrMagnitude > 99 && dragAllowed) { s_DragMode = 1; s_PlaceholderPos = selected; s_DragPane = m_Panes[selected]; // If we're moving the only editorwindow in this dockarea, we'll be destroyed - so it looks silly if we can attach as children of ourselves s_IgnoreDockingForView = m_Panes.Count == 1 ? this : null; s_OriginalDragSource = this; float tabWidth = GetTabWidth(tabStyle, selected); PaneDragTab.get.Show( new Rect(tabAreaRect.x + screenRect.x + tabWidth * selected, tabAreaRect.y + screenRect.y, tabWidth, tabAreaRect.height - 1f), s_DragPane.titleContent, position.size, GUIUtility.GUIToScreenPoint(evt.mousePosition) ); EditorApplication.update += CheckDragWindowExists; Invoke("OnTabDragging", s_DragPane); // We just showed a window. Exit the GUI because the window might be // repainting already (esp. on Windows) GUIUtility.ExitGUI(); } if (s_DragMode == 1) { // Go over all container windows, ask them to dock the window. DropInfo di = null; ContainerWindow[] windows = ContainerWindow.windows; Vector2 screenMousePos = GUIUtility.GUIToScreenPoint(evt.mousePosition); ContainerWindow win = null; foreach (ContainerWindow w in windows) { var rootSplitView = w.rootSplitView; if (rootSplitView == null) { continue; } di = rootSplitView.DragOverRootView(screenMousePos); if (di == null) { foreach (View view in w.rootView.allChildren) { IDropArea ida = view as IDropArea; if (ida != null) { di = ida.DragOver(s_DragPane, screenMousePos); } if (di != null) { break; } } } if (di != null) { win = w; break; } } // Ok, we couldn't find anything, let's create a simplified DropIn if (di == null) { di = new DropInfo(null); } if (di.type != DropInfo.Type.Tab) { s_PlaceholderPos = -1; } s_DropInfo = di; // Handle the window getting closed mid-drag if (PaneDragTab.get.m_Window) { PaneDragTab.get.SetDropInfo(di, screenMousePos, win); } } } break; case EventType.MouseUp: if (GUIUtility.hotControl == id) { Vector2 screenMousePos = GUIUtility.GUIToScreenPoint(evt.mousePosition); if (s_DragMode != 0) { // This is where we want to insert it. s_DragMode = 0; PaneDragTab.get.Close(); EditorApplication.update -= CheckDragWindowExists; // Try to tell the current DPZ if (s_DropInfo?.dropArea != null) { Invoke("OnTabDetached", s_DragPane); s_DropInfo.dropArea.PerformDrop(s_DragPane, s_DropInfo, screenMousePos); UpdateWindowTitle(s_DragPane); } else { EditorWindow w = s_DragPane; ResetDragVars(); // The active tab that we're moving to the new window stays focused at all times. // Do not remove focus from the tab being detached. RemoveTab(w, killIfEmpty: true, sendEvents: false); Rect wPos = w.position; wPos.x = screenMousePos.x - wPos.width * .5f; wPos.y = screenMousePos.y - wPos.height * .5f; // don't put windows top outside of the screen, on mac OS handles this if (Application.platform == RuntimePlatform.WindowsEditor) { wPos.y = Mathf.Max(InternalEditorUtility.GetBoundsOfDesktopAtPoint(screenMousePos).y, wPos.y); } // Don't call OnFocus on the tab when it is moved to the new window EditorWindow.CreateNewWindowForEditorWindow(w, loadPosition: false, showImmediately: false, setFocus: false); w.position = w.m_Parent.window.FitWindowRectToScreen(wPos, true, true); Invoke("OnTabNewWindow", w); GUIUtility.hotControl = 0; GUIUtility.ExitGUI(); } ResetDragVars(); } GUIUtility.hotControl = 0; evt.Use(); } break; case EventType.Repaint: xPos = tabAreaRect.xMin; if (actualView) { for (int i = 0, drawNum = 0; i < m_Panes.Count; i++) { // If we're dragging the tab we're about to draw, don't do that (handled by some window) if (s_DragPane == m_Panes[i]) { continue; } // If we need space for inserting a tab here, skip some horizontal if (s_DropInfo != null && ReferenceEquals(s_DropInfo.dropArea, this) && s_PlaceholderPos == drawNum) { xPos += s_DropInfo.rect.width; } var style = i == 0 ? firstTabStyle : tabStyle; xPos += DrawTab(tabAreaRect, style, i, xPos); drawNum++; } } else { Rect r = new Rect(xPos, tabAreaRect.yMin, Styles.tabDragWidth, tabAreaRect.height); float roundR = Mathf.Round(r.x); Rect r2 = new Rect(roundR, r.y, Mathf.Round(r.x + r.width) - roundR, r.height); tabStyle.Draw(r2, "Failed to load", false, true, true, false); } break; } selected = Mathf.Clamp(selected, 0, m_Panes.Count - 1); return(xPos); }
void Xceed.Wpf.AvalonDock.Controls.IOverlayWindow.DragEnter(IDropArea area) { FrameworkElement width; System.Windows.Visibility visibility; System.Windows.Visibility visibility1; System.Windows.Visibility visibility2; System.Windows.Visibility visibility3; this._visibleAreas.Add(area); switch (area.Type) { case DropAreaType.DockingManager: { width = this._gridDockingManagerDropTargets; break; } case DropAreaType.DocumentPane: { if (!(this._floatingWindow.Model is LayoutAnchorableFloatingWindow) || this._gridDocumentPaneFullDropTargets == null) { width = this._gridDocumentPaneDropTargets; LayoutDocumentPane model = (area as DropArea <LayoutDocumentPaneControl>).AreaElement.Model as LayoutDocumentPane; LayoutDocumentPaneGroup parent = model.Parent as LayoutDocumentPaneGroup; if (parent != null) { if (( from c in parent.Children where c.IsVisible select c).Count <ILayoutDocumentPane>() > 1) { if (parent.Root.Manager.AllowMixedOrientation) { this._documentPaneDropTargetLeft.Visibility = System.Windows.Visibility.Visible; this._documentPaneDropTargetRight.Visibility = System.Windows.Visibility.Visible; this._documentPaneDropTargetTop.Visibility = System.Windows.Visibility.Visible; this._documentPaneDropTargetBottom.Visibility = System.Windows.Visibility.Visible; break; } else { this._documentPaneDropTargetLeft.Visibility = (parent.Orientation == Orientation.Horizontal ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden); this._documentPaneDropTargetRight.Visibility = (parent.Orientation == Orientation.Horizontal ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden); this._documentPaneDropTargetTop.Visibility = (parent.Orientation == Orientation.Vertical ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden); this._documentPaneDropTargetBottom.Visibility = (parent.Orientation == Orientation.Vertical ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden); break; } } } if (parent != null || model == null || model.ChildrenCount != 0) { this._documentPaneDropTargetLeft.Visibility = System.Windows.Visibility.Visible; this._documentPaneDropTargetRight.Visibility = System.Windows.Visibility.Visible; this._documentPaneDropTargetTop.Visibility = System.Windows.Visibility.Visible; this._documentPaneDropTargetBottom.Visibility = System.Windows.Visibility.Visible; break; } else { this._documentPaneDropTargetLeft.Visibility = System.Windows.Visibility.Hidden; this._documentPaneDropTargetRight.Visibility = System.Windows.Visibility.Hidden; this._documentPaneDropTargetTop.Visibility = System.Windows.Visibility.Hidden; this._documentPaneDropTargetBottom.Visibility = System.Windows.Visibility.Hidden; break; } } else { width = this._gridDocumentPaneFullDropTargets; LayoutDocumentPane layoutDocumentPane = (area as DropArea <LayoutDocumentPaneControl>).AreaElement.Model as LayoutDocumentPane; LayoutDocumentPaneGroup layoutDocumentPaneGroup = layoutDocumentPane.Parent as LayoutDocumentPaneGroup; if (layoutDocumentPaneGroup != null) { if (( from c in layoutDocumentPaneGroup.Children where c.IsVisible select c).Count <ILayoutDocumentPane>() <= 1) { goto Label1; } if (layoutDocumentPaneGroup.Root.Manager.AllowMixedOrientation) { this._documentPaneFullDropTargetLeft.Visibility = System.Windows.Visibility.Visible; this._documentPaneFullDropTargetRight.Visibility = System.Windows.Visibility.Visible; this._documentPaneFullDropTargetTop.Visibility = System.Windows.Visibility.Visible; this._documentPaneFullDropTargetBottom.Visibility = System.Windows.Visibility.Visible; goto Label0; } else { this._documentPaneFullDropTargetLeft.Visibility = (layoutDocumentPaneGroup.Orientation == Orientation.Horizontal ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden); this._documentPaneFullDropTargetRight.Visibility = (layoutDocumentPaneGroup.Orientation == Orientation.Horizontal ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden); this._documentPaneFullDropTargetTop.Visibility = (layoutDocumentPaneGroup.Orientation == Orientation.Vertical ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden); this._documentPaneFullDropTargetBottom.Visibility = (layoutDocumentPaneGroup.Orientation == Orientation.Vertical ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden); goto Label0; } } Label1: if (layoutDocumentPaneGroup != null || layoutDocumentPane == null || layoutDocumentPane.ChildrenCount != 0) { this._documentPaneFullDropTargetLeft.Visibility = System.Windows.Visibility.Visible; this._documentPaneFullDropTargetRight.Visibility = System.Windows.Visibility.Visible; this._documentPaneFullDropTargetTop.Visibility = System.Windows.Visibility.Visible; this._documentPaneFullDropTargetBottom.Visibility = System.Windows.Visibility.Visible; } else { this._documentPaneFullDropTargetLeft.Visibility = System.Windows.Visibility.Hidden; this._documentPaneFullDropTargetRight.Visibility = System.Windows.Visibility.Hidden; this._documentPaneFullDropTargetTop.Visibility = System.Windows.Visibility.Hidden; this._documentPaneFullDropTargetBottom.Visibility = System.Windows.Visibility.Hidden; } Label0: if (layoutDocumentPaneGroup != null) { if (( from c in layoutDocumentPaneGroup.Children where c.IsVisible select c).Count <ILayoutDocumentPane>() > 1) { int num = ( from ch in layoutDocumentPaneGroup.Children where ch.IsVisible select ch).ToList <ILayoutDocumentPane>().IndexOf(layoutDocumentPane); bool flag = num == 0; bool childrenCount = num == layoutDocumentPaneGroup.ChildrenCount - 1; if (layoutDocumentPaneGroup.Root.Manager.AllowMixedOrientation) { this._documentPaneDropTargetBottomAsAnchorablePane.Visibility = System.Windows.Visibility.Visible; this._documentPaneDropTargetLeftAsAnchorablePane.Visibility = System.Windows.Visibility.Visible; this._documentPaneDropTargetRightAsAnchorablePane.Visibility = System.Windows.Visibility.Visible; this._documentPaneDropTargetTopAsAnchorablePane.Visibility = System.Windows.Visibility.Visible; break; } else { FrameworkElement frameworkElement = this._documentPaneDropTargetBottomAsAnchorablePane; if (layoutDocumentPaneGroup.Orientation == Orientation.Vertical) { visibility = (childrenCount ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden); } else { visibility = System.Windows.Visibility.Hidden; } frameworkElement.Visibility = visibility; FrameworkElement frameworkElement1 = this._documentPaneDropTargetTopAsAnchorablePane; if (layoutDocumentPaneGroup.Orientation == Orientation.Vertical) { visibility1 = (flag ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden); } else { visibility1 = System.Windows.Visibility.Hidden; } frameworkElement1.Visibility = visibility1; FrameworkElement frameworkElement2 = this._documentPaneDropTargetLeftAsAnchorablePane; if (layoutDocumentPaneGroup.Orientation == Orientation.Horizontal) { visibility2 = (flag ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden); } else { visibility2 = System.Windows.Visibility.Hidden; } frameworkElement2.Visibility = visibility2; FrameworkElement frameworkElement3 = this._documentPaneDropTargetRightAsAnchorablePane; if (layoutDocumentPaneGroup.Orientation == Orientation.Horizontal) { visibility3 = (childrenCount ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden); } else { visibility3 = System.Windows.Visibility.Hidden; } frameworkElement3.Visibility = visibility3; break; } } } this._documentPaneDropTargetBottomAsAnchorablePane.Visibility = System.Windows.Visibility.Visible; this._documentPaneDropTargetLeftAsAnchorablePane.Visibility = System.Windows.Visibility.Visible; this._documentPaneDropTargetRightAsAnchorablePane.Visibility = System.Windows.Visibility.Visible; this._documentPaneDropTargetTopAsAnchorablePane.Visibility = System.Windows.Visibility.Visible; break; } } case DropAreaType.DocumentPaneGroup: { width = this._gridDocumentPaneDropTargets; ILayoutContainer layoutContainer = (((area as DropArea <LayoutDocumentPaneGroupControl>).AreaElement.Model as LayoutDocumentPaneGroup).Children.First <ILayoutDocumentPane>() as LayoutDocumentPane).Parent; this._documentPaneDropTargetLeft.Visibility = System.Windows.Visibility.Hidden; this._documentPaneDropTargetRight.Visibility = System.Windows.Visibility.Hidden; this._documentPaneDropTargetTop.Visibility = System.Windows.Visibility.Hidden; this._documentPaneDropTargetBottom.Visibility = System.Windows.Visibility.Hidden; break; } case DropAreaType.AnchorablePane: { width = this._gridAnchorablePaneDropTargets; break; } default: { goto case DropAreaType.DocumentPane; } } Rect detectionRect = area.DetectionRect; Canvas.SetLeft(width, detectionRect.Left - base.Left); detectionRect = area.DetectionRect; Canvas.SetTop(width, detectionRect.Top - base.Top); width.Width = area.DetectionRect.Width; width.Height = area.DetectionRect.Height; width.Visibility = System.Windows.Visibility.Visible; }
public DropInfo(IDropArea source) { dropArea = source; }
private void DragTab(Rect pos, GUIStyle tabStyle) { int controlID = GUIUtility.GetControlID(FocusType.Passive); float tabWidth = this.GetTabWidth(pos.width); Event current = Event.current; if ((s_DragMode != 0) && (GUIUtility.hotControl == 0)) { PaneDragTab.get.Close(); ResetDragVars(); } EventType typeForControl = current.GetTypeForControl(controlID); switch (typeForControl) { case EventType.MouseDown: if (pos.Contains(current.mousePosition) && (GUIUtility.hotControl == 0)) { int tabAtMousePos = this.GetTabAtMousePos(current.mousePosition, pos); if (tabAtMousePos < this.m_Panes.Count) { switch (current.button) { case 0: if (tabAtMousePos != this.selected) { this.selected = tabAtMousePos; } GUIUtility.hotControl = controlID; s_StartDragPosition = current.mousePosition; s_DragMode = 0; current.Use(); break; case 2: this.m_Panes[tabAtMousePos].Close(); current.Use(); break; } } } goto Label_06B9; case EventType.MouseUp: if (GUIUtility.hotControl == controlID) { Vector2 vector3 = GUIUtility.GUIToScreenPoint(current.mousePosition); if (s_DragMode != 0) { s_DragMode = 0; PaneDragTab.get.Close(); EditorApplication.update = (EditorApplication.CallbackFunction)Delegate.Remove(EditorApplication.update, new EditorApplication.CallbackFunction(DockArea.CheckDragWindowExists)); if ((s_DropInfo == null) || (s_DropInfo.dropArea == null)) { EditorWindow pane = s_DragPane; ResetDragVars(); this.RemoveTab(pane); Rect position = pane.position; position.x = vector3.x - (position.width * 0.5f); position.y = vector3.y - (position.height * 0.5f); if (Application.platform == RuntimePlatform.WindowsEditor) { position.y = Mathf.Max(InternalEditorUtility.GetBoundsOfDesktopAtPoint(vector3).y, position.y); } EditorWindow.CreateNewWindowForEditorWindow(pane, false, false); pane.position = pane.m_Parent.window.FitWindowRectToScreen(position, true, true); GUIUtility.hotControl = 0; GUIUtility.ExitGUI(); } else { s_DropInfo.dropArea.PerformDrop(s_DragPane, s_DropInfo, vector3); } ResetDragVars(); } GUIUtility.hotControl = 0; current.Use(); } goto Label_06B9; case EventType.MouseDrag: if (GUIUtility.hotControl == controlID) { Vector2 vector = current.mousePosition - s_StartDragPosition; current.Use(); Rect screenPosition = base.screenPosition; if ((s_DragMode == 0) && (vector.sqrMagnitude > 99f)) { s_DragMode = 1; s_PlaceholderPos = this.selected; s_DragPane = this.m_Panes[this.selected]; if (this.m_Panes.Count != 1) { s_IgnoreDockingForView = null; } else { s_IgnoreDockingForView = this; } s_OriginalDragSource = this; PaneDragTab.get.content = s_DragPane.titleContent; base.Internal_SetAsActiveWindow(); PaneDragTab.get.GrabThumbnail(); PaneDragTab.get.Show(new Rect((pos.x + screenPosition.x) + (tabWidth * this.selected), pos.y + screenPosition.y, tabWidth, pos.height), GUIUtility.GUIToScreenPoint(current.mousePosition)); EditorApplication.update = (EditorApplication.CallbackFunction)Delegate.Combine(EditorApplication.update, new EditorApplication.CallbackFunction(DockArea.CheckDragWindowExists)); GUIUtility.ExitGUI(); } if (s_DragMode == 1) { DropInfo di = null; ContainerWindow[] windows = ContainerWindow.windows; Vector2 screenPos = GUIUtility.GUIToScreenPoint(current.mousePosition); ContainerWindow inFrontOf = null; foreach (ContainerWindow window2 in windows) { foreach (View view in window2.mainView.allChildren) { IDropArea area = view as IDropArea; if (area != null) { di = area.DragOver(s_DragPane, screenPos); } if (di != null) { break; } } if (di != null) { inFrontOf = window2; break; } } if (di == null) { di = new DropInfo(null); } if (di.type != DropInfo.Type.Tab) { s_PlaceholderPos = -1; } s_DropInfo = di; if (PaneDragTab.get.m_Window != null) { PaneDragTab.get.SetDropInfo(di, screenPos, inFrontOf); } } } goto Label_06B9; case EventType.Repaint: { float xMin = pos.xMin; int num8 = 0; if (base.actualView == null) { Rect rect5 = new Rect(xMin, pos.yMin, tabWidth, pos.height); float x = Mathf.Round(rect5.x); Rect rect6 = new Rect(x, rect5.y, Mathf.Round(rect5.x + rect5.width) - x, rect5.height); tabStyle.Draw(rect6, "Failed to load", false, false, true, false); } else { for (int i = 0; i < this.m_Panes.Count; i++) { if (s_DragPane != this.m_Panes[i]) { if (((s_DropInfo != null) && object.ReferenceEquals(s_DropInfo.dropArea, this)) && (s_PlaceholderPos == num8)) { xMin += tabWidth; } Rect rect3 = new Rect(xMin, pos.yMin, tabWidth, pos.height); float num10 = Mathf.Round(rect3.x); Rect rect4 = new Rect(num10, rect3.y, Mathf.Round(rect3.x + rect3.width) - num10, rect3.height); tabStyle.Draw(rect4, this.m_Panes[i].titleContent, false, false, i == this.selected, base.hasFocus); xMin += tabWidth; num8++; } } } goto Label_06B9; } } if ((typeForControl == EventType.ContextClick) && (pos.Contains(current.mousePosition) && (GUIUtility.hotControl == 0))) { int num4 = this.GetTabAtMousePos(current.mousePosition, pos); if (num4 < this.m_Panes.Count) { base.PopupGenericMenu(this.m_Panes[num4], new Rect(current.mousePosition.x, current.mousePosition.y, 0f, 0f)); } } Label_06B9: this.selected = Mathf.Clamp(this.selected, 0, this.m_Panes.Count - 1); }