You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ca...@apache.org on 2019/12/12 23:47:28 UTC

[royale-asjs] 27/42: jewel-datagrid: get initial layout working

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

commit 6b1c95de33a2c9f7bcb395b163825accfbbf3f0c
Author: Carlos Rovira <ca...@apache.org>
AuthorDate: Fri Dec 6 11:47:49 2019 +0100

    jewel-datagrid: get initial layout working
---
 .../src/main/royale/DataGridPlayGround.mxml        |   6 +-
 .../royale/jewel/beads/layouts/DataGridLayout.as   | 111 +++++++++++----------
 .../supportClasses/datagrid/DataGridColumnList.as  |   2 +-
 3 files changed, 60 insertions(+), 59 deletions(-)

diff --git a/examples/royale/TourDeJewel/src/main/royale/DataGridPlayGround.mxml b/examples/royale/TourDeJewel/src/main/royale/DataGridPlayGround.mxml
index 9d11a51..b9b3b7a 100644
--- a/examples/royale/TourDeJewel/src/main/royale/DataGridPlayGround.mxml
+++ b/examples/royale/TourDeJewel/src/main/royale/DataGridPlayGround.mxml
@@ -65,9 +65,9 @@ limitations under the License.
 							destinationPropertyName="dataProvider" />
 					</j:beads>
 					<j:columns>
