Пример #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)
                    {
                        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);
        }
Пример #2
0
        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);
        }
Пример #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);
        }
Пример #4
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 ((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);
        }