Repository: flex-asjs
Updated Branches:
  refs/heads/feature/chart-work 01c55f2e0 -> 087b870e9


Updates to some layouts.


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

Branch: refs/heads/feature/chart-work
Commit: 087b870e97f411fd10269c5ec139d458d38be5be
Parents: 01c55f2
Author: Peter Ent <p...@apache.org>
Authored: Mon Apr 3 15:56:31 2017 -0400
Committer: Peter Ent <p...@apache.org>
Committed: Mon Apr 3 15:56:31 2017 -0400

----------------------------------------------------------------------
 .../flex/html/beads/layouts/HorizontalLayout.as | 24 ++++++----
 .../layouts/OneFlexibleChildHorizontalLayout.as | 39 +++++++++++-----
 .../layouts/OneFlexibleChildVerticalLayout.as   | 49 +++++++++++++-------
 .../flex/html/beads/layouts/VerticalLayout.as   | 24 ++++++----
 4 files changed, 89 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/087b870e/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/HorizontalLayout.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/HorizontalLayout.as
 
b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/HorizontalLayout.as
index b58497a..148866b 100644
--- 
a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/HorizontalLayout.as
+++ 
b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/HorizontalLayout.as
@@ -107,9 +107,10 @@ package org.apache.flex.html.beads.layouts
 
                                var maxWidth:Number = 0;
                                var maxHeight:Number = 0;
-                               var hostSizedToContent:Boolean = 
host.isHeightSizedToContent();
-                               var hostWidth:Number = contentView.width;
-                               var hostHeight:Number = hostSizedToContent ? 0 
: contentView.height;
+                               var hostWidthSizedToContent:Boolean = 
host.isWidthSizedToContent();
+                               var hostHeightSizedToContent:Boolean = 
host.isHeightSizedToContent();
+                               var hostWidth:Number = hostWidthSizedToContent 
? 0 : contentView.width;
+                               var hostHeight:Number = 
hostHeightSizedToContent ? 0 : contentView.height;
 
                                var ilc:ILayoutChild;
                                var data:Object;
@@ -117,6 +118,11 @@ package org.apache.flex.html.beads.layouts
 
                                var paddingMetrics:Rectangle = 
CSSContainerUtils.getPaddingMetrics(host);
                                var borderMetrics:Rectangle = 
CSSContainerUtils.getBorderMetrics(host);
+                               
+                               // adjust the host's usable size by the 
metrics. If hostSizedToContent, then the
+                               // resulting adjusted value may be less than 
zero.
+                               hostWidth -= paddingMetrics.left + 
paddingMetrics.right + borderMetrics.left + borderMetrics.right;
+                               hostHeight -= paddingMetrics.top + 
paddingMetrics.bottom + borderMetrics.top + borderMetrics.bottom;
 
                                var xpos:Number = borderMetrics.left + 
paddingMetrics.left;
                                var ypos:Number = borderMetrics.top + 
paddingMetrics.left;
@@ -135,11 +141,11 @@ package org.apache.flex.html.beads.layouts
 
                                        var childYpos:Number = ypos + 
margins.top; // default y position
 
