royale-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From carlosrov...@apache.org
Subject [royale-asjs] branch develop updated: solve a bug in layouts where class names added by user override class names set up by layouts
Date Fri, 08 Jun 2018 11:05:45 GMT
This is an automated email from the ASF dual-hosted git repository.

carlosrovira pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git


The following commit(s) were added to refs/heads/develop by this push:
     new 7ba6ff2  solve a bug in layouts where class names added by user override class names
set up by layouts
7ba6ff2 is described below

commit 7ba6ff2b9f8dc6934b519d139a3084914afae8a8
Author: Carlos Rovira <carlosrovira@apache.org>
AuthorDate: Fri Jun 8 13:05:33 2018 +0200

    solve a bug in layouts where class names added by user override class names set up by
layouts
---
 .../main/royale/org/apache/royale/jewel/Card.as    |   9 --
 .../main/royale/org/apache/royale/jewel/Group.as   |  11 ++
 .../royale/jewel/beads/layouts/BasicLayout.as      |   6 +-
 .../royale/jewel/beads/layouts/HorizontalLayout.as |   6 +-
 .../royale/jewel/beads/layouts/TileLayout.as       | 155 ++++++++++++++++-----
 .../royale/jewel/beads/layouts/VerticalLayout.as   |   6 +-
 6 files changed, 143 insertions(+), 50 deletions(-)

diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/Card.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/Card.as
index ff0808d..781ecf6 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/Card.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/Card.as
@@ -45,12 +45,9 @@ package org.apache.royale.jewel
 		{
 			super();
 
-            classSelectorList = new ClassSelectorList(this);
             typeNames = "jewel card";
 		}
 
-        protected var classSelectorList:ClassSelectorList;
-
 		protected var _shadow:Number = 0;
         /**
 		 *  A boolean flag to activate "shadow-Xdp" effect selector.
@@ -86,12 +83,6 @@ package org.apache.royale.jewel
             }
         }
 
-        COMPILE::JS
-		override protected function setClassName(value:String):void
-        {
-            classSelectorList.addNames(value);
-        }
-
 		override public function addedToParent():void
 		{
 			super.addedToParent();
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/Group.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/Group.as
index 0cfa316..c488cda 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/Group.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/Group.as
@@ -19,6 +19,8 @@
 package org.apache.royale.jewel
 {
 	import org.apache.royale.html.Group;
+    import org.apache.royale.utils.ClassSelectorList;
+
     /**
      *  The Group class provides a light-weight container for visual elements. By default
 	 *  the Group does not have a layout, allowing its children to be sized and positioned
@@ -45,7 +47,16 @@ package org.apache.royale.jewel
 		public function Group()
 		{
 			super();
+            classSelectorList = new ClassSelectorList(this);
             typeNames = "";
 		}
+
+        protected var classSelectorList:ClassSelectorList;
+
+        COMPILE::JS
+        override protected function setClassName(value:String):void
+        {
+            classSelectorList.addNames(value);
+        }
 	}
 }
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/BasicLayout.as
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/BasicLayout.as
index 4633cf6..0633a06 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/BasicLayout.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/BasicLayout.as
@@ -24,12 +24,11 @@ package org.apache.royale.jewel.beads.layouts
 	import org.apache.royale.core.ILayoutHost;
 	import org.apache.royale.core.ILayoutView;
 	import org.apache.royale.core.IUIBase;
-    import org.apache.royale.core.UIBase;
 	import org.apache.royale.core.IParentIUIBase;
 
 	COMPILE::JS {
-		import org.apache.royale.utils.cssclasslist.addStyles;
 		import org.apache.royale.core.WrappedHTMLElement;
+    	import org.apache.royale.core.UIBase;
     }
 
     /**
@@ -181,7 +180,8 @@ package org.apache.royale.jewel.beads.layouts
             COMPILE::JS
             {
                 var contentView:IParentIUIBase = layoutView as IParentIUIBase;
-				addStyles (contentView, "layout absolute");
+				(contentView as UIBase).className += " layout absolute";
+				
 
 				// without this a state change in a View with BasicLayout will have a wrong behaviour
 				var children:Array = contentView.internalChildren();
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/HorizontalLayout.as
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/HorizontalLayout.as
index 0afc6e8..9e4a656 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/HorizontalLayout.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/HorizontalLayout.as
@@ -32,8 +32,8 @@ package org.apache.royale.jewel.beads.layouts
 	import org.apache.royale.core.IBorderPaddingMarginValuesImpl;
 
 	COMPILE::JS {
-		import org.apache.royale.utils.cssclasslist.addStyles;
         import org.apache.royale.core.WrappedHTMLElement;
+		import org.apache.royale.core.UIBase;
     }
 
     /**
@@ -287,7 +287,7 @@ package org.apache.royale.jewel.beads.layouts
 						// the following code middle-aligns the child, but since HTML does not
 						// do this normally, this code is commented. (Use HorizontalFlexLayout for
 						// vertically centered elements in a horizontal row).
-//						childYpos = hostHeight/2 - (childHeight + mt + mb)/2;
+						//						childYpos = hostHeight/2 - (childHeight + mt + mb)/2;
 					}
 
 					if (ilc) {
@@ -313,7 +313,7 @@ package org.apache.royale.jewel.beads.layouts
             COMPILE::JS
             {
                 var contentView:IParentIUIBase = layoutView as IParentIUIBase;
-				addStyles (contentView, "layout horizontal");
+				(contentView as UIBase).className += " layout horizontal";
 
 				var children:Array = contentView.internalChildren();
 				var i:int;
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/TileLayout.as
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/TileLayout.as
index c7df7ff..9b2f6e9 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/TileLayout.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/TileLayout.as
@@ -24,13 +24,12 @@ package org.apache.royale.jewel.beads.layouts
 	import org.apache.royale.core.IParentIUIBase;
 	import org.apache.royale.core.IUIBase;
     import org.apache.royale.core.layout.EdgeData;
-	import org.apache.royale.core.UIBase;
     import org.apache.royale.core.ValuesManager;
 	import org.apache.royale.core.layout.ILayoutStyleProperties;
+	import org.apache.royale.core.UIBase;
 
 	COMPILE::JS
 	{
-		import org.apache.royale.utils.cssclasslist.addStyles;
 		import org.apache.royale.core.WrappedHTMLElement;
 	}
 
@@ -122,6 +121,110 @@ package org.apache.royale.jewel.beads.layouts
 		/**
 		 *  @private
 		 */
