private static void RecalcMinMaxRecurse(SplitView node) { foreach (View child in node.children) { SplitView node1 = child as SplitView; if ((bool) ((Object) node1)) SplitView.RecalcMinMaxRecurse(node1); } node.ChildrenMinMaxChanged(); }
private static void ReflowRecurse(SplitView node) { node.Reflow(); foreach (View child in node.children) { SplitView node1 = child as SplitView; if ((bool) ((Object) node1)) SplitView.RecalcMinMaxRecurse(node1); } }
private static void RecalcMinMaxAndReflowAll(SplitView start) { SplitView splitView = start; SplitView node; do { node = splitView; splitView = node.parent as SplitView; } while ((bool) ((Object) splitView)); SplitView.RecalcMinMaxRecurse(node); SplitView.ReflowRecurse(node); }
private static void RecalcMinMaxAndReflowAll(SplitView start) { SplitView splitView = start; SplitView splitView2; do { splitView2 = splitView; splitView = (splitView2.parent as SplitView); } while (splitView); SplitView.RecalcMinMaxRecurse(splitView2); SplitView.ReflowRecurse(splitView2); }
private static void RecalcMinMaxRecurse(SplitView node) { View[] children = node.children; for (int i = 0; i < children.Length; i++) { View view = children[i]; SplitView splitView = view as SplitView; if (splitView) { SplitView.RecalcMinMaxRecurse(splitView); } } node.ChildrenMinMaxChanged(); }
private void KillIfEmpty() { if (this.m_Panes.Count == 0) { if (base.parent == null) { base.window.InternalCloseWindow(); } else { SplitView splitView = base.parent as SplitView; ICleanuppable cleanuppable = base.parent as ICleanuppable; splitView.RemoveChildNice(this); if (!this.m_IsBeingDestroyed) { UnityEngine.Object.DestroyImmediate(this, true); } if (cleanuppable != null) { cleanuppable.Cleanup(); } } } }
public static void Unmaximize(EditorWindow win) { HostView parent = win.m_Parent; if (parent == null) { UnityEngine.Debug.LogError("Host view was not found"); RevertFactorySettings(); } else { UnityEngine.Object[] objArray = InternalEditorUtility.LoadSerializedFileAndForget(Path.Combine(layoutsProjectPath, "CurrentMaximizeLayout.dwlt")); if (objArray.Length < 2) { UnityEngine.Debug.Log("Maximized serialized file backup not found"); RevertFactorySettings(); } else { SplitView child = objArray[0] as SplitView; EditorWindow item = objArray[1] as EditorWindow; if (child == null) { UnityEngine.Debug.Log("Maximization failed because the root split view was not found"); RevertFactorySettings(); } else { ContainerWindow window = win.m_Parent.window; if (window == null) { UnityEngine.Debug.Log("Maximization failed because the root split view has no container window"); RevertFactorySettings(); } else { try { ContainerWindow.SetFreezeDisplay(true); if (parent.parent == null) { throw new Exception(); } int idx = parent.parent.IndexOfChild(parent); Rect position = parent.position; View view3 = parent.parent; view3.RemoveChild(idx); view3.AddChild(child, idx); child.position = position; DockArea area = item.m_Parent as DockArea; int index = area.m_Panes.IndexOf(item); parent.actualView = null; win.m_Parent = null; area.AddTab(index, win); area.RemoveTab(item); UnityEngine.Object.DestroyImmediate(item); foreach (UnityEngine.Object obj2 in objArray) { EditorWindow window3 = obj2 as EditorWindow; if (window3 != null) { window3.MakeParentsSettingsMatchMe(); } } view3.Initialize(view3.window); view3.position = view3.position; child.Reflow(); UnityEngine.Object.DestroyImmediate(parent); win.Focus(); window.DisplayAllViews(); win.m_Parent.MakeVistaDWMHappyDance(); } catch (Exception exception) { UnityEngine.Debug.Log("Maximization failed: " + exception); RevertFactorySettings(); } try { if (((Application.platform == RuntimePlatform.OSXEditor) && SystemInfo.operatingSystem.Contains("10.7")) && SystemInfo.graphicsDeviceVendor.Contains("ATI")) { foreach (GUIView view4 in UnityEngine.Resources.FindObjectsOfTypeAll(typeof(GUIView))) { view4.Repaint(); } } } finally { ContainerWindow.SetFreezeDisplay(false); } } } } } }
public static void Unmaximize(EditorWindow win) { HostView maximizedHostView = win.m_Parent; if (maximizedHostView == null) { Debug.LogError("Host view was not found"); RevertFactorySettings(); return; } UnityObject[] newWindows = InternalEditorUtility.LoadSerializedFileAndForget(Path.Combine(layoutsProjectPath, kMaximizeRestoreFile)); if (newWindows.Length < 2) { Debug.Log("Maximized serialized file backup not found"); RevertFactorySettings(); return; } SplitView oldRoot = newWindows[0] as SplitView; EditorWindow oldWindow = newWindows[1] as EditorWindow; if (oldRoot == null) { Debug.Log("Maximization failed because the root split view was not found"); RevertFactorySettings(); return; } ContainerWindow parentWindow = win.m_Parent.window; if (parentWindow == null) { Debug.Log("Maximization failed because the root split view has no container window"); RevertFactorySettings(); return; } try { ContainerWindow.SetFreezeDisplay(true); // Put the loaded SplitView where the MaximizedHostView was if (maximizedHostView.parent) { int i = maximizedHostView.parent.IndexOfChild(maximizedHostView); Rect r = maximizedHostView.position; View parent = maximizedHostView.parent; parent.RemoveChild(i); parent.AddChild(oldRoot, i); oldRoot.position = r; // Move the Editor Window to the right spot in the DockArea newDockArea = oldWindow.m_Parent as DockArea; int oldDockAreaIndex = newDockArea.m_Panes.IndexOf(oldWindow); maximizedHostView.actualView = null; win.m_Parent = null; newDockArea.AddTab(oldDockAreaIndex, win); newDockArea.RemoveTab(oldWindow); UnityObject.DestroyImmediate(oldWindow); foreach (UnityObject o in newWindows) { EditorWindow curWin = o as EditorWindow; if (curWin != null) { curWin.MakeParentsSettingsMatchMe(); } } parent.Initialize(parent.window); //If parent window had to be resized, call this to make sure new size gets propagated parent.position = parent.position; oldRoot.Reflow(); } else { throw new System.Exception(); } // Kill the maximizedMainView UnityObject.DestroyImmediate(maximizedHostView); win.Focus(); parentWindow.DisplayAllViews(); win.m_Parent.MakeVistaDWMHappyDance(); } catch (System.Exception ex) { Debug.Log("Maximization failed: " + ex); RevertFactorySettings(); } try { // Weird bug on AMD graphic cards under OSX Lion: Sometimes when unmaximizing we get stray white rectangles. // work around that by issueing an extra repaint (case 438764) if (Application.platform == RuntimePlatform.OSXEditor && SystemInfo.operatingSystem.Contains("10.7") && SystemInfo.graphicsDeviceVendor.Contains("ATI")) { foreach (GUIView v in Resources.FindObjectsOfTypeAll(typeof(GUIView))) { v.Repaint(); } } } finally { ContainerWindow.SetFreezeDisplay(false); } }
public void SplitGUI(Event evt) { if (splitState == null) { SetupSplitter(); } SplitView sp = parent as SplitView; if (sp) { Event e = new Event(evt); e.mousePosition += new Vector2(position.x, position.y); sp.SplitGUI(e); if (e.type == EventType.Used) { evt.Use(); } } float pos = vertical ? evt.mousePosition.y : evt.mousePosition.x; int id = GUIUtility.GetControlID(546739, FocusType.Passive); controlID = id; switch (evt.GetTypeForControl(id)) { case EventType.MouseDown: if (children.Length != 1) // is there a splitter { int cursor = vertical ? (int)children[0].position.y : (int)children[0].position.x; for (int i = 0; i < children.Length - 1; i++) { if (i >= splitState.realSizes.Length) { DockArea dock = GUIView.current as DockArea; string name = "Non-dock area " + GUIView.current.GetType(); if (dock && dock.m_Selected < dock.m_Panes.Count && dock.m_Panes[dock.m_Selected]) { name = dock.m_Panes[dock.m_Selected].GetType().ToString(); } if (Unsupported.IsDeveloperMode()) { Debug.LogError("Real sizes out of bounds for: " + name + " index: " + i + " RealSizes: " + splitState.realSizes.Length); } SetupSplitter(); } Rect splitterRect = vertical ? new Rect(children[0].position.x, cursor + splitState.realSizes[i] - splitState.splitSize / 2, children[0].position.width, splitState.splitSize) : new Rect(cursor + splitState.realSizes[i] - splitState.splitSize / 2, children[0].position.y, splitState.splitSize, children[0].position.height); if (splitterRect.Contains(evt.mousePosition)) { splitState.splitterInitialOffset = (int)pos; splitState.currentActiveSplitter = i; GUIUtility.hotControl = id; evt.Use(); break; } cursor += splitState.realSizes[i]; } } break; case EventType.MouseDrag: if (children.Length > 1 && (GUIUtility.hotControl == id) && (splitState.currentActiveSplitter >= 0)) { int diff = (int)pos - splitState.splitterInitialOffset; if (diff != 0) { splitState.splitterInitialOffset = (int)pos; splitState.DoSplitter(splitState.currentActiveSplitter, splitState.currentActiveSplitter + 1, diff); } SetupRectsFromSplitter(); evt.Use(); } break; case EventType.MouseUp: if (GUIUtility.hotControl == id) { GUIUtility.hotControl = 0; } break; } }
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, killIfEmpty: true, sendEvents: false); dropWindow.m_Parent = newDockArea; newDockArea.AddTab(dropWindow, sendPaneEvents: false); Reflow(); RecalcMinMaxAndReflowAll(this); newDockArea.MakeVistaDWMHappyDance(); return(true); }
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(); } } }
public void Cleanup() { SplitView parent1 = this.parent as SplitView; if (this.children.Length == 1 && (Object)parent1 != (Object)null) { View child = this.children[0]; child.position = this.position; if ((Object)this.parent != (Object)null) { this.parent.AddChild(child, this.parent.IndexOfChild((View)this)); this.parent.RemoveChild((View)this); if ((bool)((Object)parent1)) { parent1.Cleanup(); } child.position = this.position; if (Unsupported.IsDestroyScriptableObject((ScriptableObject)this)) { return; } Object.DestroyImmediate((Object)this); return; } if (child is SplitView) { this.RemoveChild(child); this.window.mainView = child; child.position = new Rect(0.0f, 0.0f, child.window.position.width, this.window.position.height); child.Reflow(); if (Unsupported.IsDestroyScriptableObject((ScriptableObject)this)) { return; } Object.DestroyImmediate((Object)this); return; } } if ((bool)((Object)parent1)) { parent1.Cleanup(); SplitView parent2 = this.parent as SplitView; if ((bool)((Object)parent2) && parent2.vertical == this.vertical) { int num = new List <View>((IEnumerable <View>) this.parent.children).IndexOf((View)this); foreach (View child in this.children) { parent2.AddChild(child, num++); child.position = new Rect(this.position.x + child.position.x, this.position.y + child.position.y, child.position.width, child.position.height); } } } if (this.children.Length == 0) { if ((Object)this.parent == (Object)null && (Object)this.window != (Object)null) { this.window.Close(); } else { ICleanuppable parent2 = this.parent as ICleanuppable; if (this.parent is SplitView) { ((SplitView)this.parent).RemoveChildNice((View)this); if (!Unsupported.IsDestroyScriptableObject((ScriptableObject)this)) { Object.DestroyImmediate((Object)this, true); } } parent2.Cleanup(); } } else { this.splitState = (SplitterState)null; this.Reflow(); } }
private void DragTab(Rect pos, GUIStyle tabStyle) { int controlID = GUIUtility.GetControlID(FocusType.Passive); float tabWidth = this.GetTabWidth(pos.width); Event current = Event.current; if (DockArea.s_DragMode != 0 && GUIUtility.hotControl == 0) { PaneDragTab.get.Close(); DockArea.ResetDragVars(); } EventType typeForControl = current.GetTypeForControl(controlID); switch (typeForControl) { case EventType.MouseDown: if (pos.Contains(current.mousePosition) && GUIUtility.hotControl == 0) { int tabAtMousePos = this.GetTabAtMousePos(current.mousePosition, pos); if (tabAtMousePos < this.m_Panes.Count) { int button = current.button; if (button != 0) { if (button == 2) { this.m_Panes[tabAtMousePos].Close(); current.Use(); } } else { if (tabAtMousePos != this.selected) { this.selected = tabAtMousePos; } GUIUtility.hotControl = controlID; DockArea.s_StartDragPosition = current.mousePosition; DockArea.s_DragMode = 0; current.Use(); } } } goto IL_746; case EventType.MouseUp: if (GUIUtility.hotControl == controlID) { Vector2 vector = GUIUtility.GUIToScreenPoint(current.mousePosition); if (DockArea.s_DragMode != 0) { DockArea.s_DragMode = 0; PaneDragTab.get.Close(); Delegate arg_49F_0 = EditorApplication.update; if (DockArea.< > f__mg$cache1 == null) { DockArea.< > f__mg$cache1 = new EditorApplication.CallbackFunction(DockArea.CheckDragWindowExists); } EditorApplication.update = (EditorApplication.CallbackFunction)Delegate.Remove(arg_49F_0, DockArea.< > f__mg$cache1); if (DockArea.s_DropInfo != null && DockArea.s_DropInfo.dropArea != null) { DockArea.s_DropInfo.dropArea.PerformDrop(DockArea.s_DragPane, DockArea.s_DropInfo, vector); } else { EditorWindow editorWindow = DockArea.s_DragPane; DockArea.ResetDragVars(); this.RemoveTab(editorWindow); Rect position = editorWindow.position; position.x = vector.x - position.width * 0.5f; position.y = vector.y - position.height * 0.5f; if (Application.platform == RuntimePlatform.WindowsEditor) { position.y = Mathf.Max(InternalEditorUtility.GetBoundsOfDesktopAtPoint(vector).y, position.y); } EditorWindow.CreateNewWindowForEditorWindow(editorWindow, false, false); editorWindow.position = editorWindow.m_Parent.window.FitWindowRectToScreen(position, true, true); GUIUtility.hotControl = 0; GUIUtility.ExitGUI(); } DockArea.ResetDragVars(); } GUIUtility.hotControl = 0; current.Use(); } goto IL_746; case EventType.MouseMove: case EventType.KeyDown: case EventType.KeyUp: case EventType.ScrollWheel: IL_6F: if (typeForControl != EventType.ContextClick) { goto IL_746; } if (pos.Contains(current.mousePosition) && GUIUtility.hotControl == 0) { int tabAtMousePos2 = this.GetTabAtMousePos(current.mousePosition, pos); if (tabAtMousePos2 < this.m_Panes.Count) { base.PopupGenericMenu(this.m_Panes[tabAtMousePos2], new Rect(current.mousePosition.x, current.mousePosition.y, 0f, 0f)); } } goto IL_746; case EventType.MouseDrag: if (GUIUtility.hotControl == controlID) { Vector2 vector2 = current.mousePosition - DockArea.s_StartDragPosition; current.Use(); Rect screenPosition = base.screenPosition; bool flag = base.window.showMode != ShowMode.MainWindow || this.AllowTabAction(); if (DockArea.s_DragMode == 0 && vector2.sqrMagnitude > 99f && flag) { DockArea.s_DragMode = 1; DockArea.s_PlaceholderPos = this.selected; DockArea.s_DragPane = this.m_Panes[this.selected]; if (this.m_Panes.Count == 1) { DockArea.s_IgnoreDockingForView = this; } else { DockArea.s_IgnoreDockingForView = null; } DockArea.s_OriginalDragSource = this; PaneDragTab.get.Show(new Rect(pos.x + screenPosition.x + tabWidth * (float)this.selected, pos.y + screenPosition.y, tabWidth, pos.height), DockArea.s_DragPane.titleContent, base.position.size, GUIUtility.GUIToScreenPoint(current.mousePosition)); Delegate arg_2F5_0 = EditorApplication.update; if (DockArea.< > f__mg$cache0 == null) { DockArea.< > f__mg$cache0 = new EditorApplication.CallbackFunction(DockArea.CheckDragWindowExists); } EditorApplication.update = (EditorApplication.CallbackFunction)Delegate.Combine(arg_2F5_0, DockArea.< > f__mg$cache0); GUIUtility.ExitGUI(); } if (DockArea.s_DragMode == 1) { DropInfo dropInfo = null; ContainerWindow[] windows = ContainerWindow.windows; Vector2 vector3 = GUIUtility.GUIToScreenPoint(current.mousePosition); ContainerWindow inFrontOf = null; ContainerWindow[] array = windows; for (int i = 0; i < array.Length; i++) { ContainerWindow containerWindow = array[i]; SplitView rootSplitView = containerWindow.rootSplitView; if (!(rootSplitView == null)) { dropInfo = rootSplitView.DragOverRootView(vector3); if (dropInfo == null) { View[] allChildren = containerWindow.rootView.allChildren; for (int j = 0; j < allChildren.Length; j++) { View view = allChildren[j]; IDropArea dropArea = view as IDropArea; if (dropArea != null) { dropInfo = dropArea.DragOver(DockArea.s_DragPane, vector3); } if (dropInfo != null) { break; } } } if (dropInfo != null) { inFrontOf = containerWindow; break; } } } if (dropInfo == null) { dropInfo = new DropInfo(null); } if (dropInfo.type != DropInfo.Type.Tab) { DockArea.s_PlaceholderPos = -1; } DockArea.s_DropInfo = dropInfo; if (PaneDragTab.get.m_Window) { PaneDragTab.get.SetDropInfo(dropInfo, vector3, inFrontOf); } } } goto IL_746; case EventType.Repaint: { float num = pos.xMin; int num2 = 0; if (base.actualView) { for (int k = 0; k < this.m_Panes.Count; k++) { if (!(DockArea.s_DragPane == this.m_Panes[k])) { if (DockArea.s_DropInfo != null && object.ReferenceEquals(DockArea.s_DropInfo.dropArea, this) && DockArea.s_PlaceholderPos == num2) { num += tabWidth; } Rect rect = new Rect(num, pos.yMin, tabWidth, pos.height); float num3 = Mathf.Round(rect.x); Rect position2 = new Rect(num3, rect.y, Mathf.Round(rect.x + rect.width) - num3, rect.height); tabStyle.Draw(position2, this.m_Panes[k].titleContent, false, false, k == this.selected, base.hasFocus); num += tabWidth; num2++; } } } else { Rect rect2 = new Rect(num, pos.yMin, tabWidth, pos.height); float num4 = Mathf.Round(rect2.x); Rect position3 = new Rect(num4, rect2.y, Mathf.Round(rect2.x + rect2.width) - num4, rect2.height); tabStyle.Draw(position3, "Failed to load", false, false, true, false); } goto IL_746; } } goto IL_6F; IL_746: this.selected = Mathf.Clamp(this.selected, 0, this.m_Panes.Count - 1); }
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); }
private static void RecalcMinMaxAndReflowAll(SplitView start) { SplitView node = start; SplitView parent = start; do { node = parent; parent = node.parent as SplitView; } while (parent != null); RecalcMinMaxRecurse(node); ReflowRecurse(node); }
private static void RecalcMinMaxRecurse(SplitView node) { foreach (View view in node.children) { SplitView view2 = view as SplitView; if (view2 != null) { RecalcMinMaxRecurse(view2); } } node.ChildrenMinMaxChanged(); }
private static void ReflowRecurse(SplitView node) { node.Reflow(); foreach (View view in node.children) { SplitView view2 = view as SplitView; if (view2 != null) { RecalcMinMaxRecurse(view2); } } }
public ExtraDropInfo(bool rootWindow, SplitView.ViewEdge edge, int index) { this.rootWindow = rootWindow; this.edge = edge; this.index = index; }
public void SplitGUI(Event evt) { if (this.splitState == null) { this.SetupSplitter(); } SplitView parent = base.parent as SplitView; if (parent != null) { Event event2 = new Event(evt); event2.mousePosition += new Vector2(base.position.x, base.position.y); parent.SplitGUI(event2); if (event2.type == EventType.Used) { evt.Use(); } } float num = !this.vertical ? evt.mousePosition.x : evt.mousePosition.y; int controlID = GUIUtility.GetControlID(0x857b3, FocusType.Passive); this.controlID = controlID; EventType typeForControl = evt.GetTypeForControl(controlID); if (typeForControl == EventType.MouseDown) { if (base.children.Length != 1) { int num3 = !this.vertical ? ((int)base.children[0].position.x) : ((int)base.children[0].position.y); for (int i = 0; i < (base.children.Length - 1); i++) { if (i >= this.splitState.realSizes.Length) { DockArea current = GUIView.current as DockArea; string str = "Non-dock area " + GUIView.current.GetType(); if (((current != null) && (current.m_Selected < current.m_Panes.Count)) && (current.m_Panes[current.m_Selected] != null)) { str = current.m_Panes[current.m_Selected].GetType().ToString(); } if (Unsupported.IsDeveloperBuild()) { Debug.LogError(string.Concat(new object[] { "Real sizes out of bounds for: ", str, " index: ", i, " RealSizes: ", this.splitState.realSizes.Length })); } this.SetupSplitter(); } Rect rect5 = !this.vertical ? new Rect((float)((num3 + this.splitState.realSizes[i]) - (this.splitState.splitSize / 2)), base.children[0].position.y, (float)this.splitState.splitSize, base.children[0].position.height) : new Rect(base.children[0].position.x, (float)((num3 + this.splitState.realSizes[i]) - (this.splitState.splitSize / 2)), base.children[0].position.width, (float)this.splitState.splitSize); if (rect5.Contains(evt.mousePosition)) { this.splitState.splitterInitialOffset = (int)num; this.splitState.currentActiveSplitter = i; GUIUtility.hotControl = controlID; evt.Use(); break; } num3 += this.splitState.realSizes[i]; } } } else if (typeForControl == EventType.MouseDrag) { if (((base.children.Length > 1) && (GUIUtility.hotControl == controlID)) && (this.splitState.currentActiveSplitter >= 0)) { int diff = ((int)num) - this.splitState.splitterInitialOffset; if (diff != 0) { this.splitState.splitterInitialOffset = (int)num; this.splitState.DoSplitter(this.splitState.currentActiveSplitter, this.splitState.currentActiveSplitter + 1, diff); } this.SetupRectsFromSplitter(); evt.Use(); } } else if ((typeForControl == EventType.MouseUp) && (GUIUtility.hotControl == controlID)) { GUIUtility.hotControl = 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); }
public void OldOnGUI() { 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.rootView.GetType() != typeof(MainView)) { 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(); } } Rect rect = this.background.margin.Remove(new Rect(0f, 0f, base.position.width, base.position.height)); rect.x = (float)this.background.margin.left; rect.y = (float)this.background.margin.top; Rect windowPosition = base.windowPosition; float num2 = 2f; if (windowPosition.x == 0f) { rect.x -= num2; rect.width += num2; } if (windowPosition.xMax == base.window.position.width) { rect.width += num2; } if (windowPosition.yMax == base.window.position.height) { rect.height += ((!flag) ? 2f : 2f); } if (Event.current.type == EventType.Repaint) { this.background.Draw(rect, GUIContent.none, 0); } if (this.tabStyle == null) { this.tabStyle = "dragtab"; } if (this.m_Panes.Count > 0) { HostView.BeginOffsetArea(new Rect(rect.x + 2f, rect.y + 17f, rect.width - 4f, rect.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; HostView.EndOffsetArea(); } this.DragTab(new Rect(rect.x + 1f, rect.y, rect.width - 40f, 17f), this.tabStyle); this.tabStyle = "dragtab"; base.ShowGenericMenu(); if (this.m_Panes.Count > 0) { base.InvokeOnGUI(rect); } EditorGUI.ShowRepaints(); Highlighter.ControlHighlightGUI(this); }
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); }
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); }
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); }
public void SplitGUI(Event evt) { if (this.splitState == null) { this.SetupSplitter(); } SplitView parent = this.parent as SplitView; if ((bool)((Object)parent)) { Event evt1 = new Event(evt); evt1.mousePosition += new Vector2(this.position.x, this.position.y); parent.SplitGUI(evt1); if (evt1.type == EventType.Used) { evt.Use(); } } float num1 = !this.vertical ? evt.mousePosition.x : evt.mousePosition.y; int controlId = GUIUtility.GetControlID(546739, FocusType.Passive); this.controlID = controlId; switch (evt.GetTypeForControl(controlId)) { case EventType.MouseDown: if (this.children.Length == 1) { break; } int num2 = !this.vertical ? (int)this.children[0].position.x : (int)this.children[0].position.y; for (int index = 0; index < this.children.Length - 1; ++index) { if (index >= this.splitState.realSizes.Length) { DockArea current = GUIView.current as DockArea; string str = "Non-dock area " + (object)GUIView.current.GetType(); if ((bool)((Object)current) && current.m_Selected < current.m_Panes.Count && (bool)((Object)current.m_Panes[current.m_Selected])) { str = current.m_Panes[current.m_Selected].GetType().ToString(); } if (Unsupported.IsDeveloperBuild()) { Debug.LogError((object)("Real sizes out of bounds for: " + str + " index: " + (object)index + " RealSizes: " + (object)this.splitState.realSizes.Length)); } this.SetupSplitter(); } if ((!this.vertical ? new Rect((float)(num2 + this.splitState.realSizes[index] - this.splitState.splitSize / 2), this.children[0].position.y, (float)this.splitState.splitSize, this.children[0].position.height) : new Rect(this.children[0].position.x, (float)(num2 + this.splitState.realSizes[index] - this.splitState.splitSize / 2), this.children[0].position.width, (float)this.splitState.splitSize)).Contains(evt.mousePosition)) { this.splitState.splitterInitialOffset = (int)num1; this.splitState.currentActiveSplitter = index; GUIUtility.hotControl = controlId; evt.Use(); break; } num2 += this.splitState.realSizes[index]; } break; case EventType.MouseUp: if (GUIUtility.hotControl != controlId) { break; } GUIUtility.hotControl = 0; break; case EventType.MouseDrag: if (this.children.Length <= 1 || GUIUtility.hotControl != controlId || this.splitState.currentActiveSplitter < 0) { break; } int diff = (int)num1 - this.splitState.splitterInitialOffset; if (diff != 0) { this.splitState.splitterInitialOffset = (int)num1; this.splitState.DoSplitter(this.splitState.currentActiveSplitter, this.splitState.currentActiveSplitter + 1, diff); } this.SetupRectsFromSplitter(); evt.Use(); break; } }
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); }
public void OnGUI() { this.ClearBackground(); EditorGUIUtility.ResetGUIState(); SplitView parent = this.parent as SplitView; if (Event.current.type == EventType.Repaint && (bool)((UnityEngine.Object)parent)) { View child = (View)this; for (; (bool)((UnityEngine.Object)parent); parent = parent.parent as SplitView) { int controlId = parent.controlID; if (controlId == GUIUtility.hotControl || GUIUtility.hotControl == 0) { int num = parent.IndexOfChild(child); if (parent.vertical) { if (num != 0) { EditorGUIUtility.AddCursorRect(new Rect(0.0f, 0.0f, this.position.width, 5f), MouseCursor.SplitResizeUpDown, controlId); } if (num != parent.children.Length - 1) { EditorGUIUtility.AddCursorRect(new Rect(0.0f, this.position.height - 5f, this.position.width, 5f), MouseCursor.SplitResizeUpDown, controlId); } } else { if (num != 0) { EditorGUIUtility.AddCursorRect(new Rect(0.0f, 0.0f, 5f, this.position.height), MouseCursor.SplitResizeLeftRight, controlId); } if (num != parent.children.Length - 1) { EditorGUIUtility.AddCursorRect(new Rect(this.position.width - 5f, 0.0f, 5f, this.position.height), MouseCursor.SplitResizeLeftRight, controlId); } } } child = (View)parent; } parent = this.parent as SplitView; } bool flag = false; if (this.window.mainView.GetType() != typeof(MainWindow)) { flag = true; if ((double)this.windowPosition.y == 0.0) { this.background = (GUIStyle)"dockareaStandalone"; } else { this.background = (GUIStyle)"dockarea"; } } else { this.background = (GUIStyle)"dockarea"; } if ((bool)((UnityEngine.Object)parent)) { Event evt = new Event(Event.current); evt.mousePosition += new Vector2(this.position.x, this.position.y); parent.SplitGUI(evt); if (evt.type == EventType.Used) { Event.current.Use(); } } GUIStyle style = (GUIStyle)"dockareaoverlay"; Rect position = this.background.margin.Remove(new Rect(0.0f, 0.0f, this.position.width, this.position.height)); position.x = (float)this.background.margin.left; position.y = (float)this.background.margin.top; Rect windowPosition = this.windowPosition; float num1 = 2f; if ((double)windowPosition.x == 0.0) { position.x -= num1; position.width += num1; } if ((double)windowPosition.xMax == (double)this.window.position.width) { position.width += num1; } if ((double)windowPosition.yMax == (double)this.window.position.height) { position.height += !flag ? 2f : 2f; } GUI.Box(position, GUIContent.none, this.background); if (this.tabStyle == null) { this.tabStyle = (GUIStyle)"dragtab"; } this.DragTab(new Rect(position.x + 1f, position.y, position.width - 40f, 17f), this.tabStyle); this.tabStyle = (GUIStyle)"dragtab"; this.ShowGenericMenu(); this.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, (float)((double)position.height - 17.0 - 2.0)), GUIContent.none, (GUIStyle)"TabWindowBackground"); Vector2 screenPoint = GUIUtility.GUIToScreenPoint(Vector2.zero); Rect rect = this.borderSize.Remove(this.position); rect.x = screenPoint.x; rect.y = screenPoint.y; this.m_Panes[this.selected].m_Pos = rect; EditorGUIUtility.ResetGUIState(); try { this.Invoke("OnGUI"); } catch (TargetInvocationException ex) { throw ex.InnerException; } EditorGUIUtility.ResetGUIState(); if ((UnityEngine.Object) this.actualView != (UnityEngine.Object)null && (double)this.actualView.m_FadeoutTime != 0.0 && (Event.current != null && Event.current.type == EventType.Repaint)) { this.actualView.DrawNotification(); } DockArea.EndOffsetArea(); } this.DoWindowDecorationEnd(); GUI.Box(position, GUIContent.none, style); EditorGUI.ShowRepaints(); Highlighter.ControlHighlightGUI((GUIView)this); }
public void Cleanup() { SplitView splitView = base.parent as SplitView; if (base.children.Length == 1 && splitView != null) { View view = base.children[0]; view.position = base.position; if (base.parent != null) { base.parent.AddChild(view, base.parent.IndexOfChild(this)); base.parent.RemoveChild(this); if (splitView) { splitView.Cleanup(); } view.position = base.position; if (!Unsupported.IsDestroyScriptableObject(this)) { UnityEngine.Object.DestroyImmediate(this); } return; } if (view is SplitView) { this.RemoveChild(view); base.window.rootView = view; view.position = new Rect(0f, 0f, view.window.position.width, base.window.position.height); view.Reflow(); if (!Unsupported.IsDestroyScriptableObject(this)) { UnityEngine.Object.DestroyImmediate(this); } return; } } if (splitView) { splitView.Cleanup(); splitView = (base.parent as SplitView); if (splitView) { if (splitView.vertical == this.vertical) { int num = new List <View>(base.parent.children).IndexOf(this); View[] children = base.children; for (int i = 0; i < children.Length; i++) { View view2 = children[i]; splitView.AddChild(view2, num++); view2.position = new Rect(base.position.x + view2.position.x, base.position.y + view2.position.y, view2.position.width, view2.position.height); } } } } if (base.children.Length == 0) { if (base.parent == null && base.window != null) { base.window.Close(); } else { ICleanuppable cleanuppable = base.parent as ICleanuppable; if (base.parent is SplitView) { ((SplitView)base.parent).RemoveChildNice(this); if (!Unsupported.IsDestroyScriptableObject(this)) { UnityEngine.Object.DestroyImmediate(this, true); } } cleanuppable.Cleanup(); } } else { this.splitState = null; this.Reflow(); } }
/// clean up this view & propagate down public void Cleanup() { // if I'm a one-view splitview, I can propagate my child up and kill myself SplitView sp = parent as SplitView; if (children.Length == 1 && sp != null) { View c = children[0]; c.position = position; if (parent != null) { parent.AddChild(c, parent.IndexOfChild(this)); parent.RemoveChild(this); if (sp) { sp.Cleanup(); } c.position = position; if (!Unsupported.IsDestroyScriptableObject(this)) { DestroyImmediate(this); } return; } else if (c is SplitView) { RemoveChild(c); window.rootView = c; c.position = new Rect(0, 0, c.window.position.width, window.position.height); c.Reflow(); if (!Unsupported.IsDestroyScriptableObject(this)) { DestroyImmediate(this); } return; } } if (sp) { sp.Cleanup(); // the parent might have moved US up and gotten rid of itself sp = parent as SplitView; if (sp) { // If the parent has the same orientation as us, we can move our views up and kill ourselves if (sp.vertical == vertical) { int idx = new List <View>(parent.children).IndexOf(this); foreach (View child in children) { sp.AddChild(child, idx++); child.position = new Rect(position.x + child.position.x, position.y + child.position.y, child.position.width, child.position.height); } } } } if (children.Length == 0) { if (parent == null && window != null) { // if we're root in the window, we'll remove ourselves window.Close(); } else { ICleanuppable ic = parent as ICleanuppable; if (parent is SplitView) { ((SplitView)parent).RemoveChildNice(this); if (!Unsupported.IsDestroyScriptableObject(this)) { DestroyImmediate(this, true); } } else { // This is we're root in the main window. // We want to stay, but tell the parent (MainWindow) to Cleanup, so he can reduce us to zero-size /* parent.RemoveChild (this);*/ } ic.Cleanup(); } return; } else { splitState = null; Reflow(); } }
public void SplitGUI(Event evt) { if (this.splitState == null) { this.SetupSplitter(); } SplitView splitView = base.parent as SplitView; if (splitView) { Event @event = new Event(evt); @event.mousePosition += new Vector2(base.position.x, base.position.y); splitView.SplitGUI(@event); if (@event.type == EventType.Used) { evt.Use(); } } float num = (!this.vertical) ? evt.mousePosition.x : evt.mousePosition.y; int num2 = GUIUtility.GetControlID(546739, FocusType.Passive); this.controlID = num2; EventType typeForControl = evt.GetTypeForControl(num2); if (typeForControl != EventType.MouseDown) { if (typeForControl != EventType.MouseDrag) { if (typeForControl == EventType.MouseUp) { if (GUIUtility.hotControl == num2) { GUIUtility.hotControl = 0; } } } else if (base.children.Length > 1 && GUIUtility.hotControl == num2 && this.splitState.currentActiveSplitter >= 0) { int num3 = (int)num - this.splitState.splitterInitialOffset; if (num3 != 0) { this.splitState.splitterInitialOffset = (int)num; this.splitState.DoSplitter(this.splitState.currentActiveSplitter, this.splitState.currentActiveSplitter + 1, num3); } this.SetupRectsFromSplitter(); evt.Use(); } } else if (base.children.Length != 1) { int num4 = (!this.vertical) ? ((int)base.children[0].position.x) : ((int)base.children[0].position.y); for (int i = 0; i < base.children.Length - 1; i++) { if (i >= this.splitState.realSizes.Length) { DockArea dockArea = GUIView.current as DockArea; string text = "Non-dock area " + GUIView.current.GetType(); if (dockArea && dockArea.m_Selected < dockArea.m_Panes.Count && dockArea.m_Panes[dockArea.m_Selected]) { text = dockArea.m_Panes[dockArea.m_Selected].GetType().ToString(); } if (Unsupported.IsDeveloperBuild()) { Debug.LogError(string.Concat(new object[] { "Real sizes out of bounds for: ", text, " index: ", i, " RealSizes: ", this.splitState.realSizes.Length })); } this.SetupSplitter(); } if (((!this.vertical) ? new Rect((float)(num4 + this.splitState.realSizes[i] - this.splitState.splitSize / 2), base.children[0].position.y, (float)this.splitState.splitSize, base.children[0].position.height) : new Rect(base.children[0].position.x, (float)(num4 + this.splitState.realSizes[i] - this.splitState.splitSize / 2), base.children[0].position.width, (float)this.splitState.splitSize)).Contains(evt.mousePosition)) { this.splitState.splitterInitialOffset = (int)num; this.splitState.currentActiveSplitter = i; GUIUtility.hotControl = num2; evt.Use(); break; } num4 += this.splitState.realSizes[i]; } } }
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); }
public void Cleanup() { SplitView parent = base.parent as SplitView; if ((base.children.Length == 1) && (parent != null)) { View child = base.children[0]; child.position = base.position; if (base.parent != null) { base.parent.AddChild(child, base.parent.IndexOfChild(this)); base.parent.RemoveChild(this); if (parent != null) { parent.Cleanup(); } child.position = base.position; if (!Unsupported.IsDestroyScriptableObject(this)) { UnityEngine.Object.DestroyImmediate(this); } return; } if (child is SplitView) { this.RemoveChild(child); base.window.rootView = child; child.position = new Rect(0f, 0f, child.window.position.width, base.window.position.height); child.Reflow(); if (!Unsupported.IsDestroyScriptableObject(this)) { UnityEngine.Object.DestroyImmediate(this); } return; } } if (parent != null) { parent.Cleanup(); parent = base.parent as SplitView; if ((parent != null) && (parent.vertical == this.vertical)) { int index = new List <View>(base.parent.children).IndexOf(this); foreach (View view3 in base.children) { parent.AddChild(view3, index++); view3.position = new Rect(base.position.x + view3.position.x, base.position.y + view3.position.y, view3.position.width, view3.position.height); } } } if (base.children.Length == 0) { if ((base.parent == null) && (base.window != null)) { base.window.Close(); } else { ICleanuppable cleanuppable = base.parent as ICleanuppable; if (base.parent is SplitView) { ((SplitView)base.parent).RemoveChildNice(this); if (!Unsupported.IsDestroyScriptableObject(this)) { UnityEngine.Object.DestroyImmediate(this, true); } } cleanuppable.Cleanup(); } } else { this.splitState = null; this.Reflow(); } }
public static void Unmaximize(EditorWindow win) { HostView parent = win.m_Parent; if (parent == null) { UnityEngine.Debug.LogError("Host view was not found"); WindowLayout.RevertFactorySettings(); } else { UnityEngine.Object[] array = InternalEditorUtility.LoadSerializedFileAndForget(Path.Combine(WindowLayout.layoutsProjectPath, "CurrentMaximizeLayout.dwlt")); if (array.Length < 2) { UnityEngine.Debug.Log("Maximized serialized file backup not found"); WindowLayout.RevertFactorySettings(); } else { SplitView splitView = array[0] as SplitView; EditorWindow editorWindow = array[1] as EditorWindow; if (splitView == null) { UnityEngine.Debug.Log("Maximization failed because the root split view was not found"); WindowLayout.RevertFactorySettings(); } else { ContainerWindow window = win.m_Parent.window; if (window == null) { UnityEngine.Debug.Log("Maximization failed because the root split view has no container window"); WindowLayout.RevertFactorySettings(); } else { try { ContainerWindow.SetFreezeDisplay(true); if (!parent.parent) { throw new Exception(); } int idx = parent.parent.IndexOfChild(parent); Rect position = parent.position; View parent2 = parent.parent; parent2.RemoveChild(idx); parent2.AddChild(splitView, idx); splitView.position = position; DockArea dockArea = editorWindow.m_Parent as DockArea; int idx2 = dockArea.m_Panes.IndexOf(editorWindow); parent.actualView = null; win.m_Parent = null; dockArea.AddTab(idx2, win); dockArea.RemoveTab(editorWindow); UnityEngine.Object.DestroyImmediate(editorWindow); UnityEngine.Object[] array2 = array; for (int i = 0; i < array2.Length; i++) { UnityEngine.Object @object = array2[i]; EditorWindow editorWindow2 = @object as EditorWindow; if (editorWindow2 != null) { editorWindow2.MakeParentsSettingsMatchMe(); } } parent2.Initialize(parent2.window); parent2.position = parent2.position; splitView.Reflow(); UnityEngine.Object.DestroyImmediate(parent); win.Focus(); window.DisplayAllViews(); win.m_Parent.MakeVistaDWMHappyDance(); } catch (Exception arg) { UnityEngine.Debug.Log("Maximization failed: " + arg); WindowLayout.RevertFactorySettings(); } try { if (Application.platform == RuntimePlatform.OSXEditor && SystemInfo.operatingSystem.Contains("10.7") && SystemInfo.graphicsDeviceVendor.Contains("ATI")) { UnityEngine.Object[] array3 = Resources.FindObjectsOfTypeAll(typeof(GUIView)); for (int j = 0; j < array3.Length; j++) { GUIView gUIView = (GUIView)array3[j]; gUIView.Repaint(); } } } finally { ContainerWindow.SetFreezeDisplay(false); } } } } } }
public static void Unmaximize(EditorWindow win) { HostView parent1 = win.m_Parent; if ((UnityEngine.Object)parent1 == (UnityEngine.Object)null) { UnityEngine.Debug.LogError((object)"Host view was not found"); WindowLayout.RevertFactorySettings(); } else { UnityEngine.Object[] objectArray = InternalEditorUtility.LoadSerializedFileAndForget(Path.Combine(WindowLayout.layoutsProjectPath, "CurrentMaximizeLayout.dwlt")); if (objectArray.Length < 2) { UnityEngine.Debug.Log((object)"Maximized serialized file backup not found"); WindowLayout.RevertFactorySettings(); } else { SplitView splitView = objectArray[0] as SplitView; EditorWindow pane = objectArray[1] as EditorWindow; if ((UnityEngine.Object)splitView == (UnityEngine.Object)null) { UnityEngine.Debug.Log((object)"Maximization failed because the root split view was not found"); WindowLayout.RevertFactorySettings(); } else { ContainerWindow window = win.m_Parent.window; if ((UnityEngine.Object)window == (UnityEngine.Object)null) { UnityEngine.Debug.Log((object)"Maximization failed because the root split view has no container window"); WindowLayout.RevertFactorySettings(); } else { try { ContainerWindow.SetFreezeDisplay(true); if (!(bool)((UnityEngine.Object)parent1.parent)) { throw new Exception(); } int idx1 = parent1.parent.IndexOfChild((View)parent1); Rect position = parent1.position; View parent2 = parent1.parent; parent2.RemoveChild(idx1); parent2.AddChild((View)splitView, idx1); splitView.position = position; DockArea parent3 = pane.m_Parent as DockArea; int idx2 = parent3.m_Panes.IndexOf(pane); parent1.actualView = (EditorWindow)null; win.m_Parent = (HostView)null; parent3.AddTab(idx2, win); parent3.RemoveTab(pane); UnityEngine.Object.DestroyImmediate((UnityEngine.Object)pane); foreach (UnityEngine.Object @object in objectArray) { EditorWindow editorWindow = @object as EditorWindow; if ((UnityEngine.Object)editorWindow != (UnityEngine.Object)null) { editorWindow.MakeParentsSettingsMatchMe(); } } parent2.Initialize(parent2.window); parent2.position = parent2.position; splitView.Reflow(); UnityEngine.Object.DestroyImmediate((UnityEngine.Object)parent1); win.Focus(); window.DisplayAllViews(); win.m_Parent.MakeVistaDWMHappyDance(); } catch (Exception ex) { UnityEngine.Debug.Log((object)("Maximization failed: " + (object)ex)); WindowLayout.RevertFactorySettings(); } try { if (Application.platform != RuntimePlatform.OSXEditor || !SystemInfo.operatingSystem.Contains("10.7") || !SystemInfo.graphicsDeviceVendor.Contains("ATI")) { return; } foreach (GUIView guiView in Resources.FindObjectsOfTypeAll(typeof(GUIView))) { guiView.Repaint(); } } finally { ContainerWindow.SetFreezeDisplay(false); } } } } } }