예제 #1
0
		public void SetDropInfo(DropInfo di, Vector2 mouseScreenPos, ContainerWindow inFrontOf)
		{
			if (this.m_Type != di.type || (di.type == DropInfo.Type.Pane && di.rect != this.m_TargetRect))
			{
				this.m_Type = di.type;
				this.m_StartRect = this.GetInterpolatedRect(this.CalcFade());
				this.m_StartTime = Time.realtimeSinceStartup;
				switch (di.type)
				{
				case DropInfo.Type.Tab:
				case DropInfo.Type.Pane:
					this.m_TargetAlpha = 1f;
					break;
				case DropInfo.Type.Window:
					this.m_TargetAlpha = 0.6f;
					break;
				}
			}
			switch (di.type)
			{
			case DropInfo.Type.Tab:
			case DropInfo.Type.Pane:
				this.m_TargetRect = di.rect;
				break;
			case DropInfo.Type.Window:
				this.m_TargetRect = new Rect(mouseScreenPos.x - this.m_ThumbnailSize.x / 2f, mouseScreenPos.y - this.m_ThumbnailSize.y / 2f, this.m_ThumbnailSize.x, this.m_ThumbnailSize.y);
				break;
			}
			this.m_PaneVisible.target = (di.type == DropInfo.Type.Pane);
			this.m_TabVisible.target = (di.type == DropInfo.Type.Tab);
			this.m_TargetRect.x = Mathf.Round(this.m_TargetRect.x);
			this.m_TargetRect.y = Mathf.Round(this.m_TargetRect.y);
			this.m_TargetRect.width = Mathf.Round(this.m_TargetRect.width);
			this.m_TargetRect.height = Mathf.Round(this.m_TargetRect.height);
			this.m_InFrontOfWindow = inFrontOf;
			this.m_Window.MoveInFrontOf(this.m_InFrontOfWindow);
			this.SetWindowPos(this.GetInterpolatedRect(this.CalcFade()));
			base.Repaint();
		}
예제 #2
0
        public void SetDropInfo(DropInfo di, Vector2 mouseScreenPos, ContainerWindow inFrontOf)
        {
            if ((this.m_Type != di.type) || ((di.type == DropInfo.Type.Pane) && (di.rect != this.m_TargetRect)))
            {
                this.m_Type = di.type;
                switch (di.type)
                {
                    case DropInfo.Type.Window:
                        this.m_TargetAlpha = 0.6f;
                        break;

                    case DropInfo.Type.Pane:
                    case DropInfo.Type.Tab:
                        this.m_TargetAlpha = 1f;
                        break;
                }
            }
            switch (di.type)
            {
                case DropInfo.Type.Window:
                    this.m_TargetRect = new Rect(mouseScreenPos.x - (this.m_FullWindowSize.x / 2f), mouseScreenPos.y - (this.m_FullWindowSize.y / 2f), this.m_FullWindowSize.x, this.m_FullWindowSize.y);
                    break;

                case DropInfo.Type.Pane:
                case DropInfo.Type.Tab:
                    this.m_TargetRect = di.rect;
                    break;
            }
            this.m_TabVisible = di.type == DropInfo.Type.Tab;
            this.m_TargetRect.x = Mathf.Round(this.m_TargetRect.x);
            this.m_TargetRect.y = Mathf.Round(this.m_TargetRect.y);
            this.m_TargetRect.width = Mathf.Round(this.m_TargetRect.width);
            this.m_TargetRect.height = Mathf.Round(this.m_TargetRect.height);
            this.m_InFrontOfWindow = inFrontOf;
            this.m_Window.MoveInFrontOf(this.m_InFrontOfWindow);
            this.SetWindowPos(this.m_TargetRect);
            base.Repaint();
        }
예제 #3
0
 public bool PerformDrop(EditorWindow w, DropInfo info, Vector2 screenPos)
 {
     s_OriginalDragSource.RemoveTab(w, s_OriginalDragSource != this);
     int idx = (s_PlaceholderPos <= this.m_Panes.Count) ? s_PlaceholderPos : this.m_Panes.Count;
     this.AddTab(idx, w);
     this.selected = idx;
     return true;
 }
예제 #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);
        }
예제 #5
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);
 }
예제 #6
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)
                    {
                        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);
        }
예제 #7
0
        public bool PerformDrop(EditorWindow dropWindow, DropInfo dropInfo, Vector2 screenPos)
        {
            SplitView.ExtraDropInfo extraDropInfo = dropInfo.userData as SplitView.ExtraDropInfo;
            bool rootWindow = extraDropInfo.rootWindow;

            SplitView.ViewEdge edge = extraDropInfo.edge;
            int       num           = extraDropInfo.index;
            Rect      rect          = dropInfo.rect;
            bool      flag          = (edge & SplitView.ViewEdge.TopLeft) != SplitView.ViewEdge.None;
            bool      flag2         = (edge & SplitView.ViewEdge.FitsVertical) != SplitView.ViewEdge.None;
            SplitView splitView;

            if (this.vertical == flag2 || base.children.Length < 2)
            {
                if (!flag)
                {
                    if (rootWindow)
                    {
                        num = base.children.Length;
                    }
                    else
                    {
                        num++;
                    }
                }
                splitView = this;
            }
            else if (rootWindow)
            {
                SplitView splitView2 = ScriptableObject.CreateInstance <SplitView>();
                splitView2.position = base.position;
                if (base.window.rootView == this)
                {
                    base.window.rootView = splitView2;
                }
                else
                {
                    base.parent.AddChild(splitView2, base.parent.IndexOfChild(this));
                }
                splitView2.AddChild(this);
                base.position = new Rect(Vector2.zero, base.position.size);
                num           = ((!flag) ? 1 : 0);
                splitView     = splitView2;
            }
            else
            {
                SplitView splitView3 = ScriptableObject.CreateInstance <SplitView>();
                splitView3.AddChild(base.children[num]);
                this.AddChild(splitView3, num);
                splitView3.position             = splitView3.children[0].position;
                splitView3.children[0].position = new Rect(Vector2.zero, splitView3.position.size);
                num       = ((!flag) ? 1 : 0);
                splitView = splitView3;
            }
            rect.position -= base.screenPosition.position;
            DockArea dockArea = ScriptableObject.CreateInstance <DockArea>();

            splitView.vertical = flag2;
            splitView.MakeRoomForRect(rect);
            splitView.AddChild(dockArea, num);
            dockArea.position = rect;
            DockArea.s_OriginalDragSource.RemoveTab(dropWindow);
            dropWindow.m_Parent = dockArea;
            dockArea.AddTab(dropWindow);
            this.Reflow();
            SplitView.RecalcMinMaxAndReflowAll(this);
            dockArea.MakeVistaDWMHappyDance();
            return(true);
        }
