示例#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;
 }