flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mih...@apache.org
Subject [2/5] git commit: [flex-sdk] [refs/heads/develop] - FLEX-35260 Now the unit test passes, having been updated to check the column header view boundaries. Other changes: -Now we're ignoring the grid header's right padding, because it doesn't make a visual
Date Wed, 29 Mar 2017 11:17:31 GMT
FLEX-35260 Now the unit test passes, having been updated to check the column header view boundaries.
Other changes:
-Now we're ignoring the grid header's right padding, because it doesn't make a visual difference
(except in the edge case where, together with the left and right padding, the column widths
are wider than the grid's width, in which case the grid header expands beyond the grid limits),
but we are starting to take into account bottom and top padding.
-Renamed some variables and functions for clarity in GridColumnHeaderView and GridDimensions.
-Improved error messages in the unit test


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

Branch: refs/heads/develop
Commit: d7299c330fe7bbfd348a8db03258cb3ab777e32b
Parents: 9e2620e
Author: Mihai Chira <mihaic@apache.org>
Authored: Thu Mar 16 12:45:29 2017 +0100
Committer: Mihai Chira <mihaic@apache.org>
Committed: Thu Mar 16 12:45:29 2017 +0100

----------------------------------------------------------------------
 .../spark/components/GridColumnHeaderGroup.as   | 32 ++++++--
 .../gridClasses/GridColumnHeaderView.as         | 15 ++--
 .../components/gridClasses/GridDimensions.as    | 14 ++--
 .../GridHeaderViewLayout_FLEX_35260_Tests.as    | 81 +++++++++++++++-----
 4 files changed, 104 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/d7299c33/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 a9209a1..0b202b7 100644
--- a/frameworks/projects/spark/src/spark/components/GridColumnHeaderGroup.as
+++ b/frameworks/projects/spark/src/spark/components/GridColumnHeaderGroup.as
@@ -783,6 +783,15 @@ public class GridColumnHeaderGroup extends Group implements IDataGridElement
         return (_visibleSortIndicatorIndices.indexOf(columnIndex) != -1);
     }
 
+    /**
+     *  True if either of this GridColumnHeaderGroup's views contains the global
+     *  coordinates in the event, or if they fall over this component's padding.
+     */
+    public function containsMouseEvent(event:MouseEvent):Boolean
+    {
+        return containsGlobalCoordinates(new Point(event.stageX, event.stageY));
+    }
+
     public function containsGlobalCoordinates(coordinates:Point):Boolean
     {
         return areCoordinatesOverAHeaderView(coordinates) || areCoordinatesOverPadding(coordinates);
@@ -795,7 +804,7 @@ public class GridColumnHeaderGroup extends Group implements IDataGridElement
 
     public function areCoordinatesOverPadding(coordinates:Point):Boolean
     {
-        return areCoordinatesOverLeftPadding(coordinates) || areCoordinatesOverRightPadding(coordinates);
+        return areCoordinatesOverLeftPadding(coordinates) || areCoordinatesOverTopPadding(coordinates)
|| areCoordinatesOverBottomPadding(coordinates);
     }
 
     public function areCoordinatesOverLeftPadding(coordinates:Point):Boolean
@@ -807,13 +816,22 @@ public class GridColumnHeaderGroup extends Group implements IDataGridElement
                 getHeaderViewUnderGlobalCoordinates(new Point(coordinates.x + paddingLeft,
coordinates.y)) != null;
     }
     
