@deephaven/grid 0.22.3-beta.18 → 0.22.3-beta.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CellInputField.d.ts +5 -5
- package/dist/CellInputField.d.ts.map +1 -1
- package/dist/CellInputField.js +6 -23
- package/dist/CellInputField.js.map +1 -1
- package/dist/EditableGridModel.js +1 -0
- package/dist/EditableGridModel.js.map +1 -1
- package/dist/ExpandableGridModel.js +1 -0
- package/dist/ExpandableGridModel.js.map +1 -1
- package/dist/Grid.js +77 -315
- package/dist/Grid.js.map +1 -1
- package/dist/GridAxisRange.js.map +1 -1
- package/dist/GridColorUtils.js +1 -2
- package/dist/GridColorUtils.js.map +1 -1
- package/dist/GridMetricCalculator.js +83 -240
- package/dist/GridMetricCalculator.js.map +1 -1
- package/dist/GridModel.js +13 -31
- package/dist/GridModel.js.map +1 -1
- package/dist/GridMouseHandler.js +2 -15
- package/dist/GridMouseHandler.js.map +1 -1
- package/dist/GridRange.js +46 -160
- package/dist/GridRange.js.map +1 -1
- package/dist/GridRenderer.js +126 -407
- package/dist/GridRenderer.js.map +1 -1
- package/dist/GridTestUtils.js +0 -5
- package/dist/GridTestUtils.js.map +1 -1
- package/dist/GridTheme.js.map +1 -1
- package/dist/GridUtils.js +68 -217
- package/dist/GridUtils.js.map +1 -1
- package/dist/KeyHandler.js +2 -8
- package/dist/KeyHandler.js.map +1 -1
- package/dist/MockGridData.js.map +1 -1
- package/dist/MockGridModel.js +0 -42
- package/dist/MockGridModel.js.map +1 -1
- package/dist/MockTreeGridModel.js +6 -55
- package/dist/MockTreeGridModel.js.map +1 -1
- package/dist/StaticDataGridModel.js +0 -15
- package/dist/StaticDataGridModel.js.map +1 -1
- package/dist/ThemeContext.js.map +1 -1
- package/dist/ViewportDataGridModel.js +0 -14
- package/dist/ViewportDataGridModel.js.map +1 -1
- package/dist/errors/AssertionError.js +0 -3
- package/dist/errors/AssertionError.js.map +1 -1
- package/dist/errors/PasteError.js +0 -3
- package/dist/errors/PasteError.js.map +1 -1
- package/dist/errors/assertIsDefined.js.map +1 -1
- package/dist/errors/index.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/key-handlers/EditKeyHandler.js +0 -12
- package/dist/key-handlers/EditKeyHandler.js.map +1 -1
- package/dist/key-handlers/PasteKeyHandler.js +15 -33
- package/dist/key-handlers/PasteKeyHandler.js.map +1 -1
- package/dist/key-handlers/SelectionKeyHandler.js +6 -53
- package/dist/key-handlers/SelectionKeyHandler.js.map +1 -1
- package/dist/key-handlers/TreeKeyHandler.js +0 -11
- package/dist/key-handlers/TreeKeyHandler.js.map +1 -1
- package/dist/key-handlers/index.js.map +1 -1
- package/dist/memoizeClear.js +1 -4
- package/dist/memoizeClear.js.map +1 -1
- package/dist/mouse-handlers/EditMouseHandler.js +0 -5
- package/dist/mouse-handlers/EditMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridColumnMoveMouseHandler.js +35 -123
- package/dist/mouse-handlers/GridColumnMoveMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridColumnSeparatorMouseHandler.js +2 -27
- package/dist/mouse-handlers/GridColumnSeparatorMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridHorizontalScrollBarMouseHandler.js +0 -28
- package/dist/mouse-handlers/GridHorizontalScrollBarMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridRowMoveMouseHandler.js +0 -27
- package/dist/mouse-handlers/GridRowMoveMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridRowSeparatorMouseHandler.js +0 -23
- package/dist/mouse-handlers/GridRowSeparatorMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridRowTreeMouseHandler.js +0 -10
- package/dist/mouse-handlers/GridRowTreeMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridScrollBarCornerMouseHandler.js +0 -6
- package/dist/mouse-handlers/GridScrollBarCornerMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridSelectionMouseHandler.js +8 -38
- package/dist/mouse-handlers/GridSelectionMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridSeparatorMouseHandler.js +5 -54
- package/dist/mouse-handlers/GridSeparatorMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridVerticalScrollBarMouseHandler.js +0 -28
- package/dist/mouse-handlers/GridVerticalScrollBarMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
-
|
|
3
2
|
import clamp from 'lodash.clamp';
|
|
4
3
|
import GridUtils from "./GridUtils.js";
|
|
5
4
|
import { isExpandableGridModel } from "./ExpandableGridModel.js";
|
|
6
|
-
|
|
7
5
|
/**
|
|
8
6
|
* Retrieve a value from a map. If the value is not found and no default value is provided, throw.
|
|
9
7
|
* Use when the value _must_ be present
|
|
@@ -14,16 +12,14 @@ import { isExpandableGridModel } from "./ExpandableGridModel.js";
|
|
|
14
12
|
*/
|
|
15
13
|
export function getOrThrow(map, key) {
|
|
16
14
|
var _map$get;
|
|
17
|
-
|
|
18
15
|
var defaultValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
|
|
19
16
|
var value = (_map$get = map.get(key)) !== null && _map$get !== void 0 ? _map$get : defaultValue;
|
|
20
|
-
|
|
21
17
|
if (value !== undefined) {
|
|
22
18
|
return value;
|
|
23
19
|
}
|
|
24
|
-
|
|
25
20
|
throw new Error("Missing value for key ".concat(key));
|
|
26
21
|
}
|
|
22
|
+
|
|
27
23
|
/**
|
|
28
24
|
* Trim the provided map in place. Trims oldest inserted items down to the target size if the cache size is exceeded.
|
|
29
25
|
* Instead of trimming one item on every tick, we trim half the items so there isn't a cache clear on every new item.
|
|
@@ -31,19 +27,17 @@ export function getOrThrow(map, key) {
|
|
|
31
27
|
* @param cacheSize The maximum number of elements to cache
|
|
32
28
|
* @param targetSize The number of elements to reduce the cache down to if `cacheSize` is exceeded
|
|
33
29
|
*/
|
|
34
|
-
|
|
35
30
|
export function trimMap(map) {
|
|
36
31
|
var cacheSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : GridMetricCalculator.CACHE_SIZE;
|
|
37
32
|
var targetSize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Math.floor(cacheSize / 2);
|
|
38
|
-
|
|
39
33
|
if (map.size > cacheSize) {
|
|
40
34
|
var iter = map.keys();
|
|
41
|
-
|
|
42
35
|
while (map.size > targetSize) {
|
|
43
36
|
map.delete(iter.next().value);
|
|
44
37
|
}
|
|
45
38
|
}
|
|
46
39
|
}
|
|
40
|
+
|
|
47
41
|
/**
|
|
48
42
|
* Get the coordinates of floating items in one dimension.
|
|
49
43
|
* Can be used for getting the y coordinates of floating rows, or x coordinates of floating columns, calculated using the `sizeMap` passed in.
|
|
@@ -53,31 +47,26 @@ export function trimMap(map) {
|
|
|
53
47
|
* @param max The max coordinate value (ie. `maxY` for rows, `maxX` for columns)
|
|
54
48
|
* @param sizeMap Map from index to size of item (ie. `rowHeightMap` for rows, `columnWidthMap` for columns)
|
|
55
49
|
*/
|
|
56
|
-
|
|
57
50
|
export function getFloatingCoordinates(startCount, endCount, totalCount, max, sizeMap) {
|
|
58
51
|
var coordinates = new Map();
|
|
59
52
|
var x = 0;
|
|
60
|
-
|
|
61
53
|
for (var i = 0; i < startCount && i < totalCount; i += 1) {
|
|
62
54
|
coordinates.set(i, x);
|
|
63
55
|
x += getOrThrow(sizeMap, i);
|
|
64
56
|
}
|
|
65
|
-
|
|
66
57
|
x = max;
|
|
67
|
-
|
|
68
58
|
for (var _i = 0; _i < endCount && totalCount - _i - 1 >= 0; _i += 1) {
|
|
69
59
|
x -= getOrThrow(sizeMap, totalCount - _i - 1);
|
|
70
60
|
coordinates.set(totalCount - _i - 1, x);
|
|
71
61
|
}
|
|
72
|
-
|
|
73
62
|
return coordinates;
|
|
74
63
|
}
|
|
64
|
+
|
|
75
65
|
/**
|
|
76
66
|
* Class to calculate all the metrics for drawing a grid.
|
|
77
67
|
* Call getMetrics() with the state to get the full metrics.
|
|
78
68
|
* Override this class and override the individual methods to provide additional functionality.
|
|
79
69
|
*/
|
|
80
|
-
|
|
81
70
|
export class GridMetricCalculator {
|
|
82
71
|
/** The size of the caches this calculator stores */
|
|
83
72
|
|
|
@@ -100,6 +89,7 @@ export class GridMetricCalculator {
|
|
|
100
89
|
/** List of moved row operations. Need to track the previous value so we know if modelRows needs to be cleared. */
|
|
101
90
|
|
|
102
91
|
/** List of moved column operations. Need to track the previous value so we know if modelColumns needs to be cleared. */
|
|
92
|
+
|
|
103
93
|
constructor() {
|
|
104
94
|
var {
|
|
105
95
|
userColumnWidths = new Map(),
|
|
@@ -112,43 +102,33 @@ export class GridMetricCalculator {
|
|
|
112
102
|
movedRows = [],
|
|
113
103
|
movedColumns = []
|
|
114
104
|
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
115
|
-
|
|
116
105
|
_defineProperty(this, "userColumnWidths", void 0);
|
|
117
|
-
|
|
118
106
|
_defineProperty(this, "userRowHeights", void 0);
|
|
119
|
-
|
|
120
107
|
_defineProperty(this, "calculatedColumnWidths", void 0);
|
|
121
|
-
|
|
122
108
|
_defineProperty(this, "calculatedRowHeights", void 0);
|
|
123
|
-
|
|
124
109
|
_defineProperty(this, "fontWidths", void 0);
|
|
125
|
-
|
|
126
110
|
_defineProperty(this, "modelRows", void 0);
|
|
127
|
-
|
|
128
111
|
_defineProperty(this, "modelColumns", void 0);
|
|
129
|
-
|
|
130
112
|
_defineProperty(this, "movedRows", void 0);
|
|
131
|
-
|
|
132
113
|
_defineProperty(this, "movedColumns", void 0);
|
|
133
|
-
|
|
134
114
|
this.userColumnWidths = userColumnWidths;
|
|
135
115
|
this.userRowHeights = userRowHeights;
|
|
136
116
|
this.calculatedRowHeights = calculatedRowHeights;
|
|
137
117
|
this.calculatedColumnWidths = calculatedColumnWidths;
|
|
138
|
-
this.fontWidths = fontWidths;
|
|
118
|
+
this.fontWidths = fontWidths;
|
|
139
119
|
|
|
120
|
+
// Need to track the last moved rows/columns array so we know if we need to reset our models cache
|
|
140
121
|
this.modelRows = modelRows;
|
|
141
122
|
this.modelColumns = modelColumns;
|
|
142
123
|
this.movedRows = movedRows;
|
|
143
124
|
this.movedColumns = movedColumns;
|
|
144
125
|
}
|
|
126
|
+
|
|
145
127
|
/**
|
|
146
128
|
* Get the metrics for the provided metric state
|
|
147
129
|
* @params state The state to get metrics for
|
|
148
130
|
* @returns The full metrics
|
|
149
131
|
*/
|
|
150
|
-
|
|
151
|
-
|
|
152
132
|
getMetrics(state) {
|
|
153
133
|
var {
|
|
154
134
|
left,
|
|
@@ -172,17 +152,14 @@ export class GridMetricCalculator {
|
|
|
172
152
|
minScrollHandleSize,
|
|
173
153
|
scrollBarSize
|
|
174
154
|
} = theme;
|
|
175
|
-
|
|
176
155
|
if (movedRows !== this.movedRows) {
|
|
177
156
|
this.movedRows = movedRows;
|
|
178
157
|
this.modelRows.clear();
|
|
179
158
|
}
|
|
180
|
-
|
|
181
159
|
if (movedColumns !== this.movedColumns) {
|
|
182
160
|
this.movedColumns = movedColumns;
|
|
183
161
|
this.modelColumns.clear();
|
|
184
162
|
}
|
|
185
|
-
|
|
186
163
|
var {
|
|
187
164
|
columnCount,
|
|
188
165
|
rowCount,
|
|
@@ -191,8 +168,9 @@ export class GridMetricCalculator {
|
|
|
191
168
|
floatingLeftColumnCount,
|
|
192
169
|
floatingRightColumnCount,
|
|
193
170
|
columnHeaderMaxDepth
|
|
194
|
-
} = model;
|
|
171
|
+
} = model;
|
|
195
172
|
|
|
173
|
+
// Get some basic metrics
|
|
196
174
|
var firstRow = this.getFirstRow(state);
|
|
197
175
|
var firstColumn = this.getFirstColumn(state);
|
|
198
176
|
var gridX = this.getGridX(state);
|
|
@@ -201,12 +179,14 @@ export class GridMetricCalculator {
|
|
|
201
179
|
var treePaddingY = 0; // We don't support trees on columns (at least not yet)
|
|
202
180
|
|
|
203
181
|
var visibleRowHeights = this.getVisibleRowHeights(state);
|
|
204
|
-
var visibleColumnWidths = this.getVisibleColumnWidths(state, firstColumn, treePaddingX);
|
|
182
|
+
var visibleColumnWidths = this.getVisibleColumnWidths(state, firstColumn, treePaddingX);
|
|
205
183
|
|
|
184
|
+
// Calculate the metrics for the main grid
|
|
206
185
|
var visibleRows = Array.from(visibleRowHeights.keys());
|
|
207
|
-
var visibleColumns = Array.from(visibleColumnWidths.keys());
|
|
208
|
-
// TODO #316: Create an allRowHeights/allColumnWidths maps
|
|
186
|
+
var visibleColumns = Array.from(visibleColumnWidths.keys());
|
|
209
187
|
|
|
188
|
+
// Add the floating row heights/column widths
|
|
189
|
+
// TODO #316: Create an allRowHeights/allColumnWidths maps
|
|
210
190
|
visibleRowHeights = new Map([...visibleRowHeights, ...this.getFloatingRowHeights(state)]);
|
|
211
191
|
visibleColumnWidths = new Map([...visibleColumnWidths, ...this.getFloatingColumnWidths(state)]);
|
|
212
192
|
var visibleColumnXs = this.getVisibleColumnXs(visibleColumnWidths, visibleColumns, leftOffset);
|
|
@@ -224,14 +204,17 @@ export class GridMetricCalculator {
|
|
|
224
204
|
var maxX = columnWidthValues.reduce((x, w) => x + w, 0) - leftOffset;
|
|
225
205
|
var maxY = rowHeightValues.reduce((y, h) => y + h, 0) - topOffset;
|
|
226
206
|
var lastLeft = this.getLastLeft(state, null, width - gridX - scrollBarSize - rowFooterWidth);
|
|
227
|
-
var lastTop = this.getLastTop(state, null, height - gridY - scrollBarSize - floatingBottomHeight);
|
|
207
|
+
var lastTop = this.getLastTop(state, null, height - gridY - scrollBarSize - floatingBottomHeight);
|
|
228
208
|
|
|
209
|
+
// How much total space the content will take
|
|
229
210
|
var scrollableContentWidth = leftOffset + maxX + rowFooterWidth;
|
|
230
|
-
var scrollableContentHeight = topOffset + maxY;
|
|
211
|
+
var scrollableContentHeight = topOffset + maxY;
|
|
231
212
|
|
|
213
|
+
// Visible space available in the canvas viewport
|
|
232
214
|
var scrollableViewportWidth = width - gridX;
|
|
233
|
-
var scrollableViewportHeight = height - gridY;
|
|
215
|
+
var scrollableViewportHeight = height - gridY;
|
|
234
216
|
|
|
217
|
+
// Calculate some metrics for the scroll bars
|
|
235
218
|
var hasHorizontalBar = lastLeft > 0 || scrollableContentWidth > scrollableViewportWidth;
|
|
236
219
|
var horizontalBarHeight = hasHorizontalBar ? scrollBarSize : 0;
|
|
237
220
|
var hasVerticalBar = lastTop > 0 || scrollableContentHeight > scrollableViewportHeight - horizontalBarHeight;
|
|
@@ -239,8 +222,9 @@ export class GridMetricCalculator {
|
|
|
239
222
|
var barWidth = width - rowHeaderWidth - verticalBarWidth;
|
|
240
223
|
var barHeight = height - columnHeaderHeight - horizontalBarHeight;
|
|
241
224
|
var barLeft = rowHeaderWidth;
|
|
242
|
-
var barTop = columnHeaderHeight;
|
|
225
|
+
var barTop = columnHeaderHeight;
|
|
243
226
|
|
|
227
|
+
// How big the scroll handle is relative to the bar
|
|
244
228
|
var horizontalHandlePercent = columnCount === 1 ? barWidth / scrollableContentWidth : (columnCount - lastLeft) / columnCount;
|
|
245
229
|
var verticalHandlePercent = rowCount === 1 ? barHeight / scrollableContentHeight : (rowCount - lastTop) / rowCount;
|
|
246
230
|
var handleWidth = hasHorizontalBar ? clamp(barWidth * horizontalHandlePercent, minScrollHandleSize, barWidth - 1) : 0;
|
|
@@ -248,49 +232,44 @@ export class GridMetricCalculator {
|
|
|
248
232
|
var leftColumnWidth = getOrThrow(visibleColumnWidths, left, 0);
|
|
249
233
|
var topRowHeight = getOrThrow(visibleRowHeights, top, 0);
|
|
250
234
|
var leftOffsetPercent = leftColumnWidth > 0 ? leftOffset / leftColumnWidth : 0;
|
|
251
|
-
var topOffsetPercent = topRowHeight > 0 ? topOffset / topRowHeight : 0;
|
|
235
|
+
var topOffsetPercent = topRowHeight > 0 ? topOffset / topRowHeight : 0;
|
|
252
236
|
|
|
237
|
+
// How much of the available space has been scrolled
|
|
253
238
|
var horizontalScrollPercent = columnCount === 1 ? leftOffset / (scrollableContentWidth - scrollableViewportWidth) : (left + leftOffsetPercent) / lastLeft;
|
|
254
239
|
var verticalScrollPercent = rowCount === 1 ? topOffset / (scrollableContentHeight - scrollableViewportHeight) : (top + topOffsetPercent) / lastTop;
|
|
255
240
|
var scrollX = hasHorizontalBar ? horizontalScrollPercent * (barWidth - handleWidth) : 0;
|
|
256
|
-
var scrollY = hasVerticalBar ? verticalScrollPercent * (barHeight - handleHeight) : 0;
|
|
241
|
+
var scrollY = hasVerticalBar ? verticalScrollPercent * (barHeight - handleHeight) : 0;
|
|
257
242
|
|
|
243
|
+
// Now add the floating sections positions
|
|
258
244
|
var floatingRows = [];
|
|
259
|
-
|
|
260
245
|
if (floatingTopRowCount > 0 || floatingBottomRowCount > 0) {
|
|
261
246
|
floatingRows = [...Array(floatingTopRowCount).keys(), ...[...Array(floatingBottomRowCount).keys()].map(i => rowCount - i - 1)];
|
|
262
247
|
visibleRowYs = new Map([...visibleRowYs, ...this.getFloatingRowYs(state, visibleRowHeights, Math.floor(height - gridY - horizontalBarHeight))]);
|
|
263
248
|
}
|
|
264
|
-
|
|
265
249
|
var floatingColumns = [];
|
|
266
|
-
|
|
267
250
|
if (floatingLeftColumnCount > 0 || floatingRightColumnCount > 0) {
|
|
268
251
|
floatingColumns = [...Array(floatingLeftColumnCount).keys(), ...[...Array(floatingRightColumnCount).keys()].map(i => columnCount - i - 1)];
|
|
269
252
|
visibleColumnXs = new Map([...visibleColumnXs, ...this.getFloatingColumnXs(state, visibleColumnWidths, Math.floor(width - gridX - verticalBarWidth))]);
|
|
270
253
|
}
|
|
271
|
-
|
|
272
254
|
var draggingColumns = [];
|
|
273
|
-
|
|
274
255
|
if (draggingColumn) {
|
|
275
256
|
for (var i = draggingColumn.range[0]; i <= draggingColumn.range[1]; i += 1) {
|
|
276
257
|
draggingColumns.push(i);
|
|
277
|
-
|
|
278
258
|
if (!visibleColumnWidths.has(i)) {
|
|
279
259
|
visibleColumnWidths.set(i, this.getVisibleColumnWidth(i, state));
|
|
280
260
|
}
|
|
281
|
-
|
|
282
261
|
if (!visibleColumnXs.has(i)) {
|
|
283
262
|
visibleColumnXs.set(i, 0);
|
|
284
263
|
}
|
|
285
264
|
}
|
|
286
265
|
}
|
|
287
|
-
|
|
288
266
|
var allRows = visibleRows.concat(floatingRows);
|
|
289
267
|
var allColumns = visibleColumns.concat(floatingColumns).concat(draggingColumns);
|
|
290
268
|
var modelRows = this.getModelRows(allRows, state);
|
|
291
269
|
var modelColumns = this.getModelColumns(allColumns, state);
|
|
292
|
-
var visibleRowTreeBoxes = this.getVisibleRowTreeBoxes(visibleRowHeights, modelRows, state);
|
|
270
|
+
var visibleRowTreeBoxes = this.getVisibleRowTreeBoxes(visibleRowHeights, modelRows, state);
|
|
293
271
|
|
|
272
|
+
// Calculate the visible viewport based on scroll position and floating sections
|
|
294
273
|
var topVisible = this.getTopVisible(state, visibleRowYs, visibleRowHeights, visibleRows);
|
|
295
274
|
var leftVisible = this.getLeftVisible(state, visibleColumnXs, visibleColumnWidths, visibleColumns);
|
|
296
275
|
var bottomVisible = lastTop > 0 ? this.getBottomVisible(state, visibleRowYs, visibleRowHeights, visibleRows, gridY) : bottom;
|
|
@@ -406,13 +385,12 @@ export class GridMetricCalculator {
|
|
|
406
385
|
columnHeaderMaxDepth
|
|
407
386
|
};
|
|
408
387
|
}
|
|
388
|
+
|
|
409
389
|
/**
|
|
410
390
|
* The x offset of the grid
|
|
411
391
|
* @param state The current grid state
|
|
412
392
|
* @returns x value of the left side of the first cell
|
|
413
393
|
*/
|
|
414
|
-
|
|
415
|
-
|
|
416
394
|
getGridX(state) {
|
|
417
395
|
var {
|
|
418
396
|
theme
|
|
@@ -422,13 +400,12 @@ export class GridMetricCalculator {
|
|
|
422
400
|
} = theme;
|
|
423
401
|
return rowHeaderWidth;
|
|
424
402
|
}
|
|
403
|
+
|
|
425
404
|
/**
|
|
426
405
|
* The y offset of the grid
|
|
427
406
|
* @param state The current grid state
|
|
428
407
|
* @returns y value of the top side of the first cell
|
|
429
408
|
*/
|
|
430
|
-
|
|
431
|
-
|
|
432
409
|
getGridY(state) {
|
|
433
410
|
var {
|
|
434
411
|
theme,
|
|
@@ -442,14 +419,13 @@ export class GridMetricCalculator {
|
|
|
442
419
|
} = model;
|
|
443
420
|
return columnHeaderMaxDepth * columnHeaderHeight;
|
|
444
421
|
}
|
|
422
|
+
|
|
445
423
|
/**
|
|
446
424
|
* The height of the "visible" area (excludes floating areas)
|
|
447
425
|
* @param state The current grid state
|
|
448
426
|
* @param visibleRowHeights All the visible row heights
|
|
449
427
|
* @returns The visible height in pixels
|
|
450
428
|
*/
|
|
451
|
-
|
|
452
|
-
|
|
453
429
|
getVisibleHeight(state) {
|
|
454
430
|
var visibleRowHeights = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getFloatingRowHeights(state);
|
|
455
431
|
var {
|
|
@@ -464,14 +440,13 @@ export class GridMetricCalculator {
|
|
|
464
440
|
var floatingTopHeight = this.getFloatingTopHeight(state, visibleRowHeights);
|
|
465
441
|
return height - floatingBottomHeight - floatingTopHeight - gridY - scrollBarSize;
|
|
466
442
|
}
|
|
443
|
+
|
|
467
444
|
/**
|
|
468
445
|
* The width of the "visible" area (excludes floating areas)
|
|
469
446
|
* @param state The current grid state
|
|
470
447
|
* @param visibleColumnWidths All the visible column widths
|
|
471
448
|
* @returns The visible width in pixels
|
|
472
449
|
*/
|
|
473
|
-
|
|
474
|
-
|
|
475
450
|
getVisibleWidth(state) {
|
|
476
451
|
var visibleColumnWidths = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getFloatingColumnWidths(state);
|
|
477
452
|
var {
|
|
@@ -487,6 +462,7 @@ export class GridMetricCalculator {
|
|
|
487
462
|
var floatingLeftWidth = this.getFloatingLeftWidth(state, visibleColumnWidths);
|
|
488
463
|
return width - floatingLeftWidth - floatingRightWidth - gridX - scrollBarSize - rowFooterWidth;
|
|
489
464
|
}
|
|
465
|
+
|
|
490
466
|
/**
|
|
491
467
|
* Retrieve the index of the first non-hidden item
|
|
492
468
|
* @param itemSizes The size of the items in this dimension
|
|
@@ -494,42 +470,36 @@ export class GridMetricCalculator {
|
|
|
494
470
|
* @param state The current grid state
|
|
495
471
|
* @returns The first item that is not hidden
|
|
496
472
|
*/
|
|
497
|
-
|
|
498
|
-
|
|
499
473
|
getFirstIndex(itemSizes, getModelIndex, state) {
|
|
500
474
|
// We only need to check at the very most the number of items the user has hidden + 1
|
|
501
475
|
var max = itemSizes.size + 1;
|
|
502
|
-
|
|
503
476
|
for (var i = 0; i < max; i += 1) {
|
|
504
477
|
var modelIndex = getModelIndex(i, state);
|
|
505
|
-
|
|
506
478
|
if (itemSizes.get(modelIndex) !== 0) {
|
|
507
479
|
return i;
|
|
508
480
|
}
|
|
509
481
|
}
|
|
510
|
-
|
|
511
482
|
return 0;
|
|
512
483
|
}
|
|
484
|
+
|
|
513
485
|
/**
|
|
514
486
|
* Get the first column index that isn't hidden
|
|
515
487
|
* @param state The current grid state
|
|
516
488
|
* @returns The first column that is not hidden
|
|
517
489
|
*/
|
|
518
|
-
|
|
519
|
-
|
|
520
490
|
getFirstColumn(state) {
|
|
521
491
|
return this.getFirstIndex(this.userColumnWidths, this.getModelColumn.bind(this), state);
|
|
522
492
|
}
|
|
493
|
+
|
|
523
494
|
/**
|
|
524
495
|
* Get the first row index that isn't hidden
|
|
525
496
|
* @param state The current grid state
|
|
526
497
|
* @returns The first row that is not hidden
|
|
527
498
|
*/
|
|
528
|
-
|
|
529
|
-
|
|
530
499
|
getFirstRow(state) {
|
|
531
500
|
return this.getFirstIndex(this.userRowHeights, this.getModelRow.bind(this), state);
|
|
532
501
|
}
|
|
502
|
+
|
|
533
503
|
/**
|
|
534
504
|
* Get the last column that can be the left most column (e.g. scrolled to the right)
|
|
535
505
|
* If no right column is provided, then the last column is used.
|
|
@@ -538,8 +508,6 @@ export class GridMetricCalculator {
|
|
|
538
508
|
* @param visibleWidth The width of the "visible" area (excluding floating items)
|
|
539
509
|
* @returns The index of the last left visible column
|
|
540
510
|
*/
|
|
541
|
-
|
|
542
|
-
|
|
543
511
|
getLastLeft(state, right, visibleWidth) {
|
|
544
512
|
var {
|
|
545
513
|
model
|
|
@@ -549,26 +517,21 @@ export class GridMetricCalculator {
|
|
|
549
517
|
floatingRightColumnCount
|
|
550
518
|
} = model;
|
|
551
519
|
var lastLeft = Math.max(0, columnCount - floatingRightColumnCount - 1);
|
|
552
|
-
|
|
553
520
|
if (right != null) {
|
|
554
521
|
lastLeft = right;
|
|
555
522
|
}
|
|
556
|
-
|
|
557
523
|
var x = 0;
|
|
558
|
-
|
|
559
524
|
while (lastLeft > 0) {
|
|
560
525
|
var columnWidth = this.getVisibleColumnWidth(lastLeft, state);
|
|
561
526
|
x += columnWidth;
|
|
562
|
-
|
|
563
527
|
if (x >= visibleWidth) {
|
|
564
528
|
return Math.min(lastLeft + 1, right !== null && right !== void 0 ? right : columnCount - 1);
|
|
565
529
|
}
|
|
566
|
-
|
|
567
530
|
lastLeft -= 1;
|
|
568
531
|
}
|
|
569
|
-
|
|
570
532
|
return 0;
|
|
571
533
|
}
|
|
534
|
+
|
|
572
535
|
/**
|
|
573
536
|
* The last row that can be the top row (e.g. scrolled to the bottom)
|
|
574
537
|
* If no bottom row is provided, then the last row that is not floating is used
|
|
@@ -577,8 +540,6 @@ export class GridMetricCalculator {
|
|
|
577
540
|
* @param visibleHeight The height of the "visible" area (excluding floating items)
|
|
578
541
|
* @returns The index of the last top visible row
|
|
579
542
|
*/
|
|
580
|
-
|
|
581
|
-
|
|
582
543
|
getLastTop(state, bottom, visibleHeight) {
|
|
583
544
|
var {
|
|
584
545
|
model
|
|
@@ -588,26 +549,21 @@ export class GridMetricCalculator {
|
|
|
588
549
|
floatingBottomRowCount
|
|
589
550
|
} = model;
|
|
590
551
|
var lastTop = Math.max(0, rowCount - floatingBottomRowCount - 1);
|
|
591
|
-
|
|
592
552
|
if (bottom != null) {
|
|
593
553
|
lastTop = bottom;
|
|
594
554
|
}
|
|
595
|
-
|
|
596
555
|
var y = 0;
|
|
597
|
-
|
|
598
556
|
while (lastTop > 0) {
|
|
599
557
|
var rowHeight = this.getVisibleRowHeight(lastTop, state);
|
|
600
558
|
y += rowHeight;
|
|
601
|
-
|
|
602
559
|
if (y >= visibleHeight) {
|
|
603
560
|
return Math.min(lastTop + 1, rowCount - 1);
|
|
604
561
|
}
|
|
605
|
-
|
|
606
562
|
lastTop -= 1;
|
|
607
563
|
}
|
|
608
|
-
|
|
609
564
|
return 0;
|
|
610
565
|
}
|
|
566
|
+
|
|
611
567
|
/**
|
|
612
568
|
* Retrieve the top row to scroll to so the passed in `topVisible` is completely visible, taking the floating rows into account.
|
|
613
569
|
* The `top` row is at the top underneath any floating rows, whereas `topVisible` is visible below the floating rows.
|
|
@@ -616,20 +572,17 @@ export class GridMetricCalculator {
|
|
|
616
572
|
* @param topVisible The top row to be visible
|
|
617
573
|
* @returns The index of the top row to scroll to (under the floating top rows)
|
|
618
574
|
*/
|
|
619
|
-
|
|
620
|
-
|
|
621
575
|
getTopForTopVisible(state, topVisible) {
|
|
622
576
|
var floatingTopHeight = this.getFloatingTopHeight(state);
|
|
623
577
|
var top = topVisible;
|
|
624
578
|
var y = 0;
|
|
625
|
-
|
|
626
579
|
while (top > 0 && y < floatingTopHeight) {
|
|
627
580
|
top -= 1;
|
|
628
581
|
y += this.getVisibleRowHeight(top, state);
|
|
629
582
|
}
|
|
630
|
-
|
|
631
583
|
return top;
|
|
632
584
|
}
|
|
585
|
+
|
|
633
586
|
/**
|
|
634
587
|
* Retrieve the top row to scroll to so the passed in `bottomVisible` is completely visible
|
|
635
588
|
* at the bottom of the visible viewport, taking the floating rows into account.
|
|
@@ -637,8 +590,6 @@ export class GridMetricCalculator {
|
|
|
637
590
|
* @param bottomVisible The bottom row to be visible
|
|
638
591
|
* @returns The index of the top row to scroll to (under the floating top rows)
|
|
639
592
|
*/
|
|
640
|
-
|
|
641
|
-
|
|
642
593
|
getTopForBottomVisible(state, bottomVisible) {
|
|
643
594
|
var {
|
|
644
595
|
height
|
|
@@ -648,6 +599,7 @@ export class GridMetricCalculator {
|
|
|
648
599
|
var availableHeight = height - gridY - floatingBottomHeight;
|
|
649
600
|
return this.getLastTop(state, bottomVisible, availableHeight);
|
|
650
601
|
}
|
|
602
|
+
|
|
651
603
|
/**
|
|
652
604
|
* Retrieve the left column to scroll to so the passed in `leftVisible` is completely visible
|
|
653
605
|
* at the left of the visible viewport, taking the floating columns into account.
|
|
@@ -655,20 +607,17 @@ export class GridMetricCalculator {
|
|
|
655
607
|
* @param leftVisible The left column to be visible
|
|
656
608
|
* @returns The index of the left column to scroll to (under the floating left columns)
|
|
657
609
|
*/
|
|
658
|
-
|
|
659
|
-
|
|
660
610
|
getLeftForLeftVisible(state, leftVisible) {
|
|
661
611
|
var floatingLeftWidth = this.getFloatingLeftWidth(state);
|
|
662
612
|
var left = leftVisible;
|
|
663
613
|
var x = 0;
|
|
664
|
-
|
|
665
614
|
while (left > 0 && x < floatingLeftWidth) {
|
|
666
615
|
left -= 1;
|
|
667
616
|
x += this.getVisibleColumnWidth(left, state);
|
|
668
617
|
}
|
|
669
|
-
|
|
670
618
|
return left;
|
|
671
619
|
}
|
|
620
|
+
|
|
672
621
|
/**
|
|
673
622
|
* Retrieve the left column to scroll to so the passed in `rightVisible` is completely visible
|
|
674
623
|
* at the right of the visible viewport, taking the floating columns into account.
|
|
@@ -676,8 +625,6 @@ export class GridMetricCalculator {
|
|
|
676
625
|
* @param rightVisible The right column to be visible
|
|
677
626
|
* @returns The index of the left column to scroll to (under the floating left columns)
|
|
678
627
|
*/
|
|
679
|
-
|
|
680
|
-
|
|
681
628
|
getLeftForRightVisible(state, rightVisible) {
|
|
682
629
|
var {
|
|
683
630
|
width
|
|
@@ -687,13 +634,12 @@ export class GridMetricCalculator {
|
|
|
687
634
|
var availableWidth = width - gridX - floatingRightWidth;
|
|
688
635
|
return this.getLastLeft(state, rightVisible, availableWidth);
|
|
689
636
|
}
|
|
637
|
+
|
|
690
638
|
/**
|
|
691
639
|
* Retrieve a map of the height of each floating row
|
|
692
640
|
* @param state The grid metric state
|
|
693
641
|
* @returns The heights of all the floating rows
|
|
694
642
|
*/
|
|
695
|
-
|
|
696
|
-
|
|
697
643
|
getFloatingRowHeights(state) {
|
|
698
644
|
var {
|
|
699
645
|
model
|
|
@@ -704,25 +650,21 @@ export class GridMetricCalculator {
|
|
|
704
650
|
rowCount
|
|
705
651
|
} = model;
|
|
706
652
|
var rowHeights = new Map();
|
|
707
|
-
|
|
708
653
|
for (var i = 0; i < floatingTopRowCount && i < rowCount; i += 1) {
|
|
709
654
|
rowHeights.set(i, this.getVisibleRowHeight(i, state));
|
|
710
655
|
}
|
|
711
|
-
|
|
712
656
|
for (var _i2 = 0; _i2 < floatingBottomRowCount && rowCount - _i2 - 1 >= 0; _i2 += 1) {
|
|
713
657
|
var row = rowCount - _i2 - 1;
|
|
714
658
|
rowHeights.set(row, this.getVisibleRowHeight(row, state));
|
|
715
659
|
}
|
|
716
|
-
|
|
717
660
|
return rowHeights;
|
|
718
661
|
}
|
|
662
|
+
|
|
719
663
|
/**
|
|
720
664
|
* Retrieve a map of the height of all the visible rows (non-floating)
|
|
721
665
|
* @param state The grid metric state
|
|
722
666
|
* @returns The heights of all the visible rows
|
|
723
667
|
*/
|
|
724
|
-
|
|
725
|
-
|
|
726
668
|
getVisibleRowHeights(state) {
|
|
727
669
|
var {
|
|
728
670
|
top,
|
|
@@ -736,16 +678,15 @@ export class GridMetricCalculator {
|
|
|
736
678
|
var {
|
|
737
679
|
rowCount
|
|
738
680
|
} = model;
|
|
739
|
-
|
|
740
681
|
while (y < height + topOffset && row < rowCount) {
|
|
741
682
|
var rowHeight = this.getVisibleRowHeight(row, state);
|
|
742
683
|
rowHeights.set(row, rowHeight);
|
|
743
684
|
y += rowHeight;
|
|
744
685
|
row += 1;
|
|
745
686
|
}
|
|
746
|
-
|
|
747
687
|
return rowHeights;
|
|
748
688
|
}
|
|
689
|
+
|
|
749
690
|
/**
|
|
750
691
|
* Retrieve a map of the width of each floating column
|
|
751
692
|
* @param state The grid metric state
|
|
@@ -753,8 +694,6 @@ export class GridMetricCalculator {
|
|
|
753
694
|
* @param treePaddingX The amount of padding taken up for the tree expansion buttons
|
|
754
695
|
* @returns The widths of all the floating columns
|
|
755
696
|
*/
|
|
756
|
-
|
|
757
|
-
|
|
758
697
|
getFloatingColumnWidths(state) {
|
|
759
698
|
var firstColumn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getFirstColumn(state);
|
|
760
699
|
var treePaddingX = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.calculateTreePaddingX(state);
|
|
@@ -767,25 +706,21 @@ export class GridMetricCalculator {
|
|
|
767
706
|
floatingRightColumnCount
|
|
768
707
|
} = model;
|
|
769
708
|
var columnWidths = new Map();
|
|
770
|
-
|
|
771
709
|
for (var i = 0; i < floatingLeftColumnCount && i < columnCount; i += 1) {
|
|
772
710
|
columnWidths.set(i, this.getVisibleColumnWidth(i, state, firstColumn, treePaddingX));
|
|
773
711
|
}
|
|
774
|
-
|
|
775
712
|
for (var _i3 = 0; _i3 < floatingRightColumnCount && columnCount - _i3 - 1 >= 0; _i3 += 1) {
|
|
776
713
|
var column = columnCount - _i3 - 1;
|
|
777
714
|
columnWidths.set(column, this.getVisibleColumnWidth(column, state, firstColumn, treePaddingX));
|
|
778
715
|
}
|
|
779
|
-
|
|
780
716
|
return columnWidths;
|
|
781
717
|
}
|
|
718
|
+
|
|
782
719
|
/**
|
|
783
720
|
* Retrieve a map of the width of all the visible columns (non-floating)
|
|
784
721
|
* @param state The grid metric state
|
|
785
722
|
* @returns The widths of all the visible columns
|
|
786
723
|
*/
|
|
787
|
-
|
|
788
|
-
|
|
789
724
|
getVisibleColumnWidths(state) {
|
|
790
725
|
var firstColumn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getFirstColumn(state);
|
|
791
726
|
var treePaddingX = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.calculateTreePaddingX(state);
|
|
@@ -801,16 +736,15 @@ export class GridMetricCalculator {
|
|
|
801
736
|
var {
|
|
802
737
|
columnCount
|
|
803
738
|
} = model;
|
|
804
|
-
|
|
805
739
|
while (x < width + leftOffset && column < columnCount) {
|
|
806
740
|
var columnWidth = this.getVisibleColumnWidth(column, state, firstColumn, treePaddingX);
|
|
807
741
|
columnWidths.set(column, columnWidth);
|
|
808
742
|
x += columnWidth;
|
|
809
743
|
column += 1;
|
|
810
744
|
}
|
|
811
|
-
|
|
812
745
|
return columnWidths;
|
|
813
746
|
}
|
|
747
|
+
|
|
814
748
|
/**
|
|
815
749
|
* Retrieve a map of all the floating columns to their x coordinate
|
|
816
750
|
* @param state The grid metric state
|
|
@@ -818,8 +752,6 @@ export class GridMetricCalculator {
|
|
|
818
752
|
* @param maxX The maximum X size for the grid
|
|
819
753
|
* @returns Map of the x coordinate of all floating columns
|
|
820
754
|
*/
|
|
821
|
-
|
|
822
|
-
|
|
823
755
|
getFloatingColumnXs(state, columnWidthMap, maxX) {
|
|
824
756
|
var {
|
|
825
757
|
model
|
|
@@ -831,6 +763,7 @@ export class GridMetricCalculator {
|
|
|
831
763
|
} = model;
|
|
832
764
|
return getFloatingCoordinates(floatingLeftColumnCount, floatingRightColumnCount, columnCount, maxX, columnWidthMap);
|
|
833
765
|
}
|
|
766
|
+
|
|
834
767
|
/**
|
|
835
768
|
* Retrieve a map of all the visible columns to their x coordinate.
|
|
836
769
|
* Starts at leftOffset with the first index in `visibleColumns`, then
|
|
@@ -840,21 +773,18 @@ export class GridMetricCalculator {
|
|
|
840
773
|
* @param leftOffset The left scroll offset
|
|
841
774
|
* @returns Map of the x coordinate of all visible columns
|
|
842
775
|
*/
|
|
843
|
-
|
|
844
|
-
|
|
845
776
|
getVisibleColumnXs(visibleColumnWidths, visibleColumns, leftOffset) {
|
|
846
777
|
var visibleColumnXs = new Map();
|
|
847
778
|
var x = -leftOffset;
|
|
848
|
-
|
|
849
779
|
for (var i = 0; i < visibleColumns.length; i += 1) {
|
|
850
780
|
var column = visibleColumns[i];
|
|
851
781
|
var columnWidth = getOrThrow(visibleColumnWidths, column);
|
|
852
782
|
visibleColumnXs.set(column, x);
|
|
853
783
|
x += columnWidth;
|
|
854
784
|
}
|
|
855
|
-
|
|
856
785
|
return visibleColumnXs;
|
|
857
786
|
}
|
|
787
|
+
|
|
858
788
|
/**
|
|
859
789
|
* Retrieve a map of all the floating rows to their y coordinate
|
|
860
790
|
* @param state The grid metric state
|
|
@@ -862,8 +792,6 @@ export class GridMetricCalculator {
|
|
|
862
792
|
* @param maxY The maximum Y size for the grid
|
|
863
793
|
* @returns Map of the y coordinate of all floating rows
|
|
864
794
|
*/
|
|
865
|
-
|
|
866
|
-
|
|
867
795
|
getFloatingRowYs(state, rowHeightMap, maxY) {
|
|
868
796
|
var {
|
|
869
797
|
model
|
|
@@ -875,6 +803,7 @@ export class GridMetricCalculator {
|
|
|
875
803
|
} = model;
|
|
876
804
|
return getFloatingCoordinates(floatingTopRowCount, floatingBottomRowCount, rowCount, maxY, rowHeightMap);
|
|
877
805
|
}
|
|
806
|
+
|
|
878
807
|
/**
|
|
879
808
|
* Retrieve a map of all the visible rows to their y coordinate.
|
|
880
809
|
* Starts at topOffset with the first index in `visibleRows`, then
|
|
@@ -884,21 +813,18 @@ export class GridMetricCalculator {
|
|
|
884
813
|
* @param topOffset The top scroll offset
|
|
885
814
|
* @returns Map of the y coordinate of all visible rows
|
|
886
815
|
*/
|
|
887
|
-
|
|
888
|
-
|
|
889
816
|
getVisibleRowYs(visibleRowHeights, visibleRows, topOffset) {
|
|
890
817
|
var visibleRowYs = new Map();
|
|
891
818
|
var y = -topOffset;
|
|
892
|
-
|
|
893
819
|
for (var i = 0; i < visibleRows.length; i += 1) {
|
|
894
820
|
var row = visibleRows[i];
|
|
895
821
|
var rowHeight = getOrThrow(visibleRowHeights, row);
|
|
896
822
|
visibleRowYs.set(row, y);
|
|
897
823
|
y += rowHeight;
|
|
898
824
|
}
|
|
899
|
-
|
|
900
825
|
return visibleRowYs;
|
|
901
826
|
}
|
|
827
|
+
|
|
902
828
|
/**
|
|
903
829
|
* Calculates the tree box click areas that are visible. In relation to the columnX/rowY
|
|
904
830
|
* @param visibleRowHeights Map of visible index to row height
|
|
@@ -906,8 +832,6 @@ export class GridMetricCalculator {
|
|
|
906
832
|
* @param state The grid metric state
|
|
907
833
|
* @returns Coordinates of tree boxes for each row
|
|
908
834
|
*/
|
|
909
|
-
|
|
910
|
-
|
|
911
835
|
getVisibleRowTreeBoxes(visibleRowHeights, modelRows, state) {
|
|
912
836
|
var visibleRowTreeBoxes = new Map();
|
|
913
837
|
var {
|
|
@@ -918,11 +842,9 @@ export class GridMetricCalculator {
|
|
|
918
842
|
treeDepthIndent,
|
|
919
843
|
treeHorizontalPadding
|
|
920
844
|
} = theme;
|
|
921
|
-
|
|
922
845
|
if (isExpandableGridModel(model) && model.hasExpandableRows) {
|
|
923
846
|
visibleRowHeights.forEach((rowHeight, row) => {
|
|
924
847
|
var modelRow = getOrThrow(modelRows, row);
|
|
925
|
-
|
|
926
848
|
if (model.isRowExpandable(modelRow)) {
|
|
927
849
|
var depth = model.depthForRow(modelRow);
|
|
928
850
|
var x1 = depth * treeDepthIndent + treeHorizontalPadding;
|
|
@@ -938,17 +860,15 @@ export class GridMetricCalculator {
|
|
|
938
860
|
}
|
|
939
861
|
});
|
|
940
862
|
}
|
|
941
|
-
|
|
942
863
|
return visibleRowTreeBoxes;
|
|
943
864
|
}
|
|
865
|
+
|
|
944
866
|
/**
|
|
945
867
|
* Get the total width of the floating columns on the left
|
|
946
868
|
* @param state The grid metric state
|
|
947
869
|
* @param columnWidths Map of column index to width
|
|
948
870
|
* @returns The total width of the floating left section
|
|
949
871
|
*/
|
|
950
|
-
|
|
951
|
-
|
|
952
872
|
getFloatingLeftWidth(state) {
|
|
953
873
|
var columnWidths = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getFloatingColumnWidths(state);
|
|
954
874
|
var {
|
|
@@ -958,21 +878,18 @@ export class GridMetricCalculator {
|
|
|
958
878
|
floatingLeftColumnCount
|
|
959
879
|
} = model;
|
|
960
880
|
var floatingWidth = 0;
|
|
961
|
-
|
|
962
881
|
for (var i = 0; i < floatingLeftColumnCount; i += 1) {
|
|
963
882
|
floatingWidth += getOrThrow(columnWidths, i);
|
|
964
883
|
}
|
|
965
|
-
|
|
966
884
|
return floatingWidth;
|
|
967
885
|
}
|
|
886
|
+
|
|
968
887
|
/**
|
|
969
888
|
* Get the total width of the floating columns on the right
|
|
970
889
|
* @param state The grid metric state
|
|
971
890
|
* @param columnWidths Map of column index to width
|
|
972
891
|
* @returns The total width of the floating right section
|
|
973
892
|
*/
|
|
974
|
-
|
|
975
|
-
|
|
976
893
|
getFloatingRightWidth(state) {
|
|
977
894
|
var columnWidths = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getFloatingColumnWidths(state);
|
|
978
895
|
var {
|
|
@@ -983,21 +900,18 @@ export class GridMetricCalculator {
|
|
|
983
900
|
columnCount
|
|
984
901
|
} = model;
|
|
985
902
|
var floatingWidth = 0;
|
|
986
|
-
|
|
987
903
|
for (var i = 0; i < floatingRightColumnCount; i += 1) {
|
|
988
904
|
floatingWidth += getOrThrow(columnWidths, columnCount - i - 1);
|
|
989
905
|
}
|
|
990
|
-
|
|
991
906
|
return floatingWidth;
|
|
992
907
|
}
|
|
908
|
+
|
|
993
909
|
/**
|
|
994
910
|
* Get the total height of the floating rows on the top
|
|
995
911
|
* @param state The grid metric state
|
|
996
912
|
* @param rowHeights Map of row index to height
|
|
997
913
|
* @returns The total height of the floating top section
|
|
998
914
|
*/
|
|
999
|
-
|
|
1000
|
-
|
|
1001
915
|
getFloatingTopHeight(state) {
|
|
1002
916
|
var rowHeights = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getFloatingRowHeights(state);
|
|
1003
917
|
var {
|
|
@@ -1007,21 +921,18 @@ export class GridMetricCalculator {
|
|
|
1007
921
|
floatingTopRowCount
|
|
1008
922
|
} = model;
|
|
1009
923
|
var floatingHeight = 0;
|
|
1010
|
-
|
|
1011
924
|
for (var i = 0; i < floatingTopRowCount; i += 1) {
|
|
1012
925
|
floatingHeight += getOrThrow(rowHeights, i);
|
|
1013
926
|
}
|
|
1014
|
-
|
|
1015
927
|
return floatingHeight;
|
|
1016
928
|
}
|
|
929
|
+
|
|
1017
930
|
/**
|
|
1018
931
|
* Get the total height of the floating rows on the bottom
|
|
1019
932
|
* @param state The grid metric state
|
|
1020
933
|
* @param rowHeights Map of row index to height
|
|
1021
934
|
* @returns The total height of the floating bottom section
|
|
1022
935
|
*/
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
936
|
getFloatingBottomHeight(state) {
|
|
1026
937
|
var rowHeights = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getFloatingRowHeights(state);
|
|
1027
938
|
var {
|
|
@@ -1032,13 +943,12 @@ export class GridMetricCalculator {
|
|
|
1032
943
|
rowCount
|
|
1033
944
|
} = model;
|
|
1034
945
|
var floatingHeight = 0;
|
|
1035
|
-
|
|
1036
946
|
for (var i = 0; i < floatingBottomRowCount; i += 1) {
|
|
1037
947
|
floatingHeight += getOrThrow(rowHeights, rowCount - i - 1);
|
|
1038
948
|
}
|
|
1039
|
-
|
|
1040
949
|
return floatingHeight;
|
|
1041
950
|
}
|
|
951
|
+
|
|
1042
952
|
/**
|
|
1043
953
|
* Retrieve the index of the first fully visible row in the "visible" viewport of the grid.
|
|
1044
954
|
* E.g. First row visible after the floating rows, provided the visible rows.
|
|
@@ -1048,22 +958,18 @@ export class GridMetricCalculator {
|
|
|
1048
958
|
* @param visibleRows Array of visible row indexes
|
|
1049
959
|
* @returns Index of the top visible row
|
|
1050
960
|
*/
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
961
|
getTopVisible(state, visibleRowYs, visibleRowHeights, visibleRows) {
|
|
1054
962
|
var floatingHeight = this.getFloatingTopHeight(state, visibleRowHeights);
|
|
1055
|
-
|
|
1056
963
|
for (var i = 0; i < visibleRows.length; i += 1) {
|
|
1057
964
|
var row = visibleRows[i];
|
|
1058
965
|
var y = getOrThrow(visibleRowYs, row);
|
|
1059
|
-
|
|
1060
966
|
if (y >= floatingHeight) {
|
|
1061
967
|
return row;
|
|
1062
968
|
}
|
|
1063
969
|
}
|
|
1064
|
-
|
|
1065
970
|
return 0;
|
|
1066
971
|
}
|
|
972
|
+
|
|
1067
973
|
/**
|
|
1068
974
|
* Retrieve the index of the first fully visible column in the "visible" viewport of the grid.
|
|
1069
975
|
* E.g. First column visible after the floating columns, provided the visible columns.
|
|
@@ -1073,22 +979,18 @@ export class GridMetricCalculator {
|
|
|
1073
979
|
* @param visibleColumns Array of visible row indexes
|
|
1074
980
|
* @returns Index of the left visible column
|
|
1075
981
|
*/
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
982
|
getLeftVisible(state, visibleColumnXs, visibleColumnWidths, visibleColumns) {
|
|
1079
983
|
var floatingWidth = this.getFloatingLeftWidth(state, visibleColumnWidths);
|
|
1080
|
-
|
|
1081
984
|
for (var i = 0; i < visibleColumns.length; i += 1) {
|
|
1082
985
|
var column = visibleColumns[i];
|
|
1083
986
|
var x = getOrThrow(visibleColumnXs, column);
|
|
1084
|
-
|
|
1085
987
|
if (x >= floatingWidth) {
|
|
1086
988
|
return column;
|
|
1087
989
|
}
|
|
1088
990
|
}
|
|
1089
|
-
|
|
1090
991
|
return 0;
|
|
1091
992
|
}
|
|
993
|
+
|
|
1092
994
|
/**
|
|
1093
995
|
* Retrieve the index of the last fully visible row in the "visible" viewport of the grid.
|
|
1094
996
|
* E.g. Last row visible before the bottom floating rows, provided the visible rows.
|
|
@@ -1099,8 +1001,6 @@ export class GridMetricCalculator {
|
|
|
1099
1001
|
* @param gridY The starting y coordinate of the grid
|
|
1100
1002
|
* @returns Index of the bottom visible row
|
|
1101
1003
|
*/
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
1004
|
getBottomVisible(state, visibleRowYs, visibleRowHeights, visibleRows, gridY) {
|
|
1105
1005
|
var {
|
|
1106
1006
|
height,
|
|
@@ -1111,19 +1011,17 @@ export class GridMetricCalculator {
|
|
|
1111
1011
|
} = theme;
|
|
1112
1012
|
var floatingHeight = this.getFloatingBottomHeight(state, visibleRowHeights);
|
|
1113
1013
|
var visibleHeight = height - gridY - scrollBarSize - floatingHeight;
|
|
1114
|
-
|
|
1115
1014
|
for (var i = visibleRows.length - 1; i >= 0; i -= 1) {
|
|
1116
1015
|
var row = visibleRows[i];
|
|
1117
1016
|
var rowY = getOrThrow(visibleRowYs, row);
|
|
1118
1017
|
var rowHeight = getOrThrow(visibleRowHeights, row);
|
|
1119
|
-
|
|
1120
1018
|
if (rowY + rowHeight <= visibleHeight) {
|
|
1121
1019
|
return row;
|
|
1122
1020
|
}
|
|
1123
1021
|
}
|
|
1124
|
-
|
|
1125
1022
|
return 0;
|
|
1126
1023
|
}
|
|
1024
|
+
|
|
1127
1025
|
/**
|
|
1128
1026
|
* Retrieve the index of the last fully visible column in the "visible" viewport of the grid.
|
|
1129
1027
|
* E.g. Last column visible before the floating columns, provided the visible columns.
|
|
@@ -1133,8 +1031,6 @@ export class GridMetricCalculator {
|
|
|
1133
1031
|
* @param visibleColumns Array of visible column indexes
|
|
1134
1032
|
* @returns Index of the right visible column
|
|
1135
1033
|
*/
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
1034
|
getRightVisible(state, visibleColumnXs, visibleColumnWidths, visibleColumns, gridX) {
|
|
1139
1035
|
var {
|
|
1140
1036
|
width,
|
|
@@ -1145,19 +1041,17 @@ export class GridMetricCalculator {
|
|
|
1145
1041
|
} = theme;
|
|
1146
1042
|
var floatingWidth = this.getFloatingRightWidth(state, visibleColumnWidths);
|
|
1147
1043
|
var visibleWidth = width - gridX - scrollBarSize - floatingWidth;
|
|
1148
|
-
|
|
1149
1044
|
for (var i = visibleColumns.length - 1; i >= 0; i -= 1) {
|
|
1150
1045
|
var column = visibleColumns[i];
|
|
1151
1046
|
var columnX = getOrThrow(visibleColumnXs, column);
|
|
1152
1047
|
var columnWidth = getOrThrow(visibleColumnWidths, column);
|
|
1153
|
-
|
|
1154
1048
|
if (columnX + columnWidth <= visibleWidth) {
|
|
1155
1049
|
return column;
|
|
1156
1050
|
}
|
|
1157
1051
|
}
|
|
1158
|
-
|
|
1159
1052
|
return 0;
|
|
1160
1053
|
}
|
|
1054
|
+
|
|
1161
1055
|
/**
|
|
1162
1056
|
* Retrieve the possible bottom of the visible viewport (not limited by data size)
|
|
1163
1057
|
* @param state The grid metric state
|
|
@@ -1166,8 +1060,6 @@ export class GridMetricCalculator {
|
|
|
1166
1060
|
* @param visibleRowHeights Map of row index to height
|
|
1167
1061
|
* @returns The index of the bottom viewport possible
|
|
1168
1062
|
*/
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
1063
|
getBottomViewport(state, visibleRows, visibleRowYs, visibleRowHeights) {
|
|
1172
1064
|
var {
|
|
1173
1065
|
height,
|
|
@@ -1178,6 +1070,7 @@ export class GridMetricCalculator {
|
|
|
1178
1070
|
} = theme;
|
|
1179
1071
|
return this.getLastIndexViewport(visibleRows, visibleRowYs, visibleRowHeights, height, rowHeight);
|
|
1180
1072
|
}
|
|
1073
|
+
|
|
1181
1074
|
/**
|
|
1182
1075
|
* Retrieve the possible right of the visible viewport (not limited by data size)
|
|
1183
1076
|
* @param state The grid metric state
|
|
@@ -1186,8 +1079,6 @@ export class GridMetricCalculator {
|
|
|
1186
1079
|
* @param visibleColumnWidths Map of column index to width
|
|
1187
1080
|
* @returns The index of the right viewport possible
|
|
1188
1081
|
*/
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
1082
|
getRightViewport(state, visibleColumns, visibleColumnXs, visibleColumnWidths) {
|
|
1192
1083
|
var {
|
|
1193
1084
|
width,
|
|
@@ -1198,6 +1089,7 @@ export class GridMetricCalculator {
|
|
|
1198
1089
|
} = theme;
|
|
1199
1090
|
return this.getLastIndexViewport(visibleColumns, visibleColumnXs, visibleColumnWidths, width, columnWidth);
|
|
1200
1091
|
}
|
|
1092
|
+
|
|
1201
1093
|
/**
|
|
1202
1094
|
* Get the Index of the of the last index visible
|
|
1203
1095
|
* @param items Array of visible item indexes
|
|
@@ -1207,23 +1099,19 @@ export class GridMetricCalculator {
|
|
|
1207
1099
|
* @param defaultItemSize Default size of an item
|
|
1208
1100
|
* @returns The Index of the last index visible
|
|
1209
1101
|
*/
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
1102
|
getLastIndexViewport(items, itemXs, itemSizes, maxSize, defaultItemSize) {
|
|
1213
1103
|
var lastIndex = 0;
|
|
1214
1104
|
var dataSize = 0;
|
|
1215
|
-
|
|
1216
1105
|
if (items.length > 0) {
|
|
1217
1106
|
lastIndex = items[items.length - 1];
|
|
1218
1107
|
dataSize = getOrThrow(itemXs, lastIndex) + getOrThrow(itemSizes, lastIndex);
|
|
1219
1108
|
}
|
|
1220
|
-
|
|
1221
1109
|
if (dataSize < maxSize) {
|
|
1222
1110
|
lastIndex += Math.ceil((maxSize - dataSize) / defaultItemSize);
|
|
1223
1111
|
}
|
|
1224
|
-
|
|
1225
1112
|
return lastIndex;
|
|
1226
1113
|
}
|
|
1114
|
+
|
|
1227
1115
|
/**
|
|
1228
1116
|
* Get the size from the provided size map of the specified item
|
|
1229
1117
|
* @param modelIndex The model index to get the size for
|
|
@@ -1231,27 +1119,24 @@ export class GridMetricCalculator {
|
|
|
1231
1119
|
* @param calculateSize Method to calculate the size for this item
|
|
1232
1120
|
* @returns The size from the provided size map of the specified item
|
|
1233
1121
|
*/
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
1122
|
getVisibleItemSize(modelIndex, userSizes, calculateSize) {
|
|
1237
1123
|
var _userSizes$get;
|
|
1238
|
-
|
|
1239
1124
|
// Always re-calculate the size of the item so the calculated size maps are populated
|
|
1240
1125
|
var calculatedSize = calculateSize();
|
|
1241
1126
|
return (_userSizes$get = userSizes.get(modelIndex)) !== null && _userSizes$get !== void 0 ? _userSizes$get : calculatedSize;
|
|
1242
1127
|
}
|
|
1128
|
+
|
|
1243
1129
|
/**
|
|
1244
1130
|
* Get the height of the specified row
|
|
1245
1131
|
* @param row Index of the row to get the height of
|
|
1246
1132
|
* @param state The grid metric state
|
|
1247
1133
|
* @returns The height of the row specified
|
|
1248
1134
|
*/
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
1135
|
getVisibleRowHeight(row, state) {
|
|
1252
1136
|
var modelRow = this.getModelRow(row, state);
|
|
1253
1137
|
return this.getVisibleItemSize(modelRow, this.userRowHeights, () => this.calculateRowHeight(row, modelRow, state));
|
|
1254
1138
|
}
|
|
1139
|
+
|
|
1255
1140
|
/**
|
|
1256
1141
|
* Get the width of the specified column
|
|
1257
1142
|
* @param column Index of the column to get the width of
|
|
@@ -1260,46 +1145,39 @@ export class GridMetricCalculator {
|
|
|
1260
1145
|
* @param treePaddingX The amount of tree padding to add to the first visible column
|
|
1261
1146
|
* @returns The width of the column
|
|
1262
1147
|
*/
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
1148
|
getVisibleColumnWidth(column, state) {
|
|
1266
1149
|
var firstColumn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.getFirstColumn(state);
|
|
1267
1150
|
var treePaddingX = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : this.calculateTreePaddingX(state);
|
|
1268
1151
|
var modelColumn = this.getModelColumn(column, state);
|
|
1269
1152
|
return this.getVisibleItemSize(modelColumn, this.userColumnWidths, () => this.calculateColumnWidth(column, modelColumn, state, firstColumn, treePaddingX));
|
|
1270
1153
|
}
|
|
1154
|
+
|
|
1271
1155
|
/**
|
|
1272
1156
|
* Get a map of VisibleIndex to ModelIndex
|
|
1273
1157
|
* @param visibleRows Array of visible row indexes
|
|
1274
1158
|
* @param state The grid metric state
|
|
1275
1159
|
* @returns Map of VisibleIndex to ModelIndex
|
|
1276
1160
|
*/
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
1161
|
getModelRows(visibleRows, state) {
|
|
1280
1162
|
var modelRows = new Map();
|
|
1281
|
-
|
|
1282
1163
|
for (var i = 0; i < visibleRows.length; i += 1) {
|
|
1283
1164
|
var visibleRow = visibleRows[i];
|
|
1284
1165
|
var modelRow = this.getModelRow(visibleRow, state);
|
|
1285
1166
|
modelRows.set(visibleRow, modelRow);
|
|
1286
1167
|
}
|
|
1287
|
-
|
|
1288
1168
|
return modelRows;
|
|
1289
1169
|
}
|
|
1170
|
+
|
|
1290
1171
|
/**
|
|
1291
1172
|
* Get the ModelIndex of the specified row
|
|
1292
1173
|
* @param visibleRow Index of the row
|
|
1293
1174
|
* @param state The grid metric state
|
|
1294
1175
|
* @returns ModelIndex of the row
|
|
1295
1176
|
*/
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
1177
|
getModelRow(visibleRow, state) {
|
|
1299
1178
|
if (this.modelRows.has(visibleRow)) {
|
|
1300
1179
|
return getOrThrow(this.modelRows, visibleRow);
|
|
1301
1180
|
}
|
|
1302
|
-
|
|
1303
1181
|
var {
|
|
1304
1182
|
movedRows
|
|
1305
1183
|
} = state;
|
|
@@ -1307,40 +1185,34 @@ export class GridMetricCalculator {
|
|
|
1307
1185
|
this.modelRows.set(visibleRow, modelRow);
|
|
1308
1186
|
return modelRow;
|
|
1309
1187
|
}
|
|
1188
|
+
|
|
1310
1189
|
/**
|
|
1311
1190
|
* Get a map of Index to ModelIndex. Applies the move operations to get the transformation.
|
|
1312
1191
|
* @param visibleColumns Array of visible column indexes
|
|
1313
1192
|
* @param state The grid metric state
|
|
1314
1193
|
* @returns Map of Index to ModelIndex
|
|
1315
1194
|
*/
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
1195
|
getModelColumns(visibleColumns, state) {
|
|
1319
1196
|
var modelColumns = new Map();
|
|
1320
|
-
|
|
1321
1197
|
for (var i = 0; i < visibleColumns.length; i += 1) {
|
|
1322
1198
|
var visibleColumn = visibleColumns[i];
|
|
1323
1199
|
var modelColumn = this.getModelColumn(visibleColumn, state);
|
|
1324
1200
|
modelColumns.set(visibleColumn, modelColumn);
|
|
1325
1201
|
}
|
|
1326
|
-
|
|
1327
1202
|
return modelColumns;
|
|
1328
1203
|
}
|
|
1204
|
+
|
|
1329
1205
|
/**
|
|
1330
1206
|
* Get the ModelIndex of the specified column
|
|
1331
1207
|
* @param visibleColumn Index of the column
|
|
1332
1208
|
* @param state The grid metric state
|
|
1333
1209
|
* @returns ModelIndex of the column
|
|
1334
1210
|
*/
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
1211
|
getModelColumn(visibleColumn, state) {
|
|
1338
1212
|
var hasVisibleColumn = this.modelColumns.has(visibleColumn);
|
|
1339
|
-
|
|
1340
1213
|
if (hasVisibleColumn) {
|
|
1341
1214
|
return getOrThrow(this.modelColumns, visibleColumn);
|
|
1342
1215
|
}
|
|
1343
|
-
|
|
1344
1216
|
var {
|
|
1345
1217
|
movedColumns
|
|
1346
1218
|
} = state;
|
|
@@ -1348,6 +1220,7 @@ export class GridMetricCalculator {
|
|
|
1348
1220
|
this.modelColumns.set(visibleColumn, modelColumn);
|
|
1349
1221
|
return modelColumn;
|
|
1350
1222
|
}
|
|
1223
|
+
|
|
1351
1224
|
/**
|
|
1352
1225
|
* Calculate the height of the row specified.
|
|
1353
1226
|
* @param row Index of the row to calculate the height for
|
|
@@ -1355,8 +1228,6 @@ export class GridMetricCalculator {
|
|
|
1355
1228
|
* @param state The grid metric state
|
|
1356
1229
|
* @returns The height of the row
|
|
1357
1230
|
*/
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
1231
|
calculateRowHeight(row, modelRow, state) {
|
|
1361
1232
|
var {
|
|
1362
1233
|
theme
|
|
@@ -1365,22 +1236,20 @@ export class GridMetricCalculator {
|
|
|
1365
1236
|
autoSizeRows,
|
|
1366
1237
|
rowHeight
|
|
1367
1238
|
} = theme;
|
|
1368
|
-
|
|
1369
1239
|
if (!autoSizeRows) {
|
|
1370
1240
|
return rowHeight;
|
|
1371
1241
|
}
|
|
1372
|
-
|
|
1373
1242
|
var cachedValue = this.calculatedRowHeights.get(modelRow);
|
|
1374
|
-
|
|
1375
1243
|
if (cachedValue != null) {
|
|
1376
1244
|
return cachedValue;
|
|
1377
|
-
}
|
|
1378
|
-
|
|
1245
|
+
}
|
|
1379
1246
|
|
|
1247
|
+
// Not sure how to accurately get the height of text. For now just return the theme height.
|
|
1380
1248
|
this.calculatedRowHeights.set(modelRow, Math.ceil(rowHeight));
|
|
1381
1249
|
trimMap(this.calculatedRowHeights);
|
|
1382
1250
|
return rowHeight;
|
|
1383
1251
|
}
|
|
1252
|
+
|
|
1384
1253
|
/**
|
|
1385
1254
|
* Calculates the column width based on the provided column model index
|
|
1386
1255
|
* @param column Index of the column to calculate the width for
|
|
@@ -1390,8 +1259,6 @@ export class GridMetricCalculator {
|
|
|
1390
1259
|
* @param treePaddingX Tree padding offset for expandable rows
|
|
1391
1260
|
* @returns The width of the column
|
|
1392
1261
|
*/
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
1262
|
calculateColumnWidth(column, modelColumn, state) {
|
|
1396
1263
|
var firstColumn = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : this.getFirstColumn(state);
|
|
1397
1264
|
var treePaddingX = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : this.calculateTreePaddingX(state);
|
|
@@ -1402,41 +1269,35 @@ export class GridMetricCalculator {
|
|
|
1402
1269
|
autoSizeColumns,
|
|
1403
1270
|
minColumnWidth
|
|
1404
1271
|
} = theme;
|
|
1405
|
-
|
|
1406
1272
|
if (!autoSizeColumns) {
|
|
1407
1273
|
var {
|
|
1408
1274
|
columnWidth: _columnWidth
|
|
1409
1275
|
} = theme;
|
|
1410
1276
|
return _columnWidth;
|
|
1411
1277
|
}
|
|
1412
|
-
|
|
1413
1278
|
var headerWidth = this.calculateColumnHeaderWidth(modelColumn, state);
|
|
1414
1279
|
var dataWidth = this.calculateColumnDataWidth(modelColumn, state);
|
|
1415
1280
|
var cachedValue = this.calculatedColumnWidths.get(modelColumn);
|
|
1416
1281
|
var columnWidth = Math.ceil(Math.max(headerWidth, dataWidth));
|
|
1417
1282
|
columnWidth = Math.max(minColumnWidth, columnWidth);
|
|
1418
|
-
|
|
1419
1283
|
if (cachedValue != null && cachedValue > columnWidth) {
|
|
1420
1284
|
columnWidth = cachedValue;
|
|
1421
1285
|
} else {
|
|
1422
1286
|
this.calculatedColumnWidths.set(modelColumn, columnWidth);
|
|
1423
1287
|
trimMap(this.calculatedColumnWidths);
|
|
1424
1288
|
}
|
|
1425
|
-
|
|
1426
1289
|
if (column === firstColumn) {
|
|
1427
1290
|
columnWidth += treePaddingX;
|
|
1428
1291
|
}
|
|
1429
|
-
|
|
1430
1292
|
return columnWidth;
|
|
1431
1293
|
}
|
|
1294
|
+
|
|
1432
1295
|
/**
|
|
1433
1296
|
* Calculate the width of the specified column's header
|
|
1434
1297
|
* @param modelColumn ModelIndex of the column to get the header width for
|
|
1435
1298
|
* @param state The grid metric state
|
|
1436
1299
|
* @returns The calculated width of the column header
|
|
1437
1300
|
*/
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
1301
|
calculateColumnHeaderWidth(modelColumn, state) {
|
|
1441
1302
|
var {
|
|
1442
1303
|
model,
|
|
@@ -1447,22 +1308,19 @@ export class GridMetricCalculator {
|
|
|
1447
1308
|
headerHorizontalPadding
|
|
1448
1309
|
} = theme;
|
|
1449
1310
|
var headerText = model.textForColumnHeader(modelColumn, 0);
|
|
1450
|
-
|
|
1451
1311
|
if (headerText !== undefined && headerText !== '') {
|
|
1452
1312
|
var headerFontWidth = this.getWidthForFont(headerFont, state);
|
|
1453
1313
|
return headerText.length * headerFontWidth + headerHorizontalPadding * 2;
|
|
1454
1314
|
}
|
|
1455
|
-
|
|
1456
1315
|
return headerHorizontalPadding * 2;
|
|
1457
1316
|
}
|
|
1317
|
+
|
|
1458
1318
|
/**
|
|
1459
1319
|
* Calculate the width of the specified column's data
|
|
1460
1320
|
* @param modelColumn ModelIndex of the column to get the data width for
|
|
1461
1321
|
* @param state The grid metric state
|
|
1462
1322
|
* @returns The calculated width of the column data
|
|
1463
1323
|
*/
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
1324
|
calculateColumnDataWidth(modelColumn, state) {
|
|
1467
1325
|
var {
|
|
1468
1326
|
top,
|
|
@@ -1491,7 +1349,6 @@ export class GridMetricCalculator {
|
|
|
1491
1349
|
GridUtils.iterateAllItems(top, bottom, floatingTopRowCount, floatingBottomRowCount, rowCount, row => {
|
|
1492
1350
|
var modelRow = this.getModelRow(row, state);
|
|
1493
1351
|
var text = model.textForCell(modelColumn, modelRow);
|
|
1494
|
-
|
|
1495
1352
|
if (text) {
|
|
1496
1353
|
var cellPadding = cellHorizontalPadding * 2;
|
|
1497
1354
|
columnWidth = Math.max(columnWidth, text.length * fontWidth + cellPadding);
|
|
@@ -1500,13 +1357,12 @@ export class GridMetricCalculator {
|
|
|
1500
1357
|
columnWidth = Math.max(Math.min(columnWidth, (width - rowHeaderWidth - scrollBarSize - rowFooterWidth) * GridMetricCalculator.MAX_COLUMN_WIDTH), cellHorizontalPadding * 2);
|
|
1501
1358
|
return columnWidth;
|
|
1502
1359
|
}
|
|
1360
|
+
|
|
1503
1361
|
/**
|
|
1504
1362
|
* The coordinate for where the tree padding should be drawn
|
|
1505
1363
|
* @param state The grid metric state
|
|
1506
1364
|
* @returns The coordinate for tree padding
|
|
1507
1365
|
*/
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
1366
|
calculateTreePaddingX(state) {
|
|
1511
1367
|
var {
|
|
1512
1368
|
top,
|
|
@@ -1518,23 +1374,20 @@ export class GridMetricCalculator {
|
|
|
1518
1374
|
rowHeight,
|
|
1519
1375
|
treeDepthIndent
|
|
1520
1376
|
} = theme;
|
|
1521
|
-
|
|
1522
1377
|
if (!isExpandableGridModel(model) || !model.hasExpandableRows) {
|
|
1523
1378
|
return 0;
|
|
1524
1379
|
}
|
|
1525
|
-
|
|
1526
1380
|
var treePadding = 0;
|
|
1527
1381
|
var rowsPerPage = height / rowHeight;
|
|
1528
1382
|
var bottom = Math.ceil(top + rowsPerPage);
|
|
1529
|
-
|
|
1530
1383
|
for (var row = top; row <= bottom; row += 1) {
|
|
1531
1384
|
var modelRow = this.getModelRow(row, state);
|
|
1532
1385
|
var depth = model.depthForRow(modelRow);
|
|
1533
1386
|
treePadding = Math.max(treePadding, treeDepthIndent * (depth + 1));
|
|
1534
1387
|
}
|
|
1535
|
-
|
|
1536
1388
|
return treePadding;
|
|
1537
1389
|
}
|
|
1390
|
+
|
|
1538
1391
|
/**
|
|
1539
1392
|
* Get the width of the provided font. Exploits the fact that we're
|
|
1540
1393
|
* using tabular figures so every character is same width
|
|
@@ -1542,13 +1395,10 @@ export class GridMetricCalculator {
|
|
|
1542
1395
|
* @param state The grid metric state
|
|
1543
1396
|
* @returns Width of the char `8` for the specified font
|
|
1544
1397
|
*/
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
1398
|
getWidthForFont(font, state) {
|
|
1548
1399
|
if (this.fontWidths.has(font)) {
|
|
1549
1400
|
return getOrThrow(this.fontWidths, font);
|
|
1550
1401
|
}
|
|
1551
|
-
|
|
1552
1402
|
var {
|
|
1553
1403
|
context
|
|
1554
1404
|
} = state;
|
|
@@ -1556,20 +1406,20 @@ export class GridMetricCalculator {
|
|
|
1556
1406
|
var textMetrics = context.measureText('8');
|
|
1557
1407
|
var {
|
|
1558
1408
|
width
|
|
1559
|
-
} = textMetrics;
|
|
1560
|
-
// Rather than require checking with the correct font def (theme, or context font), just key it to both
|
|
1409
|
+
} = textMetrics;
|
|
1561
1410
|
|
|
1411
|
+
// context.font changes the string a little bit, e.g. '10px Arial, sans serif' => '10px Arial, "sans serif"'
|
|
1412
|
+
// Rather than require checking with the correct font def (theme, or context font), just key it to both
|
|
1562
1413
|
this.fontWidths.set(font, width);
|
|
1563
1414
|
this.fontWidths.set(context.font, width);
|
|
1564
1415
|
return width;
|
|
1565
1416
|
}
|
|
1417
|
+
|
|
1566
1418
|
/**
|
|
1567
1419
|
* Sets the width for the specified column
|
|
1568
1420
|
* @param column The column model index to set
|
|
1569
1421
|
* @param size The size to set it to
|
|
1570
1422
|
*/
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
1423
|
setColumnWidth(column, size) {
|
|
1574
1424
|
// Always use a new instance of the map so any consumer of the metrics knows there has been a change
|
|
1575
1425
|
var userColumnWidths = new Map(this.userColumnWidths);
|
|
@@ -1577,25 +1427,23 @@ export class GridMetricCalculator {
|
|
|
1577
1427
|
trimMap(userColumnWidths);
|
|
1578
1428
|
this.userColumnWidths = userColumnWidths;
|
|
1579
1429
|
}
|
|
1430
|
+
|
|
1580
1431
|
/**
|
|
1581
1432
|
* Resets the column width for the specified column to the calculated width
|
|
1582
1433
|
* @param column The column model index to reset
|
|
1583
1434
|
*/
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
1435
|
resetColumnWidth(column) {
|
|
1587
1436
|
// Always use a new instance of the map so any consumer of the metrics knows there has been a change
|
|
1588
1437
|
var userColumnWidths = new Map(this.userColumnWidths);
|
|
1589
1438
|
userColumnWidths.delete(column);
|
|
1590
1439
|
this.userColumnWidths = userColumnWidths;
|
|
1591
1440
|
}
|
|
1441
|
+
|
|
1592
1442
|
/**
|
|
1593
1443
|
* Sets the width for the specified row
|
|
1594
1444
|
* @param row The row model index to set
|
|
1595
1445
|
* @param size The size to set it to
|
|
1596
1446
|
*/
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
1447
|
setRowHeight(row, size) {
|
|
1600
1448
|
// Always use a new instance of the map so any consumer of the metrics knows there has been a change
|
|
1601
1449
|
var userRowHeights = new Map(this.userRowHeights);
|
|
@@ -1603,12 +1451,11 @@ export class GridMetricCalculator {
|
|
|
1603
1451
|
trimMap(userRowHeights);
|
|
1604
1452
|
this.userRowHeights = userRowHeights;
|
|
1605
1453
|
}
|
|
1454
|
+
|
|
1606
1455
|
/**
|
|
1607
1456
|
* Resets the row height for the specified row to the calculated height
|
|
1608
1457
|
* @param row The row model index to reset
|
|
1609
1458
|
*/
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
1459
|
resetRowHeight(row) {
|
|
1613
1460
|
// Always use a new instance of the map so any consumer of the metrics knows there has been a change
|
|
1614
1461
|
var userRowHeights = new Map(this.userRowHeights);
|
|
@@ -1616,12 +1463,8 @@ export class GridMetricCalculator {
|
|
|
1616
1463
|
this.userRowHeights = userRowHeights;
|
|
1617
1464
|
this.calculatedRowHeights.delete(row);
|
|
1618
1465
|
}
|
|
1619
|
-
|
|
1620
1466
|
}
|
|
1621
|
-
|
|
1622
1467
|
_defineProperty(GridMetricCalculator, "CACHE_SIZE", 10000);
|
|
1623
|
-
|
|
1624
1468
|
_defineProperty(GridMetricCalculator, "MAX_COLUMN_WIDTH", 0.8);
|
|
1625
|
-
|
|
1626
1469
|
export default GridMetricCalculator;
|
|
1627
1470
|
//# sourceMappingURL=GridMetricCalculator.js.map
|