예제 #8
0
        public bool PerformDrop(EditorWindow dropWindow, DropInfo dropInfo, Vector2 screenPos)
        {
            var       extraInfo     = dropInfo.userData as ExtraDropInfo;
            var       rootWindow    = extraInfo.rootWindow;
            var       edge          = extraInfo.edge;
            var       dropIndex     = extraInfo.index;
            var       dropRect      = dropInfo.rect;
            var       beginning     = (edge & ViewEdge.Before) != 0;
            var       wantsVertical = (edge & ViewEdge.FitsVertical) != 0;
            SplitView parentForDrop = null;

            if (vertical == wantsVertical || children.Length < 2)
            { // Current view can accommodate desired drop
                if (!beginning)
                {
                    if (rootWindow)
                    {
                        dropIndex = children.Length;
                    }
                    else
                    {
                        ++dropIndex;
                    }
                }
                parentForDrop = this;
            }
            else if (rootWindow)
            { // Docking to a window: need to insert a parent
                var newParent = ScriptableObject.CreateInstance <SplitView>();
                newParent.position = position;
                if (window.rootView == this)
                {
                    window.rootView = newParent;
                }
                else // Main window has MainView as its root
                {
                    parent.AddChild(newParent, parent.IndexOfChild(this));
                }
                newParent.AddChild(this);
                position = new Rect(Vector2.zero, position.size);

                dropIndex     = beginning ? 0 : 1;
                parentForDrop = newParent;
            }
            else
            { // Docking in a view: need to insert a child
                var newChild = ScriptableObject.CreateInstance <SplitView>();

                newChild.AddChild(children[dropIndex]);
                AddChild(newChild, dropIndex);
                newChild.position             = newChild.children[0].position;
                newChild.children[0].position = new Rect(Vector2.zero, newChild.position.size);

                dropIndex     = beginning ? 0 : 1;
                parentForDrop = newChild;
            }
            dropRect.position = dropRect.position - screenPosition.position;
            var newDockArea = ScriptableObject.CreateInstance <DockArea>();

            parentForDrop.vertical = wantsVertical;
            parentForDrop.MakeRoomForRect(dropRect);
            parentForDrop.AddChild(newDockArea, dropIndex);
            newDockArea.position = dropRect;
            DockArea.s_OriginalDragSource.RemoveTab(dropWindow);
            dropWindow.m_Parent = newDockArea;
            newDockArea.AddTab(dropWindow);
            Reflow();
            RecalcMinMaxAndReflowAll(this);
            newDockArea.MakeVistaDWMHappyDance();
            return(true);
        }
예제 #9
0
        public bool PerformDrop(EditorWindow w, DropInfo di, Vector2 screenPos)
        {
            int      userData = (int)di.userData;
            DockArea child    = ScriptableObject.CreateInstance <DockArea>();
            Rect     r        = di.rect;

            switch (userData)
            {
            case -1:
            case -2:
            case -3:
            {
                bool flag  = userData == -2;
                bool flag2 = userData == -1;
                this.splitState = null;
                if ((this.vertical == flag2) || (base.children.Length < 2))
                {
                    this.vertical = flag2;
                    r.x          -= base.screenPosition.x;
                    r.y          -= base.screenPosition.y;
                    this.MakeRoomForRect(r);
                    this.AddChild(child, !flag ? base.children.Length : 0);
                    child.position = r;
                }
                else
                {
                    SplitView view     = ScriptableObject.CreateInstance <SplitView>();
                    Rect      position = base.position;
                    view.vertical = flag2;
                    view.position = new Rect(position.x, position.y, position.width, position.height);
                    if (base.window.mainView == this)
                    {
                        base.window.mainView = view;
                    }
                    else
                    {
                        base.parent.AddChild(view, base.parent.IndexOfChild(this));
                    }
                    view.AddChild(this);
                    base.position = new Rect(0f, 0f, position.width, position.height);
                    Rect rect3 = r;
                    rect3.x -= base.screenPosition.x;
                    rect3.y -= base.screenPosition.y;
                    view.MakeRoomForRect(rect3);
                    child.position = rect3;
                    view.AddChild(child, !flag ? 1 : 0);
                }
                break;
            }

            default:
                if (userData < 0x3e8)
                {
                    Rect rect4 = r;
                    rect4.x -= base.screenPosition.x;
                    rect4.y -= base.screenPosition.y;
                    this.MakeRoomForRect(rect4);
                    this.AddChild(child, userData);
                    child.position = rect4;
                }
                else
                {
                    int index = userData % 0x3e8;
                    if (base.children.Length != 1)
                    {
                        SplitView view2 = ScriptableObject.CreateInstance <SplitView>();
                        view2.vertical = !this.vertical;
                        Rect rect5 = base.children[index].position;
                        view2.AddChild(base.children[index]);
                        this.AddChild(view2, index);
                        view2.position = rect5;
                        float num3 = 0f;
                        rect5.y = num3;
                        rect5.x = num3;
                        view2.children[0].position = rect5;
                        Rect rect6 = r;
                        rect6.x -= view2.screenPosition.x;
                        rect6.y -= view2.screenPosition.y;
                        view2.MakeRoomForRect(rect6);
                        view2.AddChild(child, (userData >= 0x7d0) ? 1 : 0);
                        child.position = rect6;
                    }
                    else
                    {
                        this.vertical = !this.vertical;
                        Rect rect7 = r;
                        rect7.x -= base.screenPosition.x;
                        rect7.y -= base.screenPosition.y;
                        this.MakeRoomForRect(rect7);
                        this.AddChild(child, (userData != 0x3e8) ? 1 : 0);
                        child.position = rect7;
                    }
                }
                break;
            }
            DockArea.s_OriginalDragSource.RemoveTab(w);
            w.m_Parent = child;
            child.AddTab(w);
            this.Reflow();
            RecalcMinMaxAndReflowAll(this);
            child.MakeVistaDWMHappyDance();
            return(true);
        }
