You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by jm...@apache.org on 2017/12/31 00:02:53 UTC

[02/50] git commit: [flex-sdk] [refs/heads/master] - FLEX-35267 FLEX-35260 FLEX-35029 1. GridHeaderViewLayout.getHeaderIndexAt() now verifies if the coordinates are over the GridColumnHeaderView's left or right padding. 2. Renamed GridColumnHeaderGroup.m

FLEX-35267 FLEX-35260 FLEX-35029
1. GridHeaderViewLayout.getHeaderIndexAt() now verifies if the coordinates are over the GridColumnHeaderView's left or right padding.
2. Renamed GridColumnHeaderGroup.mouseEventHeaderView() to getHeaderViewUnderGlobalCoordinates(), while also changing the parameter to be a Point instead of a MouseEvent. This is so that areCoordinatesOverAHeaderView(), areCoordinatesOverLeftPadding() and areCoordinatesOverRightPadding() can use it too.
3. Expanded some variable names in GridColumnHeaderGroup.


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

Branch: refs/heads/master
Commit: ad48251737546e5ae17081044f3051bfbb1997e8
Parents: a603b07
Author: Mihai Chira <mi...@apache.org>
Authored: Fri Mar 10 17:44:32 2017 +0100
Committer: Mihai Chira <mi...@apache.org>
Committed: Fri Mar 10 17:44:32 2017 +0100

----------------------------------------------------------------------
 .../spark/components/GridColumnHeaderGroup.as   | 66 +++++++++++++++-----
 .../gridClasses/GridColumnHeaderView.as         |  9 ++-
 .../gridClasses/GridHeaderViewLayout.as         | 40 +++++-------
 3 files changed, 72 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/ad482517/frameworks/projects/spark/src/spark/components/GridColumnHeaderGroup.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/spark/src/spark/components/GridColumnHeaderGroup.as b/frameworks/projects/spark/src/spark/components/GridColumnHeaderGroup.as
index 9d5b81d..a9209a1 100644
--- a/frameworks/projects/spark/src/spark/components/GridColumnHeaderGroup.as
+++ b/frameworks/projects/spark/src/spark/components/GridColumnHeaderGroup.as
@@ -782,7 +782,40 @@ public class GridColumnHeaderGroup extends Group implements IDataGridElement
     {
         return (_visibleSortIndicatorIndices.indexOf(columnIndex) != -1);
     }
+
+    public function containsGlobalCoordinates(coordinates:Point):Boolean
+    {
+        return areCoordinatesOverAHeaderView(coordinates) || areCoordinatesOverPadding(coordinates);
+    }
+
+    public function areCoordinatesOverAHeaderView(coordinates:Point):Boolean
+    {
+        return getHeaderViewUnderGlobalCoordinates(coordinates) != null;
+    }
+
+    public function areCoordinatesOverPadding(coordinates:Point):Boolean
+    {
+        return areCoordinatesOverLeftPadding(coordinates) || areCoordinatesOverRightPadding(coordinates);
+    }
+
+    public function areCoordinatesOverLeftPadding(coordinates:Point):Boolean
+    {
+        var paddingLeftStyle:Number = getStyle("paddingLeft");
+        var paddingLeft:Number = isNaN(paddingLeftStyle) ? 0 : paddingLeftStyle;
+
+        return getHeaderViewUnderGlobalCoordinates(new Point(coordinates.x, coordinates.y)) == null &&
+                getHeaderViewUnderGlobalCoordinates(new Point(coordinates.x + paddingLeft, coordinates.y)) != null;
+    }
     
+    public function areCoordinatesOverRightPadding(coordinates:Point):Boolean
+    {
+        var paddingRightStyle:Number = getStyle("paddingRight");
+        var paddingRight:Number = isNaN(paddingRightStyle) ? 0 : paddingRightStyle;
+
+        return getHeaderViewUnderGlobalCoordinates(new Point(coordinates.x, coordinates.y)) == null &&
+        getHeaderViewUnderGlobalCoordinates(new Point(coordinates.x, coordinates.y - paddingRight)) != null;
+    }
+
     //--------------------------------------------------------------------------
     //
     //  Methods 
