Skip to content

Commit

Permalink
GridView, TreeGridView: better column header lookup
Browse files Browse the repository at this point in the history
Was previously looking up in an array of layout items, but that's less likely to be up to date compared to the map
  • Loading branch information
joshtynjala committed Apr 11, 2024
1 parent 5f0bd97 commit 3ff35d2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions src/feathers/controls/GridView.hx
Original file line number Diff line number Diff line change
Expand Up @@ -3182,7 +3182,7 @@ class GridView extends BaseScrollContainer implements IIndexSelector implements
var column = this._columns.get(this._resizingHeaderIndex);
// clear the explicit width because the user resized it
column.width = null;
var headerRenderer = this._headerLayoutItems[this._resizingHeaderIndex];
var headerRenderer = this.dataToHeaderRenderer.get(column);
var column = this._columns.get(this._resizingHeaderIndex);
var minX = this._headerContainer.x + headerRenderer.x + column.minWidth;
var maxX = this.actualWidth - this.rightViewPortOffset;
Expand All @@ -3204,7 +3204,7 @@ class GridView extends BaseScrollContainer implements IIndexSelector implements
// however, we're not setting the width property on the
// DataGridColumn because we want them to be able to resize
// later if the whole DataGrid resizes.
headerRenderer = this._headerLayoutItems[i];
headerRenderer = this.dataToHeaderRenderer.get(currentColumn);
this._customColumnWidths[i] = headerRenderer.width;
totalMinWidth += headerRenderer.width;
} else {
Expand All @@ -3213,7 +3213,7 @@ class GridView extends BaseScrollContainer implements IIndexSelector implements
continue;
}
totalMinWidth += currentColumn.minWidth;
headerRenderer = this._headerLayoutItems[i];
headerRenderer = this.dataToHeaderRenderer.get(currentColumn);
var columnWidth = headerRenderer.width;
totalWidthAfter += columnWidth;
this._customColumnWidths[i] = columnWidth;
Expand Down Expand Up @@ -3256,9 +3256,9 @@ class GridView extends BaseScrollContainer implements IIndexSelector implements
var i = indices.length - 1;
while (i >= 0) {
var index = indices[i];
var headerRenderer = this._headerLayoutItems[index];
var columnWidth = headerRenderer.width;
var column = this._columns.get(index);
var headerRenderer = this.dataToHeaderRenderer.get(column);
var columnWidth = headerRenderer.width;
var percent = columnWidth / totalWidthOfIndices;
var offset = widthToDistribute * percent;
var newWidth = this._customColumnWidths[index] + offset;
Expand Down Expand Up @@ -3289,8 +3289,8 @@ class GridView extends BaseScrollContainer implements IIndexSelector implements
if (this._currentColumnResizeSkin == null) {
return;
}
var headerRenderer = this._headerLayoutItems[this._resizingHeaderIndex];
var column = this._columns.get(this._resizingHeaderIndex);
var headerRenderer = this.dataToHeaderRenderer.get(column);
var minX = this._headerContainer.x + headerRenderer.x + column.minWidth;
var maxX = this.actualWidth - this.rightViewPortOffset;
var originalX = this._headerContainer.x + headerRenderer.x + headerRenderer.width;
Expand Down
12 changes: 6 additions & 6 deletions src/feathers/controls/TreeGridView.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2891,7 +2891,7 @@ class TreeGridView extends BaseScrollContainer implements IDataSelector<Dynamic>
var column = this._columns.get(this._resizingHeaderIndex);
// clear the explicit width because the user resized it
column.width = null;
var headerRenderer = this._headerLayoutItems[this._resizingHeaderIndex];
var headerRenderer = this.dataToHeaderRenderer.get(column);
var column = this._columns.get(this._resizingHeaderIndex);
var minX = this._headerContainer.x + headerRenderer.x + column.minWidth;
var maxX = this.actualWidth - this.rightViewPortOffset;
Expand All @@ -2913,7 +2913,7 @@ class TreeGridView extends BaseScrollContainer implements IDataSelector<Dynamic>
// however, we're not setting the width property on the
// DataGridColumn because we want them to be able to resize
// later if the whole DataGrid resizes.
headerRenderer = this._headerLayoutItems[i];
headerRenderer = this.dataToHeaderRenderer.get(currentColumn);
this._customColumnWidths[i] = headerRenderer.width;
totalMinWidth += headerRenderer.width;
} else {
Expand All @@ -2922,7 +2922,7 @@ class TreeGridView extends BaseScrollContainer implements IDataSelector<Dynamic>
continue;
}
totalMinWidth += currentColumn.minWidth;
headerRenderer = this._headerLayoutItems[i];
headerRenderer = this.dataToHeaderRenderer.get(currentColumn);
var columnWidth = headerRenderer.width;
totalWidthAfter += columnWidth;
this._customColumnWidths[i] = columnWidth;
Expand Down Expand Up @@ -2965,9 +2965,9 @@ class TreeGridView extends BaseScrollContainer implements IDataSelector<Dynamic>
var i = indices.length - 1;
while (i >= 0) {
var index = indices[i];
var headerRenderer = this._headerLayoutItems[index];
var columnWidth = headerRenderer.width;
var column = this._columns.get(index);
var headerRenderer = this.dataToHeaderRenderer.get(column);
var columnWidth = headerRenderer.width;
var percent = columnWidth / totalWidthOfIndices;
var offset = widthToDistribute * percent;
var newWidth = this._customColumnWidths[index] + offset;
Expand Down Expand Up @@ -2998,8 +2998,8 @@ class TreeGridView extends BaseScrollContainer implements IDataSelector<Dynamic>
if (this._currentColumnResizeSkin == null) {
return;
}
var headerRenderer = this._headerLayoutItems[this._resizingHeaderIndex];
var column = this._columns.get(this._resizingHeaderIndex);
var headerRenderer = this.dataToHeaderRenderer.get(column);
var minX = this._headerContainer.x + headerRenderer.x + column.minWidth;
var maxX = this.actualWidth - this.rightViewPortOffset;
var originalX = this._headerContainer.x + headerRenderer.x + headerRenderer.width;
Expand Down

0 comments on commit 3ff35d2

Please sign in to comment.