+		private var _paddingTop:Number = 0;
+
+		/**
+		 *  The top padding value.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.3
+		 */
+		public function get paddingTop():Number
+		{
+			return _paddingTop;
+		}
+
+		/**
+		 *  @private
+		 */
+		public function set paddingTop(value:Number):void
+		{
+			_paddingTop = value;
+		}
+
+		/**
+		 *  @private
+		 */
+		private var _paddingRight:Number = 0;
+
+		/**
+		 *  The right padding value.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.3
+		 */
+		public function get paddingRight():Number
+		{
+			return _paddingRight;
+		}
+
+		/**
+		 *  @private
+		 */
+		public function set paddingRight(value:Number):void
+		{
+			_paddingRight = value;
+		}
+
+		/**
+		 *  @private
+		 */
+		private var _paddingBottom:Number = 0;
+
+		/**
+		 *  The top padding value.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.3
+		 */
+		public function get paddingBottom():Number
+		{
+			return _paddingBottom;
+		}
+
+		/**
+		 *  @private
+		 */
+		public function set paddingBottom(value:Number):void
+		{
+			_paddingBottom = value;
+		}
+
+		/**
+		 *  @private
+		 */
+		private var _paddingLeft:Number = 0;
+
+		/**
+		 *  The left padding value.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.3
+		 */
+		public function get paddingLeft():Number
+		{
+			return _paddingLeft;
+		}
+
+		/**
+		 *  @private
+		 */
+		public function set paddingLeft(value:Number):void
+		{
+			_paddingLeft = value;
+		}
+
+		/**
+		 *  @private
+		 */
 		private var verticalGapInitialized:Boolean;
 		public static const VERTICAL_GAP_STYLE:String = "verticalGap"
 		private var _verticalGap:Number = 0;
@@ -286,13 +389,8 @@ package org.apache.royale.jewel.beads.layouts
 			}
 			COMPILE::JS
 			{
-				var _paddingTop:Number = 10;
-				var _paddingRight:Number = 10;
-				var _paddingBottom:Number = 10;
-				var _paddingLeft:Number = 10;
-
 				var contentView:IParentIUIBase = layoutView as IParentIUIBase;
-				addStyles (contentView, "layout tile");
+				(contentView as UIBase).className += " layout tile";
 				
 				var children:Array = contentView.internalChildren();
 				var i:int;
@@ -305,25 +403,25 @@ package org.apache.royale.jewel.beads.layouts
 					child = children[i].royale_wrapper;
 					if (!child.visible) realN--;
 				}