@@ -804,28 +837,28 @@ public class GridColumnHeaderGroup extends Group implements IDataGridElement
 	 */
 	public function configureGridColumnHeaderViews():void
 	{
-        const ghl:GridHeaderLayout = layout as GridHeaderLayout;
-        if (!ghl)
+        const headerLayout:GridHeaderLayout = layout as GridHeaderLayout;
+        if (!headerLayout)
             return;
         
-		if (ghl.centerGridColumnHeaderView == null)
-			ghl.centerGridColumnHeaderView = createGridColumnHeaderView();
+		if (headerLayout.centerGridColumnHeaderView == null)
+			headerLayout.centerGridColumnHeaderView = createGridColumnHeaderView();
 		
 		if (dataGrid.lockedColumnCount > 0)
 		{
-			ghl.leftGridColumnHeaderView = createGridColumnHeaderView();
+			headerLayout.leftGridColumnHeaderView = createGridColumnHeaderView();
 		}
-		else if (ghl.leftGridColumnHeaderView)
+		else if (headerLayout.leftGridColumnHeaderView)
 		{
-			removeElement(ghl.leftGridColumnHeaderView);
-			ghl.leftGridColumnHeaderView = null;
+			removeElement(headerLayout.leftGridColumnHeaderView);
+			headerLayout.leftGridColumnHeaderView = null;
 		}
 		
 		const gridLayout:GridLayout = dataGrid.grid.layout as GridLayout;
 
-		GridHeaderViewLayout(ghl.centerGridColumnHeaderView.layout).gridView = gridLayout.centerGridView;
-		if (ghl.leftGridColumnHeaderView)
-			GridHeaderViewLayout(ghl.leftGridColumnHeaderView.layout).gridView = gridLayout.leftGridView;
+		GridHeaderViewLayout(headerLayout.centerGridColumnHeaderView.layout).gridView = gridLayout.centerGridView;
+		if (headerLayout.leftGridColumnHeaderView)
+			GridHeaderViewLayout(headerLayout.leftGridColumnHeaderView.layout).gridView = gridLayout.leftGridView;
 	}
 	
 	/**
@@ -850,7 +883,6 @@ public class GridColumnHeaderGroup extends Group implements IDataGridElement
      */
     public function getHeaderIndexAt(x:Number, y:Number):int
     {
-        // TODO: fix this: x coordinate has to be adjusted
 		const view:Group = getColumnHeaderViewAtX(x);
         return GridHeaderViewLayout(view.layout).getHeaderIndexAt(x, y);
     }
@@ -1000,16 +1032,16 @@ public class GridColumnHeaderGroup extends Group implements IDataGridElement
 	 *  comparison is based strictly on the event's location and the GridViews' bounds.
 	 *  The event's target can be anything.
 	 */
