flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [1/2] git commit: [flex-asjs] [refs/heads/develop] - update the way layout works
Date Mon, 18 May 2015 17:44:52 GMT
Repository: flex-asjs
Updated Branches:
  refs/heads/develop 40b5b8cfb -> 3c23b3a1a


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3c23b3a1/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/VerticalLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/VerticalLayout.as
b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/VerticalLayout.as
index a9db932..b758f88 100644
--- a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/VerticalLayout.as
+++ b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/VerticalLayout.as
@@ -20,15 +20,15 @@ package org.apache.flex.html.beads.layouts
 {
 	
 	import org.apache.flex.core.IBeadLayout;
-    import org.apache.flex.core.ILayoutChild;
+	import org.apache.flex.core.ILayoutChild;
 	import org.apache.flex.core.ILayoutParent;
-    import org.apache.flex.core.IParentIUIBase;
+	import org.apache.flex.core.IParentIUIBase;
 	import org.apache.flex.core.IStrand;
-    import org.apache.flex.core.IUIBase;
+	import org.apache.flex.core.IUIBase;
 	import org.apache.flex.core.ValuesManager;
 	import org.apache.flex.events.Event;
 	import org.apache.flex.events.IEventDispatcher;
-    import org.apache.flex.utils.dbg.DOMPathUtil;
+	import org.apache.flex.utils.dbg.DOMPathUtil;
 
     /**
      *  The VerticalLayout class is a simple layout
@@ -70,46 +70,25 @@ package org.apache.flex.html.beads.layouts
          */
 		public function set strand(value:IStrand):void
 		{
-            host = value as ILayoutChild;
-            
-            // if host is going to be sized by its parent, then don't
-            // run layout when the children are added until after the
-            // initial sizing by the parent.
-            if (host.isWidthSizedToContent() && host.isHeightSizedToContent())
-            {
-                addOtherListeners();
-            }
-            else
-            {
-                host.addEventListener("widthChanged", changeHandler);
-                host.addEventListener("heightChanged", changeHandler);
-                host.addEventListener("sizeChanged", sizeChangeHandler);
-                if (!isNaN(host.explicitWidth) && !isNaN(host.explicitHeight))
-                    addOtherListeners();
-            }
+            host = value as ILayoutChild;            
 		}
 	
-        private function addOtherListeners():void
-        {
-            host.addEventListener("childrenAdded", changeHandler);
-            host.addEventListener("layoutNeeded", changeHandler);
-			host.addEventListener("itemsCreated", changeHandler);
-        }
-        
-        private function sizeChangeHandler(event:Event):void
-        {
-            addOtherListeners();
-            changeHandler(event);
-        }
-        
-		private function changeHandler(event:Event):void
+        /**
+         *  @copy org.apache.flex.core.IBeadLayout#layout
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.0
+         */
+		public function layout():Boolean
 		{
-            //trace(DOMPathUtil.getPath(host), event ? event.type : "fixed size");
 			var layoutParent:ILayoutParent = host.getBeadByType(ILayoutParent) as ILayoutParent;
 			var contentView:IParentIUIBase = layoutParent ? layoutParent.contentView : IParentIUIBase(host);
 			
 			var n:int = contentView.numElements;
 			var hasHorizontalFlex:Boolean;
+            var hostSizedToContent:Boolean = host.isWidthSizedToContent();
 			var flexibleHorizontalMargins:Array = [];
             var ilc:ILayoutChild;
 			var marginLeft:Object;
@@ -118,10 +97,15 @@ package org.apache.flex.html.beads.layouts
 			var marginBottom:Object;
 			var margin:Object;
 			var maxWidth:Number = 0;
+            // asking for contentView.width can result in infinite loop if host isn't sized
already
+            var w:Number = hostSizedToContent ? 0 : contentView.width;
 			for (var i:int = 0; i < n; i++)
 			{
 				var child:IUIBase = contentView.getElementAt(i) as IUIBase;
 				if (child == null || !child.visible) continue;
+                ilc = child as ILayoutChild;
+                var left:Number = ValuesManager.valuesImpl.getValue(child, "left");
+                var right:Number = ValuesManager.valuesImpl.getValue(child, "right");
 				margin = ValuesManager.valuesImpl.getValue(child, "margin");
 				if (margin is Array)
 				{
@@ -167,19 +151,18 @@ package org.apache.flex.html.beads.layouts
 					child.y = mt;
 				else
 					child.y = yy + Math.max(mt, lastmb);
-                if (child is ILayoutChild)
+                if (ilc)
                 {
-                    ilc = child as ILayoutChild;
                     if (!isNaN(ilc.percentHeight))
-                        ilc.setHeight(contentView.height * ilc.percentHeight / 100, true);
+                        ilc.setHeight(contentView.height * ilc.percentHeight / 100, !isNaN(ilc.percentWidth));
                 }
-				yy = child.y + child.clientHeight;
 				lastmb = mb;
-				flexibleHorizontalMargins[i] = {};
+                var marginObject:Object = {};
+				flexibleHorizontalMargins[i] = marginObject;
 				if (marginLeft == "auto")
 				{
 					ml = 0;
-					flexibleHorizontalMargins[i].marginLeft = marginLeft;
+                    marginObject.marginLeft = marginLeft;
 					hasHorizontalFlex = true;
 				}
 				else
@@ -188,15 +171,15 @@ package org.apache.flex.html.beads.layouts
 					if (isNaN(ml))
 					{
 						ml = 0;
-						flexibleHorizontalMargins[i].marginLeft = marginLeft;
+                        marginObject.marginLeft = marginLeft;
 					}
 					else
-						flexibleHorizontalMargins[i].marginLeft = ml;
+                        marginObject.marginLeft = ml;
 				}
 				if (marginRight == "auto")
 				{
 					mr = 0;
-					flexibleHorizontalMargins[i].marginRight = marginRight;
+                    marginObject.marginRight = marginRight;
 					hasHorizontalFlex = true;
 				}
 				else
@@ -205,34 +188,107 @@ package org.apache.flex.html.beads.layouts
 					if (isNaN(mr))
 					{
 						mr = 0;
-						flexibleHorizontalMargins[i].marginRight = marginRight;
+                        marginObject.marginRight = marginRight;
 					}
 					else
-						flexibleHorizontalMargins[i].marginRight = mr;
+                        marginObject.marginRight = mr;
 				}
-				child.x = ml;
-                if (child is ILayoutChild)
+                if (!hostSizedToContent)
                 {
-                    ilc = child as ILayoutChild;
-                    if (!isNaN(ilc.percentWidth))
-                        ilc.setWidth(contentView.width * ilc.percentWidth / 100, true);
+                    // if host is sized by parent,
+                    // we can position and size children horizontally now
+                    setPositionAndWidth(child, left, ml, right, mr, w);
                 }
-				maxWidth = Math.max(maxWidth, ml + child.clientWidth + mr);
-			}
-			for (i = 0; i < n; i++)
-			{
-                child = contentView.getElementAt(i) as IUIBase;
-				if (child == null || !child.visible) continue;
-                if (hasHorizontalFlex)
+                else
                 {
-					var obj:Object = flexibleHorizontalMargins[i];
-					if (obj.marginLeft == "auto" && obj.marginRight == "auto")
-						child.x = maxWidth - child.clientWidth / 2;
-					else if (obj.marginLeft == "auto")
-						child.x = maxWidth - child.clientWidth - obj.marginRight;
-				}
-                child.dispatchEvent(new Event("sizeChanged"));
+                    if (!isNaN(left))
+                    {
+                        ml = left;
+                        marginObject.left = ml;
+                    }
+                    if (!isNaN(right))
+                    {
+                        mr = right;
+                        marginObject.right = mr;
+                    }
+                    maxWidth = Math.max(maxWidth, ml + child.clientWidth + mr);         
          
+                }
+                yy = child.y + child.clientHeight;
 			}