예제 #10
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);
        }
예제 #11
0
 public bool PerformDrop(EditorWindow w, DropInfo di, Vector2 screenPos)
 {
   int userData = (int) di.userData;
   DockArea instance1 = ScriptableObject.CreateInstance<DockArea>();
   Rect rect = di.rect;
   if (userData == -1 || userData == -2 || userData == -3)
   {
     bool flag1 = userData == -2;
     bool flag2 = userData == -1;
     this.splitState = (SplitterState) null;
     if (this.vertical == flag2 || this.children.Length < 2)
     {
       this.vertical = flag2;
       rect.x -= this.screenPosition.x;
       rect.y -= this.screenPosition.y;
       this.MakeRoomForRect(rect);
       this.AddChild((View) instance1, !flag1 ? this.children.Length : 0);
       instance1.position = rect;
     }
     else
     {
       SplitView instance2 = ScriptableObject.CreateInstance<SplitView>();
       Rect position = this.position;
       instance2.vertical = flag2;
       instance2.position = new Rect(position.x, position.y, position.width, position.height);
       if ((Object) this.window.mainView == (Object) this)
         this.window.mainView = (View) instance2;
       else
         this.parent.AddChild((View) instance2, this.parent.IndexOfChild((View) this));
       instance2.AddChild((View) this);
       this.position = new Rect(0.0f, 0.0f, position.width, position.height);
       Rect r = rect;
       r.x -= this.screenPosition.x;
       r.y -= this.screenPosition.y;
       instance2.MakeRoomForRect(r);
       instance1.position = r;
       instance2.AddChild((View) instance1, !flag1 ? 1 : 0);
     }
   }
   else if (userData < 1000)
   {
     Rect r = rect;
     r.x -= this.screenPosition.x;
     r.y -= this.screenPosition.y;
     this.MakeRoomForRect(r);
     this.AddChild((View) instance1, userData);
     instance1.position = r;
   }
   else
   {
     int idx = userData % 1000;
     if (this.children.Length != 1)
     {
       SplitView instance2 = ScriptableObject.CreateInstance<SplitView>();
       instance2.vertical = !this.vertical;
       Rect position = this.children[idx].position;
       instance2.AddChild(this.children[idx]);
       this.AddChild((View) instance2, idx);
       instance2.position = position;
       // ISSUE: explicit reference operation
       // ISSUE: variable of a reference type
       Rect& local = @position;
       float num1 = 0.0f;
       position.y = num1;
       double num2 = (double) num1;
       // ISSUE: explicit reference operation
       (^local).x = (float) num2;
       instance2.children[0].position = position;
       Rect r = rect;
       r.x -= instance2.screenPosition.x;
       r.y -= instance2.screenPosition.y;
       instance2.MakeRoomForRect(r);
       instance2.AddChild((View) instance1, userData >= 2000 ? 1 : 0);
       instance1.position = r;
     }
     else
     {
       this.vertical = !this.vertical;
       Rect r = rect;
       r.x -= this.screenPosition.x;
       r.y -= this.screenPosition.y;
       this.MakeRoomForRect(r);
       this.AddChild((View) instance1, userData != 1000 ? 1 : 0);
       instance1.position = r;
     }
   }
   DockArea.s_OriginalDragSource.RemoveTab(w);
   w.m_Parent = (HostView) instance1;
   instance1.AddTab(w);
   this.Reflow();
   SplitView.RecalcMinMaxAndReflowAll(this);
   instance1.MakeVistaDWMHappyDance();
   return true;
 }
예제 #12
0
 public bool PerformDrop(EditorWindow dropWindow, DropInfo dropInfo, Vector2 screenPos)
 {
     ExtraDropInfo userData = dropInfo.userData as ExtraDropInfo;
     bool rootWindow = userData.rootWindow;
     ViewEdge edge = userData.edge;
     int index = userData.index;
     Rect r = dropInfo.rect;
     bool flag2 = (edge & ViewEdge.Before) != ViewEdge.None;
     bool flag3 = (edge & ViewEdge.FitsVertical) != ViewEdge.None;
     SplitView view = null;
     if ((this.vertical == flag3) || (base.children.Length < 2))
     {
         if (!flag2)
         {
             if (rootWindow)
             {
                 index = base.children.Length;
             }
             else
             {
                 index++;
             }
         }
         view = this;
     }
     else if (rootWindow)
     {
         SplitView view2 = ScriptableObject.CreateInstance<SplitView>();
         view2.position = base.position;
         if (base.window.rootView == this)
         {
             base.window.rootView = view2;
         }
         else
         {
             base.parent.AddChild(view2, base.parent.IndexOfChild(this));
         }
         view2.AddChild(this);
         base.position = new Rect(Vector2.zero, base.position.size);
         index = !flag2 ? 1 : 0;
         view = view2;
     }
     else
     {
         SplitView view3 = ScriptableObject.CreateInstance<SplitView>();
         view3.AddChild(base.children[index]);
         this.AddChild(view3, index);
         view3.position = view3.children[0].position;
         view3.children[0].position = new Rect(Vector2.zero, view3.position.size);
         index = !flag2 ? 1 : 0;
         view = view3;
     }
     r.position -= base.screenPosition.position;
     DockArea child = ScriptableObject.CreateInstance<DockArea>();
     view.vertical = flag3;
     view.MakeRoomForRect(r);
     view.AddChild(child, index);
     child.position = r;
     DockArea.s_OriginalDragSource.RemoveTab(dropWindow);
     dropWindow.m_Parent = child;
     child.AddTab(dropWindow);
     this.Reflow();
     RecalcMinMaxAndReflowAll(this);
     child.MakeVistaDWMHappyDance();
     return true;
 }
