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.
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 @@
{
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 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 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 @@
* 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 @@
// 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;
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 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;
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 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;
}
/**