public static void Begin(HorizontalPaneState prototype) { int id = GUIUtility.GetControlID(FocusType.Passive); hState = (HorizontalPaneState)GUIUtility.GetStateObject(typeof(HorizontalPaneState), id); hState.ResolveStateToCurrentContext(id, prototype); // *INDENT-OFF* Rect totalArea = EditorGUILayout.BeginHorizontal(); hState.availableWidth = totalArea.width - HorizontalPaneState.SPLITTER_WIDTH; hState.isPaneWidthChanged = false; if(totalArea.width > 0) { if(hState.leftPaneWidth < 0) { if(hState.initialLeftPaneWidth < 0) hState.leftPaneWidth = hState.availableWidth * 0.5f; else hState.leftPaneWidth = hState.initialLeftPaneWidth; hState.isPaneWidthChanged = true; } if(hState.lastAvailableWidth < 0) hState.lastAvailableWidth = hState.availableWidth; if(hState.lastAvailableWidth != hState.availableWidth) { hState.leftPaneWidth = hState.availableWidth * (hState.leftPaneWidth / hState.lastAvailableWidth); hState.isPaneWidthChanged = true; } hState.lastAvailableWidth = hState.availableWidth; } GUILayout.BeginHorizontal(GUILayout.Width(hState.leftPaneWidth)); // *INDENT-ON* }
/* * Some aspects of our state are really just static configuration that * shouldn't be modified by the control, so we blindly set them if we have a * prototype from which to do so. */ protected virtual void InitFromPrototype(int newId, HorizontalPaneState prototype) { id = newId; initialLeftPaneWidth = prototype.initialLeftPaneWidth; minPaneWidthLeft = prototype.minPaneWidthLeft; minPaneWidthRight = prototype.minPaneWidthRight; }
public static void Begin(HorizontalPaneState prototype) { int id = GUIUtility.GetControlID(FocusType.Passive); hState = (HorizontalPaneState)GUIUtility.GetStateObject(typeof(HorizontalPaneState), id); hState.ResolveStateToCurrentContext(id, prototype); Rect totalArea = EditorGUILayout.BeginHorizontal(); hState.availableWidth = totalArea.width - hState.splitterWidth; hState.isPaneWidthChanged = false; if(totalArea.width > 0) { if(hState.leftPaneWidth < 0) { if(hState.initialLeftPaneWidth < 0) hState.leftPaneWidth = hState.availableWidth * 0.5f; else hState.leftPaneWidth = hState.initialLeftPaneWidth; hState.isPaneWidthChanged = true; } if(hState.lastAvailableWidth < 0) hState.lastAvailableWidth = hState.availableWidth; if(hState.lastAvailableWidth != hState.availableWidth) { hState.leftPaneWidth = hState.availableWidth * (hState.leftPaneWidth / hState.lastAvailableWidth); hState.isPaneWidthChanged = true; } hState.lastAvailableWidth = hState.availableWidth; } GUILayout.BeginHorizontal(GUILayout.Width(hState.leftPaneWidth)); }
public MissionWindowState() { missionPageTreeViewState = new TreeViewState(); aiPageTreeViewState = new TreeViewState(); missionPageSplitterState = new HorizontalPaneState(); shipPageSplitterState = new HorizontalPaneState(); aiPageSplitterState = new HorizontalPaneState(); }
public static void HorizontalSplitPane(HorizontalPaneState paneState, Action left, Action right) { EditorGUILayoutHorizontalPanes.Begin(paneState); left(); EditorGUILayoutHorizontalPanes.Splitter(); right(); EditorGUILayoutHorizontalPanes.End(); }
/* * This method takes care of guarding against state object recycling, and * ensures we pick up what we need, when we need to, from the prototype state * object. */ public void ResolveStateToCurrentContext(int currentId, HorizontalPaneState prototype) { if (id != currentId) { Reset(currentId); } else if (prototype != null) { InitFromPrototype(currentId, prototype); } }
/* * This method takes care of guarding against state object recycling, and * ensures we pick up what we need, when we need to, from the prototype state * object. */ public void ResolveStateToCurrentContext(int currentId, HorizontalPaneState prototype) { if(id != currentId) { Reset(currentId); } else if(prototype != null) { InitFromPrototype(currentId, prototype); } }