예제 #13
0
 public bool PerformDrop(EditorWindow w, DropInfo di, Vector2 screenPos)
 {
     int userData = (int) di.userData;
     DockArea child = ScriptableObject.CreateInstance<DockArea>();
     Rect r = di.rect;
     switch (userData)
     {
         case -1:
         case -2:
         case -3:
         {
             bool flag = userData == -2;
             bool flag2 = userData == -1;
             this.splitState = null;
             if ((this.vertical == flag2) || (base.children.Length < 2))
             {
                 this.vertical = flag2;
                 r.x -= base.screenPosition.x;
                 r.y -= base.screenPosition.y;
                 this.MakeRoomForRect(r);
                 this.AddChild(child, !flag ? base.children.Length : 0);
                 child.position = r;
             }
             else
             {
                 SplitView view = ScriptableObject.CreateInstance<SplitView>();
                 Rect position = base.position;
                 view.vertical = flag2;
                 view.position = new Rect(position.x, position.y, position.width, position.height);
                 if (base.window.mainView == this)
                 {
                     base.window.mainView = view;
                 }
                 else
                 {
                     base.parent.AddChild(view, base.parent.IndexOfChild(this));
                 }
                 view.AddChild(this);
                 base.position = new Rect(0f, 0f, position.width, position.height);
                 Rect rect3 = r;
                 rect3.x -= base.screenPosition.x;
                 rect3.y -= base.screenPosition.y;
                 view.MakeRoomForRect(rect3);
                 child.position = rect3;
                 view.AddChild(child, !flag ? 1 : 0);
             }
             break;
         }
         default:
             if (userData < 0x3e8)
             {
                 Rect rect4 = r;
                 rect4.x -= base.screenPosition.x;
                 rect4.y -= base.screenPosition.y;
                 this.MakeRoomForRect(rect4);
                 this.AddChild(child, userData);
                 child.position = rect4;
             }
             else
             {
                 int index = userData % 0x3e8;
                 if (base.children.Length != 1)
                 {
                     SplitView view2 = ScriptableObject.CreateInstance<SplitView>();
                     view2.vertical = !this.vertical;
                     Rect rect5 = base.children[index].position;
                     view2.AddChild(base.children[index]);
                     this.AddChild(view2, index);
                     view2.position = rect5;
                     float num3 = 0f;
                     rect5.y = num3;
                     rect5.x = num3;
                     view2.children[0].position = rect5;
                     Rect rect6 = r;
                     rect6.x -= view2.screenPosition.x;
                     rect6.y -= view2.screenPosition.y;
                     view2.MakeRoomForRect(rect6);
                     view2.AddChild(child, (userData >= 0x7d0) ? 1 : 0);
                     child.position = rect6;
                 }
                 else
                 {
                     this.vertical = !this.vertical;
                     Rect rect7 = r;
                     rect7.x -= base.screenPosition.x;
                     rect7.y -= base.screenPosition.y;
                     this.MakeRoomForRect(rect7);
                     this.AddChild(child, (userData != 0x3e8) ? 1 : 0);
                     child.position = rect7;
                 }
             }
             break;
     }
     DockArea.s_OriginalDragSource.RemoveTab(w);
     w.m_Parent = child;
     child.AddTab(w);
     this.Reflow();
     RecalcMinMaxAndReflowAll(this);
     child.MakeVistaDWMHappyDance();
     return true;
 }
예제 #14
0
 private static void ResetDragVars()
 {
   DockArea.s_DragPane = (EditorWindow) null;
   DockArea.s_DropInfo = (DropInfo) null;
   DockArea.s_PlaceholderPos = -1;
   DockArea.s_DragMode = 0;
   DockArea.s_OriginalDragSource = (DockArea) null;
 }
예제 #15
0
 private static void ResetDragVars()
 {
     s_DragPane = null;
     s_DropInfo = null;
     s_PlaceholderPos = -1;
     s_DragMode = 0;
     s_OriginalDragSource = null;
 }
예제 #16
0
        public DropInfo DragOver(EditorWindow w, Vector2 mouseScreenPosition)
        {
            DropInfo info = this.CheckRootWindowDropZones(mouseScreenPosition);

            if (info != null)
            {
                return(info);
            }
            for (int i = 0; i < base.children.Length; i++)
            {
                View view = base.children[i];
                if ((view != DockArea.s_IgnoreDockingForView) && !(view is SplitView))
                {
                    Rect  screenPosition = view.screenPosition;
                    int   num2           = 0;
                    float width          = Mathf.Round(Mathf.Min((float)(screenPosition.width / 3f), (float)300f));
                    float height         = Mathf.Round(Mathf.Min((float)(screenPosition.height / 3f), (float)300f));
                    Rect  rect2          = new Rect(screenPosition.x, screenPosition.y + 39f, width, screenPosition.height - 39f);
                    if (rect2.Contains(mouseScreenPosition))
                    {
                        num2 |= 1;
                    }
                    Rect rect3 = new Rect(screenPosition.x, screenPosition.yMax - height, screenPosition.width, height);
                    if (rect3.Contains(mouseScreenPosition))
                    {
                        num2 |= 2;
                    }
                    Rect rect4 = new Rect(screenPosition.xMax - width, screenPosition.y + 39f, width, screenPosition.height - 39f);
                    if (rect4.Contains(mouseScreenPosition))
                    {
                        num2 |= 4;
                    }
                    if (num2 == 3)
                    {
                        Vector2 vector  = new Vector2(screenPosition.x, screenPosition.yMax) - mouseScreenPosition;
                        Vector2 vector2 = new Vector2(width, -height);
                        if (((vector.x * vector2.y) - (vector.y * vector2.x)) < 0f)
                        {
                            num2 = 1;
                        }
                        else
                        {
                            num2 = 2;
                        }
                    }
                    else if (num2 == 6)
                    {
                        Vector2 vector3 = new Vector2(screenPosition.xMax, screenPosition.yMax) - mouseScreenPosition;
                        Vector2 vector4 = new Vector2(-width, -height);
                        if (((vector3.x * vector4.y) - (vector3.y * vector4.x)) < 0f)
                        {
                            num2 = 2;
                        }
                        else
                        {
                            num2 = 4;
                        }
                    }
                    float num5 = Mathf.Round(Mathf.Max((float)(screenPosition.width / 3f), (float)100f));
                    float num6 = Mathf.Round(Mathf.Max((float)(screenPosition.height / 3f), (float)100f));
                    if (this.vertical)
                    {
                        switch (num2)
                        {
                        case 1:
                            return(new DropInfo(this)
                            {
                                userData = i + 0x3e8, type = DropInfo.Type.Pane, rect = new Rect(screenPosition.x, screenPosition.y, num5, screenPosition.height)
                            });

                        case 2:
                            return(new DropInfo(this)
                            {
                                userData = i + 1, type = DropInfo.Type.Pane, rect = new Rect(screenPosition.x, screenPosition.yMax - num6, screenPosition.width, num6)
                            });

                        case 4:
                            return(new DropInfo(this)
                            {
                                userData = i + 0x7d0, type = DropInfo.Type.Pane, rect = new Rect(screenPosition.xMax - num5, screenPosition.y, num5, screenPosition.height)
                            });
                        }
                    }
                    else
                    {
                        switch (num2)
                        {
                        case 1:
                            return(new DropInfo(this)
                            {
                                userData = i, type = DropInfo.Type.Pane, rect = new Rect(screenPosition.x, screenPosition.y, num5, screenPosition.height)
                            });

                        case 2:
                            return(new DropInfo(this)
                            {
                                userData = i + 0x7d0, type = DropInfo.Type.Pane, rect = new Rect(screenPosition.x, screenPosition.yMax - num6, screenPosition.width, num6)
                            });

                        case 4:
                            return(new DropInfo(this)
                            {
                                userData = i + 1, type = DropInfo.Type.Pane, rect = new Rect(screenPosition.xMax - num5, screenPosition.y, num5, screenPosition.height)
                            });
                        }
                    }
                }
            }
            if (base.screenPosition.Contains(mouseScreenPosition) && !(base.parent is SplitView))
            {
                return(new DropInfo(null));
            }
            return(null);
        }
