UnityEditor.SplitView.DragOverRootView C# (CSharp) Method

DragOverRootView() public method

public DragOverRootView ( Vector2 mouseScreenPosition ) : DropInfo
mouseScreenPosition Vector2
return DropInfo
        public DropInfo DragOverRootView(Vector2 mouseScreenPosition)
        {
            if ((base.children.Length == 1) && (DockArea.s_IgnoreDockingForView == base.children[0]))
            {
                return null;
            }
            DropInfo info1 = this.RootViewDropZone(ViewEdge.Bottom, mouseScreenPosition, base.screenPosition);
            if (info1 != null)
            {
                return info1;
            }
            DropInfo info2 = this.RootViewDropZone(ViewEdge.Top, mouseScreenPosition, base.screenPosition);
            if (info2 != null)
            {
                return info2;
            }
            DropInfo info3 = this.RootViewDropZone(ViewEdge.Left, mouseScreenPosition, base.screenPosition);
            if (info3 != null)
            {
                return info3;
            }
            return this.RootViewDropZone(ViewEdge.Right, mouseScreenPosition, base.screenPosition);
        }

Usage Example

示例#1
0
        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)
                    {
                        int button = current.button;
                        if (button != 0)
                        {
                            if (button == 2)
                            {
                                this.m_Panes[tabAtMousePos].Close();
                                current.Use();
                            }
                        }
                        else
                        {
                            if (tabAtMousePos != this.selected)
                            {
                                this.selected = tabAtMousePos;
                            }
                            GUIUtility.hotControl        = controlID;
                            DockArea.s_StartDragPosition = current.mousePosition;
                            DockArea.s_DragMode          = 0;
                            current.Use();
                        }
                    }
                }
                goto IL_746;

            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();
                        Delegate arg_49F_0 = EditorApplication.update;
                        if (DockArea.< > f__mg$cache1 == null)
                        {
                            DockArea.< > f__mg$cache1 = new EditorApplication.CallbackFunction(DockArea.CheckDragWindowExists);
                        }
                        EditorApplication.update = (EditorApplication.CallbackFunction)Delegate.Remove(arg_49F_0, DockArea.< > f__mg$cache1);
                        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_746;

            case EventType.MouseMove:
            case EventType.KeyDown:
            case EventType.KeyUp:
            case EventType.ScrollWheel:
IL_6F:
                if (typeForControl != EventType.ContextClick)
                {
                    goto IL_746;
                }
                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_746;

            case EventType.MouseDrag:
                if (GUIUtility.hotControl == controlID)
                {
                    Vector2 vector2 = current.mousePosition - DockArea.s_StartDragPosition;
                    current.Use();
                    Rect screenPosition = base.screenPosition;
                    bool flag           = base.window.showMode != ShowMode.MainWindow || this.AllowTabAction();
                    if (DockArea.s_DragMode == 0 && vector2.sqrMagnitude > 99f && flag)
                    {
                        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.Show(new Rect(pos.x + screenPosition.x + tabWidth * (float)this.selected, pos.y + screenPosition.y, tabWidth, pos.height), DockArea.s_DragPane.titleContent, base.position.size, GUIUtility.GUIToScreenPoint(current.mousePosition));
                        Delegate arg_2F5_0 = EditorApplication.update;
                        if (DockArea.< > f__mg$cache0 == null)
                        {
                            DockArea.< > f__mg$cache0 = new EditorApplication.CallbackFunction(DockArea.CheckDragWindowExists);
                        }
                        EditorApplication.update = (EditorApplication.CallbackFunction)Delegate.Combine(arg_2F5_0, DockArea.< > f__mg$cache0);
                        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];
                            SplitView       rootSplitView   = containerWindow.rootSplitView;
                            if (!(rootSplitView == null))
                            {
                                dropInfo = rootSplitView.DragOverRootView(vector3);
                                if (dropInfo == null)
                                {
                                    View[] allChildren = containerWindow.rootView.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_746;

            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].titleContent, 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_746;
            }
            }
            goto IL_6F;
IL_746:
            this.selected = Mathf.Clamp(this.selected, 0, this.m_Panes.Count - 1);
        }