+            if (hostSizedToContent)
+            {
+                ILayoutChild(contentView).setWidth(maxWidth, true);
+                if (host.isHeightSizedToContent())
+                    ILayoutChild(contentView).setHeight(yy, true);
+    			for (i = 0; i < n; i++)
+    			{
+                    child = contentView.getElementAt(i) as IUIBase;
+    				if (child == null || !child.visible) continue;
+                    var obj:Object = flexibleHorizontalMargins[i];
+                    setPositionAndWidth(child, obj.left, obj.marginLeft,
+                        obj.right, obj.marginRight, maxWidth);
+    			}
+            }
+            if (hasHorizontalFlex)
+            {
+                for (i = 0; i < n; i++)
+                {
+                    child = contentView.getElementAt(i) as IUIBase;
+                    if (child == null || !child.visible) continue;
+                    ilc = child as ILayoutChild;
+                    obj = flexibleHorizontalMargins[i];
+                    if (hasHorizontalFlex)
+                    {
+                        if (obj.marginLeft == "auto" && obj.marginRight == "auto")
+                            child.x = maxWidth - child.clientWidth / 2;
+                        else if (obj.marginLeft == "auto")
+                            child.x = maxWidth - child.clientWidth - obj.marginRight;
+                    }
+                }
+            }
+            return true;
 		}
