ResetDragVars() private static method

private static ResetDragVars ( ) : void
return void
示例#1
0
 private static void CheckDragWindowExists()
 {
     if (DockArea.s_DragMode == 1 && !PaneDragTab.get.m_Window)
     {
         DockArea.s_OriginalDragSource.RemoveTab(DockArea.s_DragPane);
         UnityEngine.Object.DestroyImmediate(DockArea.s_DragPane);
         PaneDragTab.get.Close();
         GUIUtility.hotControl = 0;
         DockArea.ResetDragVars();
     }
 }
示例#2
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)
                    {
                        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);
        }
示例#3
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)
                    {
                        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);
        }