http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5300c4e9/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/FlexibleFirstChildHorizontalLayout.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/FlexibleFirstChildHorizontalLayout.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/FlexibleFirstChildHorizontalLayout.as index 347c304..66a8533 100644 --- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/FlexibleFirstChildHorizontalLayout.as +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/FlexibleFirstChildHorizontalLayout.as @@ -20,7 +20,7 @@ package org.apache.flex.html.beads.layouts { import org.apache.flex.core.IBeadLayout; import org.apache.flex.core.ILayoutChild; - import org.apache.flex.core.ILayoutObject; + import org.apache.flex.core.ILayoutView; import org.apache.flex.core.ILayoutHost; import org.apache.flex.core.ILayoutParent; import org.apache.flex.core.IParentIUIBase; @@ -44,7 +44,7 @@ package org.apache.flex.html.beads.layouts * CSS layout rules for margin and padding styles. But it * will size the first child to take up as much or little * room as possible. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -54,7 +54,7 @@ package org.apache.flex.html.beads.layouts { /** * Constructor. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -63,15 +63,15 @@ package org.apache.flex.html.beads.layouts public function FlexibleFirstChildHorizontalLayout() { } - + // the strand/host container is also an ILayoutChild because // can have its size dictated by the host's parent which is // important to know for layout optimization private var host:ILayoutChild; - + /** * @copy org.apache.flex.core.IBead#strand - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -81,12 +81,12 @@ package org.apache.flex.html.beads.layouts { host = value as ILayoutChild; } - + private var _maxWidth:Number; - + /** * @copy org.apache.flex.core.IBead#maxWidth - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -96,20 +96,20 @@ package org.apache.flex.html.beads.layouts { return _maxWidth; } - + /** - * @private + * @private */ public function set maxWidth(value:Number):void { _maxWidth = value; } - + private var _maxHeight:Number; - + /** * @copy org.apache.flex.core.IBead#maxHeight - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -119,33 +119,33 @@ package org.apache.flex.html.beads.layouts { return _maxHeight; } - + /** - * @private + * @private */ public function set maxHeight(value:Number):void { _maxHeight = value; } - + /** * @copy org.apache.flex.core.IBeadLayout#layout */ COMPILE::SWF public function layout():Boolean - { - var layoutHost:ILayoutHost = (host as ILayoutParent).getLayoutHost(); - var contentView:ILayoutObject = layoutHost.contentView; - + { + var layoutHost:ILayoutHost = (host as ILayoutParent).getLayoutHost(); + var contentView:ILayoutView = layoutHost.contentView; + var n:Number = contentView.numElements; if (n == 0) return false; - + var maxWidth:Number = 0; var maxHeight:Number = 0; var hostSizedToContent:Boolean = host.isHeightSizedToContent(); var hostWidth:Number = contentView.width; var hostHeight:Number = hostSizedToContent ? 0 : contentView.height; - + var ilc:ILayoutChild; var data:Object; var canAdjust:Boolean = false; @@ -154,14 +154,14 @@ package org.apache.flex.html.beads.layouts var marginTop:Object; var marginBottom:Object; var margin:Object; - + var paddingMetrics:Rectangle = CSSContainerUtils.getPaddingMetrics(host); var borderMetrics:Rectangle = CSSContainerUtils.getBorderMetrics(host); - + var xpos:Number = hostWidth - borderMetrics.right - paddingMetrics.right; var ypos:Number = borderMetrics.top + paddingMetrics.left; var adjustedWidth:Number = 0; - + for(var i:int=(n-1); i >= 0; i--) { var child:IUIBase = contentView.getElementAt(i) as IUIBase; @@ -181,27 +181,27 @@ package org.apache.flex.html.beads.layouts ml = 0; if (marginRight == "auto") mr = 0; - + ilc = child as ILayoutChild; - + var childYpos:Number = ypos + mt; // default y position - + if (!hostSizedToContent) { var childHeight:Number = child.height; if (ilc != null && !isNaN(ilc.percentHeight)) { childHeight = (hostHeight-borderMetrics.top-borderMetrics.bottom-paddingMetrics.top-paddingMetrics.bottom) * ilc.percentHeight/100.0; ilc.setHeight(childHeight); - } + } // the following code middle-aligns the child childYpos = hostHeight/2 - (childHeight + mt + mb)/2; } - + if (ilc) { if (!isNaN(ilc.percentWidth)) { ilc.setWidth((contentView.width-borderMetrics.left-borderMetrics.right-paddingMetrics.left-paddingMetrics.right) * ilc.percentWidth / 100); } } - + if (i > 0) { xpos -= child.width + mr; adjustedWidth = child.width; @@ -209,49 +209,49 @@ package org.apache.flex.html.beads.layouts adjustedWidth = xpos - (borderMetrics.left + paddingMetrics.left + ml + mr); xpos = borderMetrics.left + paddingMetrics.left + ml; } - + if (ilc) { ilc.setX(xpos); ilc.setY(childYpos); ilc.setWidth(adjustedWidth); - + } else { child.x = xpos; child.y = childYpos; child.width = adjustedWidth; } - + xpos -= ml; } - + host.dispatchEvent( new Event("layoutComplete") ); - + return true; } - + COMPILE::JS public function layout():Boolean { var viewBead:ILayoutHost = (host as ILayoutParent).getLayoutHost(); - var contentView:ILayoutObject = viewBead.contentView; - + var contentView:ILayoutView = viewBead.contentView; + // set the display on the contentView contentView.element.style["display"] = "flex"; contentView.element.style["flex-flow"] = "row"; contentView.element.style["align-items"] = "center"; - + var n:int = contentView.numElements; if (n == 0) return false; - + for(var i:int=0; i < n; i++) { var child:UIBase = contentView.getElementAt(i) as UIBase; child.element.style["flex-grow"] = (i == 0) ? "1" : "0"; child.element.style["flex-shrink"] = "0"; } - + return true; } } - + }
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5300c4e9/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/HorizontalFlexLayout.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/HorizontalFlexLayout.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/HorizontalFlexLayout.as index ba27c8a..1681e00 100644 --- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/HorizontalFlexLayout.as +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/HorizontalFlexLayout.as @@ -19,15 +19,15 @@ package org.apache.flex.html.beads.layouts { import org.apache.flex.html.beads.layouts.HorizontalLayout; - + import org.apache.flex.core.ILayoutChild; import org.apache.flex.core.ILayoutHost; - import org.apache.flex.core.ILayoutObject; + import org.apache.flex.core.ILayoutView; import org.apache.flex.core.ILayoutParent; import org.apache.flex.core.IStrand; import org.apache.flex.core.IParentIUIBase; import org.apache.flex.core.UIBase; - + COMPILE::SWF { import org.apache.flex.core.IUIBase; import org.apache.flex.core.ValuesManager; @@ -37,12 +37,12 @@ package org.apache.flex.html.beads.layouts import org.apache.flex.utils.CSSUtils; import org.apache.flex.utils.CSSContainerUtils; } - + public class HorizontalFlexLayout extends HorizontalLayout { /** * Constructor. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -52,25 +52,25 @@ package org.apache.flex.html.beads.layouts { super(); } - + // the strand/host container is also an ILayoutChild because // can have its size dictated by the host's parent which is // important to know for layout optimization private var host:ILayoutChild; - + override public function set strand(value:IStrand):void { super.strand = value; host = value as ILayoutChild; } - + private var _grow:Number = -1; - + /** * Sets the amount items grow in proportion to other items. * The default is 0 which prevents the items from expanding to * fit the space. Use a negative value to unset this property. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -82,15 +82,15 @@ package org.apache.flex.html.beads.layouts public function set grow(value:Number):void { _grow = value; } - + private var _shrink:Number = -1; - + /** * Sets the amount an item may shrink in proportion to other items. - * The default is 1 which allows items to shrink to fit into the space. - * Set this to 0 if you want to allow scrolling of the space. Use a + * The default is 1 which allows items to shrink to fit into the space. + * Set this to 0 if you want to allow scrolling of the space. Use a * negative value to unset this property. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -102,11 +102,11 @@ package org.apache.flex.html.beads.layouts public function set shrink(value:Number):void { _shrink = value; } - + /** * @copy org.apache.flex.core.IBeadLayout#layout * @flexjsignorecoercion org.apache.flex.core.ILayoutHost - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -117,20 +117,20 @@ package org.apache.flex.html.beads.layouts COMPILE::SWF { //return super.layout(); // this is where the layout is calculated - var layoutHost:ILayoutHost = (host as ILayoutParent).getLayoutHost(); - var contentView:ILayoutObject = layoutHost.contentView; - + var layoutHost:ILayoutHost = (host as ILayoutParent).getLayoutHost(); + var contentView:ILayoutView = layoutHost.contentView; + var n:Number = contentView.numElements; if (n == 0) return false; - + var spacing:String = "none"; - + var maxWidth:Number = 0; var maxHeight:Number = 0; var growCount:Number = 0; var remainingWidth:Number = contentView.width; var childData:Array = []; - + var ilc:ILayoutChild; var data:Object; var canAdjust:Boolean = false; @@ -139,9 +139,9 @@ package org.apache.flex.html.beads.layouts var marginTop:Object; var marginBottom:Object; var margin:Object; - + //trace("HorizontalFlexLayout for "+UIBase(host).id+" with remainingWidth: "+remainingWidth); - + // First pass determines the data about the child. for(var i:int=0; i < n; i++) { @@ -150,9 +150,9 @@ package org.apache.flex.html.beads.layouts childData.push({width:0, height:0, mt:0, ml:0, mr:0, mb:0, canAdjust:false}); continue; } - + ilc = child as ILayoutChild; - + var flexGrow:Object = ValuesManager.valuesImpl.getValue(child, "flex-grow"); var growValue:Number = -1; if (flexGrow != null) { @@ -160,7 +160,7 @@ package org.apache.flex.html.beads.layouts if (!isNaN(growValue) && growValue > 0) growCount++; else growValue = 0; } - + var useHeight:Number = -1; if (ilc) { if (!isNaN(ilc.explicitHeight)) useHeight = ilc.explicitHeight; @@ -168,7 +168,7 @@ package org.apache.flex.html.beads.layouts else useHeight = contentView.height; } if (useHeight > contentView.height) useHeight = contentView.height; - + var useWidth:Number = -1; if (ilc) { if (!isNaN(ilc.explicitWidth)) useWidth = ilc.explicitWidth; @@ -176,7 +176,7 @@ package org.apache.flex.html.beads.layouts else useWidth = ilc.width; } if (growValue == 0 && useWidth > 0) remainingWidth -= useWidth; - + margin = ValuesManager.valuesImpl.getValue(child, "margin"); marginLeft = ValuesManager.valuesImpl.getValue(child, "margin-left"); marginTop = ValuesManager.valuesImpl.getValue(child, "margin-top"); @@ -190,25 +190,25 @@ package org.apache.flex.html.beads.layouts ml = 0; if (marginRight == "auto") mr = 0; - + if (maxWidth < useWidth) maxWidth = useWidth; if (maxHeight < useHeight) maxHeight = useHeight; - + childData.push({width:useWidth, height:useHeight, mt:mt, ml:ml, mr:mr, mb:mb, grow:growValue, canAdjust:canAdjust}); } - + var xpos:Number = 0; var ypos:Number = 0; - + // Second pass sizes and positions the children based on the data gathered. for(i=0; i < n; i++) { child = contentView.getElementAt(i) as IUIBase; data = childData[i]; if (data.width == 0 || data.height == 0) continue; - + useHeight = (data.height < 0 ? maxHeight : data.height); - + var setWidth:Boolean = true; if (data.width > 0) { if (data.grow > 0 && growCount > 0) { @@ -220,7 +220,7 @@ package org.apache.flex.html.beads.layouts } else { useWidth = child.width; } - + ilc = child as ILayoutChild; if (ilc) { ilc.setX(xpos + data.ml); @@ -238,38 +238,38 @@ package org.apache.flex.html.beads.layouts child.width = useWidth - data.mr - data.ml; } } - + xpos += useWidth + data.ml + data.mr; - + //trace("HorizontalFlexLayout: setting child "+i+" to "+child.width+" x "+child.height+" at "+child.x+", "+child.y); } - + IEventDispatcher(host).dispatchEvent( new Event("layoutComplete") ); - + //trace("HorizontalFlexLayout: complete"); - + return true; } - + COMPILE::JS { var viewBead:ILayoutHost = (host as ILayoutParent).getLayoutHost(); - var contentView:ILayoutObject = viewBead.contentView; - + var contentView:ILayoutView = viewBead.contentView; + // set the display on the contentView contentView.element.style["display"] = "flex"; contentView.element.style["flex-flow"] = "row"; - + var n:int = contentView.numElements; if (n == 0) return false; - + for(var i:int=0; i < n; i++) { var child:UIBase = contentView.getElementAt(i) as UIBase; if (grow >= 0) child.element.style["flex-grow"] = String(grow); if (shrink >= 0) child.element.style["flex-shrink"] = String(shrink); } - + return true; } } } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5300c4e9/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/HorizontalFlowLayout.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/HorizontalFlowLayout.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/HorizontalFlowLayout.as index 066bc8b..e492597 100644 --- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/HorizontalFlowLayout.as +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/HorizontalFlowLayout.as @@ -21,7 +21,7 @@ package org.apache.flex.html.beads.layouts import org.apache.flex.core.IBeadLayout; import org.apache.flex.core.ILayoutHost; import org.apache.flex.core.ILayoutParent; - import org.apache.flex.core.ILayoutObject; + import org.apache.flex.core.ILayoutView; import org.apache.flex.core.IParentIUIBase; import org.apache.flex.core.IStrand; import org.apache.flex.core.IUIBase; @@ -35,7 +35,7 @@ package org.apache.flex.html.beads.layouts * the remainder onto the next lines. If an element does not already have an explicit or percentage * size, a size is chosen for it based on the defaultColumnCount property which divides the * layout space into equal number of cells as a default measurement. - * + * * The height of each row is determined by the tallest element in the row. The next row flows * below that. * @@ -78,7 +78,7 @@ package org.apache.flex.html.beads.layouts private var _columnGap:int = 4; private var _rowGap:int = 4; private var _useChildWidth:Boolean = false; - + /** * The amount of spacing between the columns. * @@ -95,7 +95,7 @@ package org.apache.flex.html.beads.layouts { _columnGap = value; } - + /** * Amount of spacing between the rows. * @@ -116,7 +116,7 @@ package org.apache.flex.html.beads.layouts /** * The default number of columns the layout should assume should any or * all of the elements not have explicit or percentage widths. This value is - * used to divide the layout width into equal-width columns. An element's + * used to divide the layout width into equal-width columns. An element's * own width overrides this computed width, allowing for a ragged grid * arrangement. * @@ -152,7 +152,7 @@ package org.apache.flex.html.beads.layouts { _computedColumnWidth = value; } - + /** * Determines whether or not each child's width is set from the column size (false) or * uses its own width (true). Default is false. @@ -182,52 +182,52 @@ package org.apache.flex.html.beads.layouts var host:UIBase = _strand as UIBase; var p:ILayoutHost = (host as ILayoutParent).getLayoutHost(); var area:UIBase = p.contentView as UIBase; - + var n:Number = area.numElements; if (n == 0) return false; - + // if a computedColumnWidth hasn't been preset, calculate it // based on the default column count, giving equal-width columns. if (isNaN(computedColumnWidth)) { _computedColumnWidth = area.width / defaultColumnCount; } - + var maxWidth:Number = area.width; var maxHeight:Number = 0; var xpos:Number = columnGap/2; var ypos:Number = rowGap/2; var useWidth:Number = 0; - + for(var i:int=0; i < n; i++) { var child:UIBase = area.getElementAt(i) as UIBase; if (child == null || !child.visible) continue; - + if (!isNaN(child.explicitWidth)) useWidth = child.explicitWidth; else if (!isNaN(child.percentWidth)) useWidth = maxWidth * (child.percentWidth/100.0); else useWidth = _computedColumnWidth; - + if (xpos+useWidth > maxWidth) { ypos += maxHeight + rowGap; xpos = columnGap/2; maxHeight = 0; } - + child.x = xpos; child.y = ypos; if (!useChildWidth) { child.setWidth(useWidth) } - + var childWidth:Number = child.width; var childHeight:Number = child.height; maxHeight = Math.max(maxHeight, childHeight); - + xpos += childWidth + columnGap; } - + IEventDispatcher(_strand).dispatchEvent( new Event("layoutComplete") ); - + return true; } COMPILE::JS @@ -249,11 +249,11 @@ package org.apache.flex.html.beads.layouts if (n === 0) return false; area.width = host.width; - + var element:HTMLElement = area.element as HTMLElement; element.style["flexFlow"] = "row wrap"; element.style["display"] = "flex"; - + // if a computedColumnWidth hasn't been preset, calculate it // based on the default column count, giving equal-width columns. if (isNaN(computedColumnWidth)) { @@ -264,11 +264,11 @@ package org.apache.flex.html.beads.layouts { child = children[i].flexjs_wrapper; if (!child.visible) continue; - + if (!isNaN(child.explicitWidth)) useWidth = child.explicitWidth; else if (!isNaN(child.percentWidth)) useWidth = host.width * (child.percentWidth/100.0); else useWidth = _computedColumnWidth; - + if (useChildWidth) { children[i].style["position"] = null; } else { @@ -279,9 +279,9 @@ package org.apache.flex.html.beads.layouts children[i].style["margin-left"] = String(_columnGap/2)+"px"; children[i].style["margin-right"] = String(_columnGap/2)+"px"; } - + IEventDispatcher(_strand).dispatchEvent( new Event("layoutComplete") ); - + return true; } } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5300c4e9/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/HorizontalLayout.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/HorizontalLayout.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/HorizontalLayout.as index ec96c20..0192174 100644 --- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/HorizontalLayout.as +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/HorizontalLayout.as @@ -22,7 +22,7 @@ package org.apache.flex.html.beads.layouts import org.apache.flex.core.IBeadModel; import org.apache.flex.core.ILayoutChild; import org.apache.flex.core.ILayoutHost; - import org.apache.flex.core.ILayoutObject; + import org.apache.flex.core.ILayoutView; import org.apache.flex.core.ILayoutParent; import org.apache.flex.core.IParentIUIBase; import org.apache.flex.core.IStrand; @@ -45,7 +45,7 @@ package org.apache.flex.html.beads.layouts * bead. It takes the set of children and lays them out * horizontally in one row, separating them according to * CSS layout rules for margin and vertical-align styles. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -55,7 +55,7 @@ package org.apache.flex.html.beads.layouts { /** * Constructor. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -64,15 +64,15 @@ package org.apache.flex.html.beads.layouts public function HorizontalLayout() { } - + // the strand/host container is also an ILayoutChild because // can have its size dictated by the host's parent which is // important to know for layout optimization private var host:ILayoutChild; - + /** * @copy org.apache.flex.core.IBead#strand - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -91,7 +91,7 @@ package org.apache.flex.html.beads.layouts } } } - + /** * @copy org.apache.flex.core.IBeadLayout#layout * @flexjsignorecoercion org.apache.flex.core.ILayoutHost @@ -101,18 +101,18 @@ package org.apache.flex.html.beads.layouts { COMPILE::SWF { - var layoutHost:ILayoutHost = (host as ILayoutParent).getLayoutHost(); - var contentView:ILayoutObject = layoutHost.contentView; - + var layoutHost:ILayoutHost = (host as ILayoutParent).getLayoutHost(); + var contentView:ILayoutView = layoutHost.contentView; + var n:Number = contentView.numElements; if (n == 0) return false; - + var maxWidth:Number = 0; var maxHeight:Number = 0; var hostSizedToContent:Boolean = host.isHeightSizedToContent(); var hostWidth:Number = contentView.width; var hostHeight:Number = hostSizedToContent ? 0 : contentView.height; - + var ilc:ILayoutChild; var data:Object; var canAdjust:Boolean = false; @@ -121,13 +121,13 @@ package org.apache.flex.html.beads.layouts var marginTop:Object; var marginBottom:Object; var margin:Object; - + var paddingMetrics:Rectangle = CSSContainerUtils.getPaddingMetrics(host); var borderMetrics:Rectangle = CSSContainerUtils.getBorderMetrics(host); - + var xpos:Number = borderMetrics.left + paddingMetrics.left; var ypos:Number = borderMetrics.top + paddingMetrics.left; - + // First pass determines the data about the child. for(var i:int=0; i < n; i++) { @@ -148,68 +148,68 @@ package org.apache.flex.html.beads.layouts ml = 0; if (marginRight == "auto") mr = 0; - + ilc = child as ILayoutChild; - + xpos += ml; - + var childYpos:Number = ypos + mt; // default y position - + if (!hostSizedToContent) { var childHeight:Number = child.height; if (ilc != null && !isNaN(ilc.percentHeight)) { childHeight = (hostHeight-borderMetrics.top-borderMetrics.bottom-paddingMetrics.top-paddingMetrics.bottom) * ilc.percentHeight/100.0; ilc.setHeight(childHeight - mt - mb); - } + } // the following code middle-aligns the child, but since HTML does not // do this normally, this code is commented. (Use HorizontalFlexLayout for // vertically centered elements in a horizontal row). // childYpos = hostHeight/2 - (childHeight + mt + mb)/2; } - + if (ilc) { ilc.setX(xpos); ilc.setY(childYpos); - + if (!isNaN(ilc.percentWidth)) { var newWidth:Number = (contentView.width-borderMetrics.left-borderMetrics.right-paddingMetrics.left-paddingMetrics.right) * ilc.percentWidth / 100; ilc.setWidth(newWidth - mr - ml); } - + } else { child.x = xpos; child.y = childYpos; } - + xpos += child.width + mr; } - + host.dispatchEvent( new Event("layoutComplete") ); - + return true; - + } COMPILE::JS { var children:Array; var i:int; var n:int; - + var viewBead:ILayoutHost = (host as ILayoutParent).getLayoutHost(); var contentView:IParentIUIBase = viewBead.contentView as IParentIUIBase; - + contentView.element.style["white-space"] = "nowrap"; - + children = contentView.internalChildren(); - + n = children.length; for (i = 0; i < n; i++) { var child:WrappedHTMLElement = children[i] as WrappedHTMLElement; if (child == null) continue; child.flexjs_wrapper.setDisplayStyleForLayout('inline-block'); - if (child.style.display !== 'none') + if (child.style.display !== 'none') { child.style.display = 'inline-block'; } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5300c4e9/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildHorizontalLayout.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildHorizontalLayout.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildHorizontalLayout.as index 2f88b01..7a41bbc 100644 --- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildHorizontalLayout.as +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildHorizontalLayout.as @@ -21,7 +21,7 @@ package org.apache.flex.html.beads.layouts import org.apache.flex.core.IDocument; import org.apache.flex.core.ILayoutChild; import org.apache.flex.core.ILayoutHost; - import org.apache.flex.core.ILayoutObject; + import org.apache.flex.core.ILayoutView; import org.apache.flex.core.ILayoutParent; import org.apache.flex.core.IParentIUIBase; import org.apache.flex.core.IStrand; @@ -40,7 +40,7 @@ package org.apache.flex.html.beads.layouts * CSS layout rules for margin and padding styles. But it * will size the one child to take up as much or little * room as possible. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -50,7 +50,7 @@ package org.apache.flex.html.beads.layouts { /** * Constructor. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -59,26 +59,26 @@ package org.apache.flex.html.beads.layouts public function OneFlexibleChildHorizontalLayout() { } - - + + private var _flexibleChild:String; - + private var actualChild:ILayoutChild; - + // the strand/host container is also an ILayoutChild because // can have its size dictated by the host's parent which is // important to know for layout optimization private var host:ILayoutChild; - + /** * @private * The document. */ private var document:Object; - + /** * The id of the flexible child - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -99,7 +99,7 @@ package org.apache.flex.html.beads.layouts /** * @copy org.apache.flex.core.IBead#strand - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -109,12 +109,12 @@ package org.apache.flex.html.beads.layouts { host = value as ILayoutChild; } - + private var _maxWidth:Number; - + /** * @copy org.apache.flex.core.IBead#maxWidth - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -124,20 +124,20 @@ package org.apache.flex.html.beads.layouts { return _maxWidth; } - + /** - * @private + * @private */ public function set maxWidth(value:Number):void { _maxWidth = value; } - + private var _maxHeight:Number; - + /** * @copy org.apache.flex.core.IBead#maxHeight - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -147,15 +147,15 @@ package org.apache.flex.html.beads.layouts { return _maxHeight; } - + /** - * @private + * @private */ public function set maxHeight(value:Number):void { _maxHeight = value; } - + /** * @copy org.apache.flex.core.IBeadLayout#layout */ @@ -163,27 +163,27 @@ package org.apache.flex.html.beads.layouts public function layout():Boolean { var viewBead:ILayoutHost = (host as ILayoutParent).getLayoutHost(); - var contentView:ILayoutObject = viewBead.contentView; - + var contentView:ILayoutView = viewBead.contentView; + actualChild = document[flexibleChild]; - + // set the display on the contentView contentView.element.style["display"] = "flex"; contentView.element.style["flex-flow"] = "row"; contentView.element.style["align-items"] = "center"; - + var n:int = contentView.numElements; if (n == 0) return false; - + for(var i:int=0; i < n; i++) { var child:UIBase = contentView.getElementAt(i) as UIBase; child.element.style["flex-grow"] = (child == actualChild) ? "1" : "0"; child.element.style["flex-shrink"] = "0"; } - + return true; } - + COMPILE::SWF protected function childMargins(child:Object, hostWidth:Number, hostHeight:Number):Object { @@ -200,26 +200,26 @@ package org.apache.flex.html.beads.layouts ml = 0; if (marginRight == "auto") mr = 0; - + return {left:ml, top:mt, right:mr, bottom:mb}; } - + COMPILE::SWF public function layout():Boolean - { - var layoutHost:ILayoutHost = (host as ILayoutParent).getLayoutHost(); - var contentView:ILayoutObject = layoutHost.contentView; + { + var layoutHost:ILayoutHost = (host as ILayoutParent).getLayoutHost(); + var contentView:ILayoutView = layoutHost.contentView; var actualChild:IUIBase = document.hasOwnProperty(flexibleChild) ? document[flexibleChild] : null; - + var n:Number = contentView.numElements; if (n == 0) return false; - + var maxWidth:Number = 0; var maxHeight:Number = 0; var hostSizedToContent:Boolean = host.isHeightSizedToContent(); var hostWidth:Number = contentView.width; var hostHeight:Number = hostSizedToContent ? 0 : contentView.height; - + var ilc:ILayoutChild; var data:Object; var canAdjust:Boolean = false; @@ -233,10 +233,10 @@ package org.apache.flex.html.beads.layouts var mt:Number; var mb:Number; var margins:Object; - + var paddingMetrics:Rectangle = CSSContainerUtils.getPaddingMetrics(host); var borderMetrics:Rectangle = CSSContainerUtils.getBorderMetrics(host); - + var xpos:Number = borderMetrics.left - paddingMetrics.left; var ypos:Number = borderMetrics.top + paddingMetrics.left; var child:IUIBase; @@ -245,51 +245,51 @@ package org.apache.flex.html.beads.layouts var childYpos:Number; var adjustLeft:Number = 0; var adjustRight:Number = hostWidth - borderMetrics.right - paddingMetrics.right; - + // first work from left to right for(i=0; i < n; i++) { child = contentView.getElementAt(i) as IUIBase; if (child == null || !child.visible) continue; if (child == actualChild) break; - + margins = childMargins(child, hostWidth, hostHeight); ilc = child as ILayoutChild; - + xpos += margins.left; - + childYpos = ypos + margins.top; // default y position - + if (!hostSizedToContent) { childHeight = child.height; if (ilc != null && !isNaN(ilc.percentHeight)) { childHeight = (hostHeight-borderMetrics.top-borderMetrics.bottom-paddingMetrics.top-paddingMetrics.bottom) * ilc.percentHeight/100.0; ilc.setHeight(childHeight); - } + } // the following code middle-aligns the child childYpos = hostHeight/2 - (childHeight + margins.top + margins.bottom)/2; } - + if (ilc) { ilc.setX(xpos); ilc.setY(childYpos); - + if (!isNaN(ilc.percentWidth)) { ilc.setWidth((contentView.width-borderMetrics.left-borderMetrics.right-paddingMetrics.left-paddingMetrics.right) * ilc.percentWidth / 100); } - + } else { child.x = xpos; child.y = childYpos; } - + xpos += child.width + margins.right; adjustLeft = xpos; } - + // then work from right to left xpos = hostWidth - borderMetrics.right - paddingMetrics.right; - + for(i=(n-1); actualChild != null && i >= 0; i--) { child = contentView.getElementAt(i) as IUIBase; @@ -298,27 +298,27 @@ package org.apache.flex.html.beads.layouts margins = childMargins(child, hostWidth, hostHeight); ilc = child as ILayoutChild; - + childYpos = ypos + margins.top; // default y position - + if (!hostSizedToContent) { childHeight = child.height; if (ilc != null && !isNaN(ilc.percentHeight)) { childHeight = (hostHeight-borderMetrics.top-borderMetrics.bottom-paddingMetrics.top-paddingMetrics.bottom) * ilc.percentHeight/100.0; ilc.setHeight(childHeight); - } + } // the following code middle-aligns the child childYpos = hostHeight/2 - (childHeight + margins.top + margins.bottom)/2; } - + if (ilc) { if (!isNaN(ilc.percentWidth)) { ilc.setWidth((contentView.width-borderMetrics.left-borderMetrics.right-paddingMetrics.left-paddingMetrics.right) * ilc.percentWidth / 100); } } - + xpos -= child.width + margins.right; - + if (ilc) { ilc.setX(xpos); ilc.setY(childYpos); @@ -326,11 +326,11 @@ package org.apache.flex.html.beads.layouts child.x = xpos; child.y = childYpos; } - + xpos -= margins.left; adjustRight = xpos; } - + // now adjust the actualChild to fill the space. if (actualChild != null) { margins = childMargins(actualChild, hostWidth, hostHeight); @@ -350,16 +350,16 @@ package org.apache.flex.html.beads.layouts actualChild.width = (adjustRight-margins.right) - (adjustLeft+margins.left); } } - + host.dispatchEvent( new Event("layoutComplete") ); - + return true; } - + public function setDocument(document:Object, id:String = null):void { - this.document = document; + this.document = document; } } - + } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5300c4e9/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildVerticalLayout.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildVerticalLayout.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildVerticalLayout.as index 6099388..45c6253 100644 --- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildVerticalLayout.as +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildVerticalLayout.as @@ -21,7 +21,7 @@ package org.apache.flex.html.beads.layouts import org.apache.flex.core.IDocument; import org.apache.flex.core.ILayoutChild; import org.apache.flex.core.ILayoutHost; - import org.apache.flex.core.ILayoutObject; + import org.apache.flex.core.ILayoutView; import org.apache.flex.core.ILayoutParent; import org.apache.flex.core.IParentIUIBase; import org.apache.flex.core.IStrand; @@ -41,7 +41,7 @@ package org.apache.flex.html.beads.layouts * CSS layout rules for margin and padding styles. But it * will size the one child to take up as much or little * room as possible. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -51,7 +51,7 @@ package org.apache.flex.html.beads.layouts { /** * Constructor. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -60,26 +60,26 @@ package org.apache.flex.html.beads.layouts public function OneFlexibleChildVerticalLayout() { } - - + + private var _flexibleChild:String; - + private var actualChild:ILayoutChild; - + // the strand/host container is also an ILayoutChild because // can have its size dictated by the host's parent which is // important to know for layout optimization private var host:ILayoutChild; - + /** * @private * The document. */ private var document:Object; - + /** * The id of the flexible child - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -100,7 +100,7 @@ package org.apache.flex.html.beads.layouts /** * @copy org.apache.flex.core.IBead#strand - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -110,12 +110,12 @@ package org.apache.flex.html.beads.layouts { host = value as ILayoutChild; } - + private var _maxWidth:Number; - + /** * @copy org.apache.flex.core.IBead#maxWidth - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -125,20 +125,20 @@ package org.apache.flex.html.beads.layouts { return _maxWidth; } - + /** - * @private + * @private */ public function set maxWidth(value:Number):void { _maxWidth = value; } - + private var _maxHeight:Number; - + /** * @copy org.apache.flex.core.IBead#maxHeight - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -148,15 +148,15 @@ package org.apache.flex.html.beads.layouts { return _maxHeight; } - + /** - * @private + * @private */ public function set maxHeight(value:Number):void { _maxHeight = value; } - + COMPILE::SWF protected function childMargins(child:Object, hostWidth:Number, hostHeight:Number):Object { @@ -173,10 +173,10 @@ package org.apache.flex.html.beads.layouts ml = 0; if (marginRight == "auto") mr = 0; - + return {left:ml, top:mt, right:mr, bottom:mb}; } - + /** * @copy org.apache.flex.core.IBeadLayout#layout */ @@ -184,43 +184,43 @@ package org.apache.flex.html.beads.layouts public function layout():Boolean { var viewBead:ILayoutHost = (host as ILayoutParent).getLayoutHost(); - var contentView:ILayoutObject = viewBead.contentView; - + var contentView:ILayoutView = viewBead.contentView; + actualChild = document[flexibleChild]; - + // set the display on the contentView contentView.element.style["display"] = "flex"; contentView.element.style["flex-flow"] = "column"; contentView.element.style["align-items"] = "center"; - + var n:int = contentView.numElements; if (n == 0) return false; - + for(var i:int=0; i < n; i++) { var child:UIBase = contentView.getElementAt(i) as UIBase; child.element.style["flex-grow"] = (child == actualChild) ? "1" : "0"; child.element.style["flex-shrink"] = "0"; } - + return true; } - + COMPILE::SWF public function layout():Boolean { - var layoutHost:ILayoutHost = (host as ILayoutParent).getLayoutHost(); - var contentView:ILayoutObject = layoutHost.contentView; + var layoutHost:ILayoutHost = (host as ILayoutParent).getLayoutHost(); + var contentView:ILayoutView = layoutHost.contentView; var actualChild:IUIBase = document.hasOwnProperty(flexibleChild) ? document[flexibleChild] : null; - + var n:Number = contentView.numElements; if (n == 0) return false; - + var maxWidth:Number = 0; var maxHeight:Number = 0; var hostSizedToContent:Boolean = host.isHeightSizedToContent(); var hostWidth:Number = contentView.width; var hostHeight:Number = hostSizedToContent ? 0 : contentView.height; - + var ilc:ILayoutChild; var data:Object; var canAdjust:Boolean = false; @@ -234,10 +234,10 @@ package org.apache.flex.html.beads.layouts var mt:Number; var mb:Number; var margins:Object; - + var paddingMetrics:Rectangle = CSSContainerUtils.getPaddingMetrics(host); var borderMetrics:Rectangle = CSSContainerUtils.getBorderMetrics(host); - + var xpos:Number = borderMetrics.left - paddingMetrics.left; var ypos:Number = borderMetrics.top + paddingMetrics.left; var child:IUIBase; @@ -246,80 +246,80 @@ package org.apache.flex.html.beads.layouts var childXpos:Number; var adjustTop:Number = 0; var adjustBottom:Number = hostHeight - borderMetrics.top - paddingMetrics.bottom; - + // first work from top to bottom for(i=0; i < n; i++) { child = contentView.getElementAt(i) as IUIBase; if (child == null || !child.visible) continue; if (child == actualChild) break; - + margins = childMargins(child, hostWidth, hostHeight); ilc = child as ILayoutChild; - + ypos += margins.top; - + childXpos = xpos + margins.left; // default y position - + if (!hostSizedToContent) { childWidth = child.width; if (ilc != null && !isNaN(ilc.percentWidth)) { childWidth = (hostWidth-borderMetrics.left-borderMetrics.right-paddingMetrics.left-paddingMetrics.right) * ilc.percentWidth/100.0; ilc.setWidth(childWidth); - } + } // the following code middle-aligns the child childXpos = hostWidth/2 - (childWidth + margins.left + margins.right)/2; } - + if (ilc) { ilc.setX(childXpos); ilc.setY(ypos); - + if (!isNaN(ilc.percentHeight)) { ilc.setHeight((contentView.height-borderMetrics.top-borderMetrics.bottom-paddingMetrics.top-paddingMetrics.bottom) * ilc.percentHeight / 100); } - + } else { child.x = childXpos; child.y = ypos; } - + ypos += child.height + margins.bottom; adjustTop = ypos; } - + // then work from bottom to top ypos = hostHeight - borderMetrics.bottom - paddingMetrics.bottom; - + for(i=(n-1); actualChild != null && i >= 0; i--) { child = contentView.getElementAt(i) as IUIBase; if (child == null || !child.visible) continue; if (child == actualChild) break; - + margins = childMargins(child, hostWidth, hostHeight); ilc = child as ILayoutChild; - + childXpos = xpos + margins.left; // default y position - + if (!hostSizedToContent) { childWidth = child.width; if (ilc != null && !isNaN(ilc.percentWidth)) { childWidth = (hostWidth-borderMetrics.left-borderMetrics.right-paddingMetrics.left-paddingMetrics.right) * ilc.percentWidth/100.0; ilc.setWidth(childWidth); - } + } // the following code middle-aligns the child childXpos = hostWidth/2 - (childWidth + margins.left + margins.right)/2; } - + if (ilc) { if (!isNaN(ilc.percentHeight)) { ilc.setHeight((contentView.height-borderMetrics.top-borderMetrics.bottom-paddingMetrics.top-paddingMetrics.bottom) * ilc.percentHeight / 100); } } - + ypos -= child.height + margins.bottom; - + if (ilc) { ilc.setX(childXpos); ilc.setY(ypos); @@ -327,11 +327,11 @@ package org.apache.flex.html.beads.layouts child.x = childXpos; child.y = ypos; } - + ypos -= margins.top; adjustBottom = ypos; } - + // now adjust the actualChild to fill the space. if (actualChild != null) { margins = childMargins(actualChild, hostWidth, hostHeight); @@ -351,17 +351,17 @@ package org.apache.flex.html.beads.layouts actualChild.height = (adjustBottom-margins.bottom) - (adjustTop+margins.top); } } - + host.dispatchEvent( new Event("layoutComplete") ); - + return true; } - + public function setDocument(document:Object, id:String = null):void { - this.document = document; + this.document = document; } - + } - + } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5300c4e9/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/TileLayout.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/TileLayout.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/TileLayout.as index ec1a761..11e5b97 100644 --- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/TileLayout.as +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/TileLayout.as @@ -20,7 +20,7 @@ package org.apache.flex.html.beads.layouts { import org.apache.flex.core.IBeadLayout; import org.apache.flex.core.ILayoutHost; - import org.apache.flex.core.ILayoutObject; + import org.apache.flex.core.ILayoutView; import org.apache.flex.core.ILayoutParent; import org.apache.flex.core.IParentIUIBase; import org.apache.flex.core.IStrand; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5300c4e9/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/VerticalColumnLayout.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/VerticalColumnLayout.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/VerticalColumnLayout.as index 24c5445..bac2dc8 100644 --- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/VerticalColumnLayout.as +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/VerticalColumnLayout.as @@ -17,11 +17,11 @@ // //////////////////////////////////////////////////////////////////////////////// package org.apache.flex.html.beads.layouts -{ +{ import org.apache.flex.core.IBeadLayout; import org.apache.flex.core.IContainer; import org.apache.flex.core.ILayoutHost; - import org.apache.flex.core.ILayoutObject; + import org.apache.flex.core.ILayoutView; import org.apache.flex.core.ILayoutParent; import org.apache.flex.core.IMeasurementBead; import org.apache.flex.core.IParent; @@ -33,13 +33,13 @@ package org.apache.flex.html.beads.layouts import org.apache.flex.events.IEventDispatcher; import org.apache.flex.geom.Rectangle; import org.apache.flex.utils.CSSUtils; - import org.apache.flex.utils.CSSContainerUtils; - + import org.apache.flex.utils.CSSContainerUtils; + /** * ColumnLayout is a class that organizes the positioning of children * of a container into a set of columns where each column's width is set to * the maximum size of all of the children in that column. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -49,7 +49,7 @@ package org.apache.flex.html.beads.layouts { /** * constructor - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -58,12 +58,12 @@ package org.apache.flex.html.beads.layouts public function VerticalColumnLayout() { } - + private var _strand:IStrand; - + /** * @copy org.apache.flex.core.IBead#strand - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -73,13 +73,13 @@ package org.apache.flex.html.beads.layouts { _strand = value; } - - + + private var _numColumns:int; - + /** * The number of columns. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -93,19 +93,19 @@ package org.apache.flex.html.beads.layouts { _numColumns = value; } - + /** * @copy org.apache.flex.core.IBeadLayout#layout */ public function layout():Boolean - { + { var host:UIBase = UIBase(_strand); var layoutParent:ILayoutHost = (host as ILayoutParent).getLayoutHost(); - var contentView:ILayoutObject = layoutParent.contentView; + var contentView:ILayoutView = layoutParent.contentView; var padding:Rectangle = CSSContainerUtils.getPaddingMetrics(host); var sw:Number = host.width; var sh:Number = host.height; - + var hasWidth:Boolean = !host.isWidthSizedToContent(); var hasHeight:Boolean = !host.isHeightSizedToContent(); var e:IUIBase; @@ -128,7 +128,7 @@ package org.apache.flex.html.beads.layouts var mb:Number; var n:int = contentView.numElements; var rowData:Object = { rowHeight: 0 }; - + // determine max widths of columns for (i = 0; i < n; i++) { e = contentView.getElementAt(i) as IUIBase; @@ -150,11 +150,11 @@ package org.apache.flex.html.beads.layouts if (measure) thisPrefWidth = measure.measuredWidth + ml + mr; else - thisPrefWidth = e.width + ml + mr; + thisPrefWidth = e.width + ml + mr; } else thisPrefWidth = e.width + ml + mr; - + rowData.rowHeight = Math.max(rowData.rowHeight, e.height + mt + mb); columns[col] = Math.max(columns[col], thisPrefWidth); col = col + 1; @@ -165,14 +165,14 @@ package org.apache.flex.html.beads.layouts col = 0; } } - + var lastmb:Number = 0; var curx:int = padding.left; var cury:int = padding.top; var maxHeight:int = 0; var maxWidth:int = 0; col = 0; - for (i = 0; i < n; i++) + for (i = 0; i < n; i++) { e = contentView.getElementAt(i) as IUIBase; if (e == null || !e.visible) continue; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5300c4e9/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/VerticalFlexLayout.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/VerticalFlexLayout.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/VerticalFlexLayout.as index 04ba596..cee8416 100644 --- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/VerticalFlexLayout.as +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/VerticalFlexLayout.as @@ -19,15 +19,15 @@ package org.apache.flex.html.beads.layouts { import org.apache.flex.html.beads.layouts.VerticalLayout; - + import org.apache.flex.core.ILayoutChild; import org.apache.flex.core.ILayoutHost; - import org.apache.flex.core.ILayoutObject; + import org.apache.flex.core.ILayoutView; import org.apache.flex.core.ILayoutParent; import org.apache.flex.core.IStrand; import org.apache.flex.core.UIBase; import org.apache.flex.core.IParentIUIBase; - + COMPILE::SWF { import org.apache.flex.core.IUIBase; import org.apache.flex.core.ValuesManager; @@ -37,12 +37,12 @@ package org.apache.flex.html.beads.layouts import org.apache.flex.utils.CSSUtils; import org.apache.flex.utils.CSSContainerUtils; } - + public class VerticalFlexLayout extends VerticalLayout { /** * Constructor. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -52,25 +52,25 @@ package org.apache.flex.html.beads.layouts { super(); } - + // the strand/host container is also an ILayoutChild because // can have its size dictated by the host's parent which is // important to know for layout optimization private var host:ILayoutChild; - + override public function set strand(value:IStrand):void { super.strand = value; host = value as ILayoutChild; } - + private var _grow:Number = -1; - + /** * Sets the amount items grow in proportion to other items. * The default is 0 which prevents the items from expanding to * fit the space. Use a negative value to unset this property. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -82,15 +82,15 @@ package org.apache.flex.html.beads.layouts public function set grow(value:Number):void { _grow = value; } - + private var _shrink:Number = -1; - + /** * Sets the amount an item may shrink in proportion to other items. - * The default is 1 which allows items to shrink to fit into the space. + * The default is 1 which allows items to shrink to fit into the space. * Set this to 0 if you want to allow scrolling of the space. Use a negative * value to unset this property. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -102,11 +102,11 @@ package org.apache.flex.html.beads.layouts public function set shrink(value:Number):void { _shrink = value; } - + /** - * + * * @flexjsignorecoercion org.apache.flex.core.ILayoutHost - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -116,20 +116,20 @@ package org.apache.flex.html.beads.layouts { COMPILE::SWF { //return super.layout(); - var layoutHost:ILayoutHost = (host as ILayoutParent).getLayoutHost(); - var contentView:ILayoutObject = layoutHost.contentView; - + var layoutHost:ILayoutHost = (host as ILayoutParent).getLayoutHost(); + var contentView:ILayoutView = layoutHost.contentView; + var n:Number = contentView.numElements; if (n == 0) return false; - + var spacing:String = "none"; - + var maxWidth:Number = 0; var maxHeight:Number = 0; var growCount:Number = 0; var remainingHeight:Number = contentView.height; var childData:Array = []; - + var ilc:ILayoutChild; var data:Object; var canAdjust:Boolean = false; @@ -138,9 +138,9 @@ package org.apache.flex.html.beads.layouts var marginTop:Object; var marginBottom:Object; var margin:Object; - + //trace("VerticalFlexLayout for "+UIBase(host).id+" with remainingHeight: "+remainingHeight); - + // First pass determines the data about the child. for(var i:int=0; i < n; i++) { @@ -149,9 +149,9 @@ package org.apache.flex.html.beads.layouts childData.push({width:0, height:0, mt:0, ml:0, mr:0, mb:0, grow:0, canAdjust:false}); continue; } - + ilc = child as ILayoutChild; - + var flexGrow:Object = ValuesManager.valuesImpl.getValue(child, "flex-grow"); var growValue:Number = -1; if (flexGrow != null) { @@ -159,7 +159,7 @@ package org.apache.flex.html.beads.layouts if (!isNaN(growValue) && growValue > 0) growCount++; else growValue = 0; } - + var useWidth:Number = -1; if (ilc) { if (!isNaN(ilc.explicitWidth)) useWidth = ilc.explicitWidth; @@ -167,7 +167,7 @@ package org.apache.flex.html.beads.layouts else useWidth = contentView.width; } if (useWidth > contentView.width) useWidth = contentView.width; - + var useHeight:Number = -1; if (ilc) { if (!isNaN(ilc.explicitHeight)) useHeight = ilc.explicitHeight; @@ -175,7 +175,7 @@ package org.apache.flex.html.beads.layouts else useHeight = ilc.height; } if (growValue == 0 && useHeight > 0) remainingHeight -= useHeight; - + margin = ValuesManager.valuesImpl.getValue(child, "margin"); marginLeft = ValuesManager.valuesImpl.getValue(child, "margin-left"); marginTop = ValuesManager.valuesImpl.getValue(child, "margin-top"); @@ -189,25 +189,25 @@ package org.apache.flex.html.beads.layouts ml = 0; if (marginRight == "auto") mr = 0; - + if (maxWidth < useWidth) maxWidth = useWidth; if (maxHeight < useHeight) maxHeight = useHeight; - + childData.push({width:useWidth, height:useHeight, mt:mt, ml:ml, mr:mr, mb:mb, grow:growValue, canAdjust:canAdjust}); } - + var xpos:Number = 0; var ypos:Number = 0; - + // Second pass sizes and positions the children based on the data gathered. for(i=0; i < n; i++) { child = contentView.getElementAt(i) as IUIBase; data = childData[i]; if (data.width == 0 || data.height == 0) continue; - + useWidth = (data.width < 0 ? maxWidth : data.width); - + var setHeight:Boolean = true; if (data.height > 0) { if (data.grow > 0 && growCount > 0) { @@ -219,7 +219,7 @@ package org.apache.flex.html.beads.layouts } else { useHeight = child.height; } - + ilc = child as ILayoutChild; if (ilc) { ilc.setX(xpos + data.ml); @@ -237,37 +237,37 @@ package org.apache.flex.html.beads.layouts child.height = useHeight; } } - + ypos += useHeight + data.mt + data.mb; - + //trace("VerticalFlexLayout: setting child "+i+" to "+child.width+" x "+child.height+" at "+child.x+", "+child.y); } - + IEventDispatcher(host).dispatchEvent( new Event("layoutComplete") ); - + //trace("VerticalFlexLayout: complete"); - + return true; } - + COMPILE::JS { var viewBead:ILayoutHost = (host as ILayoutParent).getLayoutHost(); - var contentView:ILayoutObject = viewBead.contentView; + var contentView:ILayoutView = viewBead.contentView; contentView.element.style["display"] = "flex"; contentView.element.style["flex-flow"] = "column"; - + var n:int = contentView.numElements; if (n == 0) return false; - + for(var i:int=0; i < n; i++) { var child:UIBase = contentView.getElementAt(i) as UIBase; if (grow >= 0) child.element.style["flex-grow"] = String(grow); if (shrink >= 0) child.element.style["flex-shrink"] = String(shrink); } - + return true; } } } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5300c4e9/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/VerticalLayout.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/VerticalLayout.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/VerticalLayout.as index b4f5443..48679cb 100644 --- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/VerticalLayout.as +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/VerticalLayout.as @@ -22,7 +22,7 @@ package org.apache.flex.html.beads.layouts import org.apache.flex.core.IBeadModel; import org.apache.flex.core.ILayoutChild; import org.apache.flex.core.ILayoutHost; - import org.apache.flex.core.ILayoutObject; + import org.apache.flex.core.ILayoutView; import org.apache.flex.core.ILayoutParent; import org.apache.flex.core.IParentIUIBase; import org.apache.flex.core.IStrand; @@ -30,20 +30,20 @@ package org.apache.flex.html.beads.layouts import org.apache.flex.core.ValuesManager; COMPILE::JS { - import org.apache.flex.core.WrappedHTMLElement; + import org.apache.flex.core.WrappedHTMLElement; } import org.apache.flex.events.Event; import org.apache.flex.events.IEventDispatcher; import org.apache.flex.geom.Rectangle; import org.apache.flex.utils.CSSContainerUtils; import org.apache.flex.utils.CSSUtils; - + /** * The VerticalLayout class is a simple layout * bead. It takes the set of children and lays them out * vertically in one column, separating them according to * CSS layout rules for margin and horizontal-align styles. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -53,7 +53,7 @@ package org.apache.flex.html.beads.layouts { /** * Constructor. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -62,15 +62,15 @@ package org.apache.flex.html.beads.layouts public function VerticalLayout() { } - + // the strand/host container is also an ILayoutChild because // can have its size dictated by the host's parent which is // important to know for layout optimization private var host:ILayoutChild; - + /** * @copy org.apache.flex.core.IBead#strand - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -78,12 +78,12 @@ package org.apache.flex.html.beads.layouts */ public function set strand(value:IStrand):void { - host = value as ILayoutChild; + host = value as ILayoutChild; } - + /** * Layout children vertically - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -94,18 +94,18 @@ package org.apache.flex.html.beads.layouts { COMPILE::SWF { - var layoutHost:ILayoutHost = (host as ILayoutParent).getLayoutHost(); - var contentView:ILayoutObject = layoutHost.contentView; - + var layoutHost:ILayoutHost = (host as ILayoutParent).getLayoutHost(); + var contentView:ILayoutView = layoutHost.contentView; + var n:Number = contentView.numElements; if (n == 0) return false; - + var maxWidth:Number = 0; var maxHeight:Number = 0; var hostSizedToContent:Boolean = host.isWidthSizedToContent(); var hostWidth:Number = hostSizedToContent ? 0 : contentView.width; var hostHeight:Number = contentView.height; - + var ilc:ILayoutChild; var data:Object; var canAdjust:Boolean = false; @@ -114,13 +114,13 @@ package org.apache.flex.html.beads.layouts var marginTop:Object; var marginBottom:Object; var margin:Object; - + var paddingMetrics:Rectangle = CSSContainerUtils.getPaddingMetrics(host); var borderMetrics:Rectangle = CSSContainerUtils.getBorderMetrics(host); - + var xpos:Number = borderMetrics.left + paddingMetrics.left; var ypos:Number = borderMetrics.top + paddingMetrics.left; - + // First pass determines the data about the child. for(var i:int=0; i < n; i++) { @@ -141,13 +141,13 @@ package org.apache.flex.html.beads.layouts ml = 0; if (marginRight == "auto") mr = 0; - + ilc = child as ILayoutChild; - + ypos += mt; - + var childXpos:Number = xpos + ml; // default x position - + if (!hostSizedToContent) { var childWidth:Number = child.width; if (ilc != null && !isNaN(ilc.percentWidth)) { @@ -159,34 +159,34 @@ package org.apache.flex.html.beads.layouts // horizontally centered elements in a vertical column). // childXpos = hostWidth/2 - (childWidth + ml + mr)/2; } - + if (ilc) { ilc.setX(childXpos); ilc.setY(ypos); - + if (!isNaN(ilc.percentHeight)) { var newHeight:Number = (contentView.height-borderMetrics.top-borderMetrics.bottom-paddingMetrics.top-paddingMetrics.bottom) * ilc.percentHeight / 100; ilc.setHeight(newHeight - mt - mb); } - + } else { child.x = childXpos; child.y = ypos; } - + ypos += child.height + mb; } - + host.dispatchEvent( new Event("layoutComplete") ); - - return true; + + return true; } COMPILE::JS { var children:Array; var i:int; var n:int; - + var viewBead:ILayoutHost = (host as ILayoutParent).getLayoutHost(); var contentView:IParentIUIBase = viewBead.contentView as IParentIUIBase; children = contentView.internalChildren(); @@ -195,11 +195,11 @@ package org.apache.flex.html.beads.layouts { var child:WrappedHTMLElement = children[i]; child.flexjs_wrapper.setDisplayStyleForLayout('block'); - if (child.style.display === 'none') + if (child.style.display === 'none') { child.flexjs_wrapper.setDisplayStyleForLayout('block'); - } - else + } + else { // block elements don't measure width correctly so set to inline for a second child.style.display = 'inline-block'; @@ -211,6 +211,6 @@ package org.apache.flex.html.beads.layouts return true; } } - + } } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5300c4e9/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/ContainerContentArea.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/ContainerContentArea.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/ContainerContentArea.as index 947a5f1..326739d 100644 --- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/ContainerContentArea.as +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/ContainerContentArea.as @@ -22,22 +22,22 @@ package org.apache.flex.html.supportClasses import org.apache.flex.events.Event; import org.apache.flex.events.IEventDispatcher; import org.apache.flex.core.IChild; - import org.apache.flex.core.ILayoutObject; - + import org.apache.flex.core.ILayoutView; + /** * The ContainerContentArea class implements the contentView for * a Container on the SWF platform. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - public class ContainerContentArea extends UIBase implements ILayoutObject + public class ContainerContentArea extends UIBase implements ILayoutView { /** * Constructor. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -48,39 +48,11 @@ package org.apache.flex.html.supportClasses super(); addEventListener("layoutNeeded", forwardEventHandler); } - + private function forwardEventHandler(event:Event):void { if (parent is IEventDispatcher) (parent as IEventDispatcher).dispatchEvent(event); } - - /** - * @copy org.apache.flex.core.IItemRendererParent#removeAllElements() - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ -// public function removeAllElements():void -// { -// COMPILE::SWF -// { -// var n:Number = numElements; -// for (var i:Number = n-1; i >= 0; i--) { -// var child:IChild = getElementAt(i); -// removeElement(child,false); -// } -// $sprite.removeChildren(0); -// } -// COMPILE::JS -// { -// while (element.hasChildNodes()) -// { -// element.removeChild(element.lastChild); -// } -// } -// } } } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5300c4e9/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/MXMLItemRenderer.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/MXMLItemRenderer.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/MXMLItemRenderer.as index f70403e..de1b304 100644 --- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/MXMLItemRenderer.as +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/MXMLItemRenderer.as @@ -20,7 +20,7 @@ package org.apache.flex.html.supportClasses { import org.apache.flex.core.ILayoutHost; import org.apache.flex.core.ILayoutParent; - import org.apache.flex.core.ILayoutObject; + import org.apache.flex.core.ILayoutView; import org.apache.flex.core.IStrand; import org.apache.flex.core.IBead; import org.apache.flex.core.IBeadLayout; @@ -36,7 +36,7 @@ package org.apache.flex.html.supportClasses * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - public class MXMLItemRenderer extends DataItemRenderer implements ILayoutParent, ILayoutHost, IStrand, ILayoutObject + public class MXMLItemRenderer extends DataItemRenderer implements ILayoutParent, ILayoutHost, IStrand, ILayoutView { /** * constructor. @@ -50,7 +50,7 @@ package org.apache.flex.html.supportClasses { super(); } - + [Bindable("dataChange")] override public function set data(value:Object):void { @@ -60,17 +60,17 @@ package org.apache.flex.html.supportClasses dispatchEvent(new Event("dataChange")); } } - + public function getLayoutHost():ILayoutHost { - return this; + return this; } - - public function get contentView():ILayoutObject + + public function get contentView():ILayoutView { return this; } - + override public function adjustSize():void { var layout:IBeadLayout = getBeadByType(IBeadLayout) as IBeadLayout; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5300c4e9/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/PanelLayoutProxy.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/PanelLayoutProxy.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/PanelLayoutProxy.as index 5c40443..4ebc174 100644 --- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/PanelLayoutProxy.as +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/PanelLayoutProxy.as @@ -19,16 +19,16 @@ package org.apache.flex.html.supportClasses { import org.apache.flex.core.UIBase; - import org.apache.flex.core.ILayoutObject; + import org.apache.flex.core.ILayoutView; import org.apache.flex.core.IChild; import org.apache.flex.events.IEventDispatcher; - + import org.apache.flex.html.Panel; - + COMPILE::JS { import org.apache.flex.core.WrappedHTMLElement; } - + /** * The PanelLayoutProxy class is used by Panel in order for layouts to operate * on the Panel itself. If Panel were being used, its numElements, getElementAt, etc. @@ -36,17 +36,17 @@ package org.apache.flex.html.supportClasses * to work on the Panel directly (its TitleBar, Container, and ControlBar children), * this proxy is used which will invoke the Panel's $numElements, $getElementAt, etc * functions. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - public class PanelLayoutProxy implements ILayoutObject + public class PanelLayoutProxy implements ILayoutView { /** * Constructor. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -57,17 +57,17 @@ package org.apache.flex.html.supportClasses super(); _host = host; } - + private var _host:Object; - + public function get host():Object { return _host; } - + /** * The width of the bounding box. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -76,10 +76,10 @@ package org.apache.flex.html.supportClasses public function get width():Number { return (host as Panel).width; } - + /** * The height of the bounding box. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -88,10 +88,10 @@ package org.apache.flex.html.supportClasses public function get height():Number { return (host as Panel).height; } - + /** * The number of elements in the parent. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -101,12 +101,12 @@ package org.apache.flex.html.supportClasses { return (host as Panel).$numElements; } - + /** * Get a component from the parent. - * + * * @param c The index of the subcomponent. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -116,13 +116,13 @@ package org.apache.flex.html.supportClasses { return (host as Panel).$getElementAt(index); } - + COMPILE::JS public function get somethingelse():WrappedHTMLElement { return (host as Panel).element; } - + COMPILE::JS public function get element():WrappedHTMLElement {