+    
+        private function setPositionAndWidth(child:IUIBase, left:Number, ml:Number,
+                                             right:Number, mr:Number, w:Number):void
+        {
+            var widthSet:Boolean = false;
+            
+            var ww:Number = w;
+            var ilc:ILayoutChild = child as ILayoutChild;
+            if (!isNaN(left))
+            {
+                child.x = left + ml;
+                ww -= left + ml;
+            }
+            else 
+            {
+                child.x = ml;
+                ww -= left;
+            }
+            if (!isNaN(right))
+            {
+                if (!isNaN(left))
+                {
+                    if (ilc)
+                        ilc.setWidth(ww - right - mr, true);
+                    else
+                    {
+                        child.width = ww - right - mr;
+                        widthSet = true;
+                    }
+                }
+                else
+                    child.x = w - right - mr - child.clientWidth;
+            }
+            if (ilc)
+            {
+                if (!isNaN(ilc.percentWidth))
+                    ilc.setWidth(w * ilc.percentWidth / 100, true);
+            }
+            if (!widthSet)
+                child.dispatchEvent(new Event("sizeChanged"));
+        }
+
 	}
 }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3c23b3a1/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/VerticalScrollingLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/VerticalScrollingLayout.as
b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/VerticalScrollingLayout.as
index 58a6f59..2c6116c 100644
--- a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/VerticalScrollingLayout.as
+++ b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/VerticalScrollingLayout.as
@@ -76,23 +76,16 @@ package org.apache.flex.html.beads.layouts
 		public function set strand(value:IStrand):void
 		{
 			_strand = value;
-			
-			IEventDispatcher(value).addEventListener("heightChanged", changeHandler);
-			IEventDispatcher(value).addEventListener("widthChanged", changeHandler);
-			IEventDispatcher(value).addEventListener("itemsCreated", changeHandler);
-            IEventDispatcher(value).addEventListener("childrenAdded", changeHandler);
-			IEventDispatcher(value).addEventListener("layoutNeeded", changeHandler);
 		}
 		
-		private function changeHandler(event:Event):void
+        /**
+         * @copy org.apache.flex.core.IBeadLayout#layout
+         */
+		public function layout():Boolean
 		{            
             var layoutParent:IScrollingLayoutParent = 
                 _strand.getBeadByType(IScrollingLayoutParent) as IScrollingLayoutParent;
             var contentView:IParentIUIBase = layoutParent.contentView as IParentIUIBase;
-            if (!contentView)
-                return;
-            IEventDispatcher(contentView).addEventListener("childrenAdded", changeHandler);
-            IEventDispatcher(contentView).addEventListener("layoutNeeded", changeHandler);
             
 			var border:Border = layoutParent.border;
    			var borderModel:IBorderModel;
@@ -154,8 +147,7 @@ package org.apache.flex.html.beads.layouts
                 DisplayObject(contentView).scrollRect = null;
 				vScrollBar.visible = false;
 			}
-			
-			IEventDispatcher(_strand).dispatchEvent(new Event("layoutComplete"));
+			return true;
 		}
 
         private function scrollHandler(event:Event):void

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3c23b3a1/frameworks/projects/HTML/asjs/src/org/apache/flex/html/beads/DataGridView.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/asjs/src/org/apache/flex/html/beads/DataGridView.as
b/frameworks/projects/HTML/asjs/src/org/apache/flex/html/beads/DataGridView.as
index 9e36e55..8d3e8fa 100644
--- a/frameworks/projects/HTML/asjs/src/org/apache/flex/html/beads/DataGridView.as
+++ b/frameworks/projects/HTML/asjs/src/org/apache/flex/html/beads/DataGridView.as
@@ -169,7 +169,7 @@ package org.apache.flex.html.beads
 			}
 			layout.header = buttonBar;
 			layout.columns = columns;
