flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [03/15] git commit: [flex-asjs] [refs/heads/develop] - fix up this layout
Date Fri, 07 Aug 2015 17:11:59 GMT
fix up this layout


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

Branch: refs/heads/develop
Commit: d0cd3f7079ebc613ad7f1e47cd5b83e77f712ca6
Parents: 7c2221b
Author: Alex Harui <aharui@apache.org>
Authored: Thu Aug 6 22:12:53 2015 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Fri Aug 7 10:00:57 2015 -0700

----------------------------------------------------------------------
 .../layouts/OneFlexibleChildVerticalLayout.as   | 257 +++++++++----------
 1 file changed, 123 insertions(+), 134 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d0cd3f70/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 64364c8..f8805f5 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
@@ -157,14 +157,10 @@ package org.apache.flex.html.beads.layouts
 			var marginBottom:Object;
 			var margin:Object;
 			maxWidth = 0;
-			var horizontalMargins:Array = new Array(n);
-			
-            var hh:Number = layoutParent.resizableView.height;
-            var padding:Object = determinePadding();
-            if (isNaN(padding.paddingBottom))
-                padding.paddingBottom = 0;
-            hh -= padding.paddingTop + padding.paddingBottom;
-            var yy:int = padding.paddingTop;
+            
+            var w:Number = contentView.width;			
+            var hh:Number = contentView.height;
+            var yy:int = 0;
             var flexChildIndex:int;
             var ml:Number;
             var mr:Number;
@@ -173,10 +169,15 @@ package org.apache.flex.html.beads.layouts
             var lastmb:Number;
             var lastmt:Number;
             var halign:Object;
+            var left:Number;
+            var right:Number;
             
             for (var i:int = 0; i < n; i++)
             {
                 var child:IUIBase = contentView.getElementAt(i) as IUIBase;
+                ilc = child as ILayoutChild;
+                left = ValuesManager.valuesImpl.getValue(child, "left");
+                right = ValuesManager.valuesImpl.getValue(child, "right");
                 if (child == actualChild)
                 {
                     flexChildIndex = i;
@@ -217,6 +218,11 @@ package org.apache.flex.html.beads.layouts
                 mb = Number(marginBottom);
                 if (isNaN(mb))
                     mb = 0;
+                if (ilc)
+                {
+                    if (!isNaN(ilc.percentHeight))
+                        ilc.setHeight(contentView.height * ilc.percentHeight / 100, !isNaN(ilc.percentWidth));
+                }
                 if (marginLeft == "auto")
                     ml = 0;
                 else
@@ -238,14 +244,13 @@ package org.apache.flex.html.beads.layouts
                 {
                     ilc = child as ILayoutChild;
                     if (!isNaN(ilc.percentWidth))
-                        ilc.setWidth(contentView.width * ilc.percentWidth / 100, true);
+                        ilc.setWidth(contentView.width * ilc.percentWidth / 100, !isNaN(ilc.percentHeight));
                 }
                 maxWidth = Math.max(maxWidth, ml + child.width + mr);
+                setPositionAndWidth(child, left, ml, right, mr, w);
                 child.y = yy + mt;
                 yy += child.height + mt + mb;
                 lastmb = mb;
-                halign = ValuesManager.valuesImpl.getValue(child, "horizontal-align");
-                horizontalMargins[i] = { marginLeft: ml, marginRight: mr, halign: halign
};
             }
 
             if (n > 0 && n > flexChildIndex)
@@ -253,6 +258,9 @@ package org.apache.flex.html.beads.layouts
                 for (i = n - 1; i > flexChildIndex; i--)
     			{
     				child = contentView.getElementAt(i) as IUIBase;
+                    ilc = child as ILayoutChild;
+                    left = ValuesManager.valuesImpl.getValue(child, "left");
+                    right = ValuesManager.valuesImpl.getValue(child, "right");
     				margin = ValuesManager.valuesImpl.getValue(child, "margin");
     				if (margin is Array)
     				{
@@ -288,6 +296,11 @@ package org.apache.flex.html.beads.layouts
     				mb = Number(marginBottom);
     				if (isNaN(mb))
     					mb = 0;
+                    if (ilc)
+                    {
+                        if (!isNaN(ilc.percentHeight))
+                            ilc.setHeight(contentView.height * ilc.percentHeight / 100, !isNaN(ilc.percentWidth));
+                    }
     				if (marginLeft == "auto")
     					ml = 0;
     				else
@@ -304,159 +317,135 @@ package org.apache.flex.html.beads.layouts
     					if (isNaN(mr))
     						mr = 0;
     				}
-                    child.x = ml;
                     if (child is ILayoutChild)
                     {
                         ilc = child as ILayoutChild;
                         if (!isNaN(ilc.percentWidth))
-                            ilc.setWidth(contentView.width * ilc.percentWidth / 100, true);
+                            ilc.setWidth(contentView.width * ilc.percentWidth / 100, !isNaN(ilc.percentHeight));
                     }
+                    setPositionAndWidth(child, left, ml, right, mr, w);
                     maxWidth = Math.max(maxWidth, ml + child.width + mr);
                     child.y = hh - child.height - mb;
     				hh -= child.height + mt + mb;
     				lastmt = mt;
-                    halign = ValuesManager.valuesImpl.getValue(child, "horizontal-align");
-                    horizontalMargins[i] = { marginLeft: ml, marginRight: mr, halign: halign
};
     			}
+            } 
             