-                                       if (!hostSizedToContent) {
+                                       if (!hostHeightSizedToContent) {
                                                var childHeight:Number = 
child.height;
                                                if (ilc != null && 
!isNaN(ilc.percentHeight)) {
-                                                       childHeight = 
(hostHeight-borderMetrics.top-borderMetrics.bottom-paddingMetrics.top-paddingMetrics.bottom)
 * ilc.percentHeight/100.0;
-                                                       
ilc.setHeight(childHeight - margins.top - margins.bottom);
+                                                       childHeight = 
hostHeight * ilc.percentHeight/100.0;
+                                                       
ilc.setHeight(childHeight);
                                                }
                                                // the following code 
middle-aligns the child, but since HTML does not
                                                // do this normally, this code 
is commented. (Use HorizontalFlexLayout for
@@ -151,9 +157,9 @@ package org.apache.flex.html.beads.layouts
                                                ilc.setX(xpos);
                                                ilc.setY(childYpos);
 
-                                               if (!isNaN(ilc.percentWidth)) {
-                                                       var newWidth:Number = 
(contentView.width-borderMetrics.left-borderMetrics.right-paddingMetrics.left-paddingMetrics.right)
 * ilc.percentWidth / 100;
-                                                       ilc.setWidth(newWidth - 
margins.right - margins.left);
+                                               if (!hostWidthSizedToContent && 
!isNaN(ilc.percentWidth)) {
+                                                       var newWidth:Number = 
hostWidth * ilc.percentWidth / 100;
+                                                       ilc.setWidth(newWidth);
                                                }
 
                                        } else {

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/087b870e/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildHorizontalLayout.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildHorizontalLayout.as
 
b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildHorizontalLayout.as
index 5707428..c90f223 100644
--- 
a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildHorizontalLayout.as
+++ 
b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildHorizontalLayout.as
@@ -47,7 +47,7 @@ package org.apache.flex.html.beads.layouts
      *  @playerversion AIR 2.6
      *  @productversion FlexJS 0.0
      */
-       public class OneFlexibleChildHorizontalLayout extends LayoutBase 
implements IOneFlexibleChildLayout, IDocument
+       public class OneFlexibleChildHorizontalLayout extends HorizontalLayout 
implements IOneFlexibleChildLayout, IDocument
        {
         /**
          *  Constructor.
@@ -175,6 +175,12 @@ package org.apache.flex.html.beads.layouts
 
                        var n:Number = contentView.numElements;
                        if (n == 0) return false;
+                       
+                       // if the layoutView's width cannot be determined then 
this layout
+                       // will not work, so default to HorizontalLayout
+                       if (host.isWidthSizedToContent()) {
+                               return super.layout();
+                       }
 
                        var maxWidth:Number = 0;
                        var maxHeight:Number = 0;
@@ -189,15 +195,20 @@ package org.apache.flex.html.beads.layouts
 
                        var paddingMetrics:Rectangle = 
CSSContainerUtils.getPaddingMetrics(host);
                        var borderMetrics:Rectangle = 
CSSContainerUtils.getBorderMetrics(host);
+                       
+                       // adjust the host's usable size by the metrics. If 
hostSizedToContent, then the
+                       // resulting adjusted value may be less than zero.
+                       hostWidth -= paddingMetrics.left + paddingMetrics.right 
+ borderMetrics.left + borderMetrics.right;
+                       hostHeight -= paddingMetrics.top + 
paddingMetrics.bottom + borderMetrics.top + borderMetrics.bottom;
 
-                       var xpos:Number = borderMetrics.left - 
paddingMetrics.left;
+                       var xpos:Number = borderMetrics.left + 
paddingMetrics.left;
                        var ypos:Number = borderMetrics.top + 
paddingMetrics.left;
                        var child:IUIBase;
                        var childHeight:Number;
                        var i:int;
                        var childYpos:Number;
                        var adjustLeft:Number = 0;
-                       var adjustRight:Number = hostWidth - 
borderMetrics.right - paddingMetrics.right;
+                       var adjustRight:Number = hostWidth + borderMetrics.left 
+ paddingMetrics.left;
 
                        // first work from left to right
                        for(i=0; i < n; i++)
@@ -216,11 +227,11 @@ package org.apache.flex.html.beads.layouts
                                if (!hostSizedToContent) {
                                        childHeight = child.height;
                                        if (ilc != null && 
!isNaN(ilc.percentHeight)) {
-                                               childHeight = 
(hostHeight-borderMetrics.top-borderMetrics.bottom-paddingMetrics.top-paddingMetrics.bottom)
 * ilc.percentHeight/100.0;
+                                               childHeight = host.height * 
ilc.percentHeight/100.0;
                                                ilc.setHeight(childHeight);
                                        }
                                        // the following code middle-aligns the 
child
-                                       childYpos = hostHeight/2 - (childHeight 
+ margins.top + margins.bottom)/2;
+                                       childYpos = hostHeight/2 - 
childHeight/2 + ypos;
                                }
 
                                if (ilc) {
@@ -228,7 +239,7 @@ package org.apache.flex.html.beads.layouts
                                        ilc.setY(childYpos);
 
                                        if (!isNaN(ilc.percentWidth)) {
-                                               
ilc.setWidth((contentView.width-borderMetrics.left-borderMetrics.right-paddingMetrics.left-paddingMetrics.right)
 * ilc.percentWidth / 100);
+                                               ilc.setWidth(hostWidth * 
ilc.percentWidth / 100);
                                        }
 
                                } else {
@@ -241,7 +252,7 @@ package org.apache.flex.html.beads.layouts
                        }
 
                        // then work from right to left
-                       xpos = hostWidth - borderMetrics.right - 
paddingMetrics.right;
+                       xpos = hostWidth + borderMetrics.left + 
paddingMetrics.left;
 
                        for(i=(n-1); actualChild != null && i >= 0; i--)
                        {
@@ -257,16 +268,16 @@ package org.apache.flex.html.beads.layouts
                                if (!hostSizedToContent) {
                                        childHeight = child.height;
                                        if (ilc != null && 
!isNaN(ilc.percentHeight)) {
-                                               childHeight = 
(hostHeight-borderMetrics.top-borderMetrics.bottom-paddingMetrics.top-paddingMetrics.bottom)
 * ilc.percentHeight/100.0;
+                                               childHeight = hostHeight * 
ilc.percentHeight/100.0;
                                                ilc.setHeight(childHeight);
                                        }
                                        // the following code middle-aligns the 
child
-                                       childYpos = hostHeight/2 - (childHeight 
+ margins.top + margins.bottom)/2;
+                                       childYpos = hostHeight/2 - 
childHeight/2 + ypos;
                                }
 
                                if (ilc) {
                                        if (!isNaN(ilc.percentWidth)) {
-                                               
ilc.setWidth((contentView.width-borderMetrics.left-borderMetrics.right-paddingMetrics.left-paddingMetrics.right)
 * ilc.percentWidth / 100);
+                                               ilc.setWidth(hostWidth * 
ilc.percentWidth / 100);
                                        }
                                }
 
@@ -291,12 +302,16 @@ package org.apache.flex.html.beads.layouts
                                if (!hostSizedToContent) {
                                        childHeight = actualChild.height;
                                        if (ilc != null && 
!isNaN(ilc.percentHeight)) {
-                                               childHeight = 
(hostHeight-borderMetrics.top-borderMetrics.bottom-paddingMetrics.top-paddingMetrics.bottom)
 * ilc.percentHeight/100.0;
+                                               childHeight = hostHeight * 
ilc.percentHeight/100.0;
                                                ilc.setHeight(childHeight);
                                        }
                                }
-                               actualChild.y = hostHeight/2 - (childHeight + 
margins.top + margins.bottom)/2;
+                               childYpos = ypos + margins.top;
+                               if (!hostSizedToContent) {
+                                       childYpos = hostHeight/2 - 
childHeight/2 + ypos;
+                               }
                                actualChild.x = adjustLeft + margins.left;
+                               actualChild.y = childYpos;
                                if (ilc) {
                                        
ilc.setWidth((adjustRight-margins.right) - (adjustLeft+margins.left));
                                } else {

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/087b870e/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildVerticalLayout.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildVerticalLayout.as
 
b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildVerticalLayout.as
index fe4e920..9242d91 100644
--- 
a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildVerticalLayout.as
+++ 
b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildVerticalLayout.as
@@ -48,7 +48,7 @@ package org.apache.flex.html.beads.layouts
      *  @playerversion AIR 2.6
      *  @productversion FlexJS 0.0
      */
-       public class OneFlexibleChildVerticalLayout extends LayoutBase 
implements IOneFlexibleChildLayout, IDocument
+       public class OneFlexibleChildVerticalLayout extends VerticalLayout 
implements IOneFlexibleChildLayout, IDocument
        {
         /**
          *  Constructor.
@@ -176,12 +176,18 @@ package org.apache.flex.html.beads.layouts
 
                        var n:Number = contentView.numElements;
                        if (n == 0) return false;
+                       
+                       // if the layoutView has no determined height, this 
layout cannot run
+                       // so fall back to VerticalLayout
+                       if (host.isHeightSizedToContent()) {
+                               return super.layout();
+                       }
 
                        var maxWidth:Number = 0;
                        var maxHeight:Number = 0;
-                       var hostSizedToContent:Boolean = 
host.isHeightSizedToContent();
-                       var hostWidth:Number = contentView.width;
-                       var hostHeight:Number = hostSizedToContent ? 0 : 
contentView.height;
+                       var hostSizedToContent:Boolean = 
host.isWidthSizedToContent();
+                       var hostWidth:Number = hostSizedToContent ? 0 : 
contentView.width;
+                       var hostHeight:Number = contentView.height;
 
                        var ilc:ILayoutChild;
                        var data:Object;
@@ -190,15 +196,20 @@ package org.apache.flex.html.beads.layouts
 
                        var paddingMetrics:Rectangle = 
CSSContainerUtils.getPaddingMetrics(host);
                        var borderMetrics:Rectangle = 
CSSContainerUtils.getBorderMetrics(host);
+                       
+                       // adjust the host's usable size by the metrics. If 
hostSizedToContent, then the
+                       // resulting adjusted value may be less than zero.
+                       hostWidth -= paddingMetrics.left + paddingMetrics.right 
+ borderMetrics.left + borderMetrics.right;
+                       hostHeight -= paddingMetrics.top + 
paddingMetrics.bottom + borderMetrics.top + borderMetrics.bottom;
 
-                       var xpos:Number = borderMetrics.left - 
paddingMetrics.left;
+                       var xpos:Number = borderMetrics.left + 
paddingMetrics.left;
                        var ypos:Number = borderMetrics.top + 
paddingMetrics.left;
                        var child:IUIBase;
                        var childWidth:Number;
                        var i:int;
                        var childXpos:Number;
                        var adjustTop:Number = 0;
-                       var adjustBottom:Number = hostHeight - 
borderMetrics.top - paddingMetrics.bottom;
+                       var adjustBottom:Number = hostHeight + 
borderMetrics.top + paddingMetrics.top;
 
                        // first work from top to bottom
                        for(i=0; i < n; i++)
@@ -212,16 +223,16 @@ package org.apache.flex.html.beads.layouts
 
                                ypos += margins.top;
 
-                               childXpos = xpos + margins.left; // default y 
position
+                               childXpos = xpos + margins.left; // default x 
position
 
                                if (!hostSizedToContent) {
                                        childWidth = child.width;
                                        if (ilc != null && 
!isNaN(ilc.percentWidth)) {
-                                               childWidth = 
(hostWidth-borderMetrics.left-borderMetrics.right-paddingMetrics.left-paddingMetrics.right)
 * ilc.percentWidth/100.0;
+                                               childWidth = hostWidth * 
ilc.percentWidth/100.0;
                                                ilc.setWidth(childWidth);
                                        }
                                        // the following code middle-aligns the 
child
-                                       childXpos = hostWidth/2 - (childWidth + 
margins.left + margins.right)/2;
+                                       childXpos = hostWidth/2 - childWidth/2 
+ xpos;
                                }
 
                                if (ilc) {
@@ -229,7 +240,7 @@ package org.apache.flex.html.beads.layouts
                                        ilc.setY(ypos);
 
                                        if (!isNaN(ilc.percentHeight)) {
-                                               
ilc.setHeight((contentView.height-borderMetrics.top-borderMetrics.bottom-paddingMetrics.top-paddingMetrics.bottom)
 * ilc.percentHeight / 100);
+                                               ilc.setHeight(hostHeight * 
ilc.percentHeight / 100);
                                        }
 
                                } else {
@@ -242,7 +253,7 @@ package org.apache.flex.html.beads.layouts
                        }
 
                        // then work from bottom to top
-                       ypos = hostHeight - borderMetrics.bottom - 
paddingMetrics.bottom;
+                       ypos = hostHeight + borderMetrics.top + 
paddingMetrics.top;
 
                        for(i=(n-1); actualChild != null && i >= 0; i--)
                        {
@@ -253,21 +264,21 @@ package org.apache.flex.html.beads.layouts
                                margins = childMargins(child, hostWidth, 
hostHeight);
                                ilc = child as ILayoutChild;
 
-                               childXpos = xpos + margins.left; // default y 
position
+                               childXpos = xpos + margins.left; // default x 
position
 
                                if (!hostSizedToContent) {
                                        childWidth = child.width;
                                        if (ilc != null && 
!isNaN(ilc.percentWidth)) {
-                                               childWidth = 
(hostWidth-borderMetrics.left-borderMetrics.right-paddingMetrics.left-paddingMetrics.right)
 * ilc.percentWidth/100.0;
+                                               childWidth = hostWidth * 
ilc.percentWidth/100.0;
                                                ilc.setWidth(childWidth);
                                        }
                                        // the following code middle-aligns the 
child
-                                       childXpos = hostWidth/2 - (childWidth + 
margins.left + margins.right)/2;
+                                       childXpos = hostWidth/2 - childWidth/2 
+ xpos;
                                }
 
                                if (ilc) {
                                        if (!isNaN(ilc.percentHeight)) {
-                                               
ilc.setHeight((contentView.height-borderMetrics.top-borderMetrics.bottom-paddingMetrics.top-paddingMetrics.bottom)
 * ilc.percentHeight / 100);
+                                               ilc.setHeight(hostHeight * 
ilc.percentHeight / 100);
                                        }
                                }
 
@@ -292,11 +303,15 @@ package org.apache.flex.html.beads.layouts
                                if (!hostSizedToContent) {
                                        childWidth = actualChild.width;
                                        if (ilc != null && 
!isNaN(ilc.percentWidth)) {
-                                               childWidth = 
(hostWidth-borderMetrics.left-borderMetrics.right-paddingMetrics.left-paddingMetrics.right)
 * ilc.percentWidth/100.0;
+                                               childWidth = hostWidth * 
ilc.percentWidth/100.0;
                                                ilc.setWidth(childWidth);
                                        }
                                }
-                               actualChild.x = hostWidth/2 - (childWidth + 
margins.left + margins.right)/2;
+                               childXpos = xpos + margins.left;
+                               if (!hostSizedToContent) {
+                                       childXpos = hostWidth/2 - childWidth/2 
+ xpos;
+                               }
+                               actualChild.x = childXpos
                                actualChild.y = adjustTop + margins.top;
                                if (ilc) {
                                        
ilc.setHeight((adjustBottom-margins.bottom) - (adjustTop+margins.top));

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/087b870e/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/VerticalLayout.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/VerticalLayout.as
 
b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/VerticalLayout.as
index c4279a4..a8b9774 100644
--- 
a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/VerticalLayout.as
+++ 
b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/VerticalLayout.as
@@ -86,9 +86,10 @@ package org.apache.flex.html.beads.layouts
 
                                var maxWidth:Number = 0;
                                var maxHeight:Number = 0;
-                               var hostSizedToContent:Boolean = 
host.isWidthSizedToContent();
-                               var hostWidth:Number = hostSizedToContent ? 0 : 
contentView.width;
-                               var hostHeight:Number = contentView.height;
+                               var hostWidthSizedToContent:Boolean = 
host.isWidthSizedToContent();
+                               var hostHeightSizedToContent:Boolean = 
host.isHeightSizedToContent();
+                               var hostWidth:Number = hostWidthSizedToContent 
? 0 : contentView.width;
+                               var hostHeight:Number = 
hostHeightSizedToContent ? 0 : contentView.height;
 
                                var ilc:ILayoutChild;
                                var data:Object;
@@ -96,6 +97,11 @@ package org.apache.flex.html.beads.layouts
 
                                var paddingMetrics:Rectangle = 
CSSContainerUtils.getPaddingMetrics(host);
                                var borderMetrics:Rectangle = 
CSSContainerUtils.getBorderMetrics(host);
+                               
+                               // adjust the host's usable size by the 
metrics. If hostSizedToContent, then the
+                               // resulting adjusted value may be less than 
zero.
+                               hostWidth -= paddingMetrics.left + 
paddingMetrics.right + borderMetrics.left + borderMetrics.right;
+                               hostHeight -= paddingMetrics.top + 
paddingMetrics.bottom + borderMetrics.top + borderMetrics.bottom;
 
                                var xpos:Number = borderMetrics.left + 
paddingMetrics.left;
                                var ypos:Number = borderMetrics.top + 
paddingMetrics.left;
@@ -114,11 +120,11 @@ package org.apache.flex.html.beads.layouts
 
                                        var childXpos:Number = xpos + 
margins.left; // default x position
 
-                                       if (!hostSizedToContent) {
+                                       if (!hostWidthSizedToContent) {
                                                var childWidth:Number = 
child.width;
                                                if (ilc != null && 
!isNaN(ilc.percentWidth)) {
-                                                       childWidth = 
(hostWidth-borderMetrics.left-borderMetrics.right-paddingMetrics.left-paddingMetrics.right)
 * ilc.percentWidth/100.0;
-                                                       ilc.setWidth(childWidth 
- margins.right - margins.left);
+                                                       childWidth = hostWidth 
* ilc.percentWidth/100.0;
+                                                       
ilc.setWidth(childWidth);
                                                }
                                                // the following code 
center-aligns the child, but since HTML does not
                                                // do this normally, this code 
is commented. (Use VerticalFlexLayout for
@@ -130,9 +136,9 @@ package org.apache.flex.html.beads.layouts
                                                ilc.setX(childXpos);
                                                ilc.setY(ypos);
 
-                                               if (!isNaN(ilc.percentHeight)) {
-                                                       var newHeight:Number = 
(contentView.height-borderMetrics.top-borderMetrics.bottom-paddingMetrics.top-paddingMetrics.bottom)
 * ilc.percentHeight / 100;
-                                                       ilc.setHeight(newHeight 
- margins.top - margins.bottom);
+                                               if (!hostHeightSizedToContent 
&& !isNaN(ilc.percentHeight)) {
+                                                       var newHeight:Number = 
hostHeight * ilc.percentHeight / 100;
+                                                       
ilc.setHeight(newHeight);
                                                }
 
                                        } else {

Reply via email to