Exemplo n.º 1
0
        public void OnGUI()
        {
            base.ClearBackground();
            EditorGUIUtility.ResetGUIState();
            SplitView splitView = base.parent as SplitView;

            if (Event.current.type == EventType.Repaint && splitView)
            {
                View child = this;
                while (splitView)
                {
                    int controlID = splitView.controlID;
                    if (controlID == GUIUtility.hotControl || GUIUtility.hotControl == 0)
                    {
                        int num = splitView.IndexOfChild(child);
                        if (splitView.vertical)
                        {
                            if (num != 0)
                            {
                                EditorGUIUtility.AddCursorRect(new Rect(0f, 0f, base.position.width, 5f), MouseCursor.SplitResizeUpDown, controlID);
                            }
                            if (num != splitView.children.Length - 1)
                            {
                                EditorGUIUtility.AddCursorRect(new Rect(0f, base.position.height - 5f, base.position.width, 5f), MouseCursor.SplitResizeUpDown, controlID);
                            }
                        }
                        else
                        {
                            if (num != 0)
                            {
                                EditorGUIUtility.AddCursorRect(new Rect(0f, 0f, 5f, base.position.height), MouseCursor.SplitResizeLeftRight, controlID);
                            }
                            if (num != splitView.children.Length - 1)
                            {
                                EditorGUIUtility.AddCursorRect(new Rect(base.position.width - 5f, 0f, 5f, base.position.height), MouseCursor.SplitResizeLeftRight, controlID);
                            }
                        }
                    }
                    child     = splitView;
                    splitView = (splitView.parent as SplitView);
                }
                splitView = (base.parent as SplitView);
            }
            bool flag = false;

            if (base.window.mainView.GetType() != typeof(MainWindow))
            {
                flag = true;
                if (base.windowPosition.y == 0f)
                {
                    this.background = "dockareaStandalone";
                }
                else
                {
                    this.background = "dockarea";
                }
            }
            else
            {
                this.background = "dockarea";
            }
            if (splitView)
            {
                Event @event = new Event(Event.current);
                @event.mousePosition += new Vector2(base.position.x, base.position.y);
                splitView.SplitGUI(@event);
                if (@event.type == EventType.Used)
                {
                    Event.current.Use();
                }
            }
            GUIStyle style    = "dockareaoverlay";
            Rect     position = this.background.margin.Remove(new Rect(0f, 0f, base.position.width, base.position.height));

            position.x = (float)this.background.margin.left;
            position.y = (float)this.background.margin.top;
            Rect  windowPosition = base.windowPosition;
            float num2           = 2f;

            if (windowPosition.x == 0f)
            {
                position.x     -= num2;
                position.width += num2;
            }
            if (windowPosition.xMax == base.window.position.width)
            {
                position.width += num2;
            }
            if (windowPosition.yMax == base.window.position.height)
            {
                position.height += ((!flag) ? 2f : 2f);
            }
            GUI.Box(position, GUIContent.none, this.background);
            if (this.tabStyle == null)
            {
                this.tabStyle = "dragtab";
            }
            this.DragTab(new Rect(position.x + 1f, position.y, position.width - 40f, 17f), this.tabStyle);
            this.tabStyle = "dragtab";
            base.ShowGenericMenu();
            base.DoWindowDecorationStart();
            if (this.m_Panes.Count > 0)
            {
                if (this.m_Panes[this.selected] is GameView)
                {
                    GUI.Box(position, GUIContent.none, style);
                }
                DockArea.BeginOffsetArea(new Rect(position.x + 2f, position.y + 17f, position.width - 4f, position.height - 17f - 2f), GUIContent.none, "TabWindowBackground");
                Vector2 vector = GUIUtility.GUIToScreenPoint(Vector2.zero);
                Rect    pos    = base.borderSize.Remove(base.position);
                pos.x = vector.x;
                pos.y = vector.y;
                this.m_Panes[this.selected].m_Pos = pos;
                EditorGUIUtility.ResetGUIState();
                try
                {
                    base.Invoke("OnGUI");
                }
                catch (TargetInvocationException ex)
                {
                    throw ex.InnerException;
                }
                EditorGUIUtility.ResetGUIState();
                if (base.actualView != null && base.actualView.m_FadeoutTime != 0f && Event.current != null && Event.current.type == EventType.Repaint)
                {
                    base.actualView.DrawNotification();
                }
                DockArea.EndOffsetArea();
            }
            base.DoWindowDecorationEnd();
            GUI.Box(position, GUIContent.none, style);
            EditorGUI.ShowRepaints();
            Highlighter.ControlHighlightGUI(this);
        }