-				trace("realN: "+ realN);
+				
 				var useWidth:Number = columnWidth;
 				var useHeight:Number = rowHeight;
 				var needWidth:Boolean = isNaN(useWidth);
 				var needHeight:Boolean = isNaN(useHeight);
-				trace(needWidth + " o " + needHeight);
+				
+				// given the width and total number of items, how many rows?
+				var borderMetrics:EdgeData = (ValuesManager.valuesImpl as IBorderPaddingMarginValuesImpl).getBorderMetrics(host);
+				var adjustedWidth:Number = Math.floor(host.width - borderMetrics.left - borderMetrics.right);
+				var adjustedHeight:Number = Math.floor(host.height - borderMetrics.top - borderMetrics.bottom);
+				var numRows:Number = Math.ceil(realN / (numColumns + _verticalGap));
+				
 				if(needWidth || needHeight)
 				{
-					var borderMetrics:EdgeData = (ValuesManager.valuesImpl as IBorderPaddingMarginValuesImpl).getBorderMetrics(host);
-					trace("borderMetrics: " + borderMetrics);
-					var adjustedWidth:Number = Math.floor(host.width - borderMetrics.left - borderMetrics.right);
-					var adjustedHeight:Number = Math.floor(host.height - borderMetrics.top - borderMetrics.bottom);
 					if (needWidth)
 						useWidth = Math.floor(adjustedWidth / numColumns);// + _horizontalGap;
 					
 					if (needHeight)
 					{
-						// given the width and total number of items, how many rows?
-						var numRows:Number = Math.ceil(realN / numColumns);
 						if (host.isHeightSizedToContent()) 
 							useHeight = 30; // default height
 						else 
@@ -332,44 +430,37 @@ package org.apache.royale.jewel.beads.layouts
 				}
 
 				var child:UIBase;
+				var numCols:Number = Math.floor(1+(adjustedWidth - useWidth) / (useWidth + _horizontalGap));
+				
 				for (i = 0; i < n; i++)
 				{
 					child = children[i].royale_wrapper;
 					if (!child.visible) continue;
-					//child.setDisplayStyleForLayout('inline-block');
 					child.width = useWidth;
 					child.height = useHeight;
 
-					var childW:WrappedHTMLElement = children[i];// as WrappedHTMLElement;
-					trace("childW: " + childW);
+					var childW:WrappedHTMLElement = children[i];
 					if (childW == null) continue;
 					
-					childW.style.marginBottom = _paddingBottom + 'px';
-					if(i == 0)
+					if(i < numCols)
 					{
 						childW.style.marginTop = _paddingTop + 'px';
-						childW.style.marginLeft = _paddingLeft + 'px';
 					}
 					else
 					{
 						childW.style.marginTop = _verticalGap + 'px';
-						childW.style.marginLeft = _horizontalGap + 'px';
 					}
-					childW.style.marginRight = _paddingRight + 'px';
-					childW.style.marginTop = _paddingTop + 'px';
-					if(i === (n - 1))
+
+					if(i % numCols)
 					{
-						childW.style.marginBottom = _paddingBottom + 'px';
-						childW.style.marginRight = _paddingRight + 'px';
+						childW.style.marginLeft = _horizontalGap + 'px';
 					}
 					else
 					{
-						childW.style.marginBottom = '0px';
-						childW.style.marginRight = '0px';
+						childW.style.marginLeft = _paddingLeft + 'px';
 					}
-					childW.style.marginLeft = _paddingLeft + 'px';
 
-					//childW.royale_wrapper.dispatchEvent('sizeChanged');				
+					childW.royale_wrapper.dispatchEvent('sizeChanged');				
 				}
 				return true;
 			}
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/VerticalLayout.as
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/VerticalLayout.as
index 04e5ac3..e5ae419 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/VerticalLayout.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/VerticalLayout.as
@@ -33,8 +33,8 @@ package org.apache.royale.jewel.beads.layouts
 
 	COMPILE::JS
 	{
-		import org.apache.royale.utils.cssclasslist.addStyles;
 		import org.apache.royale.core.WrappedHTMLElement;
+		import org.apache.royale.core.UIBase;
 	}
 
 	/**
@@ -317,8 +317,8 @@ package org.apache.royale.jewel.beads.layouts
 			COMPILE::JS
 			{
 				var contentView:IParentIUIBase = layoutView as IParentIUIBase;
-				addStyles (contentView, "layout vertical");
-
+				(contentView as UIBase).className += " layout vertical";
+				
 				var children:Array = contentView.internalChildren();
 				var i:int;
 				var n:int = children.length;

-- 
To stop receiving notification emails like this one, please contact
carlosrovira@apache.org.

Mime
View raw message