-						<j:DataGridColumn label="Images and Pictures" dataField="image" columnWidth="15" itemRenderer="itemRenderers.ProductItemRenderer"/>
-						<j:DataGridColumn label="Title" dataField="title" columnWidth="60" />
-						<j:DataGridColumn label="Sales" dataField="sales" columnWidth="25" />
+						<j:DataGridColumn label="Images and Pictures" dataField="image" columnWidth="45" itemRenderer="itemRenderers.ProductItemRenderer"/>
+						<j:DataGridColumn label="Title" dataField="title" columnWidth="120" />
+						<j:DataGridColumn label="Sales" dataField="sales" columnWidth="50" />
 					</j:columns>
 				</j:DataGrid>
 
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/DataGridLayout.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/DataGridLayout.as
index 669ee9b..a91c6f9 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/DataGridLayout.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/DataGridLayout.as
@@ -18,6 +18,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 package org.apache.royale.jewel.beads.layouts
 {	
+    import org.apache.royale.collections.ArrayList;
     import org.apache.royale.core.IBeadLayout;
     import org.apache.royale.core.IBorderPaddingMarginValuesImpl;
     import org.apache.royale.core.IDataGridModel;
@@ -103,76 +104,76 @@ package org.apache.royale.jewel.beads.layouts
 		 * @royaleignorecoercion org.apache.royale.core.UIBase
 		 * @royaleignorecoercion org.apache.royale.html.beads.IDataGridView
 		 * @royaleignorecoercion org.apache.royale.html.beads.models.ButtonBarModel
-		 * @royaleignorecoercion org.apache.royale.html.supportClasses.IDataGridColumn
+		 * @royaleignorecoercion org.apache.royale.jewel.supportClasses.datagrid.IDataGridColumn
 		 */
 		public function layout():Boolean
 		{
-		// 	var header:IUIBase = (uiHost.view as IDataGridView).header;
-        //     // fancier DG's will filter invisible columns and only put visible columns
-        //     // in the bbmodel, so do all layout based on the bbmodel, not the set
-        //     // of columns that may contain invisible columns
-        //     var bbmodel:ButtonBarModel = header.getBeadByType(ButtonBarModel) as ButtonBarModel;
-		// 	var listArea:IUIBase = (uiHost.view as IDataGridView).listArea;
+			var header:IUIBase = (uiHost.view as IDataGridView).header;
+            // fancier DG's will filter invisible columns and only put visible columns
+            // in the bbmodel, so do all layout based on the bbmodel, not the set
+            // of columns that may contain invisible columns
+            var bbmodel:ButtonBarModel = header.getBeadByType(ButtonBarModel) as ButtonBarModel;
+			var listArea:IUIBase = (uiHost.view as IDataGridView).listArea;
 			
-		// 	var displayedColumns:Array = (uiHost.view as IDataGridView).columnLists;
-		// 	var model:IDataGridModel = uiHost.model as IDataGridModel;
+			var displayedColumns:Array = (uiHost.view as IDataGridView).columnLists;
+			var model:IDataGridModel = uiHost.model as IDataGridModel;
 			
-		// 	var borderMetrics:EdgeData = (ValuesManager.valuesImpl as IBorderPaddingMarginValuesImpl).getBorderMetrics(_strand as IUIBase);			
-		// 	var useWidth:Number = uiHost.width - (borderMetrics.left + borderMetrics.right);
-		// 	var useHeight:Number = uiHost.height - (borderMetrics.top + borderMetrics.bottom);
+			var borderMetrics:EdgeData = (ValuesManager.valuesImpl as IBorderPaddingMarginValuesImpl).getBorderMetrics(_strand as IUIBase);			
+			var useWidth:Number = uiHost.width - (borderMetrics.left + borderMetrics.right);
+			var useHeight:Number = uiHost.height - (borderMetrics.top + borderMetrics.bottom);
 			
-		// 	var xpos:Number = 0;
-		// 	var defaultColumnWidth:Number = (useWidth) / bbmodel.dataProvider.length;
-		// 	var columnWidths:Array = [];
+			// var xpos:Number = 0;
+			var defaultColumnWidth:Number = (useWidth) / bbmodel.dataProvider.length;
+			var columnWidths:Array = [];
 			
-		// 	for(var i:int=0; i < bbmodel.dataProvider.length; i++) {
-		// 		var columnDef:IDataGridColumn = bbmodel.dataProvider[i] as IDataGridColumn;
-		// 		var columnList:UIBase = displayedColumns[i] as UIBase;
+			for(var i:int=0; i < bbmodel.dataProvider.length; i++) {
+				var columnDef:IDataGridColumn = (bbmodel.dataProvider as ArrayList).getItemAt(i) as IDataGridColumn;
+				var columnList:UIBase = displayedColumns[i] as UIBase;
 				
-		// 		// probably do not need to set (x,y), but if the Container's layout requires it, they will be set.
-		// 		columnList.x = xpos;
-		// 		columnList.y = 0;
+				// probably do not need to set (x,y), but if the Container's layout requires it, they will be set.
+				// columnList.x = xpos;
+				// columnList.y = 0;
 				
-		// 		var columnWidth:Number = defaultColumnWidth;
-		// 		if (!isNaN(columnDef.columnWidth)) {
-		// 			columnWidth = columnDef.columnWidth;
-		// 		}
+				var columnWidth:Number = defaultColumnWidth;
+				if (!isNaN(columnDef.columnWidth)) {
+					columnWidth = columnDef.columnWidth;
+				}
 				
-		// 		columnList.width = columnWidth;
-		// 		columnWidths.push(columnWidth);
+				columnList.width = columnWidth;
+				columnWidths.push(columnWidth);
 				
-		// 		xpos += columnList.width;
-		// 	}
+				// xpos += columnList.width;
+			}
 			
-		// 	bbmodel.buttonWidths = columnWidths;
+			bbmodel.buttonWidths = columnWidths;
 			
-		// 	COMPILE::SWF {
-        //         header.y = borderMetrics.top;
-        //         header.x = borderMetrics.left;
-		// 		header.width = useWidth;
-		// 	}
-		// 	COMPILE::JS {
-		// 		(header as UIBase).percentWidth = 100;
-		// 		listArea.element.style.position = "absolute";
-        //         if (!(uiHost.element.style.position == 'absolute' ||
-        //               uiHost.element.style.position == 'relative' ||
-        //               uiHost.element.style.position == 'fixed'))
-        //             uiHost.element.style.position = 'relative';
-		// 	}
-		// 	// header's height is set in CSS
+			// COMPILE::SWF {
+            //     header.y = borderMetrics.top;
+            //     header.x = borderMetrics.left;
+			// 	header.width = useWidth;
+			// }
+			// COMPILE::JS {
+			// 	(header as UIBase).percentWidth = 100;
+			// 	listArea.element.style.position = "absolute";
+            //     if (!(uiHost.element.style.position == 'absolute' ||
+            //           uiHost.element.style.position == 'relative' ||
+            //           uiHost.element.style.position == 'fixed'))
+            //         uiHost.element.style.position = 'relative';
+			// }
+			// header's height is set in CSS
 			
-        //     listArea.y = header.height + header.y;
-		// 	COMPILE::SWF {
-        //         listArea.x = borderMetrics.left;
-		// 		listArea.width = useWidth;
-		// 	}
-		// 	COMPILE::JS {
-		// 		(listArea as UIBase).percentWidth = 100;
-		// 	}
-		// 	listArea.height = useHeight - header.height;
+            // listArea.y = header.height + header.y;
+			// COMPILE::SWF {
+            //     listArea.x = borderMetrics.left;
+			// 	listArea.width = useWidth;
+			// }
+			// COMPILE::JS {
+			// 	(listArea as UIBase).percentWidth = 100;
+			// }
+			// listArea.height = useHeight - header.height;
 			
-		// 	header.dispatchEvent(new Event("layoutNeeded"));
-		// 	listArea.dispatchEvent(new Event("layoutNeeded"));
+			header.dispatchEvent(new Event("layoutNeeded"));
+			listArea.dispatchEvent(new Event("layoutNeeded"));
 			
 			return true;
 		}
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/supportClasses/datagrid/DataGridColumnList.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/supportClasses/datagrid/DataGridColumnList.as
index 310c406..2c04991 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/supportClasses/datagrid/DataGridColumnList.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/supportClasses/datagrid/DataGridColumnList.as
@@ -68,7 +68,7 @@ package org.apache.royale.jewel.supportClasses.datagrid
          *  @langversion 3.0
          *  @playerversion Flash 10.2
          *  @playerversion AIR 2.6
-         *  @productversion Royale 0.9
+         *  @productversion Royale 0.9.7
          * 
          *  @royalesuppresspublicvarwarning
          */