-			
+			layout.layout();
 			IEventDispatcher(_strand).dispatchEvent(new Event("itemsCreated"));
 		}
 		

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3c23b3a1/frameworks/projects/HTML/asjs/src/org/apache/flex/html/beads/layouts/DataGridLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/asjs/src/org/apache/flex/html/beads/layouts/DataGridLayout.as
b/frameworks/projects/HTML/asjs/src/org/apache/flex/html/beads/layouts/DataGridLayout.as
index 9cf614c..0ad68df 100644
--- a/frameworks/projects/HTML/asjs/src/org/apache/flex/html/beads/layouts/DataGridLayout.as
+++ b/frameworks/projects/HTML/asjs/src/org/apache/flex/html/beads/layouts/DataGridLayout.as
@@ -65,11 +65,6 @@ package org.apache.flex.html.beads.layouts
 		public function set strand(value:IStrand):void
 		{
 			_strand = value;
-			IEventDispatcher(value).addEventListener("widthChanged", changeHandler);
-			IEventDispatcher(value).addEventListener("heightChanged", changeHandler);
-			IEventDispatcher(value).addEventListener("childrenAdded", changeHandler);
-			IEventDispatcher(value).addEventListener("itemsCreated", changeHandler);
-			IEventDispatcher(value).addEventListener("elementAdded", changeHandler);
 		}
 		
 		private var _header:UIBase;
@@ -111,10 +106,10 @@ package org.apache.flex.html.beads.layouts
 			_columns = value;
 		}
 		
-		/**
-		 * @private
-		 */
-		private function changeHandler(event:Event):void
+        /**
+         * @copy org.apache.flex.core.IBeadLayout#layout
+         */
+		public function layout():Boolean
 		{			
 			var sw:Number = UIBase(_strand).width;
 			var sh:Number = UIBase(_strand).height;
@@ -148,7 +143,7 @@ package org.apache.flex.html.beads.layouts
 				xpos += column.width;
 			}
 			
-			IEventDispatcher(_strand).dispatchEvent(new Event("layoutComplete"));
+			return true;
 		}
 	}
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3c23b3a1/frameworks/projects/HTML/asjs/src/org/apache/flex/html/beads/layouts/FlexibleFirstChildHorizontalLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/asjs/src/org/apache/flex/html/beads/layouts/FlexibleFirstChildHorizontalLayout.as
b/frameworks/projects/HTML/asjs/src/org/apache/flex/html/beads/layouts/FlexibleFirstChildHorizontalLayout.as
index a48cd63..f374fb8 100644
--- a/frameworks/projects/HTML/asjs/src/org/apache/flex/html/beads/layouts/FlexibleFirstChildHorizontalLayout.as
+++ b/frameworks/projects/HTML/asjs/src/org/apache/flex/html/beads/layouts/FlexibleFirstChildHorizontalLayout.as
@@ -19,7 +19,8 @@
 package org.apache.flex.html.beads.layouts
 {
 	import org.apache.flex.core.IBeadLayout;
-	import org.apache.flex.core.ILayoutParent;
+	import org.apache.flex.core.ILayoutChild;
+    import org.apache.flex.core.ILayoutParent;
 	import org.apache.flex.core.IParent;
 	import org.apache.flex.core.IStrand;
 	import org.apache.flex.core.IUIBase;
@@ -55,7 +56,10 @@ package org.apache.flex.html.beads.layouts
 		{
 		}
 		
-		private var _strand:IStrand;
+        // 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
@@ -67,19 +71,18 @@ package org.apache.flex.html.beads.layouts
          */
 		public function set strand(value:IStrand):void
 		{
-			_strand = value;
-            IEventDispatcher(value).addEventListener("layoutNeeded", changeHandler);
-			IEventDispatcher(value).addEventListener("widthChanged", changeHandler);
-			IEventDispatcher(value).addEventListener("childrenAdded", changeHandler);
-			IEventDispatcher(value).addEventListener("itemsCreated", changeHandler);
-			IEventDispatcher(value).addEventListener("sizeChanged", changeHandler);
+            host = value as ILayoutChild;
 		}
 	
-		private function changeHandler(event:Event):void
+        /**
+         * @copy org.apache.flex.core.IBeadLayout#layout
+         */
+		public function layout():Boolean
 		{
-			var layoutParent:ILayoutParent = _strand.getBeadByType(ILayoutParent) as ILayoutParent;
+			var layoutParent:ILayoutParent = host.getBeadByType(ILayoutParent) as ILayoutParent;
 			var contentView:IParent = layoutParent.contentView;
-			
+            var hostSizedToContent:Boolean = host.isHeightSizedToContent();
+
 			var n:int = contentView.numElements;
 			var marginLeft:Object;
 			var marginRight:Object;
@@ -91,7 +94,7 @@ package org.apache.flex.html.beads.layouts
 			
             var xx:Number = layoutParent.resizableView.width;
             if (isNaN(xx) || xx <= 0)
-                return;
+                return true;
             var padding:Object = determinePadding();
             // some browsers don't like it when you go all the way to the right edge.
             xx -= padding.paddingLeft + padding.paddingRight + 1;
@@ -180,7 +183,10 @@ package org.apache.flex.html.beads.layouts
 				else
 					child.y = obj.marginTop;
 			}
-            layoutParent.resizableView.height = maxHeight;
+            if (hostSizedToContent)
+                ILayoutChild(contentView).setHeight(maxHeight, true);
+
+            return true;
 		}
 
         // TODO (aharui): utility class or base class
