Пример #1
0
        public static void Begin(VerticalPaneState prototype)
        {
            int id = GUIUtility.GetControlID(FocusType.Passive);

            vState = (VerticalPaneState)GUIUtility.GetStateObject(typeof(VerticalPaneState), id);
            vState.ResolveStateToCurrentContext(id, prototype);

            // *INDENT-OFF*
            Rect totalArea = EditorGUILayout.BeginVertical();
            vState.availableHeight = totalArea.height - VerticalPaneState.SPLITTER_HEIGHT;
            vState.isPaneHeightChanged = false;
            if (totalArea.height > 0) {
                if (vState.topPaneHeight < 0) {
                    if (vState.initialTopPaneHeight < 0)
                        vState.topPaneHeight = vState.availableHeight * 0.5f;
                    else
                        vState.topPaneHeight = vState.initialTopPaneHeight;
                    vState.isPaneHeightChanged = true;
                }

                if (vState.lastAvailableHeight < 0)
                    vState.lastAvailableHeight = vState.availableHeight;
                if (vState.lastAvailableHeight != vState.availableHeight) {
                    vState.topPaneHeight = vState.availableHeight * (vState.topPaneHeight / vState.lastAvailableHeight);
                    vState.isPaneHeightChanged = true;
                }

                vState.lastAvailableHeight = vState.availableHeight;
            }

            GUILayout.BeginVertical(GUILayout.Height(vState.topPaneHeight));
            // *INDENT-ON*
        }
Пример #2
0
 /*
  * 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, VerticalPaneState prototype)
 {
     id = newId;
     initialTopPaneHeight = prototype.initialTopPaneHeight;
     minPaneHeightTop     = prototype.minPaneHeightTop;
     minPaneHeightBottom  = prototype.minPaneHeightBottom;
 }
Пример #3
0
 /*
  * 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, VerticalPaneState prototype)
 {
     if (id != currentId)
     {
         Reset(currentId);
     }
     else if (prototype != null)
     {
         InitFromPrototype(currentId, prototype);
     }
 }