flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [08/13] git commit: [flex-asjs] [refs/heads/release0.8.0] - try to improve Flex-box layout in SWF. Support align-items and flex-basis and fully size on the cross-axis
Date Tue, 23 May 2017 07:16:16 GMT
try to improve Flex-box layout in SWF.  Support align-items and flex-basis and fully size on
the cross-axis


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

Branch: refs/heads/release0.8.0
Commit: 646d01d3b36ba3a95a411175cc935807753d265d
Parents: 198ab8a
Author: Alex Harui <aharui@apache.org>
Authored: Sun May 21 23:33:24 2017 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Tue May 23 00:15:56 2017 -0700

----------------------------------------------------------------------
 .../FlexibleFirstChildHorizontalLayout.as       |  5 +-
 .../html/beads/layouts/HorizontalFlexLayout.as  |  2 +
 .../layouts/OneFlexibleChildHorizontalLayout.as | 53 +++++++++++++------
 .../layouts/OneFlexibleChildVerticalLayout.as   | 54 ++++++++++++++------
 .../html/beads/layouts/VerticalFlexLayout.as    |  2 +
 5 files changed, 85 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/646d01d3/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/FlexibleFirstChildHorizontalLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/FlexibleFirstChildHorizontalLayout.as
b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/FlexibleFirstChildHorizontalLayout.as
index c1e6d27..30398f1 100644
--- a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/FlexibleFirstChildHorizontalLayout.as
+++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/FlexibleFirstChildHorizontalLayout.as
@@ -209,7 +209,8 @@ package org.apache.flex.html.beads.layouts
 			// set the display on the contentView
 			contentView.element.style["display"] = "flex";
 			contentView.element.style["flex-flow"] = "row";
-			contentView.element.style["align-items"] = "center";
+			if (!contentView.element.style["align-items"])
+				contentView.element.style["align-items"] = "center";
 
 			var n:int = contentView.numElements;
 			if (n == 0) return false;
@@ -218,6 +219,8 @@ package org.apache.flex.html.beads.layouts
 				var child:UIBase = contentView.getElementAt(i) as UIBase;
 				child.element.style["flex-grow"] = (i == 0) ? "1" : "0";
 				child.element.style["flex-shrink"] = "0";
+				if (!isNaN(child.percentWidth))
+				    child.element.style["flex-basis"] = child.percentWidth.toString() + "%";
 			}
 
 			return true;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/646d01d3/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/HorizontalFlexLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/HorizontalFlexLayout.as
b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/HorizontalFlexLayout.as
index 65404ea..bbdeceb 100644
--- a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/HorizontalFlexLayout.as
+++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/HorizontalFlexLayout.as
@@ -260,6 +260,8 @@ package org.apache.flex.html.beads.layouts
 					
 					if (grow >= 0) child.element.style["flex-grow"] = String(grow);
 					if (shrink >= 0) child.element.style["flex-shrink"] = String(shrink);
+					if (!isNaN(child.percentWidth))
+						child.element.style["flex-basis"] = child.percentWidth.toString() + "%";
 					child.dispatchEvent(new Event("layoutNeeded"));
 				}
 

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/646d01d3/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildHorizontalLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildHorizontalLayout.as
b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildHorizontalLayout.as
index 17fb651..c1afc83 100644
--- a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildHorizontalLayout.as
+++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildHorizontalLayout.as
@@ -65,7 +65,7 @@ package org.apache.flex.html.beads.layouts
 
         private var _flexibleChild:String;
 