@@ -201,7 +207,7 @@ package org.apache.flex.html.beads.layouts
             var paddingLeft:Object;
             var paddingTop:Object;
             var paddingRight:Object;
-            var padding:Object = ValuesManager.valuesImpl.getValue(_strand, "padding");
+            var padding:Object = ValuesManager.valuesImpl.getValue(host, "padding");
             if (typeof(padding) == "Array")
             {
                 if (padding.length == 1)
@@ -221,9 +227,9 @@ package org.apache.flex.html.beads.layouts
             }
             else if (padding == null)
             {
-                paddingLeft = ValuesManager.valuesImpl.getValue(_strand, "padding-left");
-                paddingTop = ValuesManager.valuesImpl.getValue(_strand, "padding-top");
-                paddingRight = ValuesManager.valuesImpl.getValue(_strand, "padding-right");
+                paddingLeft = ValuesManager.valuesImpl.getValue(host, "padding-left");
+                paddingTop = ValuesManager.valuesImpl.getValue(host, "padding-top");
+                paddingRight = ValuesManager.valuesImpl.getValue(host, "padding-right");
             }
             else
             {

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3c23b3a1/frameworks/projects/HTML/asjs/src/org/apache/flex/html/beads/layouts/OneFlexibleChildHorizontalLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/asjs/src/org/apache/flex/html/beads/layouts/OneFlexibleChildHorizontalLayout.as
b/frameworks/projects/HTML/asjs/src/org/apache/flex/html/beads/layouts/OneFlexibleChildHorizontalLayout.as
index cd28e32..761f36e 100644
--- a/frameworks/projects/HTML/asjs/src/org/apache/flex/html/beads/layouts/OneFlexibleChildHorizontalLayout.as
+++ b/frameworks/projects/HTML/asjs/src/org/apache/flex/html/beads/layouts/OneFlexibleChildHorizontalLayout.as
@@ -83,38 +83,12 @@ package org.apache.flex.html.beads.layouts
 		public function set strand(value:IStrand):void
 		{
             host = value as ILayoutChild;
-            
-            // if host is going to be sized by its parent, then don't
-            // run layout when the children are added until after the
-            // initial sizing by the parent.
-            if (host.isWidthSizedToContent() && host.isHeightSizedToContent())
-            {
-                addOtherListeners();
-            }
-            else
-            {
-                host.addEventListener("widthChanged", changeHandler);
-                host.addEventListener("heightChanged", changeHandler);
-                host.addEventListener("sizeChanged", sizeChangeHandler);
-                if (!isNaN(host.explicitWidth) && !isNaN(host.explicitHeight))
-                    addOtherListeners();
-            }
 		}
 	
-        private function addOtherListeners():void
-        {
-            host.addEventListener("childrenAdded", changeHandler);
-            host.addEventListener("layoutNeeded", changeHandler);
-            host.addEventListener("itemsCreated", changeHandler);
-        }
-        
-        private function sizeChangeHandler(event:Event):void
-        {
-            addOtherListeners();
-            changeHandler(event);
-        }
-        
-		private function changeHandler(event:Event):void
+        /**
+         * @copy org.apache.flex.core.IBeadLayout#layout
+         */
+		public function layout():Boolean
 		{
             var layoutParent:ILayoutParent = host.getBeadByType(ILayoutParent) as ILayoutParent;
             var contentView:IParentIUIBase = layoutParent ? layoutParent.contentView : IParentIUIBase(host);
@@ -366,7 +340,7 @@ package org.apache.flex.html.beads.layouts
 				else
 					child.y = obj.marginTop;
 			}
-            ILayoutChild(layoutParent.resizableView).setHeight(maxHeight);
+            return true;
 		}
 
         // TODO (aharui): utility class or base class

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3c23b3a1/frameworks/projects/HTML/asjs/src/org/apache/flex/html/beads/layouts/OneFlexibleChildVerticalLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/asjs/src/org/apache/flex/html/beads/layouts/OneFlexibleChildVerticalLayout.as
b/frameworks/projects/HTML/asjs/src/org/apache/flex/html/beads/layouts/OneFlexibleChildVerticalLayout.as
index 2a0ad3c..eb641b8 100644
--- a/frameworks/projects/HTML/asjs/src/org/apache/flex/html/beads/layouts/OneFlexibleChildVerticalLayout.as
+++ b/frameworks/projects/HTML/asjs/src/org/apache/flex/html/beads/layouts/OneFlexibleChildVerticalLayout.as
@@ -83,38 +83,12 @@ package org.apache.flex.html.beads.layouts
 		public function set strand(value:IStrand):void
 		{
             host = value as ILayoutChild;
-            
-            // if host is going to be sized by its parent, then don't
-            // run layout when the children are added until after the
-            // initial sizing by the parent.
-            if (host.isWidthSizedToContent() && host.isHeightSizedToContent())
-            {
-                addOtherListeners();
-            }
-            else
-            {
-                host.addEventListener("widthChanged", changeHandler);
-                host.addEventListener("heightChanged", changeHandler);
-                host.addEventListener("sizeChanged", sizeChangeHandler);
-                if (!isNaN(host.explicitWidth) && !isNaN(host.explicitHeight))
-                    addOtherListeners();
-            }
 		}