예제 #17
0
		public bool PerformDrop(EditorWindow w, DropInfo info, Vector2 screenPos)
		{
			DockArea.s_OriginalDragSource.RemoveTab(w, DockArea.s_OriginalDragSource != this);
			int num = (DockArea.s_PlaceholderPos <= this.m_Panes.Count) ? DockArea.s_PlaceholderPos : this.m_Panes.Count;
			this.AddTab(num, w);
			this.selected = num;
			return true;
		}
예제 #18
0
        public DropInfo DragOver(EditorWindow w, Vector2 mouseScreenPosition)
        {
            for (var childIndex = 0; childIndex < children.Length; ++childIndex)
            {
                var child = children[childIndex];

                // skip so you can't dock a view to a subview of itself
                if (child == DockArea.s_IgnoreDockingForView)
                {
                    continue;
                }

                // Skip if child is a splitview (it'll handle its rect itself)
                if (child is SplitView)
                {
                    continue;
                }

                // Collect flags of which edge zones the mouse is inside
                var mouseEdges           = ViewEdge.None;
                var childRect            = child.screenPosition;
                var childRectWithoutDock = RectFromEdge(childRect, ViewEdge.Bottom, childRect.height - DockArea.kDockHeight, 0f);
                var borderWidth          = Mathf.Min(Mathf.Round(childRectWithoutDock.width / 3), kMaxViewDropZoneThickness);
                var borderHeight         = Mathf.Min(Mathf.Round(childRectWithoutDock.height / 3), kMaxViewDropZoneThickness);
                var leftDropZone         = RectFromEdge(childRectWithoutDock, ViewEdge.Left, borderWidth, 0f);
                var rightDropZone        = RectFromEdge(childRectWithoutDock, ViewEdge.Right, borderWidth, 0f);
                var bottomDropZone       = RectFromEdge(childRectWithoutDock, ViewEdge.Bottom, borderHeight, 0f);
                var topDropZone          = RectFromEdge(childRectWithoutDock, ViewEdge.Top, borderHeight, 0f);

                if (leftDropZone.Contains(mouseScreenPosition))
                {
                    mouseEdges |= ViewEdge.Left;
                }

                if (rightDropZone.Contains(mouseScreenPosition))
                {
                    mouseEdges |= ViewEdge.Right;
                }

                if (bottomDropZone.Contains(mouseScreenPosition))
                {
                    mouseEdges |= ViewEdge.Bottom;
                }

                if (topDropZone.Contains(mouseScreenPosition))
                {
                    mouseEdges |= ViewEdge.Top;
                }

                // If mouse is in more than one zone, it is in a corner. Find the corner and divide it diagonally...
                var mouseToCorner    = Vector2.zero;
                var oppositeToCorner = Vector2.zero;
                var ccwEdge          = mouseEdges;
                var cwEdge           = mouseEdges;
                switch (mouseEdges)
                {
                case ViewEdge.BottomLeft:
                    ccwEdge          = ViewEdge.Bottom;
                    cwEdge           = ViewEdge.Left;
                    mouseToCorner    = new Vector2(childRectWithoutDock.x, childRectWithoutDock.yMax) - mouseScreenPosition;
                    oppositeToCorner = new Vector2(-borderWidth, borderHeight);
                    break;

                case ViewEdge.BottomRight:
                    ccwEdge          = ViewEdge.Right;
                    cwEdge           = ViewEdge.Bottom;
                    mouseToCorner    = new Vector2(childRectWithoutDock.xMax, childRectWithoutDock.yMax) - mouseScreenPosition;
                    oppositeToCorner = new Vector2(borderWidth, borderHeight);
                    break;

                case ViewEdge.TopLeft:
                    ccwEdge          = ViewEdge.Left;
                    cwEdge           = ViewEdge.Top;
                    mouseToCorner    = new Vector2(childRectWithoutDock.x, childRectWithoutDock.y) - mouseScreenPosition;
                    oppositeToCorner = new Vector2(-borderWidth, -borderHeight);
                    break;

                case ViewEdge.TopRight:
                    ccwEdge          = ViewEdge.Top;
                    cwEdge           = ViewEdge.Right;
                    mouseToCorner    = new Vector2(childRectWithoutDock.xMax, childRectWithoutDock.y) - mouseScreenPosition;
                    oppositeToCorner = new Vector2(borderWidth, -borderHeight);
                    break;
                }
                // ...then choose the edge based on the half the mouse is in
                mouseEdges = mouseToCorner.x * oppositeToCorner.y - mouseToCorner.y * oppositeToCorner.x < 0 ? ccwEdge : cwEdge;

                if (mouseEdges != ViewEdge.None) // Valid drop zone
                {
                    var targetThickness = Mathf.Round(((mouseEdges & ViewEdge.FitsHorizontal) != 0 ? childRect.width : childRect.height) / 3);
                    targetThickness = Mathf.Max(targetThickness, kMinViewDropDestinationThickness);

                    var dropInfo = new DropInfo(this);
                    dropInfo.userData = new ExtraDropInfo(false, mouseEdges, childIndex);
                    dropInfo.type     = DropInfo.Type.Pane;
                    dropInfo.rect     = RectFromEdge(childRect, mouseEdges, targetThickness, 0f);
                    return(dropInfo);
                }
            }
            // Claim the drag if we are the root split view, so it doesn't fall through to obscured windows
            if (screenPosition.Contains(mouseScreenPosition) && !(parent is SplitView))
            {
                return(new DropInfo(null));
            }

            return(null);
        }
