flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [12/15] git commit: [flex-asjs] [refs/heads/develop] - get these layouts to use setX and get horizontallayout to always do alignment
Date Fri, 07 Aug 2015 17:12:08 GMT
get these layouts to use setX and get horizontallayout to always do alignment


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

Branch: refs/heads/develop
Commit: 25d9c0c38056086da7006e498dec2896f0628513
Parents: e0791b5
Author: Alex Harui <aharui@apache.org>
Authored: Fri Aug 7 10:00:35 2015 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Fri Aug 7 10:01:00 2015 -0700

----------------------------------------------------------------------
 .../flex/html/beads/layouts/HorizontalLayout.as | 84 +++++++++++++-------
 .../flex/html/beads/layouts/VerticalLayout.as   | 49 +++++++++---
 2 files changed, 96 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/25d9c0c3/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/HorizontalLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/HorizontalLayout.as
b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/HorizontalLayout.as
index 0ab6103..a8a235f 100644
--- a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/HorizontalLayout.as
+++ b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/HorizontalLayout.as
@@ -94,7 +94,6 @@ package org.apache.flex.html.beads.layouts
             // asking for contentView.width can result in infinite loop if host isn't sized
already
             var h:Number = hostSizedToContent ? 0 : contentView.height;
 			var verticalMargins:Array = [];
-            var hasVerticalAlign:Boolean;
 			
 			for (var i:int = 0; i < n; i++)
 			{
@@ -161,9 +160,19 @@ package org.apache.flex.html.beads.layouts
 					mb = 0;
                 var xx:Number;
                 if (i == 0)
-                    child.x = ml;
+                {
+                    if (ilc)
+                        ilc.setX(ml);
+                    else
+                        child.x = ml;
+                }
                 else
-                    child.x = xx + ml + lastmr;
+                {
+                    if (ilc)
+                        ilc.setX(xx + ml + lastmr);
+                    else
+                        child.x = xx + ml + lastmr;
+                }
                 if (ilc)
                 {
                     if (!isNaN(ilc.percentWidth))
@@ -177,6 +186,7 @@ package org.apache.flex.html.beads.layouts
                     // if host is sized by parent,
                     // we can position and size children horizontally now
                     setPositionAndHeight(child, top, mt, bottom, mb, h);
+                    maxHeight = Math.max(maxHeight, mt + child.height + mb);
                 }
                 else
                 {
@@ -195,8 +205,6 @@ package org.apache.flex.html.beads.layouts
 				xx = child.x + child.width;
 				var valign:* = ValuesManager.valuesImpl.getValue(child, "vertical-align");
 				marginObject.valign = valign;
-                if (valign !== undefined)
-                    hasVerticalAlign = true;
 			}
             if (hostSizedToContent)
             {
@@ -212,27 +220,36 @@ package org.apache.flex.html.beads.layouts
                         obj.bottom, obj.marginBottom, maxHeight);
                 }
             }
-            if (hasVerticalAlign)
-            {
-    			for (i = 0; i < n; i++)
-    			{
-    				child = contentView.getElementAt(i) as IUIBase;
-    				if (child == null || !child.visible) continue;
-                    obj = verticalMargins[i];
-                    if (child is ILayoutChild)
-                    {
-                        ilc = child as ILayoutChild;
-                        if (!isNaN(ilc.percentHeight))
-                            ilc.setHeight(contentView.height * ilc.percentHeight / 100, !isNaN(ilc.percentHeight));
-                    }
-    				if (obj.valign == "middle")
-    					child.y = (maxHeight - child.height) / 2;
+			for (i = 0; i < n; i++)
+			{
+				child = contentView.getElementAt(i) as IUIBase;
+                ilc = child as ILayoutChild;
+				if (child == null || !child.visible) continue;
+                obj = verticalMargins[i];
+                if (ilc)
+                {
+                    if (!isNaN(ilc.percentHeight))
+                        ilc.setHeight(contentView.height * ilc.percentHeight / 100, !isNaN(ilc.percentHeight));
+                }
+                if (ilc)
+                {
+    				if (obj.valign == "top")
+                        ilc.setY(obj.marginTop);
     				else if (valign == "bottom")
-    					child.y = maxHeight - child.height - obj.marginBottom;
-    				else
-    					child.y = obj.marginTop;
-    			}
-            }
+                        ilc.setY(maxHeight - child.height - obj.marginBottom);
+    				else // TODO: aharui - baseline
+                        ilc.setY((maxHeight - child.height) / 2);
+                }
+                else
+                {
+                    if (obj.valign == "top")
+                        child.y = obj.marginTop;
+                    else if (valign == "bottom")
+                        child.y = maxHeight - child.height - obj.marginBottom;
+                    else // TODO: aharui - baseline
+                        child.y = (maxHeight - child.height) / 2;                    
+                }
+			}
 			
 			// Only return true if the contentView needs to be larger; that new
 			// size is stored in the model.
