flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [41/50] git commit: [flex-asjs] [refs/heads/develop] - handle padding
Date Thu, 25 Sep 2014 16:04:23 GMT
handle padding


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

Branch: refs/heads/develop
Commit: 4f9e27ccf3882edb8abfb752f207ef5d8a5071c5
Parents: 434ab8c
Author: Alex Harui <aharui@apache.org>
Authored: Tue Sep 23 14:36:20 2014 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Tue Sep 23 15:01:33 2014 -0700

----------------------------------------------------------------------
 .../FlexibleFirstChildHorizontalLayout.as       | 65 +++++++++++++++++++-
 1 file changed, 62 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4f9e27cc/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/beads/layouts/FlexibleFirstChildHorizontalLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/beads/layouts/FlexibleFirstChildHorizontalLayout.as
b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/beads/layouts/FlexibleFirstChildHorizontalLayout.as
index c331d5b..6003f43 100644
--- a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/beads/layouts/FlexibleFirstChildHorizontalLayout.as
+++ b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/beads/layouts/FlexibleFirstChildHorizontalLayout.as
@@ -88,7 +88,11 @@ package org.apache.flex.html.beads.layouts
 			var maxHeight:Number = 0;
 			var verticalMargins:Array = [];
 			
-			for (var i:int = n - 1; i >= 0; i--)
+            var xx:Number = layoutParent.resizableView.width;
+            var padding:Object = determinePadding();
+            xx -= padding.paddingLeft + padding.paddingRight;
+            
+            for (var i:int = n - 1; i >= 0; i--)
 			{
 				var child:IUIBase = contentView.getElementAt(i) as IUIBase;
 				margin = ValuesManager.valuesImpl.getValue(child, "margin");
@@ -149,7 +153,6 @@ package org.apache.flex.html.beads.layouts
 				}
 				child.y = mt;
 				maxHeight = Math.max(maxHeight, ml + child.height + mr);
-				var xx:Number = layoutParent.resizableView.width;
 				if (i == 0)
                 {
                     child.x = ml;
@@ -173,6 +176,62 @@ package org.apache.flex.html.beads.layouts
 				else
 					child.y = obj.marginTop;
 			}
+            layoutParent.resizableView.height = maxHeight;
 		}
-	}
+
+        // 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
+        {
+            var paddingLeft:Object;
+            var paddingTop:Object;
+            var paddingRight:Object;
+            var padding:Object = ValuesManager.valuesImpl.getValue(_strand, "padding");
+            if (typeof(padding) == "Array")
+            {
+                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];
+                }
+            }
+            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");
+            }
+            else
+            {
+                paddingLeft = paddingTop = paddingRight = padding;
+            }
+            var pl:Number = Number(paddingLeft);
+            var pt:Number = Number(paddingTop);
+            var pr:Number = Number(paddingRight);
+            
+            return {paddingLeft:pl, paddingTop:pt, paddingRight:pr};
+        }
+
+    }
+        
 }


Mime
View raw message