예제 #19
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);
		}
예제 #20
0
        public DropInfo DragOver(EditorWindow w, Vector2 mouseScreenPosition)
        {
            DropInfo result;

            for (int i = 0; i < base.children.Length; i++)
            {
                View view = base.children[i];
                if (!(view == DockArea.s_IgnoreDockingForView))
                {
                    if (!(view is SplitView))
                    {
                        SplitView.ViewEdge viewEdge = SplitView.ViewEdge.None;
                        Rect  screenPosition        = view.screenPosition;
                        Rect  rect  = this.RectFromEdge(screenPosition, SplitView.ViewEdge.Bottom, screenPosition.height - 39f, 0f);
                        float num   = Mathf.Min(Mathf.Round(rect.width / 3f), 300f);
                        float num2  = Mathf.Min(Mathf.Round(rect.height / 3f), 300f);
                        Rect  rect2 = this.RectFromEdge(rect, SplitView.ViewEdge.Left, num, 0f);
                        Rect  rect3 = this.RectFromEdge(rect, SplitView.ViewEdge.Right, num, 0f);
                        Rect  rect4 = this.RectFromEdge(rect, SplitView.ViewEdge.Bottom, num2, 0f);
                        Rect  rect5 = this.RectFromEdge(rect, SplitView.ViewEdge.Top, num2, 0f);
                        if (rect2.Contains(mouseScreenPosition))
                        {
                            viewEdge |= SplitView.ViewEdge.Left;
                        }
                        if (rect3.Contains(mouseScreenPosition))
                        {
                            viewEdge |= SplitView.ViewEdge.Right;
                        }
                        if (rect4.Contains(mouseScreenPosition))
                        {
                            viewEdge |= SplitView.ViewEdge.Bottom;
                        }
                        if (rect5.Contains(mouseScreenPosition))
                        {
                            viewEdge |= SplitView.ViewEdge.Top;
                        }
                        Vector2            vector    = Vector2.zero;
                        Vector2            zero      = Vector2.zero;
                        SplitView.ViewEdge viewEdge2 = viewEdge;
                        SplitView.ViewEdge viewEdge3 = viewEdge;
                        switch (viewEdge)
                        {
                        case SplitView.ViewEdge.BottomLeft:
                            viewEdge2 = SplitView.ViewEdge.Bottom;
                            viewEdge3 = SplitView.ViewEdge.Left;
                            vector    = new Vector2(rect.x, rect.yMax) - mouseScreenPosition;
                            zero      = new Vector2(-num, num2);
                            goto IL_22E;

                        case SplitView.ViewEdge.Top:
IL_14C:
                            switch (viewEdge)
                            {
                            case SplitView.ViewEdge.BottomRight:
                                viewEdge2 = SplitView.ViewEdge.Right;
                                viewEdge3 = SplitView.ViewEdge.Bottom;
                                vector    = new Vector2(rect.xMax, rect.yMax) - mouseScreenPosition;
                                zero      = new Vector2(num, num2);
                                goto IL_22E;

                            case SplitView.ViewEdge.Left | SplitView.ViewEdge.Bottom | SplitView.ViewEdge.Right:
                                goto IL_22E;

                            case SplitView.ViewEdge.TopRight:
                                viewEdge2 = SplitView.ViewEdge.Top;
                                viewEdge3 = SplitView.ViewEdge.Right;
                                vector    = new Vector2(rect.xMax, rect.y) - mouseScreenPosition;
                                zero      = new Vector2(num, -num2);
                                goto IL_22E;

                            default:
                                goto IL_22E;
                            }
                            break;

                        case SplitView.ViewEdge.TopLeft:
                            viewEdge2 = SplitView.ViewEdge.Left;
                            viewEdge3 = SplitView.ViewEdge.Top;
                            vector    = new Vector2(rect.x, rect.y) - mouseScreenPosition;
                            zero      = new Vector2(-num, -num2);
                            goto IL_22E;
                        }
                        goto IL_14C;
IL_22E:
                        viewEdge = ((vector.x * zero.y - vector.y * zero.x >= 0f) ? viewEdge3 : viewEdge2);
                        if (viewEdge != SplitView.ViewEdge.None)
                        {
                            float num3 = Mathf.Round((((viewEdge & SplitView.ViewEdge.FitsHorizontal) == SplitView.ViewEdge.None) ? screenPosition.height : screenPosition.width) / 3f);
                            num3   = Mathf.Max(num3, 100f);
                            result = new DropInfo(this)
                            {
                                userData = new SplitView.ExtraDropInfo(false, viewEdge, i),
                                type     = DropInfo.Type.Pane,
                                rect     = this.RectFromEdge(screenPosition, viewEdge, num3, 0f)
                            };
                            return(result);
                        }
                    }
                }
            }
            if (base.screenPosition.Contains(mouseScreenPosition) && !(base.parent is SplitView))
            {
                result = new DropInfo(null);
                return(result);
            }
            result = null;
            return(result);
        }