-    public function areCoordinatesOverRightPadding(coordinates:Point):Boolean
+    public function areCoordinatesOverTopPadding(coordinates:Point):Boolean
+    {
+        var paddingTopStyle:Number = getStyle("paddingTop");
+        var paddingTop:Number = isNaN(paddingTopStyle) ? 0 : paddingTopStyle;
+
+        return getHeaderViewUnderGlobalCoordinates(new Point(coordinates.x, coordinates.y))
== null &&
+        getHeaderViewUnderGlobalCoordinates(new Point(coordinates.x, coordinates.y + paddingTop))
!= null;
+    }
+
+    public function areCoordinatesOverBottomPadding(coordinates:Point):Boolean
     {
-        var paddingRightStyle:Number = getStyle("paddingRight");
-        var paddingRight:Number = isNaN(paddingRightStyle) ? 0 : paddingRightStyle;
+        var paddingBottomStyle:Number = getStyle("paddingBottom");
+        var paddingBottom:Number = isNaN(paddingBottomStyle) ? 0 : paddingBottomStyle;
 
         return getHeaderViewUnderGlobalCoordinates(new Point(coordinates.x, coordinates.y))
== null &&
-        getHeaderViewUnderGlobalCoordinates(new Point(coordinates.x, coordinates.y - paddingRight))
!= null;
+        getHeaderViewUnderGlobalCoordinates(new Point(coordinates.x, coordinates.y - paddingBottom))
!= null;
     }
 
     //--------------------------------------------------------------------------
@@ -1037,11 +1055,11 @@ public class GridColumnHeaderGroup extends Group implements IDataGridElement
 		const ghl:GridHeaderLayout = layout as GridHeaderLayout;
 
 		const centerGridColumnHeaderView:GridColumnHeaderView = GridColumnHeaderView(ghl.centerGridColumnHeaderView);
-		if (centerGridColumnHeaderView && centerGridColumnHeaderView.containsStageCoordinates(globalCoordinates))
+		if (centerGridColumnHeaderView && centerGridColumnHeaderView.containsGlobalPoint(globalCoordinates))
 			return centerGridColumnHeaderView;
 		
 		const leftGridColumnHeaderView:GridColumnHeaderView = GridColumnHeaderView(ghl.leftGridColumnHeaderView);
-		if (leftGridColumnHeaderView && leftGridColumnHeaderView.containsStageCoordinates(globalCoordinates))
+		if (leftGridColumnHeaderView && leftGridColumnHeaderView.containsGlobalPoint(globalCoordinates))
 			return leftGridColumnHeaderView;
 		
 		return null;

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/d7299c33/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 2e6f449..a836462 100644
--- a/frameworks/projects/spark/src/spark/components/gridClasses/GridColumnHeaderView.as
+++ b/frameworks/projects/spark/src/spark/components/gridClasses/GridColumnHeaderView.as
@@ -106,13 +106,13 @@ public class GridColumnHeaderView extends Group
      */
     public function containsMouseEvent(event:MouseEvent):Boolean
     {
-        return containsStageCoordinates(new Point(event.stageX, event.stageY));
+        return containsGlobalPoint(new Point(event.stageX, event.stageY));
     }
 
-    public function containsStageCoordinates(coordinates:Point):Boolean
+    public function containsGlobalPoint(globalCoordinates:Point):Boolean
     {
-        const eventStageX:Number = coordinates.x;
-        const eventStageY:Number = coordinates.y;
+        const stageX:Number = globalCoordinates.x;
+        const stageY:Number = globalCoordinates.y;
         const origin:Point = localToGlobal(zeroPoint);
 
         origin.x += horizontalScrollPosition;
@@ -121,8 +121,11 @@ public class GridColumnHeaderView extends Group
 
         origin.y += verticalScrollPosition;
         
-        return (eventStageX >= origin.x) && (eventStageY >= origin.y) &&

-            (eventStageX < (origin.x + width)) && (eventStageY < (origin.y
+ height));
+
+        var headerViewContainsGlobalCoordinates:Boolean = (stageX >= origin.x) &&
(stageY >= origin.y) &&
+                (stageX < (origin.x + width)) && (stageY < (origin.y + height));
+
+        return headerViewContainsGlobalCoordinates;
     }   
 }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/d7299c33/frameworks/projects/spark/src/spark/components/gridClasses/GridDimensions.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/spark/src/spark/components/gridClasses/GridDimensions.as
