flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [3/6] git commit: [flex-asjs] [refs/heads/dual] - run layout in a few more scenarios
Date Thu, 27 Apr 2017 21:15:27 GMT
run layout in a few more scenarios


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/b06d5a1d
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/b06d5a1d
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/b06d5a1d

Branch: refs/heads/dual
Commit: b06d5a1d869fbe5f013cd4e83fed6b799bbdfd4b
Parents: e828d17
Author: Alex Harui <aharui@apache.org>
Authored: Wed Apr 26 22:47:37 2017 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Thu Apr 27 14:15:17 2017 -0700

----------------------------------------------------------------------
 .../flex/org/apache/flex/core/LayoutBase.as     | 33 +++++++++++++++-----
 1 file changed, 25 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/b06d5a1d/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/LayoutBase.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/LayoutBase.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/LayoutBase.as
index f23f035..979ebc7 100644
--- a/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/LayoutBase.as
+++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/LayoutBase.as
@@ -53,6 +53,8 @@ package org.apache.flex.core
 		{
 		}
 
+		private var sawInitComplete:Boolean;
+		
         /**
 		 * The strand/host container is also an ILayoutChild because
          * it can have its size dictated by the host's parent which is
@@ -116,12 +118,19 @@ package org.apache.flex.core
 		protected function handleChildrenAdded(event:Event):void
 		{
 			COMPILE::SWF {
-				var n:Number = layoutView.numElements;
-				for(var i:int=0; i < n; i++) {
-					var child:IEventDispatcher = layoutView.getElementAt(i) as IEventDispatcher;
-					child.addEventListener("widthChanged", childResizeHandler);
-					child.addEventListener("heightChanged", childResizeHandler);
-					child.addEventListener("sizeChanged", childResizeHandler);
+				if (sawInitComplete)
+				{
+					performLayout();
+				}
+				else
+				{
+					var n:Number = layoutView.numElements;
+					for(var i:int=0; i < n; i++) {
+						var child:IEventDispatcher = layoutView.getElementAt(i) as IEventDispatcher;
+						child.addEventListener("widthChanged", childResizeHandler);
+						child.addEventListener("heightChanged", childResizeHandler);
+						child.addEventListener("sizeChanged", childResizeHandler);
+					}
 				}
 			}
 		}
@@ -163,7 +172,13 @@ package org.apache.flex.core
 		 */
 		protected function handleInitComplete(event:Event):void
 		{
-			performLayout();
+			sawInitComplete = true;
+			
+			// Complete the setup if the height is sized to content or has been explicitly set
+            // and the width is sized to content or has been explicitly set
+			if ((host.isHeightSizedToContent() || !isNaN(host.explicitHeight)) &&
+                (host.isWidthSizedToContent() || !isNaN(host.explicitWidth)))
+	    		performLayout();
 		}
 		
 		/**
@@ -195,8 +210,10 @@ package org.apache.flex.core
 				ml = 0;
 			if (marginRight == "auto")
 				mr = 0;
+			if (margin == "auto")
+			    ml = mr = mt = mb = 0;
 			
-			return {left:ml, top:mt, right:mr, bottom:mb};
+			return {left:ml, top:mt, right:mr, bottom:mb, auto: (marginLeft == "auto" && marginRight
== "auto") || margin == "auto"};
 		}
 		
 		/**


Mime
View raw message