-        private var actualChild:ILayoutChild;
+        protected var actualChild:ILayoutChild;
 
         /**
          *  @private
@@ -153,7 +153,8 @@ package org.apache.flex.html.beads.layouts
 			// set the display on the contentView
 			contentView.element.style["display"] = "flex";
 			contentView.element.style["flex-flow"] = "row";
-			contentView.element.style["align-items"] = "center";
+			if (!contentView.element.style["align-items"])
+				contentView.element.style["align-items"] = "center";
 
 			var n:int = contentView.numElements;
 			if (n == 0) return false;
@@ -162,6 +163,8 @@ package org.apache.flex.html.beads.layouts
 				var child:UIBase = contentView.getElementAt(i) as UIBase;
 				child.element.style["flex-grow"] = (child == actualChild) ? "1" : "0";
 				child.element.style["flex-shrink"] = "0";
+				if (!isNaN(child.percentWidth))
+				    child.element.style["flex-basis"] = child.percentWidth.toString() + "%";
 			}
 
 			return true;
@@ -171,7 +174,7 @@ package org.apache.flex.html.beads.layouts
 		override public function layout():Boolean
 		{
 			var contentView:ILayoutView = layoutView;
-			var actualChild:IUIBase = document.hasOwnProperty(flexibleChild) ? document[flexibleChild]
: null;
+			actualChild = document.hasOwnProperty(flexibleChild) ? document[flexibleChild] : null;
 
 			var n:Number = contentView.numElements;
 			if (n == 0) return false;
@@ -225,12 +228,19 @@ package org.apache.flex.html.beads.layouts
 				childYpos = ypos + margins.top; // default y position
 
 				childHeight = child.height;
-				if (ilc != null && !isNaN(ilc.percentHeight)) {
-					childHeight = host.height * ilc.percentHeight/100.0;
+				if (ilc != null)
+				{
+					if (!isNaN(ilc.percentHeight)) {
+						childHeight = host.height * ilc.percentHeight/100.0;
+					}
+					else if (isNaN(ilc.explicitHeight)) {
+						childHeight = host.height;
+					}
 					ilc.setHeight(childHeight);
 				}
-				// the following code middle-aligns the child
-				childYpos = hostHeight/2 - childHeight/2 + ypos;
+                var align:String = ValuesManager.valuesImpl.getValue(host, "alignItems");
+				if (align == "center")
+					childYpos = hostHeight/2 - childHeight/2 + ypos;
 
 				if (ilc) {
 					ilc.setX(xpos);
@@ -264,12 +274,19 @@ package org.apache.flex.html.beads.layouts
 				childYpos = ypos + margins.top; // default y position
 
 				childHeight = child.height;
-				if (ilc != null && !isNaN(ilc.percentHeight)) {
-					childHeight = hostHeight * ilc.percentHeight/100.0;
+				if (ilc != null)
+				{
+					if (!isNaN(ilc.percentHeight)) {
+						childHeight = host.height * ilc.percentHeight/100.0;
+					}
+					else if (isNaN(ilc.explicitHeight)) {
+						childHeight = host.height;
+					}
 					ilc.setHeight(childHeight);
 				}
-				// the following code middle-aligns the child
-				childYpos = hostHeight/2 - childHeight/2 + ypos;
+                align = ValuesManager.valuesImpl.getValue(host, "alignItems");
+				if (align == "center")
+					childYpos = hostHeight/2 - childHeight/2 + ypos;
 
 				if (ilc) {
 					if (!isNaN(ilc.percentWidth)) {
@@ -296,14 +313,20 @@ package org.apache.flex.html.beads.layouts
 				margins = childMargins(actualChild, hostWidth, hostHeight);
 				ilc = actualChild as ILayoutChild;
 				childHeight = actualChild.height;
-				if (ilc != null && !isNaN(ilc.percentHeight)) {
-					childHeight = hostHeight * ilc.percentHeight/100.0;
+				if (ilc != null)
+				{
+					if (!isNaN(ilc.percentHeight)) {
+						childHeight = host.height * ilc.percentHeight/100.0;
+					}
+					else if (isNaN(ilc.explicitHeight)) {
+						childHeight = host.height;
+					}
 					ilc.setHeight(childHeight);
 				}
 				childYpos = ypos + margins.top;
-				if (!hostSizedToContent) {
+                align = ValuesManager.valuesImpl.getValue(host, "alignItems");
+				if (align == "center")
 					childYpos = hostHeight/2 - childHeight/2 + ypos;
-				}
 				actualChild.x = adjustLeft + margins.left;
 				actualChild.y = childYpos;
 				if (ilc) {

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/646d01d3/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildVerticalLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildVerticalLayout.as
b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildVerticalLayout.as
index f80bafe..51dbb72 100644
--- a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildVerticalLayout.as
+++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildVerticalLayout.as
@@ -66,7 +66,7 @@ package org.apache.flex.html.beads.layouts
 
         private var _flexibleChild:String;
 
-        private var actualChild:ILayoutChild;
+        protected var actualChild:ILayoutChild;
 
         /**
          *  @private
@@ -154,7 +154,8 @@ package org.apache.flex.html.beads.layouts
 			// set the display on the contentView
 			contentView.element.style["display"] = "flex";
 			contentView.element.style["flex-flow"] = "column";
-			contentView.element.style["align-items"] = "center";
+			if (!contentView.element.style["align-items"])
+				contentView.element.style["align-items"] = "center";
 
 			var n:int = contentView.numElements;
 			if (n == 0) return false;
@@ -163,6 +164,8 @@ package org.apache.flex.html.beads.layouts
 				var child:UIBase = contentView.getElementAt(i) as UIBase;
 				child.element.style["flex-grow"] = (child == actualChild) ? "1" : "0";
 				child.element.style["flex-shrink"] = "0";
+				if (!isNaN(child.percentHeight))
+				    child.element.style["flex-basis"] = child.percentHeight.toString() + "%";
 			}
 
 			return true;
@@ -172,7 +175,7 @@ package org.apache.flex.html.beads.layouts
 		override public function layout():Boolean
 		{
 			var contentView:ILayoutView = layoutView;
-			var actualChild:IUIBase = document.hasOwnProperty(flexibleChild) ? document[flexibleChild]
: null;
+			actualChild = document.hasOwnProperty(flexibleChild) ? document[flexibleChild] : null;
 
 			var n:Number = contentView.numElements;
 			if (n == 0) return false;
@@ -226,12 +229,19 @@ package org.apache.flex.html.beads.layouts
 				childXpos = xpos + margins.left; // default x position
 
 				childWidth = child.width;
-				if (ilc != null && !isNaN(ilc.percentWidth)) {
-					childWidth = hostWidth * ilc.percentWidth/100.0;
+				if (ilc != null)
+				{
+					if (!isNaN(ilc.percentWidth)) {
+						childWidth = hostWidth * ilc.percentWidth/100.0;
+					}
+					else if (isNaN(ilc.explicitWidth)) {
+						childWidth = hostWidth;
+					}
 					ilc.setWidth(childWidth);
 				}
-				// the following code middle-aligns the child
-				childXpos = hostWidth/2 - childWidth/2 + xpos;
+                var align:String = ValuesManager.valuesImpl.getValue(host, "alignItems");
+				if (align == "center")
+					childXpos = hostWidth/2 - childWidth/2 + xpos;
 
 				if (ilc) {
 					ilc.setX(childXpos);
@@ -265,12 +275,19 @@ package org.apache.flex.html.beads.layouts
 				childXpos = xpos + margins.left; // default x position
 
 				childWidth = child.width;
-				if (ilc != null && !isNaN(ilc.percentWidth)) {
-					childWidth = hostWidth * ilc.percentWidth/100.0;
+				if (ilc != null)
+				{
+					if (!isNaN(ilc.percentWidth)) {
+						childWidth = hostWidth * ilc.percentWidth/100.0;
+					}
+					else if (isNaN(ilc.explicitWidth)) {
+						childWidth = hostWidth;
+					}
 					ilc.setWidth(childWidth);
 				}
-				// the following code middle-aligns the child
-				childXpos = hostWidth/2 - childWidth/2 + xpos;
+                align = ValuesManager.valuesImpl.getValue(host, "alignItems");
+				if (align == "center")
+					childXpos = hostWidth/2 - childWidth/2 + xpos;
 
 				if (ilc) {
 					if (!isNaN(ilc.percentHeight)) {
@@ -297,14 +314,21 @@ package org.apache.flex.html.beads.layouts
 				margins = childMargins(actualChild, hostWidth, hostHeight);
 				ilc = actualChild as ILayoutChild;
 				childWidth = actualChild.width;
-				if (ilc != null && !isNaN(ilc.percentWidth)) {
-					childWidth = hostWidth * ilc.percentWidth/100.0;
+				if (ilc != null)
+				{
+					if (!isNaN(ilc.percentWidth)) {
+						childWidth = hostWidth * ilc.percentWidth/100.0;
+					}
+					else if (isNaN(ilc.explicitWidth)) {
+						childWidth = hostWidth;
+					}
 					ilc.setWidth(childWidth);
 				}
 				childXpos = xpos + margins.left;
-				if (!hostSizedToContent) {
+                align = ValuesManager.valuesImpl.getValue(host, "alignItems");
+				if (align == "center")
 					childXpos = hostWidth/2 - childWidth/2 + xpos;
-				}
+					
 				actualChild.x = childXpos
 				actualChild.y = adjustTop + margins.top;
 				if (ilc) {

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/646d01d3/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/VerticalFlexLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/VerticalFlexLayout.as
b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/VerticalFlexLayout.as
index 6dd6a3c..0b845b5 100644
--- a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/VerticalFlexLayout.as
+++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/VerticalFlexLayout.as
@@ -254,6 +254,8 @@ package org.apache.flex.html.beads.layouts
 
 					if (grow >= 0) child.element.style["flex-grow"] = String(grow);
 					if (shrink >= 0) child.element.style["flex-shrink"] = String(shrink);
+					if (!isNaN(child.percentHeight))
+						child.element.style["flex-basis"] = child.percentHeight.toString() + "%";
 					child.dispatchEvent(new Event("layoutNeeded"));
 				}
 


Mime
View raw message