flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [13/23] git commit: [flex-asjs] [refs/heads/develop] - be smarter about when ContentArea is resized
Date Wed, 29 Oct 2014 18:16:08 GMT
be smarter about when ContentArea is resized


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

Branch: refs/heads/develop
Commit: 904ec20175c2406cd169dbed0f6ab2e93aaa57d4
Parents: 6989ccf
Author: Alex Harui <aharui@apache.org>
Authored: Tue Oct 28 09:48:16 2014 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Wed Oct 29 11:15:43 2014 -0700

----------------------------------------------------------------------
 .../org/apache/flex/html/beads/ContainerView.as | 86 ++++++++++++++------
 1 file changed, 59 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/904ec201/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/ContainerView.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/ContainerView.as
b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/ContainerView.as
index b934e94..d6b587b 100644
--- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/ContainerView.as
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/ContainerView.as
@@ -81,10 +81,62 @@ package org.apache.flex.html.beads
 		override public function set strand(value:IStrand):void
 		{
 			super.strand = value;
-            changeHandler(null);
-            IEventDispatcher(_strand).addEventListener("childrenAdded", changeHandler); 
          
-            IEventDispatcher(_strand).addEventListener("widthChanged", changeHandler);  
         
-            IEventDispatcher(_strand).addEventListener("heightChanged", changeHandler); 
          
+            
+            var host:UIBase = value as UIBase;
+            
+            if (_strand.getBeadByType(IBeadLayout) == null)
+            {
+                var c:Class = ValuesManager.valuesImpl.getValue(host, "iBeadLayout");
+                if (c)
+                {
+                    var layout:IBeadLayout = new c() as IBeadLayout;
+                    _strand.addBead(layout);
+                }
+            }
+            
+            if (host.isWidthSizedToContent() && host.isHeightSizedToContent())
+            {
+                host.addEventListener("childrenAdded", changeHandler);
+                checkActualParent();
+            }
+            else
+            {
+                host.addEventListener("widthChanged", changeHandler);
+                host.addEventListener("heightChanged", changeHandler);
+                host.addEventListener("sizeChanged", sizeChangeHandler);
+                if (!isNaN(host.explicitWidth) && !isNaN(host.explicitHeight))
+                    sizeChangeHandler(null);
+                else
+                    checkActualParent();
+            }
+        }
+        
+        private function checkActualParent():Boolean
+        {
+            var host:UIBase = UIBase(_strand);
+            if (contentAreaNeeded())
+            {
+                if (actualParent == null || actualParent == host)
+                {
+                    actualParent = new ContainerContentArea();
+                    host.addElement(actualParent);
+                    Container(host).setActualParent(actualParent);
+                }
+                return true;
+            }
+            else
+            {
+                actualParent = host;
+            }
+            return false;
+        }
+        
+        private function sizeChangeHandler(event:Event):void
+        {
+            var host:UIBase = UIBase(_strand);
+            host.addEventListener("childrenAdded", changeHandler);
+            host.addEventListener("layoutNeeded", changeHandler);
+            changeHandler(event);
         }
         
         private var inChangeHandler:Boolean;
@@ -107,14 +159,8 @@ package org.apache.flex.html.beads
 			
 			var padding:Object = determinePadding();
 			
-			if (contentAreaNeeded())
+			if (checkActualParent())
 			{
-                if (actualParent == null || actualParent == host)
-                {
-    				actualParent = new ContainerContentArea();
-    				host.addElement(actualParent);
-                    Container(host).setActualParent(actualParent);
-                }
 				actualParent.x = padding.paddingLeft;
 				actualParent.y = padding.paddingTop;
                 var pb:Number = padding.paddingBottom;
@@ -124,19 +170,15 @@ package org.apache.flex.html.beads
                 if (isNaN(pr))
                     pr = 0;
                 if (!isNaN(host.explicitWidth) || !isNaN(host.percentWidth))
-                    actualParent.width = host.width - padding.paddingLeft - pr;
+                    actualParent.setWidth(host.width - padding.paddingLeft - pr);
                 else
                     host.dispatchEvent(new Event("widthChanged"));
                 
                 if (!isNaN(host.explicitHeight) || !isNaN(host.percentHeight))
-                    actualParent.height = host.height - padding.paddingTop - pb;
+                    actualParent.setHeight(host.height - padding.paddingTop - pb);
                 else
                     host.dispatchEvent(new Event("heightChanged"));
 			}
-			else
-			{
-				actualParent = host;
-			}
 			
 			var backgroundColor:Object = ValuesManager.valuesImpl.getValue(host, "background-color");
 			var backgroundImage:Object = ValuesManager.valuesImpl.getValue(host, "background-image");
@@ -162,16 +204,6 @@ package org.apache.flex.html.beads
                     host.addBead(new (ValuesManager.valuesImpl.getValue(host, "iBorderBead"))
as IBead);	
 			}
             
-            if (_strand.getBeadByType(IBeadLayout) == null)
-            {
-                var c:Class = ValuesManager.valuesImpl.getValue(host, "iBeadLayout");
-                if (c)
-                {
-                    var mapper:IBeadLayout = new c() as IBeadLayout;
-                    _strand.addBead(mapper);
-                }
-            }
-            
             inChangeHandler = false;
 		}
 		


Mime
View raw message