예제 #1
0
            /// <summary>
            /// Accumulates another component into the results.
            /// </summary>
            /// <param name="sizes">The size of the component to add.</param>
            /// <param name="spacing">The component spacing.</param>
            public void Accum(LayoutSizes sizes, float spacing)
            {
                float newMin = sizes.min, newPreferred = sizes.preferred;

                if (newMin > 0.0f)
                {
                    // Skip one space
                    if (haveMinSpace)
                    {
                        newMin += spacing;
                    }
                    haveMinSpace = true;
                }
                total.min += newMin;
                if (newPreferred > 0.0f)
                {
                    // Skip one space
                    if (havePrefSpace)
                    {
                        newPreferred += spacing;
                    }
                    havePrefSpace = true;
                }
                total.preferred += newPreferred;
                total.flexible  += sizes.flexible;
            }
예제 #2
0
 internal LayoutResults(PanelDirection direction, int presize)
 {
     children       = new List <LayoutSizes>(presize);
     this.direction = direction;
     haveMinSpace   = false;
     havePrefSpace  = false;
     total          = new LayoutSizes();
 }
예제 #3
0
 public override void CalculateLayoutInputVertical()
 {
     if (child != null && calcElements != null)
     {
         // Lay out children
         childVertical = PUIUtils.CalcSizes(child, PanelDirection.Vertical,
                                            calcElements);
         preferredHeight = childVertical.preferred;
         calcElements    = null;
     }
 }
예제 #4
0
        /// <summary>
        /// Determines the size for a component on a particular axis.
        /// </summary>
        /// <param name="sizes">The declared sizes.</param>
        /// <param name="allocated">The space allocated.</param>
        /// <returns>The size that the component should be.</returns>
        internal static float GetProperSize(LayoutSizes sizes, float allocated)
        {
            float size = sizes.min, preferred = Math.Max(sizes.preferred, size);

            // Compute size: minimum guaranteed, then preferred, then flexible
            if (allocated > size)
            {
                size = Math.Min(preferred, allocated);
            }
            if (allocated > preferred && sizes.flexible > 0.0f)
            {
                size = allocated;
            }
            return(size);
        }
예제 #5
0
 public override void CalculateLayoutInputHorizontal()
 {
     if (child != null)
     {
         calcElements = child.GetComponents <Component>();
         // Lay out children
         childHorizontal = PUIUtils.CalcSizes(child, PanelDirection.Horizontal,
                                              calcElements);
         if (childHorizontal.ignore)
         {
             throw new InvalidOperationException("ScrollPane child ignores layout!");
         }
         preferredWidth = childHorizontal.preferred;
     }
 }
예제 #6
0
            /// <summary>
            /// Expands the results around another component.
            /// </summary>
            /// <param name="sizes">The size of the component to expand to.</param>
            public void Expand(LayoutSizes sizes)
            {
                float newMin = sizes.min, newPreferred = sizes.preferred, newFlexible =
                    sizes.flexible;

                if (newMin > total.min)
                {
                    total.min = newMin;
                }
                if (newPreferred > total.preferred)
                {
                    total.preferred = newPreferred;
                }
                if (newFlexible > total.flexible)
                {
                    total.flexible = newFlexible;
                }
            }
예제 #7
0
 /// <summary>
 /// Enlarges this layout size, if necessary, using the values from another.
 /// </summary>
 /// <param name="other">The minimum size values to enforce.</param>
 public void Max(LayoutSizes other)
 {
     flexible  = Math.Max(flexible, other.flexible);
     min       = Math.Max(min, other.min);
     preferred = Math.Max(preferred, other.preferred);
 }
예제 #8
0
 /// <summary>
 /// Adds another set of layout sizes to this one.
 /// </summary>
 /// <param name="other">The size values to add.</param>
 public void Add(LayoutSizes other)
 {
     flexible  += other.flexible;
     min       += other.min;
     preferred += other.preferred;
 }