예제 #21
0
		public bool PerformDrop(EditorWindow w, DropInfo di, Vector2 screenPos)
		{
			int num = (int)di.userData;
			DockArea dockArea = ScriptableObject.CreateInstance<DockArea>();
			Rect rect = di.rect;
			if (num == -1 || num == -2 || num == -3)
			{
				bool flag = num == -2;
				bool flag2 = num == -1;
				this.splitState = null;
				if (this.vertical == flag2 || base.children.Length < 2)
				{
					this.vertical = flag2;
					rect.x -= base.screenPosition.x;
					rect.y -= base.screenPosition.y;
					this.MakeRoomForRect(rect);
					this.AddChild(dockArea, (!flag) ? base.children.Length : 0);
					dockArea.position = rect;
				}
				else
				{
					SplitView splitView = ScriptableObject.CreateInstance<SplitView>();
					Rect position = base.position;
					splitView.vertical = flag2;
					splitView.position = new Rect(position.x, position.y, position.width, position.height);
					if (base.window.mainView == this)
					{
						base.window.mainView = splitView;
					}
					else
					{
						base.parent.AddChild(splitView, base.parent.IndexOfChild(this));
					}
					splitView.AddChild(this);
					base.position = new Rect(0f, 0f, position.width, position.height);
					Rect rect2 = rect;
					rect2.x -= base.screenPosition.x;
					rect2.y -= base.screenPosition.y;
					splitView.MakeRoomForRect(rect2);
					dockArea.position = rect2;
					splitView.AddChild(dockArea, (!flag) ? 1 : 0);
				}
			}
			else
			{
				if (num < 1000)
				{
					Rect rect3 = rect;
					rect3.x -= base.screenPosition.x;
					rect3.y -= base.screenPosition.y;
					this.MakeRoomForRect(rect3);
					this.AddChild(dockArea, num);
					dockArea.position = rect3;
				}
				else
				{
					int num2 = num % 1000;
					if (base.children.Length != 1)
					{
						SplitView splitView2 = ScriptableObject.CreateInstance<SplitView>();
						splitView2.vertical = !this.vertical;
						Rect position2 = base.children[num2].position;
						splitView2.AddChild(base.children[num2]);
						this.AddChild(splitView2, num2);
						splitView2.position = position2;
						float num3 = 0f;
						position2.y = num3;
						position2.x = num3;
						splitView2.children[0].position = position2;
						Rect rect4 = rect;
						rect4.x -= splitView2.screenPosition.x;
						rect4.y -= splitView2.screenPosition.y;
						splitView2.MakeRoomForRect(rect4);
						splitView2.AddChild(dockArea, (num >= 2000) ? 1 : 0);
						dockArea.position = rect4;
					}
					else
					{
						this.vertical = !this.vertical;
						Rect rect5 = rect;
						rect5.x -= base.screenPosition.x;
						rect5.y -= base.screenPosition.y;
						this.MakeRoomForRect(rect5);
						this.AddChild(dockArea, (num != 1000) ? 1 : 0);
						dockArea.position = rect5;
					}
				}
			}
			DockArea.s_OriginalDragSource.RemoveTab(w);
			w.m_Parent = dockArea;
			dockArea.AddTab(w);
			this.Reflow();
			SplitView.RecalcMinMaxAndReflowAll(this);
			dockArea.MakeVistaDWMHappyDance();
			return true;
		}
예제 #22
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.titleContent;
                        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].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_6B9;
            }
            }
            goto IL_6E;
IL_6B9:
            this.selected = Mathf.Clamp(this.selected, 0, this.m_Panes.Count - 1);
        }
예제 #23
0
        public DropInfo DragOver(EditorWindow w, Vector2 mouseScreenPosition)
        {
            DropInfo dropInfo = this.CheckRootWindowDropZones(mouseScreenPosition);

            if (dropInfo != null)
            {
                return(dropInfo);
            }
            for (int i = 0; i < base.children.Length; i++)
            {
                View view = base.children[i];
                if (!(view == DockArea.s_IgnoreDockingForView))
                {
                    if (!(view is SplitView))
                    {
                        Rect  screenPosition = view.screenPosition;
                        int   num            = 0;
                        float num2           = Mathf.Round(Mathf.Min(screenPosition.width / 3f, 300f));
                        float num3           = Mathf.Round(Mathf.Min(screenPosition.height / 3f, 300f));
                        Rect  rect           = new Rect(screenPosition.x, screenPosition.y + 39f, num2, screenPosition.height - 39f);
                        if (rect.Contains(mouseScreenPosition))
                        {
                            num |= 1;
                        }
                        Rect rect2 = new Rect(screenPosition.x, screenPosition.yMax - num3, screenPosition.width, num3);
                        if (rect2.Contains(mouseScreenPosition))
                        {
                            num |= 2;
                        }
                        Rect rect3 = new Rect(screenPosition.xMax - num2, screenPosition.y + 39f, num2, screenPosition.height - 39f);
                        if (rect3.Contains(mouseScreenPosition))
                        {
                            num |= 4;
                        }
                        if (num == 3)
                        {
                            Vector2 vector  = new Vector2(screenPosition.x, screenPosition.yMax) - mouseScreenPosition;
                            Vector2 vector2 = new Vector2(num2, -num3);
                            if (vector.x * vector2.y - vector.y * vector2.x < 0f)
                            {
                                num = 1;
                            }
                            else
                            {
                                num = 2;
                            }
                        }
                        else
                        {
                            if (num == 6)
                            {
                                Vector2 vector3 = new Vector2(screenPosition.xMax, screenPosition.yMax) - mouseScreenPosition;
                                Vector2 vector4 = new Vector2(-num2, -num3);
                                if (vector3.x * vector4.y - vector3.y * vector4.x < 0f)
                                {
                                    num = 2;
                                }
                                else
                                {
                                    num = 4;
                                }
                            }
                        }
                        float num4 = Mathf.Round(Mathf.Max(screenPosition.width / 3f, 100f));
                        float num5 = Mathf.Round(Mathf.Max(screenPosition.height / 3f, 100f));
                        if (this.vertical)
                        {
                            switch (num)
                            {
                            case 1:
                                return(new DropInfo(this)
                                {
                                    userData = i + 1000,
                                    type = DropInfo.Type.Pane,
                                    rect = new Rect(screenPosition.x, screenPosition.y, num4, screenPosition.height)
                                });

                            case 2:
                                return(new DropInfo(this)
                                {
                                    userData = i + 1,
                                    type = DropInfo.Type.Pane,
                                    rect = new Rect(screenPosition.x, screenPosition.yMax - num5, screenPosition.width, num5)
                                });

                            case 4:
                                return(new DropInfo(this)
                                {
                                    userData = i + 2000,
                                    type = DropInfo.Type.Pane,
                                    rect = new Rect(screenPosition.xMax - num4, screenPosition.y, num4, screenPosition.height)
                                });
                            }
                        }
                        else
                        {
                            switch (num)
                            {
                            case 1:
                                return(new DropInfo(this)
                                {
                                    userData = i,
                                    type = DropInfo.Type.Pane,
                                    rect = new Rect(screenPosition.x, screenPosition.y, num4, screenPosition.height)
                                });

                            case 2:
                                return(new DropInfo(this)
                                {
                                    userData = i + 2000,
                                    type = DropInfo.Type.Pane,
                                    rect = new Rect(screenPosition.x, screenPosition.yMax - num5, screenPosition.width, num5)
                                });

                            case 4:
                                return(new DropInfo(this)
                                {
                                    userData = i + 1,
                                    type = DropInfo.Type.Pane,
                                    rect = new Rect(screenPosition.xMax - num4, screenPosition.y, num4, screenPosition.height)
                                });
                            }
                        }
                    }
                }
            }
            if (base.screenPosition.Contains(mouseScreenPosition) && !(base.parent is SplitView))
            {
                return(new DropInfo(null));
            }
            return(null);
        }