Exemplo n.º 2
0
        private void HandleSplitView()
        {
            // Add CursorRects
            SplitView sp = parent as SplitView;

            if (Event.current.type == EventType.Repaint && sp)
            {
                View view = this;
                while (sp)
                {
                    int id = sp.controlID;

                    if (id == GUIUtility.hotControl || GUIUtility.hotControl == 0)
                    {
                        int idx = sp.IndexOfChild(view);
                        if (sp.vertical)
                        {
                            if (idx != 0)
                            {
                                EditorGUIUtility.AddCursorRect(new Rect(0, 0, position.width, SplitView.kGrabDist), MouseCursor.SplitResizeUpDown, id);
                            }
                            if (idx != sp.children.Length - 1)
                            {
                                EditorGUIUtility.AddCursorRect(
                                    new Rect(0, position.height - SplitView.kGrabDist, position.width, SplitView.kGrabDist),
                                    MouseCursor.SplitResizeUpDown, id);
                            }
                        }
                        else // horizontal
                        {
                            if (idx != 0)
                            {
                                EditorGUIUtility.AddCursorRect(new Rect(0, 0, SplitView.kGrabDist, position.height), MouseCursor.SplitResizeLeftRight,
                                                               id);
                            }
                            if (idx != sp.children.Length - 1)
                            {
                                EditorGUIUtility.AddCursorRect(
                                    new Rect(position.width - SplitView.kGrabDist, 0, SplitView.kGrabDist, position.height),
                                    MouseCursor.SplitResizeLeftRight, id);
                            }
                        }
                    }

                    view = sp;
                    sp   = sp.parent as SplitView;
                }

                // reset
                sp = (SplitView)parent;
            }

            if (sp)
            {
                Event e = new Event(Event.current);
                e.mousePosition += new Vector2(position.x, position.y);
                sp.SplitGUI(e);
                if (e.type == EventType.Used)
                {
                    Event.current.Use();
                }
            }
        }
Exemplo n.º 3
0
        protected override void OldOnGUI()
        {
            ClearBackground();
            // Call reset GUI state as first thing so GUI.color is correct when drawing window decoration.
            EditorGUIUtility.ResetGUIState();

            // Exit if the window was destroyed after entering play mode or on domain-reload.
            if (window == null)
            {
                return;
            }

            // Add CursorRects
            SplitView sp = parent as SplitView;

            if (Event.current.type == EventType.Repaint && sp)
            {
                View view = this;
                while (sp)
                {
                    int id = sp.controlID;

                    if (id == GUIUtility.hotControl || GUIUtility.hotControl == 0)
                    {
                        int idx = sp.IndexOfChild(view);
                        if (sp.vertical)
                        {
                            if (idx != 0)
                            {
                                EditorGUIUtility.AddCursorRect(new Rect(0, 0, position.width, SplitView.kGrabDist), MouseCursor.SplitResizeUpDown, id);
                            }
                            if (idx != sp.children.Length - 1)
                            {
                                EditorGUIUtility.AddCursorRect(
                                    new Rect(0, position.height - SplitView.kGrabDist, position.width, SplitView.kGrabDist),
                                    MouseCursor.SplitResizeUpDown, id);
                            }
                        }
                        else // horizontal
                        {
                            if (idx != 0)
                            {
                                EditorGUIUtility.AddCursorRect(new Rect(0, 0, SplitView.kGrabDist, position.height), MouseCursor.SplitResizeLeftRight,
                                                               id);
                            }
                            if (idx != sp.children.Length - 1)
                            {
                                EditorGUIUtility.AddCursorRect(
                                    new Rect(position.width - SplitView.kGrabDist, 0, SplitView.kGrabDist, position.height),
                                    MouseCursor.SplitResizeLeftRight, id);
                            }
                        }
                    }

                    view = sp;
                    sp   = sp.parent as SplitView;
                }

                // reset
                sp = parent as SplitView;
            }
            bool customBorder = false;

            if (window.rootView.GetType() != typeof(MainView))
            {
                customBorder = true;
                if (windowPosition.y == 0)
                {
                    background = "dockareaStandalone";
                }
                else
                {
                    background = "dockarea";
                }
            }
            else
            {
                background = "dockarea";
            }

            if (sp)
            {
                Event e = new Event(Event.current);
                e.mousePosition += new Vector2(position.x, position.y);
                sp.SplitGUI(e);
                if (e.type == EventType.Used)
                {
                    Event.current.Use();
                }
            }
            Rect r = background.margin.Remove(new Rect(0, 0, position.width, position.height));

            r.x = background.margin.left;
            r.y = background.margin.top;
            Rect  wPos       = windowPosition;
            float sideBorder = kSideBorders;

            if (wPos.x == 0)
            {
                r.x     -= sideBorder;
                r.width += sideBorder;
            }
            if (wPos.xMax == window.position.width)
            {
                r.width += sideBorder;
            }

            if (wPos.yMax == window.position.height)
            {
                r.height += customBorder ? 2f : kBottomBorders;
            }

            if (Event.current.type == EventType.Repaint)
            {
                background.Draw(r, GUIContent.none, 0);
            }

            if (tabStyle == null)
            {
                tabStyle = "dragtab";
            }

            if (m_Panes.Count > 0)
            {
                // Set up the pane's position, so its GUI can use this

                // Contents:
                // scroll it by -1, -1 so we top & left 1px gets culled (they are drawn already by the us, so we want to
                // not have them here (thing that the default skin relies on)
                BeginOffsetArea(new Rect(r.x + 2, r.y + kTabHeight, r.width - 4, r.height - kTabHeight - 2), GUIContent.none, "TabWindowBackground");

                Vector2 basePos = GUIUtility.GUIToScreenPoint(Vector2.zero);
                Rect    p       = borderSize.Remove(position);
                p.x = basePos.x;
                p.y = basePos.y;

                if (selected >= 0 && selected < m_Panes.Count)
                {
                    m_Panes[selected].m_Pos = p;
                }

                EndOffsetArea();
            }

            DragTab(new Rect(r.x + 1, r.y, r.width - kWindowButtonsWidth, kTabHeight), tabStyle);

            // TODO: Make this nice - right now this is meant to be overridden by Panes in Layout if they want something else. Inspector does this
            tabStyle = "dragtab";

            ShowGenericMenu();

            if (m_Panes.Count > 0)
            {
                InvokeOnGUI(r);
            }

            EditorGUI.ShowRepaints();
            Highlighter.ControlHighlightGUI(this);
        }