b/frameworks/projects/spark/src/spark/components/gridClasses/GridDimensions.as
index 0c679db..9c975b2 100644
--- a/frameworks/projects/spark/src/spark/components/gridClasses/GridDimensions.as
+++ b/frameworks/projects/spark/src/spark/components/gridClasses/GridDimensions.as
@@ -1191,21 +1191,21 @@ public class GridDimensions
 
         for (i = 0; i < _columnCount; i++)
         {
-            var temp:Number = _columnWidths[i];
+            var columnWidth:Number = _columnWidths[i];
             
             // fall back on typical widths if the actual width isn't set.
-            if (isNaN(temp))
+            if (isNaN(columnWidth))
             {
-                temp = typicalCellWidths[i];
-                if (temp == 0) // invisible column
+                columnWidth = typicalCellWidths[i];
+                if (columnWidth == 0) // invisible column
                     continue;
             }
             
             // fall back on defaultColumnWidth
-            if (isNaN(temp))
-                temp = defaultColumnWidth;
+            if (isNaN(columnWidth))
+                columnWidth = defaultColumnWidth;
             
-            current -= temp + columnGap;
+            current -= columnWidth + columnGap;
 
             if (current < 0)
                 return i;

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/d7299c33/frameworks/projects/spark/tests/spark/components/gridClasses/GridHeaderViewLayout_FLEX_35260_Tests.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/spark/tests/spark/components/gridClasses/GridHeaderViewLayout_FLEX_35260_Tests.as
b/frameworks/projects/spark/tests/spark/components/gridClasses/GridHeaderViewLayout_FLEX_35260_Tests.as
index 55421f4..dad721d 100644
--- a/frameworks/projects/spark/tests/spark/components/gridClasses/GridHeaderViewLayout_FLEX_35260_Tests.as
+++ b/frameworks/projects/spark/tests/spark/components/gridClasses/GridHeaderViewLayout_FLEX_35260_Tests.as
@@ -84,12 +84,18 @@ package spark.components.gridClasses {
         private static const ITSELF:Matrix = new Matrix(1, 0, 0, 1, 0, 0); //the point, unmodified
         private static const directions:Array = [ITSELF, N, NE, E, SE, S, SW, W, NW];
 
+        private static const COLUMN_HEADER_RECTANGLES:String = "columnHeaderRectangles";
+        private static const ENTIRE_HEADER_RECTANGLE:String = "headerRectangle";
+        private static const MAIN_HEADER_VIEW_RECTANGLE:String = "mainHeaderViewRectangle";
+        private static const FIXED_HEADER_VIEW_RECTANGLE:String = "fixedHeaderViewRectangle";
+
         private static var _dataGrid:DataGrid;
 
         private var _keyRectangles:Array;
         private var _keyPoints:Array;
 
-        //@TODO add cases with horizontal scroll, and also with fixed columns
+        //@TODO we probably have to account for paddingTop and paddingBottom as well
+        //@TODO add cases with horizontal scroll, with fixed columns, and RTL
         public static var dimensions:Array = [/*x, y, width, header padding left, header
padding top, [column widths] */
             [[10, 0, 300, 5, 0, [25, 150]]],
             [[0, 0, 300, 5, 0, [25, 150]]]
@@ -192,33 +198,35 @@ package spark.components.gridClasses {
                     var actualHeaderIndex:int = getHeaderIndexAtGlobalPoint(pointToTest);
                     const errorMessageHeaderIndex:String = getHeaderIndexErrorMessage(pointName,
directions[i], pointToTest, expectedHeaderIndex, actualHeaderIndex);
 
-                    var shouldBeContainedInHeader:Boolean = getHeaderContainsPointAssumption(pointToTest);
-                    var actuallyContainedInHeader:Boolean = _sut.areCoordinatesOverAHeaderView(pointToTest);
-                    const errorMessageHeaderContainsPoint:String = getHeaderContainsPointErrorMessage(pointName,
directions[i], pointToTest, shouldBeContainedInHeader, actuallyContainedInHeader);
+                    var shouldBeContainedInMainHeaderView:Boolean = getMainHeaderViewContainsPointAssumption(pointToTest);
+                    var shouldBeContainedInFixedHeaderView:Boolean = getFixedHeaderViewContainsPointAssumption(pointToTest);
+                    const shouldBeContainedInAHeaderView:Boolean = shouldBeContainedInMainHeaderView
|| shouldBeContainedInFixedHeaderView;
+                    var actuallyContainedInAHeaderView:Boolean = _sut.areCoordinatesOverAHeaderView(pointToTest);
+                    const errorMessageHeaderViewContainsPoint:String = getHeaderContainsPointErrorMessage(pointName,
directions[i], pointToTest, shouldBeContainedInAHeaderView, actuallyContainedInAHeaderView);
 
                     //then
                     assertEquals(errorMessageHeaderIndex, expectedHeaderIndex, actualHeaderIndex);
-                    assertEquals(errorMessageHeaderContainsPoint, shouldBeContainedInHeader,
actuallyContainedInHeader);
+                    assertEquals(errorMessageHeaderViewContainsPoint, shouldBeContainedInAHeaderView,
actuallyContainedInAHeaderView);
                 }
             }
         }
 
-        private function getHeaderIndexErrorMessage(pointName:String, direction:Matrix, transformedPoint:Point,
expectedHeaderIndex:int, actualHeaderIndex:int):String
+        private function getHeaderIndexErrorMessage(pointName:String, direction:Matrix, transformedPoint:Point,
expectedColumnHeaderIndex:int, actualColumnHeaderIndex:int):String
         {
             return "The point " + pointName + " transformed with Matrix " + direction + "
(resulting in " + transformedPoint + ") should be "
-                    + (expectedHeaderIndex == -1 ? "outside any header bounds" : "inside
the header with index " + expectedHeaderIndex)
+                    + (expectedColumnHeaderIndex == -1 ? "outside any header bounds" : "inside
the column header with index " + expectedColumnHeaderIndex)
                     + " but was mistakenly found to be "
-                    + (actualHeaderIndex == -1 ? "outside any header bounds" : "inside the
header with index " + actualHeaderIndex
-                    + "\n DEBUG INFO: headerRectangles=" + headerRectangles);
+                    + (actualColumnHeaderIndex == -1 ? "outside any header bounds" : "inside
the column header with index " + actualColumnHeaderIndex
+                    + "\n DEBUG INFO: headerRectangles=" + columnHeaderRectangles);
         }
 
         private function getHeaderContainsPointErrorMessage(pointName:String, direction:Matrix,
transformedPoint:Point, shouldBeContainedInHeader:Boolean, isActuallyContainedInHeader:Boolean):String
         {
             return "The point " + pointName + " transformed with Matrix " + direction + "
(resulting in " + transformedPoint + ") should be "
-                    + (shouldBeContainedInHeader ? "within " : "outside ") + "header bounds"
+                    + (shouldBeContainedInHeader ? "within " : "outside ") + "a header view"
                     + " but was mistakenly found to be "
                     + (isActuallyContainedInHeader ? "within" : "outside")
-                    + "\n DEBUG INFO: headerRectangle=" + headerRectangle;
+                    + "\n DEBUG INFO: header views=" + fixedHeaderViewRectangle + "; " +
mainHeaderViewRectangle;
         }
 
         private function getHeaderIndexAtGlobalPoint(globalPoint:Point):int
@@ -232,9 +240,19 @@ package spark.components.gridClasses {
             return rectangleContainsPoint(headerRectangle, point);
         }
 
+        private function getFixedHeaderViewContainsPointAssumption(point:Point):Boolean
+        {
+            return rectangleContainsPoint(fixedHeaderViewRectangle, point);
+        }
+
+        private function getMainHeaderViewContainsPointAssumption(point:Point):Boolean
+        {
+            return rectangleContainsPoint(mainHeaderViewRectangle, point);
+        }
+
         private function getHeaderIndexAssumption(point:Point):int
         {
-            return getIndexOfHeaderRectangleWhichContainsPoint(point, headerRectangles);
+            return getIndexOfHeaderRectangleWhichContainsPoint(point, columnHeaderRectangles);
         }
 
         private function getAdjacentPoint(point:Point, direction:Matrix):Point
@@ -298,18 +316,35 @@ package spark.components.gridClasses {
         {
             var keyRectangles:Array = [];
 
-            keyRectangles["headerRectangles"] = generateHeaderRectangles(keyPoints, dimensions);
-            keyRectangles["headerRectangle"] = generateVisibleHeaderRectangle(keyPoints,
dimensions);
+            keyRectangles[COLUMN_HEADER_RECTANGLES] = generateHeaderColumnRectangles(keyPoints,
dimensions);
+            keyRectangles[ENTIRE_HEADER_RECTANGLE] = generateVisibleHeaderRectangle(keyPoints,
dimensions);
+            keyRectangles[MAIN_HEADER_VIEW_RECTANGLE] = generateMainHeaderViewRectangle(keyPoints,
dimensions);
+            keyRectangles[FIXED_HEADER_VIEW_RECTANGLE] = generateFixedHeaderViewRectangle(keyPoints,
dimensions);
 
             return keyRectangles;
         }
 
+        private function generateMainHeaderViewRectangle(keyPoints:Array, dimensions:Array):Rectangle
+        {
+            //this is the GridColumnHeaderGroup.centerGridColumnHeaderView, which is holds
the non-fixed columns; padding excluded
+            const topLeftCorner:Point = keyPoints["c0"];
+            return new Rectangle(topLeftCorner.x, topLeftCorner.y, getHeaderWidthFromKeyPoints(keyPoints)
- getHeaderPaddingLeft(dimensions), getHeaderHeightFromKeyPoints(keyPoints));
+        }
+
+        private function generateFixedHeaderViewRectangle(keyPoints:Array, dimensions:Array):Rectangle
+        {
+            //this is the GridColumnHeaderGroup.centerGridColumnHeaderView, which is holds
the non-fixed columns; padding excluded
+            const topLeftCorner:Point = keyPoints["b"];
+            return new Rectangle(topLeftCorner.x, topLeftCorner.y, 0, 0);
+        }
+
         private function generateVisibleHeaderRectangle(keyPoints:Array, dimensions:Array):Rectangle
         {
             const topLeftCorner:Point = keyPoints["b"];
             return new Rectangle(topLeftCorner.x, topLeftCorner.y, getHeaderWidthFromKeyPoints(keyPoints),
getHeaderHeightFromKeyPoints(keyPoints));
         }
-        private function generateHeaderRectangles(keyPoints:Array, dimensions:Array):Array
+
+        private function generateHeaderColumnRectangles(keyPoints:Array, dimensions:Array):Array
         {
             var headerRectangles:Array = [];
 
@@ -329,14 +364,24 @@ package spark.components.gridClasses {
             return headerRectangles;
         }
 
-        private function get headerRectangles():Array
+        private function get columnHeaderRectangles():Array
         {
-            return _keyRectangles["headerRectangles"];
+            return _keyRectangles[COLUMN_HEADER_RECTANGLES];
         }
 
         private function get headerRectangle():Rectangle
         {
-            return _keyRectangles["headerRectangle"] as Rectangle;
+            return _keyRectangles[ENTIRE_HEADER_RECTANGLE] as Rectangle;
+        }
+
+        private function get mainHeaderViewRectangle():Rectangle
+        {
+            return _keyRectangles[MAIN_HEADER_VIEW_RECTANGLE] as Rectangle;
+        }
+
+        private function get fixedHeaderViewRectangle():Rectangle
+        {
+            return _keyRectangles[FIXED_HEADER_VIEW_RECTANGLE] as Rectangle;
         }
 
         private function getColumnWidthFromKeyPoints(keyPoints:Array, columnIndex:int):Number


Mime
View raw message