public static Rect GetDropDownRect(Rect buttonRect, Vector2 minSize, Vector2 maxSize, ContainerWindow popupContainerWindow, PopupLocationHelper.PopupLocation[] locationPriorityOrder) { if (locationPriorityOrder == null) { locationPriorityOrder = new PopupLocationHelper.PopupLocation[] { PopupLocationHelper.PopupLocation.Below, PopupLocationHelper.PopupLocation.Above }; } List<Rect> list = new List<Rect>(); PopupLocationHelper.PopupLocation[] array = locationPriorityOrder; for (int i = 0; i < array.Length; i++) { switch (array[i]) { case PopupLocationHelper.PopupLocation.Below: { Rect rect; if (PopupLocationHelper.PopupBelow(buttonRect, minSize, maxSize, popupContainerWindow, out rect)) { return rect; } list.Add(rect); break; } case PopupLocationHelper.PopupLocation.Above: { Rect rect; if (PopupLocationHelper.PopupAbove(buttonRect, minSize, maxSize, popupContainerWindow, out rect)) { return rect; } list.Add(rect); break; } case PopupLocationHelper.PopupLocation.Left: { Rect rect; if (PopupLocationHelper.PopupLeft(buttonRect, minSize, maxSize, popupContainerWindow, out rect)) { return rect; } list.Add(rect); break; } case PopupLocationHelper.PopupLocation.Right: { Rect rect; if (PopupLocationHelper.PopupRight(buttonRect, minSize, maxSize, popupContainerWindow, out rect)) { return rect; } list.Add(rect); break; } } } return PopupLocationHelper.GetLargestRect(list); }
public static Rect GetDropDownRect(Rect buttonRect, Vector2 minSize, Vector2 maxSize, ContainerWindow popupContainerWindow, PopupLocation[] locationPriorityOrder) { if (locationPriorityOrder == null) { locationPriorityOrder = new PopupLocation[] { PopupLocation.Below }; } List<Rect> rects = new List<Rect>(); PopupLocation[] locationArray = locationPriorityOrder; for (int i = 0; i < locationArray.Length; i++) { Rect rect; switch (locationArray[i]) { case PopupLocation.Below: if (!PopupBelow(buttonRect, minSize, maxSize, popupContainerWindow, out rect)) { break; } return rect; case PopupLocation.Above: if (!PopupAbove(buttonRect, minSize, maxSize, popupContainerWindow, out rect)) { goto Label_008B; } return rect; case PopupLocation.Left: if (!PopupLeft(buttonRect, minSize, maxSize, popupContainerWindow, out rect)) { goto Label_00B1; } return rect; case PopupLocation.Right: if (!PopupRight(buttonRect, minSize, maxSize, popupContainerWindow, out rect)) { goto Label_00D7; } return rect; default: { continue; } } rects.Add(rect); continue; Label_008B: rects.Add(rect); continue; Label_00B1: rects.Add(rect); continue; Label_00D7: rects.Add(rect); } return GetLargestRect(rects); }
private static Rect FitRect(Rect rect, ContainerWindow popupContainerWindow) { if (popupContainerWindow != null) { return popupContainerWindow.FitWindowRectToScreen(rect, true, true); } return ContainerWindow.FitRectToScreen(rect, true, true); }
internal virtual void Initialize(ContainerWindow win) { this.SetWindow(win); foreach (View view in this.m_Children) { view.m_Parent = this; view.Initialize(win); } }
private static bool PopupLeft(Rect buttonRect, Vector2 minSize, Vector2 maxSize, ContainerWindow popupContainerWindow, out Rect resultRect) { Rect rect1 = new Rect(buttonRect.x - maxSize.x, buttonRect.y, maxSize.x, maxSize.y); float num = 0.0f; rect1.xMin -= num; rect1.height += PopupLocationHelper.k_SpaceFromBottom; Rect rect2 = PopupLocationHelper.FitRect(rect1, popupContainerWindow); float a = Mathf.Max(buttonRect.x - rect2.x - num, 0.0f); float width = Mathf.Min(a, maxSize.x); resultRect = new Rect(rect2.x, rect2.y, width, rect2.height - PopupLocationHelper.k_SpaceFromBottom); return (double) a >= (double) minSize.x; }
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(); }
// Show as drop down list with custom fit to screen callback // 'buttonRect' is used for displaying the dropdown below that rect if possible otherwise above // 'windowSize' is used for setting up initial size // 'locationPriorityOrder' is for manual popup direction, if null it uses default order: down, up, left or right // 'giveFocus' is for whether the window should immediately be given focus (default true) internal void ShowAsDropDown(Rect buttonRect, Vector2 windowSize, PopupLocation[] locationPriorityOrder, ShowMode mode, bool giveFocus) { // Setup position before bringing window live (otherwise the dropshadow on Windows will be placed in 0,0 first frame) position = ShowAsDropDownFitToScreen(buttonRect, windowSize, locationPriorityOrder); // ShowWithMode() always grabs window focus so we use ShowPopup() for popup windows so PopupWindowWithoutFocus // will work correctly (no focus when opened). if (ContainerWindow.IsPopup(mode)) { ShowPopupWithMode(mode, giveFocus); } else { ShowWithMode(mode); } // Fit to screen again now that we have a container window position = ShowAsDropDownFitToScreen(buttonRect, windowSize, locationPriorityOrder); // Default to none resizable window minSize = new Vector2(position.width, position.height); maxSize = new Vector2(position.width, position.height); // Focus window if (giveFocus && focusedWindow != this) { Focus(); } else { Repaint(); } // Add after unfreezing display because AuxWindowManager.cpp assumes that aux windows are added after we got/lost- focus calls. m_Parent.AddToAuxWindowList(); // Dropdown windows should not be saved to layout m_Parent.window.m_DontSaveToLayout = true; }
internal static void InitPlaymodeLayout() { EditorApplicationLayout.m_GameView = (WindowLayout.ShowAppropriateViewOnEnterExitPlaymode(true) as GameView); if (EditorApplicationLayout.m_GameView == null) { return; } if (EditorApplicationLayout.m_GameView.maximizeOnPlay) { DockArea dockArea = EditorApplicationLayout.m_GameView.m_Parent as DockArea; if (dockArea != null) { ContainerWindow window = dockArea.actualView.m_Parent.window; if (!window.maximized) { EditorApplicationLayout.m_RootSplit = WindowLayout.MaximizePrepare(dockArea.actualView); } } } EditorApplicationLayout.m_GameView.m_Parent.SetAsStartView(); Toolbar.RepaintToolbar(); }
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(); }
public static Rect GetDropDownRect(Rect buttonRect, Vector2 minSize, Vector2 maxSize, ContainerWindow popupContainerWindow, PopupLocationHelper.PopupLocation[] locationPriorityOrder) { if (locationPriorityOrder == null) locationPriorityOrder = new PopupLocationHelper.PopupLocation[2] { PopupLocationHelper.PopupLocation.Below, PopupLocationHelper.PopupLocation.Above }; List<Rect> rects = new List<Rect>(); Rect resultRect; foreach (int num in locationPriorityOrder) { switch (num) { case 0: if (PopupLocationHelper.PopupBelow(buttonRect, minSize, maxSize, popupContainerWindow, out resultRect)) return resultRect; rects.Add(resultRect); break; case 1: if (PopupLocationHelper.PopupAbove(buttonRect, minSize, maxSize, popupContainerWindow, out resultRect)) return resultRect; rects.Add(resultRect); break; case 2: if (PopupLocationHelper.PopupLeft(buttonRect, minSize, maxSize, popupContainerWindow, out resultRect)) return resultRect; rects.Add(resultRect); break; case 3: if (PopupLocationHelper.PopupRight(buttonRect, minSize, maxSize, popupContainerWindow, out resultRect)) return resultRect; rects.Add(resultRect); break; } } return PopupLocationHelper.GetLargestRect(rects); }
public static void SaveWindowLayout(string path) { TooltipView.Close(); ArrayList arrayList = new ArrayList(); UnityEngine.Object[] array = Resources.FindObjectsOfTypeAll(typeof(EditorWindow)); UnityEngine.Object[] array2 = Resources.FindObjectsOfTypeAll(typeof(ContainerWindow)); UnityEngine.Object[] array3 = Resources.FindObjectsOfTypeAll(typeof(View)); UnityEngine.Object[] array4 = array2; for (int i = 0; i < array4.Length; i++) { ContainerWindow containerWindow = (ContainerWindow)array4[i]; if (!containerWindow.m_DontSaveToLayout) { arrayList.Add(containerWindow); } } UnityEngine.Object[] array5 = array3; for (int j = 0; j < array5.Length; j++) { View view = (View)array5[j]; if (!(view.window != null) || !view.window.m_DontSaveToLayout) { arrayList.Add(view); } } UnityEngine.Object[] array6 = array; for (int k = 0; k < array6.Length; k++) { EditorWindow editorWindow = (EditorWindow)array6[k]; if (!(editorWindow.m_Parent != null) || !(editorWindow.m_Parent.window != null) || !editorWindow.m_Parent.window.m_DontSaveToLayout) { arrayList.Add(editorWindow); } } InternalEditorUtility.SaveToSerializedFileAndForget(arrayList.ToArray(typeof(UnityEngine.Object)) as UnityEngine.Object[], path, false); }
public void Show(Rect pixelPos, GUIContent content, Vector2 viewSize, Vector2 mouseScreenPosition) { m_Content = content; // scale not to be larger then maxArea pixels. var area = viewSize.x * viewSize.y; m_FullWindowSize = viewSize * Mathf.Sqrt(Mathf.Clamp01(kMaxArea / area)); if (!m_Window) { m_Window = ScriptableObject.CreateInstance <ContainerWindow>(); m_Window.m_DontSaveToLayout = true; SetMinMaxSizes(Vector2.zero, new Vector2(10000, 10000)); SetWindowPos(pixelPos); m_Window.rootView = this; } else { SetWindowPos(pixelPos); } m_Window.Show(ShowMode.NoShadow, true, false); m_TargetRect = pixelPos; }
private bool AllowTabAction() { int mainWindowPaneCount = 0; ContainerWindow w = ContainerWindow.windows.FirstOrDefault(e => e.showMode == ShowMode.MainWindow); if (w != null) { foreach (View view in w.rootView.allChildren) { DockArea da = view as DockArea; if (da != null) { mainWindowPaneCount += da.m_Panes.Count; if (mainWindowPaneCount > 1) { return(true); } } } } return(false); }
internal void ShowWithMode(ShowMode mode) { if (m_Parent == null) { SavedGUIState oldState = SavedGUIState.Create(); ContainerWindow cw = ScriptableObject.CreateInstance <ContainerWindow>(); cw.title = titleContent.text; HostView host = ScriptableObject.CreateInstance <HostView>(); host.actualView = this; // Among other things, this sets m_Parent to host Rect r = m_Parent.borderSize.Add(new Rect(position.x, position.y, position.width, position.height)); // Order is important here: first set rect of container, then assign main view, then apply various settings, then show. // Otherwise the rect won't be set until first resize happens. cw.position = r; cw.rootView = host; MakeParentsSettingsMatchMe(); cw.Show(mode, loadPosition: true, displayImmediately: false, setFocus: true); // set min/max size now that native window is not null so that it will e.g., use proper styleMask on macOS cw.SetMinMaxSizes(minSize, maxSize); oldState.ApplyAndForget(); } }
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); } } } } } }
internal void SetWindowRecurse(ContainerWindow win) { this.SetWindow(win); foreach (View view in this.m_Children) { view.SetWindowRecurse(win); } }
public static bool LoadWindowLayout(string path, bool newProjectLayoutWasCreated) { Rect mainWindowPosition = new Rect(); UnityObject[] containers = Resources.FindObjectsOfTypeAll(typeof(ContainerWindow)); foreach (ContainerWindow window in containers) { if (window.showMode == ShowMode.MainWindow) { mainWindowPosition = window.position; } } bool layoutLoadingIssue = false; // Load new windows and show them try { ContainerWindow.SetFreezeDisplay(true); CloseWindows(); // Load data UnityObject[] loadedWindows = InternalEditorUtility.LoadSerializedFileAndForget(path); if (loadedWindows == null || loadedWindows.Length == 0) { throw new ArgumentException("Window layout at '" + path + "' could not be loaded."); } List <UnityObject> newWindows = new List <UnityObject>(); // At this point, unparented editor windows are neither desired nor desirable. // This can be caused by (legacy) serialization of FallbackEditorWindows or // other serialization hiccups (note that unparented editor windows should not exist in theory). // Same goes for empty DockAreas (no panes). Leave them behind. for (int i = 0; i < loadedWindows.Length; i++) { UnityObject o = loadedWindows[i]; EditorWindow editorWin = o as EditorWindow; if (editorWin != null) { if (editorWin.m_Parent == null) { UnityObject.DestroyImmediate(editorWin, true); Console.WriteLine("LoadWindowLayout: Removed unparented EditorWindow while reading window layout: window #" + i + ", type=" + o.GetType().ToString() + ", instanceID=" + o.GetInstanceID()); layoutLoadingIssue = true; continue; } } else { DockArea dockArea = o as DockArea; if (dockArea != null && dockArea.m_Panes.Count == 0) { dockArea.Close(null); Console.WriteLine("LoadWindowLayout: Removed empty DockArea while reading window layout: window #" + i + ", instanceID=" + o.GetInstanceID()); layoutLoadingIssue = true; continue; } } newWindows.Add(o); } ContainerWindow mainWindowToSetSize = null; ContainerWindow mainWindow = null; for (int i = 0; i < newWindows.Count; i++) { ContainerWindow cur = newWindows[i] as ContainerWindow; if (cur != null && cur.showMode == ShowMode.MainWindow) { mainWindow = cur; if (mainWindowPosition.width != 0.0) { mainWindowToSetSize = cur; mainWindowToSetSize.position = mainWindowPosition; } } } for (int i = 0; i < newWindows.Count; i++) { UnityObject o = newWindows[i]; if (o == null) { Console.WriteLine("LoadWindowLayout: Error while reading window layout: window #" + i + " is null"); layoutLoadingIssue = true; // Keep going } else if (o.GetType() == null) { Console.WriteLine("LoadWindowLayout: Error while reading window layout: window #" + i + " type is null, instanceID=" + o.GetInstanceID()); layoutLoadingIssue = true; // Keep going } else { if (newProjectLayoutWasCreated) { MethodInfo method = o.GetType().GetMethod("OnNewProjectLayoutWasCreated", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); if (method != null) { method.Invoke(o, null); } } } } if (mainWindowToSetSize) { mainWindowToSetSize.position = mainWindowPosition; mainWindowToSetSize.OnResize(); } // Always show main window before other windows. So that other windows can // get their parent/owner. if (mainWindow == null) { Debug.LogError("Error while reading window layout: no main window found"); throw new System.Exception(); } mainWindow.Show(mainWindow.showMode, true, true); // Show other windows for (int i = 0; i < newWindows.Count; i++) { EditorWindow win = newWindows[i] as EditorWindow; if (win) { win.minSize = win.minSize; // Causes minSize to be propagated upwards to parents! } ContainerWindow containerWindow = newWindows[i] as ContainerWindow; if (containerWindow && containerWindow != mainWindow) { containerWindow.Show(containerWindow.showMode, true, true); } } // Unmaximize maximized GameView if maximize on play is enabled GameView gameView = GetMaximizedWindow() as GameView; if (gameView != null && gameView.maximizeOnPlay) { Unmaximize(gameView); } // For new projects, show services window if and only if online and logged in if (newProjectLayoutWasCreated) { if (UnityConnect.instance.online && UnityConnect.instance.loggedIn && UnityConnect.instance.shouldShowServicesWindow) { UnityConnectServiceCollection.instance.ShowService(HubAccess.kServiceName, true, "new_project_created"); } else { UnityConnectServiceCollection.instance.CloseServices(); } } } catch (System.Exception ex) { Debug.LogError("Failed to load window layout: " + ex); int option = 0; UnityObject[] containerWindows = Resources.FindObjectsOfTypeAll(typeof(ContainerWindow)); // Only show dialog if an actual window is present. If not, revert to default immediately if (!Application.isTestRun && containerWindows.Length > 0) { option = EditorUtility.DisplayDialogComplex("Failed to load window layout", "This can happen if layout contains custom windows and there are compile errors in the project.", "Load Default Layout", "Quit", "Revert Factory Settings"); } switch (option) { case 0: LoadDefaultLayout(); break; case 1: EditorApplication.Exit(0); break; case 2: RevertFactorySettings(); break; } return(false); } finally { ContainerWindow.SetFreezeDisplay(false); if (Path.GetExtension(path) == ".wlt") { Toolbar.lastLoadedLayoutName = Path.GetFileNameWithoutExtension(path); } else { Toolbar.lastLoadedLayoutName = null; } } if (layoutLoadingIssue) { Debug.Log("The editor layout could not be fully loaded, this can happen when the layout contains EditorWindows not available in this project"); } return(true); }
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); } }
private static bool PopupAbove(Rect buttonRect, Vector2 minSize, Vector2 maxSize, ContainerWindow popupContainerWindow, out Rect resultRect) { Rect rect = new Rect(buttonRect.x, buttonRect.y - maxSize.y, maxSize.x, maxSize.y); float num = 0f; rect.yMin -= num; rect = FitRect(rect, popupContainerWindow); float a = Mathf.Max((float) ((buttonRect.y - rect.y) - num), (float) 0f); if (a >= minSize.y) { float height = Mathf.Min(a, maxSize.y); resultRect = new Rect(rect.x, buttonRect.y - height, rect.width, height); return true; } resultRect = new Rect(rect.x, buttonRect.y - a, rect.width, a); return false; }
public static Rect GetDropDownRect(Rect buttonRect, Vector2 minSize, Vector2 maxSize, ContainerWindow popupContainerWindow) { return GetDropDownRect(buttonRect, minSize, maxSize, popupContainerWindow, null); }
private static extern void INTERNAL_CALL_Internal_SetMinMaxSizes(ContainerWindow self, ref Vector2 minSize, ref Vector2 maxSize);
private static Rect FitRect(Rect rect, ContainerWindow popupContainerWindow) { if ((bool) ((Object) popupContainerWindow)) return popupContainerWindow.FitWindowRectToScreen(rect, true, true); return ContainerWindow.FitRectToScreen(rect, true, true); }
private static extern void INTERNAL_CALL_SetBackgroundColor(ContainerWindow self, ref Color color);
public static Rect GetDropDownRect(Rect buttonRect, Vector2 minSize, Vector2 maxSize, ContainerWindow popupContainerWindow) { return PopupLocationHelper.GetDropDownRect(buttonRect, minSize, maxSize, popupContainerWindow, (PopupLocationHelper.PopupLocation[]) null); }
private static bool PopupBelow(Rect buttonRect, Vector2 minSize, Vector2 maxSize, ContainerWindow popupContainerWindow, out Rect resultRect) { Rect rect1 = new Rect(buttonRect.x, buttonRect.yMax, maxSize.x, maxSize.y); rect1.height += PopupLocationHelper.k_SpaceFromBottom; Rect rect2 = PopupLocationHelper.FitRect(rect1, popupContainerWindow); float num = Mathf.Max(rect2.yMax - buttonRect.yMax - PopupLocationHelper.k_SpaceFromBottom, 0.0f); if ((double) num >= (double) minSize.y) { float height = Mathf.Min(num, maxSize.y); resultRect = new Rect(rect2.x, buttonRect.yMax, rect2.width, height); return true; } resultRect = new Rect(rect2.x, buttonRect.yMax, rect2.width, num); return false; }
public extern void MoveBehindOf(ContainerWindow other);
public extern void MoveInFrontOf(ContainerWindow other);
private static extern void INTERNAL_CALL_Internal_Show(ContainerWindow self, ref Rect r, int showMode, ref Vector2 minSize, ref Vector2 maxSize);
public static bool LoadWindowLayout(string path, bool newProjectLayoutWasCreated) { Rect position = default(Rect); UnityEngine.Object[] array = Resources.FindObjectsOfTypeAll(typeof(ContainerWindow)); UnityEngine.Object[] array2 = array; for (int i = 0; i < array2.Length; i++) { ContainerWindow containerWindow = (ContainerWindow)array2[i]; if (containerWindow.showMode == ShowMode.MainWindow) { position = containerWindow.position; } } bool result; try { ContainerWindow.SetFreezeDisplay(true); WindowLayout.CloseWindows(); UnityEngine.Object[] array3 = InternalEditorUtility.LoadSerializedFileAndForget(path); List <UnityEngine.Object> list = new List <UnityEngine.Object>(); int j = 0; while (j < array3.Length) { UnityEngine.Object @object = array3[j]; EditorWindow editorWindow = @object as EditorWindow; if (editorWindow != null) { if (!(editorWindow.m_Parent == null)) { goto IL_17D; } UnityEngine.Object.DestroyImmediate(editorWindow, true); UnityEngine.Debug.LogError(string.Concat(new object[] { "Removed unparented EditorWindow while reading window layout: window #", j, ", type=", @object.GetType().ToString(), ", instanceID=", @object.GetInstanceID() })); } else { DockArea dockArea = @object as DockArea; if (!(dockArea != null) || dockArea.m_Panes.Count != 0) { goto IL_17D; } dockArea.Close(null); UnityEngine.Debug.LogError(string.Concat(new object[] { "Removed empty DockArea while reading window layout: window #", j, ", instanceID=", @object.GetInstanceID() })); } IL_187: j++; continue; IL_17D: list.Add(@object); goto IL_187; } ContainerWindow containerWindow2 = null; ContainerWindow containerWindow3 = null; for (int k = 0; k < list.Count; k++) { ContainerWindow containerWindow4 = list[k] as ContainerWindow; if (containerWindow4 != null && containerWindow4.showMode == ShowMode.MainWindow) { containerWindow3 = containerWindow4; if ((double)position.width != 0.0) { containerWindow2 = containerWindow4; containerWindow2.position = position; } } } for (int l = 0; l < list.Count; l++) { UnityEngine.Object object2 = list[l]; if (object2 == null) { UnityEngine.Debug.LogError("Error while reading window layout: window #" + l + " is null"); } else if (object2.GetType() == null) { UnityEngine.Debug.LogError(string.Concat(new object[] { "Error while reading window layout: window #", l, " type is null, instanceID=", object2.GetInstanceID() })); } else if (newProjectLayoutWasCreated) { MethodInfo method = object2.GetType().GetMethod("OnNewProjectLayoutWasCreated", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { method.Invoke(object2, null); } } } if (containerWindow2) { containerWindow2.position = position; containerWindow2.OnResize(); } if (containerWindow3 == null) { UnityEngine.Debug.LogError("Error while reading window layout: no main window found"); throw new Exception(); } containerWindow3.Show(containerWindow3.showMode, true, true); for (int m = 0; m < list.Count; m++) { EditorWindow editorWindow2 = list[m] as EditorWindow; if (editorWindow2) { editorWindow2.minSize = editorWindow2.minSize; } ContainerWindow containerWindow5 = list[m] as ContainerWindow; if (containerWindow5 && containerWindow5 != containerWindow3) { containerWindow5.Show(containerWindow5.showMode, true, true); } } GameView gameView = WindowLayout.GetMaximizedWindow() as GameView; if (gameView != null && gameView.maximizeOnPlay) { WindowLayout.Unmaximize(gameView); } if (newProjectLayoutWasCreated) { if (UnityConnect.instance.online && UnityConnect.instance.loggedIn && UnityConnect.instance.shouldShowServicesWindow) { UnityConnectServiceCollection.instance.ShowService("Hub", true); } else { UnityConnectServiceCollection.instance.CloseServices(); } } } catch (Exception arg) { UnityEngine.Debug.LogError("Failed to load window layout: " + arg); int num = 0; if (!Application.isTestRun) { num = EditorUtility.DisplayDialogComplex("Failed to load window layout", "This can happen if layout contains custom windows and there are compile errors in the project.", "Load Default Layout", "Quit", "Revert Factory Settings"); } if (num != 0) { if (num != 1) { if (num == 2) { WindowLayout.RevertFactorySettings(); } } else { EditorApplication.Exit(0); } } else { WindowLayout.LoadDefaultLayout(); } result = false; return(result); } finally { ContainerWindow.SetFreezeDisplay(false); if (Path.GetExtension(path) == ".wlt") { Toolbar.lastLoadedLayoutName = Path.GetFileNameWithoutExtension(path); } else { Toolbar.lastLoadedLayoutName = null; } } result = true; return(result); }
internal static extern void Internal_MakeModal(ContainerWindow win);
private static bool PopupRight(Rect buttonRect, Vector2 minSize, Vector2 maxSize, ContainerWindow popupContainerWindow, out Rect resultRect) { Rect rect = new Rect(buttonRect.xMax, buttonRect.y, maxSize.x, maxSize.y); float num = 0f; rect.xMax += num; rect.height += PopupLocationHelper.k_SpaceFromBottom; rect = PopupLocationHelper.FitRect(rect, popupContainerWindow); float num2 = Mathf.Max(rect.xMax - buttonRect.xMax - num, 0f); float width = Mathf.Min(num2, maxSize.x); resultRect = new Rect(rect.x, rect.y, width, rect.height - PopupLocationHelper.k_SpaceFromBottom); return num2 >= minSize.x; }
private static bool PopupAbove(Rect buttonRect, Vector2 minSize, Vector2 maxSize, ContainerWindow popupContainerWindow, out Rect resultRect) { Rect rect1 = new Rect(buttonRect.x, buttonRect.y - maxSize.y, maxSize.x, maxSize.y); float num1 = 0.0f; rect1.yMin -= num1; Rect rect2 = PopupLocationHelper.FitRect(rect1, popupContainerWindow); float num2 = Mathf.Max(buttonRect.y - rect2.y - num1, 0.0f); if ((double) num2 >= (double) minSize.y) { float height = Mathf.Min(num2, maxSize.y); resultRect = new Rect(rect2.x, buttonRect.y - height, rect2.width, height); return true; } resultRect = new Rect(rect2.x, buttonRect.y - num2, rect2.width, num2); return false; }
internal override void Initialize(ContainerWindow win) { base.Initialize(win); this.RemoveNullWindows(); foreach (EditorWindow window in this.m_Panes) { window.m_Parent = this; } }
private static bool PopupAbove(Rect buttonRect, Vector2 minSize, Vector2 maxSize, ContainerWindow popupContainerWindow, out Rect resultRect) { Rect rect = new Rect(buttonRect.x, buttonRect.y - maxSize.y, maxSize.x, maxSize.y); float num = 0f; rect.yMin -= num; rect = PopupLocationHelper.FitRect(rect, popupContainerWindow); float num2 = Mathf.Max(buttonRect.y - rect.y - num, 0f); if (num2 >= minSize.y) { float num3 = Mathf.Min(num2, maxSize.y); resultRect = new Rect(rect.x, buttonRect.y - num3, rect.width, num3); return true; } resultRect = new Rect(rect.x, buttonRect.y - num2, rect.width, num2); return false; }
internal extern void MakeModal(ContainerWindow win);
public static bool MaximizePrepare(EditorWindow win) { // Find Root SplitView View itor = win.m_Parent.parent; View rootSplit = itor; while (itor != null && itor is SplitView) { rootSplit = itor; itor = itor.parent; } // Make sure it has a dockarea DockArea dockArea = win.m_Parent as DockArea; if (dockArea == null) { return(false); } if (itor == null) { return(false); } var mainView = rootSplit.parent as MainView; if (mainView == null) { return(false); } ContainerWindow parentWindow = win.m_Parent.window; if (parentWindow == null) { return(false); } int oldDockIndex = dockArea.m_Panes.IndexOf(win); if (oldDockIndex == -1) { return(false); } dockArea.selected = oldDockIndex; // Save current state to disk SaveSplitViewAndChildren(rootSplit, win, Path.Combine(layoutsProjectPath, kMaximizeRestoreFile)); // Remove the window from the HostView now in order to invoke OnBecameInvisible before OnBecameVisible dockArea.actualView = null; dockArea.m_Panes[oldDockIndex] = null; MaximizedHostView maximizedHostView = ScriptableObject.CreateInstance <MaximizedHostView>(); int i = itor.IndexOfChild(rootSplit); Rect p = rootSplit.position; itor.RemoveChild(rootSplit); itor.AddChild(maximizedHostView, i); maximizedHostView.actualView = win; maximizedHostView.position = p; // Must be set after actualView so that value is propagated UnityObject.DestroyImmediate(rootSplit, true); return(true); }
protected virtual void SetWindow(ContainerWindow win) { this.m_Window = win; }
private static extern Rect INTERNAL_CALL_FitWindowRectToScreen(ContainerWindow self, ref Rect r, bool forceCompletelyVisible, bool useMouseScreen);
protected override void SetWindow(ContainerWindow win) { base.SetWindow(win); this.Internal_Init(this.m_DepthBufferBits, this.m_AntiAlias); if (win != null) { this.Internal_SetWindow(win); } this.Internal_SetAutoRepaint(this.m_AutoRepaintOnSceneChange); this.Internal_SetPosition(base.windowPosition); this.Internal_SetWantsMouseMove(this.m_WantsMouseMove); this.m_BackgroundValid = false; }
public void HandleEdgesStart(Rect windowPosition) { bool left = windowPosition.x == 0f; bool flag = windowPosition.y == 0f; bool flag2 = Mathf.Abs(windowPosition.xMax - this.position.width) < 2f; bool bottom = Mathf.Abs(windowPosition.yMax - this.position.height) < 2f; ContainerWindow.InitIcons(); if (ContainerWindow.macEditor) { if (flag2 && flag && this.showMode != ShowMode.Utility && this.showMode != ShowMode.PopupMenu) { GUIView focusedView = GUIView.focusedView; GUIStyle style; GUIStyle style2; GUIStyle style3; if (focusedView && focusedView.window == this) { style = ContainerWindow.s_ButtonClose; style2 = ContainerWindow.s_ButtonMin; style3 = ContainerWindow.s_ButtonMax; } else { style2 = (style = (style3 = ContainerWindow.s_ButtonInactive)); } if (GUI.Button(new Rect(windowPosition.width - 13f - 4f, 0f, 13f, 13f), GUIContent.none, style)) { this.Close(); } if (GUI.Button(new Rect(windowPosition.width - 26f - 3f - 4f, 0f, 13f, 13f), GUIContent.none, style2)) { this.Minimize(); GUIUtility.ExitGUI(); } if (GUI.Button(new Rect(windowPosition.width - 39f - 6f - 4f, 0f, 13f, 13f), GUIContent.none, style3)) { this.ToggleMaximize(); } } if (this.MacWindowCanResize(windowPosition)) { this.DragWindowEdgesMac(left, flag, flag2, bottom, windowPosition); } } else { if (flag2 && flag && this.showMode != ShowMode.Utility && this.showMode != ShowMode.PopupMenu) { if (GUI.Button(new Rect(windowPosition.width - 13f - 4f, 0f, 13f, 13f), GUIContent.none, ContainerWindow.s_ButtonClose)) { this.Close(); } if (GUI.Button(new Rect(windowPosition.width - 26f - 3f - 4f, 0f, 13f, 13f), GUIContent.none, ContainerWindow.s_ButtonMax)) { this.ToggleMaximize(); } } if (!this.maximized) { this.DragWindowEdgesWin(left, flag, flag2, bottom, windowPosition); } } }
public static bool MaximizePrepare(EditorWindow win) { View parent = win.m_Parent.parent; View view = parent; while (parent != null && parent is SplitView) { view = parent; parent = parent.parent; } DockArea dockArea = win.m_Parent as DockArea; bool result; if (dockArea == null) { result = false; } else if (parent == null) { result = false; } else { MainView x = view.parent as MainView; if (x == null) { result = false; } else { ContainerWindow window = win.m_Parent.window; if (window == null) { result = false; } else { int num = dockArea.m_Panes.IndexOf(win); if (num == -1) { result = false; } else { dockArea.selected = num; WindowLayout.SaveSplitViewAndChildren(view, win, Path.Combine(WindowLayout.layoutsProjectPath, "CurrentMaximizeLayout.dwlt")); dockArea.actualView = null; dockArea.m_Panes[num] = null; MaximizedHostView maximizedHostView = ScriptableObject.CreateInstance <MaximizedHostView>(); int idx = parent.IndexOfChild(view); Rect position = view.position; parent.RemoveChild(view); parent.AddChild(maximizedHostView, idx); maximizedHostView.actualView = win; maximizedHostView.position = position; UnityEngine.Object.DestroyImmediate(view, true); result = true; } } } } return(result); }
public void Show(Rect pixelPos, GUIContent content, Vector2 viewSize, Vector2 mouseScreenPosition) { this.m_Content = content; float num = viewSize.x * viewSize.y; this.m_FullWindowSize = (Vector2) (viewSize * Mathf.Sqrt(Mathf.Clamp01(50000f / num))); if (this.m_Window == null) { this.m_Window = ScriptableObject.CreateInstance<ContainerWindow>(); this.m_Window.m_DontSaveToLayout = true; base.SetMinMaxSizes(Vector2.zero, new Vector2(10000f, 10000f)); this.SetWindowPos(pixelPos); this.m_Window.rootView = this; } else { this.SetWindowPos(pixelPos); } this.m_Window.Show(ShowMode.NoShadow, true, false); this.m_TargetRect = pixelPos; }
private extern void Internal_SetWindow(ContainerWindow win);
private static bool PopupBelow(Rect buttonRect, Vector2 minSize, Vector2 maxSize, ContainerWindow popupContainerWindow, out Rect resultRect) { Rect rect; rect = new Rect(buttonRect.x, buttonRect.yMax, maxSize.x, maxSize.y) { height = rect.height + k_SpaceFromBottom }; rect = FitRect(rect, popupContainerWindow); float a = Mathf.Max((float) ((rect.yMax - buttonRect.yMax) - k_SpaceFromBottom), (float) 0f); if (a >= minSize.y) { float height = Mathf.Min(a, maxSize.y); resultRect = new Rect(rect.x, buttonRect.yMax, rect.width, height); return true; } resultRect = new Rect(rect.x, buttonRect.yMax, rect.width, a); return false; }
private void Internal_SetMinMaxSizes(Vector2 minSize, Vector2 maxSize) { ContainerWindow.INTERNAL_CALL_Internal_SetMinMaxSizes(this, ref minSize, ref maxSize); }
private static bool PopupRight(Rect buttonRect, Vector2 minSize, Vector2 maxSize, ContainerWindow popupContainerWindow, out Rect resultRect) { Rect rect = new Rect(buttonRect.xMax, buttonRect.y, maxSize.x, maxSize.y); float num = 0f; rect.xMax += num; rect.height += k_SpaceFromBottom; rect = FitRect(rect, popupContainerWindow); float a = Mathf.Max((float) ((rect.xMax - buttonRect.xMax) - num), (float) 0f); float width = Mathf.Min(a, maxSize.x); resultRect = new Rect(rect.x, rect.y, width, rect.height - k_SpaceFromBottom); return (a >= minSize.x); }
private void Internal_Show(Rect r, int showMode, Vector2 minSize, Vector2 maxSize) { ContainerWindow.INTERNAL_CALL_Internal_Show(this, ref r, showMode, ref minSize, ref maxSize); }
private static extern void INTERNAL_CALL_FitWindowRectToScreen(ContainerWindow self, ref Rect r, bool forceCompletelyVisible, bool useMouseScreen, out Rect value);
private float DragTab(Rect tabAreaRect, float scrollOffset, GUIStyle tabStyle, GUIStyle firstTabStyle) { Event evt = Event.current; int id = GUIUtility.GetControlID(FocusType.Passive); // Detect if hotcontrol was cleared while dragging (happens when pressing Esc). // We do not listen for the Escape keydown event because it is sent to the dragged window (not this dockarea) if (s_DragMode != 0 && GUIUtility.hotControl == 0) { PaneDragTab.get.Close(); ResetDragVars(); } float xPos = 0f; switch (evt.GetTypeForControl(id)) { case EventType.MouseDown: if (GUIUtility.hotControl == 0) { int sel = GetTabAtMousePos(tabStyle, evt.mousePosition, scrollOffset, tabAreaRect); if (sel != -1 && sel < m_Panes.Count) { switch (evt.button) { case 0: if (selected != sel) { selected = sel; } GUIUtility.hotControl = id; s_StartDragPosition = evt.mousePosition; s_DragMode = 0; evt.Use(); break; case 2: m_Panes[sel].Close(); evt.Use(); break; } } } break; case EventType.ContextClick: if (GUIUtility.hotControl == 0) { int sel = GetTabAtMousePos(tabStyle, evt.mousePosition, scrollOffset, tabAreaRect); var menuPos = new Rect(evt.mousePosition.x, evt.mousePosition.y, 0, 0); if (sel != -1 && sel < m_Panes.Count && !ContainerWindow.s_Modal) { PopupGenericMenu(m_Panes[sel], menuPos); } else if (!ContainerWindow.s_Modal && m_Panes.Count == 0) // i.e. all panes have failed to load { PopupGenericMenu(null, menuPos); } } break; case EventType.MouseDrag: if (GUIUtility.hotControl == id) { Vector2 delta = evt.mousePosition - s_StartDragPosition; evt.Use(); Rect screenRect = screenPosition; // if we're not tab dragging yet, check to see if we should start // If modal window exists, disable all tab behavior if (ContainerWindow.s_Modal) { break; } // check if we're allowed to drag tab bool dragAllowed = (window.showMode != ShowMode.MainWindow || AllowTabAction()); if (s_DragMode == 0 && delta.sqrMagnitude > 99 && dragAllowed) { s_DragMode = 1; s_PlaceholderPos = selected; s_DragPane = m_Panes[selected]; // If we're moving the only editorwindow in this dockarea, we'll be destroyed - so it looks silly if we can attach as children of ourselves s_IgnoreDockingForView = m_Panes.Count == 1 ? this : null; s_OriginalDragSource = this; float tabWidth = GetTabWidth(tabStyle, selected); PaneDragTab.get.Show( new Rect(tabAreaRect.x + screenRect.x + tabWidth * selected, tabAreaRect.y + screenRect.y, tabWidth, tabAreaRect.height - 1f), s_DragPane.titleContent, position.size, GUIUtility.GUIToScreenPoint(evt.mousePosition) ); EditorApplication.update += CheckDragWindowExists; Invoke("OnTabDragging", s_DragPane); // We just showed a window. Exit the GUI because the window might be // repainting already (esp. on Windows) GUIUtility.ExitGUI(); } if (s_DragMode == 1) { // Go over all container windows, ask them to dock the window. DropInfo di = null; ContainerWindow[] windows = ContainerWindow.windows; Vector2 screenMousePos = GUIUtility.GUIToScreenPoint(evt.mousePosition); ContainerWindow win = null; foreach (ContainerWindow w in windows) { var rootSplitView = w.rootSplitView; if (rootSplitView == null) { continue; } di = rootSplitView.DragOverRootView(screenMousePos); if (di == null) { foreach (View view in w.rootView.allChildren) { IDropArea ida = view as IDropArea; if (ida != null) { di = ida.DragOver(s_DragPane, screenMousePos); } if (di != null) { break; } } } if (di != null) { win = w; break; } } // Ok, we couldn't find anything, let's create a simplified DropIn if (di == null) { di = new DropInfo(null); } if (di.type != DropInfo.Type.Tab) { s_PlaceholderPos = -1; } s_DropInfo = di; // Handle the window getting closed mid-drag if (PaneDragTab.get.m_Window) { PaneDragTab.get.SetDropInfo(di, screenMousePos, win); } } } break; case EventType.MouseUp: if (GUIUtility.hotControl == id) { Vector2 screenMousePos = GUIUtility.GUIToScreenPoint(evt.mousePosition); if (s_DragMode != 0) { // This is where we want to insert it. s_DragMode = 0; PaneDragTab.get.Close(); EditorApplication.update -= CheckDragWindowExists; // Try to tell the current DPZ if (s_DropInfo?.dropArea != null) { Invoke("OnTabDetached", s_DragPane); s_DropInfo.dropArea.PerformDrop(s_DragPane, s_DropInfo, screenMousePos); UpdateWindowTitle(s_DragPane); } else { EditorWindow w = s_DragPane; ResetDragVars(); // The active tab that we're moving to the new window stays focused at all times. // Do not remove focus from the tab being detached. RemoveTab(w, killIfEmpty: true, sendEvents: false); Rect wPos = w.position; wPos.x = screenMousePos.x - wPos.width * .5f; wPos.y = screenMousePos.y - wPos.height * .5f; // don't put windows top outside of the screen, on mac OS handles this if (Application.platform == RuntimePlatform.WindowsEditor) { wPos.y = Mathf.Max(InternalEditorUtility.GetBoundsOfDesktopAtPoint(screenMousePos).y, wPos.y); } // Don't call OnFocus on the tab when it is moved to the new window EditorWindow.CreateNewWindowForEditorWindow(w, loadPosition: false, showImmediately: false, setFocus: false); w.position = w.m_Parent.window.FitWindowRectToScreen(wPos, true, true); Invoke("OnTabNewWindow", w); GUIUtility.hotControl = 0; GUIUtility.ExitGUI(); } ResetDragVars(); } GUIUtility.hotControl = 0; evt.Use(); } break; case EventType.Repaint: xPos = tabAreaRect.xMin; if (actualView) { for (int i = 0, drawNum = 0; i < m_Panes.Count; i++) { // If we're dragging the tab we're about to draw, don't do that (handled by some window) if (s_DragPane == m_Panes[i]) { continue; } // If we need space for inserting a tab here, skip some horizontal if (s_DropInfo != null && ReferenceEquals(s_DropInfo.dropArea, this) && s_PlaceholderPos == drawNum) { xPos += s_DropInfo.rect.width; } var style = i == 0 ? firstTabStyle : tabStyle; xPos += DrawTab(tabAreaRect, style, i, xPos); drawNum++; } } else { Rect r = new Rect(xPos, tabAreaRect.yMin, Styles.tabDragWidth, tabAreaRect.height); float roundR = Mathf.Round(r.x); Rect r2 = new Rect(roundR, r.y, Mathf.Round(r.x + r.width) - roundR, r.height); tabStyle.Draw(r2, "Failed to load", false, true, true, false); } break; } selected = Mathf.Clamp(selected, 0, m_Panes.Count - 1); return(xPos); }
internal Rect FitWindowRectToScreen(Rect r, bool forceCompletelyVisible, bool useMouseScreen) { return(ContainerWindow.INTERNAL_CALL_FitWindowRectToScreen(this, ref r, forceCompletelyVisible, useMouseScreen)); }
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); }
internal static Rect FitRectToScreen(Rect defaultRect, bool forceCompletelyVisible, bool useMouseScreen) { return(ContainerWindow.INTERNAL_CALL_FitRectToScreen(ref defaultRect, forceCompletelyVisible, useMouseScreen)); }
protected virtual void SetWindow(ContainerWindow win) { m_Window = win; }
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); }