-	private function mouseEventHeaderView(event:MouseEvent):GridColumnHeaderView
+	private function getHeaderViewUnderGlobalCoordinates(globalCoordinates:Point):GridColumnHeaderView
 	{
 		const ghl:GridHeaderLayout = layout as GridHeaderLayout;
 
-		const centerGridColumnHeaderView:GridColumnHeaderView = GridColumnHeaderView(ghl.centerGridColumnHeaderView)
-		if (centerGridColumnHeaderView && centerGridColumnHeaderView.containsMouseEvent(event))
+		const centerGridColumnHeaderView:GridColumnHeaderView = GridColumnHeaderView(ghl.centerGridColumnHeaderView);
+		if (centerGridColumnHeaderView && centerGridColumnHeaderView.containsStageCoordinates(globalCoordinates))
 			return centerGridColumnHeaderView;
 		
 		const leftGridColumnHeaderView:GridColumnHeaderView = GridColumnHeaderView(ghl.leftGridColumnHeaderView);
-		if (leftGridColumnHeaderView && leftGridColumnHeaderView.containsMouseEvent(event))
+		if (leftGridColumnHeaderView && leftGridColumnHeaderView.containsStageCoordinates(globalCoordinates))
 			return leftGridColumnHeaderView;
 		
 		return null;
@@ -1018,7 +1050,7 @@ public class GridColumnHeaderGroup extends Group implements IDataGridElement
     // TODO: apologize for stashing the separatorIndex in headerCP.rowIndex
     private function eventToHeaderLocations(event:MouseEvent, headerCP:CellPosition, headerXY:Point):Boolean
     {
-        const view:Group = mouseEventHeaderView(event);
+        const view:Group = getHeaderViewUnderGlobalCoordinates(new Point(event.stageX, event.stageY));
         if (!view)
             return false;
 

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/ad482517/frameworks/projects/spark/src/spark/components/gridClasses/GridColumnHeaderView.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/spark/src/spark/components/gridClasses/GridColumnHeaderView.as b/frameworks/projects/spark/src/spark/components/gridClasses/GridColumnHeaderView.as
index ee475ee..2e6f449 100644
--- a/frameworks/projects/spark/src/spark/components/gridClasses/GridColumnHeaderView.as
+++ b/frameworks/projects/spark/src/spark/components/gridClasses/GridColumnHeaderView.as
@@ -106,8 +106,13 @@ public class GridColumnHeaderView extends Group
      */
     public function containsMouseEvent(event:MouseEvent):Boolean
     {
-        const eventStageX:Number = event.stageX;
-        const eventStageY:Number = event.stageY;
+        return containsStageCoordinates(new Point(event.stageX, event.stageY));
+    }
+
+    public function containsStageCoordinates(coordinates:Point):Boolean
+    {
+        const eventStageX:Number = coordinates.x;
+        const eventStageY:Number = coordinates.y;
         const origin:Point = localToGlobal(zeroPoint);
 
         origin.x += horizontalScrollPosition;

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/ad482517/frameworks/projects/spark/src/spark/components/gridClasses/GridHeaderViewLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/spark/src/spark/components/gridClasses/GridHeaderViewLayout.as b/frameworks/projects/spark/src/spark/components/gridClasses/GridHeaderViewLayout.as
index 2d98b89..4dd36b8 100644
--- a/frameworks/projects/spark/src/spark/components/gridClasses/GridHeaderViewLayout.as
+++ b/frameworks/projects/spark/src/spark/components/gridClasses/GridHeaderViewLayout.as
@@ -500,33 +500,25 @@ public class GridHeaderViewLayout extends LayoutBase
      */
     public function getHeaderIndexAt(x:Number, y:Number):int
     {
-        return gridView.gridViewLayout.gridDimensionsView.getColumnIndexAt(x, y);
-        
-        // TODO: restore the special case handling below
-        /*
-        const gridColumnHeaderGroup:GridColumnHeaderGroup = this.gridColumnHeaderGroup;
-        const grid:Grid = this.grid;
-        const columnsView:IList = this.columnsView;
-        
-        if (!gridColumnHeaderGroup || !grid || !columnsView)
-            return -1; 
-        
-        const paddingLeft:Number = gridColumnHeaderGroup.getStyle("paddingLeft");
-        const paddedX:Number = x + paddingLeft;
-        var columnIndex:int = grid.getColumnIndexAt(paddedX, 0);
-        
-        // Special case for the stretched renderer above the vertical scrollbar
-        // TODO (klin): Rethink this case if we change how the last header looks.
-        if (columnIndex < 0)
+        var headerIndex:int = -1;
+        var globalPoint:Point = gridColumnHeaderGroup.localToGlobal(new Point(x, y));
+
+        if(!gridColumnHeaderGroup.areCoordinatesOverLeftPadding(globalPoint))
         {
-            const contentWidth:Number = gridColumnHeaderGroup.contentWidth;
-            const totalWidth:Number = horizontalScrollPosition + gridColumnHeaderGroup.width - gridColumnHeaderGroup.getStyle("paddingRight");
-            if (paddedX >= contentWidth && paddedX < totalWidth)
-                columnIndex = grid.getPreviousVisibleColumnIndex(columnsView.length)
+            var paddingLeftStyle:Number = gridColumnHeaderGroup.getStyle("paddingLeft");
+            var paddingLeft:Number = isNaN(paddingLeftStyle) ? 0 : paddingLeftStyle;
+        
+            headerIndex = gridView.gridViewLayout.gridDimensionsView.getColumnIndexAt(x - paddingLeft + horizontalScrollPosition, y);
+
+            if(headerIndex == -1 && gridColumnHeaderGroup.containsGlobalCoordinates(globalPoint))
+            {
+                //then the point is either over the right padding, over the width of the vertical
+                //scroll bar, or over the space between the last separator and the width of the grid
+                headerIndex = grid.getPreviousVisibleColumnIndex(columnsView.length);
+            }
         }
         
-        return columnIndex;
-        */
+        return headerIndex;
     }
     
     /**