com.yahoo.astra.layout.modes.PercentageSizeUtil
Keywords: PercentageSizeUtil,com.yahoo.astra.layout.modes.PercentageSizeUtil,distributeExtraHeight,distributeExtraWidth,flexChildHeightsProportionally,flexChildWidthsProportionally,flexChildrenProportionally

YUI Flash Component Documentation | All Packages | All Classes | Index | Frames No Frames |
Class PercentageSizeUtil

Package | com.yahoo.astra.layout.modes
Class | public class PercentageSizeUtil

Utility functions used for determining pixel-based sizes from percentage-based sizes.

Public Methods

| Method | Defined by
--- | --- | ---
|  | distributeExtraHeight(children:Array, configurations:Array, spaceForChildren:Number):void [static] This function distributes excess space among the flexible children because of rounding errors where we want to keep children's dimensions full pixel amounts. | PercentageSizeUtil
|  | distributeExtraWidth(children:Array, configurations:Array, spaceForChildren:Number):void [static] This function distributes excess space among the flexible children because of rounding errors where we want to keep children's dimensions full pixel amounts. | PercentageSizeUtil
|  | flexChildHeightsProportionally(children:Array, configurations:Array, totalWidth:Number, totalHeight:Number):Number [static] This function sets the height of each child so that the heights add up to spaceForChildren. | PercentageSizeUtil
|  | flexChildrenProportionally(spaceForChildren:Number, spaceToDistribute:Number, totalPercent:Number, childInfoArray:Array):Number [static] This function distributes excess space among the flexible children. | PercentageSizeUtil
|  | flexChildWidthsProportionally(children:Array, configurations:Array, totalWidth:Number, totalHeight:Number):Number [static] This function sets the width of each child so that the widths add up to spaceForChildren. | PercentageSizeUtil

Method detail

distributeExtraHeight | () | method

`public static function distributeExtraHeight(children:Array, configurations:Array, spaceForChildren:Number):void`

This function distributes excess space among the flexible children because of rounding errors where we want to keep children's dimensions full pixel amounts. This only distributes the extra space if there was some rounding down and there are still flexible children.

Parameters

| `children:Array` — The parent container of the children.
| `configurations:Array` — The total space for all children
| `spaceForChildren:Number`

distributeExtraWidth | () | method |

`public static function distributeExtraWidth(children:Array, configurations:Array, spaceForChildren:Number):void`

This function distributes excess space among the flexible children because of rounding errors where we want to keep children's dimensions full pixel amounts. This only distributes the extra space if there was some rounding down and there are still flexible children.

Parameters

| `children:Array` — The parent container of the children.
| `configurations:Array` — The total space for all children
| `spaceForChildren:Number`

flexChildHeightsProportionally | () | method |

`public static function flexChildHeightsProportionally(children:Array, configurations:Array, totalWidth:Number, totalHeight:Number):Number`

This function sets the height of each child so that the heights add up to spaceForChildren. Each child is set to its preferred height if its percentHeight is zero. If its percentHeight is a positive number, the child grows (or shrinks) to consume its share of extra space. The width of each child is set to its preferred width. The return value is any extra space that's left over after growing all children to their maxHeight.

Parameters

| `children:Array`
| `configurations:Array`
| `totalWidth:Number`
| `totalHeight:Number`

Returns

| `Number`

flexChildrenProportionally | () | method |

`public static function flexChildrenProportionally(spaceForChildren:Number, spaceToDistribute:Number, totalPercent:Number, childInfoArray:Array):Number`

This function distributes excess space among the flexible children. It does so with a view to keep the children's overall size close the ratios specified by their percent.

Parameters

| `spaceForChildren:Number` — The total space for all children
| `spaceToDistribute:Number` — The space that needs to be distributed among the flexible children.
| `totalPercent:Number` — An array of Objects. When this function is called, each object should define the following properties: - percent: the percentWidth or percentHeight of the child (depending on whether we're growing in a horizontal or vertical direction) - min: the minimum width (or height) for that child - max: the maximum width (or height) for that child
| `childInfoArray:Array`

Returns

| `Number` — When this function finishes executing, a "size" property will be defined for each child object. The size property contains the portion of the spaceToDistribute to be distributed to the child. Ideally, the sum of all size properties is spaceToDistribute. If all the children hit their minWidth/maxWidth/minHeight/maxHeight before the space was distributed, then the remaining unused space is returned. Otherwise, the return value is zero.

flexChildWidthsProportionally | () | method |

`public static function flexChildWidthsProportionally(children:Array, configurations:Array, totalWidth:Number, totalHeight:Number):Number`

This function sets the width of each child so that the widths add up to spaceForChildren. Each child is set to its preferred width if its percentWidth is zero. If it's percentWidth is a positive number the child grows depending on the size of its parent. The height of each child is set to its preferred height. The return value is any extra space that's left over after growing all children to their maxWidth.

Parameters

| `children:Array`
| `configurations:Array`
| `totalWidth:Number`
| `totalHeight:Number`

Returns

| `Number`