예제 #24
0
        public bool PerformDrop(EditorWindow w, DropInfo di, Vector2 screenPos)
        {
            int      num      = (int)di.userData;
            DockArea dockArea = ScriptableObject.CreateInstance <DockArea>();
            Rect     rect     = di.rect;

            if (num == -1 || num == -2 || num == -3)
            {
                bool flag  = num == -2;
                bool flag2 = num == -1;
                this.splitState = null;
                if (this.vertical == flag2 || base.children.Length < 2)
                {
                    this.vertical = flag2;
                    rect.x       -= base.screenPosition.x;
                    rect.y       -= base.screenPosition.y;
                    this.MakeRoomForRect(rect);
                    this.AddChild(dockArea, (!flag) ? base.children.Length : 0);
                    dockArea.position = rect;
                }
                else
                {
                    SplitView splitView = ScriptableObject.CreateInstance <SplitView>();
                    Rect      position  = base.position;
                    splitView.vertical = flag2;
                    splitView.position = new Rect(position.x, position.y, position.width, position.height);
                    if (base.window.mainView == this)
                    {
                        base.window.mainView = splitView;
                    }
                    else
                    {
                        base.parent.AddChild(splitView, base.parent.IndexOfChild(this));
                    }
                    splitView.AddChild(this);
                    base.position = new Rect(0f, 0f, position.width, position.height);
                    Rect rect2 = rect;
                    rect2.x -= base.screenPosition.x;
                    rect2.y -= base.screenPosition.y;
                    splitView.MakeRoomForRect(rect2);
                    dockArea.position = rect2;
                    splitView.AddChild(dockArea, (!flag) ? 1 : 0);
                }
            }
            else
            {
                if (num < 1000)
                {
                    Rect rect3 = rect;
                    rect3.x -= base.screenPosition.x;
                    rect3.y -= base.screenPosition.y;
                    this.MakeRoomForRect(rect3);
                    this.AddChild(dockArea, num);
                    dockArea.position = rect3;
                }
                else
                {
                    int num2 = num % 1000;
                    if (base.children.Length != 1)
                    {
                        SplitView splitView2 = ScriptableObject.CreateInstance <SplitView>();
                        splitView2.vertical = !this.vertical;
                        Rect position2 = base.children[num2].position;
                        splitView2.AddChild(base.children[num2]);
                        this.AddChild(splitView2, num2);
                        splitView2.position = position2;
                        float num3 = 0f;
                        position2.y = num3;
                        position2.x = num3;
                        splitView2.children[0].position = position2;
                        Rect rect4 = rect;
                        rect4.x -= splitView2.screenPosition.x;
                        rect4.y -= splitView2.screenPosition.y;
                        splitView2.MakeRoomForRect(rect4);
                        splitView2.AddChild(dockArea, (num >= 2000) ? 1 : 0);
                        dockArea.position = rect4;
                    }
                    else
                    {
                        this.vertical = !this.vertical;
                        Rect rect5 = rect;
                        rect5.x -= base.screenPosition.x;
                        rect5.y -= base.screenPosition.y;
                        this.MakeRoomForRect(rect5);
                        this.AddChild(dockArea, (num != 1000) ? 1 : 0);
                        dockArea.position = rect5;
                    }
                }
            }
            DockArea.s_OriginalDragSource.RemoveTab(w);
            w.m_Parent = dockArea;
            dockArea.AddTab(w);
            this.Reflow();
            SplitView.RecalcMinMaxAndReflowAll(this);
            dockArea.MakeVistaDWMHappyDance();
            return(true);
        }
예제 #25
0
 public bool PerformDrop(EditorWindow w, DropInfo info, Vector2 screenPos)
 {
   DockArea.s_OriginalDragSource.RemoveTab(w, (UnityEngine.Object) DockArea.s_OriginalDragSource != (UnityEngine.Object) this);
   int idx = DockArea.s_PlaceholderPos <= this.m_Panes.Count ? DockArea.s_PlaceholderPos : this.m_Panes.Count;
   this.AddTab(idx, w);
   this.selected = idx;
   return true;
 }