-	
-        private function addOtherListeners():void
-        {
-            host.addEventListener("childrenAdded", changeHandler);
-            host.addEventListener("layoutNeeded", changeHandler);
-            host.addEventListener("itemsCreated", changeHandler);
-        }
-        
-        private function sizeChangeHandler(event:Event):void
-        {
-            addOtherListeners();
-            changeHandler(event);
-        }
-        
-		private function changeHandler(event:Event):void
+	        
+        /**
+         * @copy org.apache.flex.core.IBeadLayout#layout
+         */
+		public function layout():Boolean
 		{
             var layoutParent:ILayoutParent = host.getBeadByType(ILayoutParent) as ILayoutParent;
             var contentView:IParentIUIBase = layoutParent ? layoutParent.contentView : IParentIUIBase(host);
@@ -366,7 +340,7 @@ package org.apache.flex.html.beads.layouts
 				else
 					child.x = obj.marginLeft;
 			}
-            layoutParent.resizableView.width = maxWidth;
+            return true;
 		}
 
         // TODO (aharui): utility class or base class

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3c23b3a1/frameworks/projects/HTML/asjs/src/org/apache/flex/html/beads/layouts/VerticalColumnLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/asjs/src/org/apache/flex/html/beads/layouts/VerticalColumnLayout.as
b/frameworks/projects/HTML/asjs/src/org/apache/flex/html/beads/layouts/VerticalColumnLayout.as
index d4b801b..32916c4 100644
--- a/frameworks/projects/HTML/asjs/src/org/apache/flex/html/beads/layouts/VerticalColumnLayout.as
+++ b/frameworks/projects/HTML/asjs/src/org/apache/flex/html/beads/layouts/VerticalColumnLayout.as
@@ -64,9 +64,6 @@ package org.apache.flex.html.beads.layouts
 		public function set strand(value:IStrand):void
 		{
 			_strand = value;
-			IEventDispatcher(value).addEventListener("widthChanged", changeHandler);
-			IEventDispatcher(value).addEventListener("heightChanged", changeHandler);
-			IEventDispatcher(value).addEventListener("childrenAdded", changeHandler);
 		}
 		
 		
@@ -89,10 +86,10 @@ package org.apache.flex.html.beads.layouts
 			_numColumns = value;
 		}
 		
-		/**
-		 * @private
-		 */
-		private function changeHandler(event:Event):void
+        /**
+         * @copy org.apache.flex.core.IBeadLayout#layout
+         */
+		public function layout():Boolean
 		{			
 			var sw:Number = UIBase(_strand).width;
 			var sh:Number = UIBase(_strand).height;
@@ -145,7 +142,7 @@ package org.apache.flex.html.beads.layouts
 				}
 			}
 			
-			IEventDispatcher(_strand).dispatchEvent(new Event("layoutComplete"));
+			return true;
 		}
 	}
 }
\ No newline at end of file


Mime
View raw message