-                child = contentView.getElementAt(flexChildIndex) as IUIBase;
-                margin = ValuesManager.valuesImpl.getValue(child, "margin");
-                if (margin is Array)
-                {
-                    if (margin.length == 1)
-                        marginLeft = marginTop = marginRight = marginBottom = margin[0];
-                    else if (margin.length <= 3)
-                    {
-                        marginLeft = marginRight = margin[1];
-                        marginTop = marginBottom = margin[0];
-                    }
-                    else if (margin.length == 4)
-                    {
-                        marginLeft = margin[3];
-                        marginBottom = margin[2];
-                        marginRight = margin[1];
-                        marginTop = margin[0];					
-                    }
-                }
-                else if (margin == null)
+            child = contentView.getElementAt(flexChildIndex) as IUIBase;
+            ilc = child as ILayoutChild;
+            left = ValuesManager.valuesImpl.getValue(child, "left");
+            right = ValuesManager.valuesImpl.getValue(child, "right");
+            margin = ValuesManager.valuesImpl.getValue(child, "margin");
+            if (margin is Array)
+            {
+                if (margin.length == 1)
+                    marginLeft = marginTop = marginRight = marginBottom = margin[0];
+                else if (margin.length <= 3)
                 {
-                    marginLeft = ValuesManager.valuesImpl.getValue(child, "margin-left");
-                    marginTop = ValuesManager.valuesImpl.getValue(child, "margin-top");
-                    marginRight = ValuesManager.valuesImpl.getValue(child, "margin-right");
-                    marginBottom = ValuesManager.valuesImpl.getValue(child, "margin-bottom");
+                    marginLeft = marginRight = margin[1];
+                    marginTop = marginBottom = margin[0];
                 }
-                else
+                else if (margin.length == 4)
                 {
-                    marginLeft = marginTop = marginBottom = marginRight = margin;
+                    marginLeft = margin[3];
+                    marginBottom = margin[2];
+                    marginRight = margin[1];
+                    marginTop = margin[0];					
                 }
-                mt = Number(marginTop);
-                if (isNaN(mt))
-                    mt = 0;
-                mb = Number(marginBottom);
-                if (isNaN(mb))
-                    mb = 0;
-                if (marginLeft == "auto")
+            }
+            else if (margin == null)
+            {
+                marginLeft = ValuesManager.valuesImpl.getValue(child, "margin-left");
+                marginTop = ValuesManager.valuesImpl.getValue(child, "margin-top");
+                marginRight = ValuesManager.valuesImpl.getValue(child, "margin-right");
+                marginBottom = ValuesManager.valuesImpl.getValue(child, "margin-bottom");
+            }
+            else
+            {
+                marginLeft = marginTop = marginBottom = marginRight = margin;
+            }
+            mt = Number(marginTop);
+            if (isNaN(mt))
+                mt = 0;
+            mb = Number(marginBottom);
+            if (isNaN(mb))
+                mb = 0;
+            if (ilc)
+            {
+                if (!isNaN(ilc.percentHeight))
+                    ilc.setHeight(contentView.height * ilc.percentHeight / 100, !isNaN(ilc.percentWidth));
+            }
+            if (marginLeft == "auto")
+                ml = 0;
+            else
+            {
+                ml = Number(marginLeft);
+                if (isNaN(ml))
                     ml = 0;
-                else
-                {
-                    ml = Number(marginLeft);
-                    if (isNaN(ml))
-                        ml = 0;
-                }
-                if (marginRight == "auto")
+            }
+            if (marginRight == "auto")
+                mr = 0;
+            else
+            {
+                mr = Number(marginRight);
+                if (isNaN(mr))
                     mr = 0;
-                else
-                {
-                    mr = Number(marginRight);
-                    if (isNaN(mr))
-                        mr = 0;
-                }
-                child.x = ml;
-                if (child is ILayoutChild)
-                {
-                    ilc = child as ILayoutChild;
-                    if (!isNaN(ilc.percentWidth))
-                        ilc.setWidth(contentView.width * ilc.percentWidth / 100, true);
-                }
-                maxWidth = Math.max(maxWidth, ml + child.width + mr);
-                child.y = yy + mt;
-                child.height = hh - yy - mb;
-                halign = ValuesManager.valuesImpl.getValue(child, "horizontal-align");
-                horizontalMargins[flexChildIndex] = { marginLeft: ml, marginRight: mr, halign:
halign };
             }