@@ -252,12 +269,18 @@ package org.apache.flex.html.beads.layouts
             var ilc:ILayoutChild = child as ILayoutChild;
             if (!isNaN(top))
             {
-                child.y = top + mt;
+                if (ilc)
+                    ilc.setY(top + mt);
+                else
+                    child.y = top + mt;
                 hh -= top + mt;
             }
             else 
             {
-                child.y = mt;
+                if (ilc)
+                    ilc.setY(mt);
+                else
+                    child.y = mt;
                 hh -= mt;
             }
             if (!isNaN(bottom))
@@ -273,7 +296,12 @@ package org.apache.flex.html.beads.layouts
                     }
                 }
                 else
-                    child.y = h - bottom - mb - child.height;
+                {
+                    if (ilc)
+                        ilc.setY(h - bottom - mb - child.height);
+                    else
+                        child.y = h - bottom - mb - child.height;
+                }
             }
             if (ilc)
             {

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/25d9c0c3/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 9c93523..55a1d08 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
@@ -141,9 +141,19 @@ package org.apache.flex.html.beads.layouts
 					mb = 0;
 				var yy:Number;
 				if (i == 0)
-					child.y = mt;
+                {
+                    if (ilc)
+                        ilc.setY(mt);
+                    else
+    					child.y = mt;
+                }
 				else
-					child.y = yy + Math.max(mt, lastmb);
+                {
+                    if (ilc)
+                        ilc.setY(yy + Math.max(mt, lastmb));
+                    else
+    					child.y = yy + Math.max(mt, lastmb);
+                }
 				if (ilc)
 				{
 					if (!isNaN(ilc.percentHeight))
@@ -229,10 +239,20 @@ package org.apache.flex.html.beads.layouts
 					obj = flexibleHorizontalMargins[i];
 					if (hasHorizontalFlex)
 					{
-						if (obj.marginLeft == "auto" && obj.marginRight == "auto")
-							child.x = maxWidth - child.width / 2;
-						else if (obj.marginLeft == "auto")
-							child.x = maxWidth - child.width - obj.marginRight;
+                        if (ilc)
+                        {
+                            if (obj.marginLeft == "auto" && obj.marginRight == "auto")
+                                ilc.setX(maxWidth - child.width / 2);
+                            else if (obj.marginLeft == "auto")
+                                ilc.setX(maxWidth - child.width - obj.marginRight);     
                      
+                        }
+                        else
+                        {
+        					if (obj.marginLeft == "auto" && obj.marginRight == "auto")
+        						child.x = maxWidth - child.width / 2;
+        					else if (obj.marginLeft == "auto")
+        						child.x = maxWidth - child.width - obj.marginRight;
+                        }
 					}
 				}
 			}
@@ -255,12 +275,18 @@ package org.apache.flex.html.beads.layouts
 			var ilc:ILayoutChild = child as ILayoutChild;
 			if (!isNaN(left))
 			{
-				child.x = left + ml;
+                if (ilc)
+                    ilc.setX(left + ml);
+                else
+    				child.x = left + ml;
 				ww -= left + ml;
 			}
 			else 
 			{
-				child.x = ml;
+                if (ilc)
+                    ilc.setX(ml);
+                else
+    				child.x = ml;
 				ww -= ml;
 			}
 			if (!isNaN(right))
@@ -276,7 +302,12 @@ package org.apache.flex.html.beads.layouts
 					}
 				}
 				else
-					child.x = w - right - mr - child.width;
+                {
+                    if (ilc)
+                        ilc.setX(w - right - mr - child.width);
+                    else
+    					child.x = w - right - mr - child.width;
+                }
 			}
 			if (ilc)
 			{


Mime
View raw message