+            if (child is ILayoutChild)
+            {
+                ilc = child as ILayoutChild;
+                if (!isNaN(ilc.percentWidth))
+                    ilc.setWidth(contentView.width * ilc.percentWidth / 100, !isNaN(ilc.percentHeight));
+            }
+            setPositionAndWidth(child, left, ml, right, mr, w);
+            maxWidth = Math.max(maxWidth, ml + child.width + mr);
+            child.y = yy + mt;
+            child.height = hh - yy - mb;
             
-            for (i = 0; i < n; i++)
-			{
-				var obj:Object = horizontalMargins[0]
-				child = contentView.getElementAt(i) as IUIBase;
-				if (obj.halign == "center")
-					child.x = (maxWidth - child.width) / 2;
-				else if (obj.halign == "bottom")
-					child.x = maxWidth - child.width - obj.marginRight;
-				else
-					child.x = obj.marginLeft;
-			}
             return true;
 		}
 
-        // TODO (aharui): utility class or base class
-        /**
-         *  Determines the top and left padding values, if any, as set by
-         *  padding style values. This includes "padding" for all padding values
-         *  as well as "padding-left" and "padding-top".
-         * 
-         *  Returns an object with paddingLeft and paddingTop properties.
-         *  
-         *  @langversion 3.0
-         *  @playerversion Flash 10.2
-         *  @playerversion AIR 2.6
-         *  @productversion FlexJS 0.0
-         */
-        protected function determinePadding():Object
+        private function setPositionAndWidth(child:IUIBase, left:Number, ml:Number,
+                                             right:Number, mr:Number, w:Number):void
         {
-            var paddingLeft:Object;
-            var paddingTop:Object;
-            var paddingRight:Object;
-            var padding:Object = ValuesManager.valuesImpl.getValue(host, "padding");
-            if (typeof(padding) == "Array")
+            var widthSet:Boolean = false;
+            
+            var ww:Number = w;
+            var ilc:ILayoutChild = child as ILayoutChild;
+            if (!isNaN(left))
             {
-                if (padding.length == 1)
-                    paddingLeft = paddingTop = paddingRight = padding[0];
-                else if (padding.length <= 3)
-                {
-                    paddingLeft = padding[1];
-                    paddingTop = padding[0];
-                    paddingRight = padding[1];
-                }
-                else if (padding.length == 4)
-                {
-                    paddingLeft = padding[3];
-                    paddingTop = padding[0];					
-                    paddingRight = padding[1];
-                }
+                child.x = left + ml;
+                ww -= left + ml;
             }
-            else if (padding == null)
+            else 
             {
-                paddingLeft = ValuesManager.valuesImpl.getValue(host, "padding-left");
-                paddingTop = ValuesManager.valuesImpl.getValue(host, "padding-top");
-                paddingRight = ValuesManager.valuesImpl.getValue(host, "padding-right");
+                child.x = ml;
+                ww -= ml;
             }
-            else
+            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.width;
+            }
+            if (ilc)
             {
-                paddingLeft = paddingTop = paddingRight = padding;
+                if (!isNaN(ilc.percentWidth))
+                    ilc.setWidth(w * ilc.percentWidth / 100, true);
             }
-            var pl:Number = Number(paddingLeft);
-            var pt:Number = Number(paddingTop);
-            var pr:Number = Number(paddingRight);
-            if (isNaN(pl))
-                pl = 0;
-            if (isNaN(pr))
-                pr = 0;
-            if (isNaN(pt))
-                pt = 0;
-            return {paddingLeft:pl, paddingTop:pt, paddingRight:pr};
+            if (!widthSet)
+                child.dispatchEvent(new Event("sizeChanged"));
         }
-
+        
         public function setDocument(document:Object, id:String = null):void
         {
             this.document = document;	


Mime
View raw message