@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
package/dist/GridRenderer.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
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 { ColorUtils } from '@deephaven/utils';
|
|
5
4
|
import memoizeClear from "./memoizeClear.js";
|
|
@@ -9,13 +8,9 @@ import { isExpandableGridModel } from "./ExpandableGridModel.js";
|
|
|
9
8
|
import { getOrThrow } from "./GridMetricCalculator.js";
|
|
10
9
|
import { isEditableGridModel } from "./EditableGridModel.js";
|
|
11
10
|
import GridColumnSeparatorMouseHandler from "./mouse-handlers/GridColumnSeparatorMouseHandler.js";
|
|
12
|
-
|
|
13
11
|
/* eslint react/destructuring-assignment: "off" */
|
|
14
|
-
|
|
15
12
|
/* eslint class-methods-use-this: "off" */
|
|
16
|
-
|
|
17
13
|
/* eslint no-param-reassign: "off" */
|
|
18
|
-
|
|
19
14
|
/**
|
|
20
15
|
* A GridRenderer handles rendering the different parts of the grid
|
|
21
16
|
* This default rendering just renders a basic grid. Extend this class and implement
|
|
@@ -26,28 +21,22 @@ export class GridRenderer {
|
|
|
26
21
|
_defineProperty(this, "getCachedTruncatedString", memoizeClear((context, text, width, fontWidth, truncationChar) => GridRenderer.truncateToWidth(context, text, width, fontWidth, truncationChar), {
|
|
27
22
|
max: 10000
|
|
28
23
|
}));
|
|
29
|
-
|
|
30
24
|
_defineProperty(this, "getCachedBackgroundColors", memoizeClear((backgroundColors, maxDepth) => backgroundColors.split(' ').map(color => {
|
|
31
25
|
var colors = [];
|
|
32
|
-
|
|
33
26
|
for (var i = 0; i < maxDepth; i += 1) {
|
|
34
27
|
colors.push(GridColorUtils.darkenForDepth(color, i, maxDepth));
|
|
35
28
|
}
|
|
36
|
-
|
|
37
29
|
return colors;
|
|
38
30
|
}), {
|
|
39
31
|
max: 1000
|
|
40
32
|
}));
|
|
41
|
-
|
|
42
33
|
_defineProperty(this, "getCachedColorWithAlpha", memoizeClear((color, alpha) => GridColorUtils.colorWithAlpha(color, alpha), {
|
|
43
34
|
max: 1000
|
|
44
35
|
}));
|
|
45
|
-
|
|
46
36
|
_defineProperty(this, "getCachedColorIsDark", memoizeClear(color => ColorUtils.isDark(color), {
|
|
47
37
|
max: 1000
|
|
48
38
|
}));
|
|
49
39
|
}
|
|
50
|
-
|
|
51
40
|
/**
|
|
52
41
|
* Truncate a string to the specified length and add ellipses if necessary
|
|
53
42
|
* @param str The string to truncate
|
|
@@ -59,9 +48,9 @@ export class GridRenderer {
|
|
|
59
48
|
// eslint-disable-next-line prefer-template
|
|
60
49
|
return str.substr(0, len) + '…';
|
|
61
50
|
}
|
|
62
|
-
|
|
63
51
|
return str;
|
|
64
52
|
}
|
|
53
|
+
|
|
65
54
|
/**
|
|
66
55
|
* Uses binary search to truncate a string to fit in the provided width
|
|
67
56
|
* @param context The drawing context to measure the text in
|
|
@@ -72,13 +61,10 @@ export class GridRenderer {
|
|
|
72
61
|
* @param truncationChar This char will be repeated as the display string if the string is truncated instead of just adding an ellipsis
|
|
73
62
|
* @returns The truncated string
|
|
74
63
|
*/
|
|
75
|
-
|
|
76
|
-
|
|
77
64
|
static binaryTruncateToWidth(context, str, width) {
|
|
78
65
|
var start = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
79
66
|
var end = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : str.length;
|
|
80
67
|
var truncationChar = arguments.length > 5 ? arguments[5] : undefined;
|
|
81
|
-
|
|
82
68
|
if (end >= str.length && context.measureText(str).width <= width) {
|
|
83
69
|
// IDS-6069 If the whole string can fit, don't bother checking for truncation
|
|
84
70
|
// The ellipses are actually slightly wider than other chars, and it's possible
|
|
@@ -87,27 +73,21 @@ export class GridRenderer {
|
|
|
87
73
|
// Besides, if we already fit, it's just faster to not bother checking other truncations.
|
|
88
74
|
return str;
|
|
89
75
|
}
|
|
90
|
-
|
|
91
76
|
if (truncationChar !== undefined) {
|
|
92
77
|
var charWidth = context.measureText(truncationChar).width;
|
|
93
78
|
return truncationChar.repeat(Math.max(1, Math.floor(width / charWidth)));
|
|
94
79
|
}
|
|
95
|
-
|
|
96
80
|
var lo = start;
|
|
97
81
|
var hi = Math.min(str.length - 1, end);
|
|
98
82
|
var result = str;
|
|
99
|
-
|
|
100
83
|
while (hi >= lo) {
|
|
101
84
|
var mid = Math.ceil((hi + lo) / 2);
|
|
102
85
|
var truncatedStr = GridRenderer.truncate(str, mid);
|
|
103
|
-
|
|
104
86
|
if (context.measureText(truncatedStr).width <= width) {
|
|
105
87
|
result = truncatedStr;
|
|
106
|
-
|
|
107
88
|
if (lo === mid) {
|
|
108
89
|
break;
|
|
109
90
|
}
|
|
110
|
-
|
|
111
91
|
lo = mid;
|
|
112
92
|
} else if (mid === 0) {
|
|
113
93
|
// We already truncated to zero chars and it still doesn't fit, no need to keep looking
|
|
@@ -117,9 +97,9 @@ export class GridRenderer {
|
|
|
117
97
|
hi = mid - 1;
|
|
118
98
|
}
|
|
119
99
|
}
|
|
120
|
-
|
|
121
100
|
return result;
|
|
122
101
|
}
|
|
102
|
+
|
|
123
103
|
/**
|
|
124
104
|
* Truncate a string (if necessary) to fit in the specified width.
|
|
125
105
|
* First uses the estimated font width to calculate a lower/upper bound
|
|
@@ -131,29 +111,25 @@ export class GridRenderer {
|
|
|
131
111
|
* @param truncationChar This char will be repeated as the display string if the string is truncated instead of just adding an ellipsis
|
|
132
112
|
* @returns The truncated string that fits within the width provided
|
|
133
113
|
*/
|
|
134
|
-
|
|
135
|
-
|
|
136
114
|
static truncateToWidth(context, str, width) {
|
|
137
115
|
var fontWidth = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : GridRenderer.DEFAULT_FONT_WIDTH;
|
|
138
116
|
var truncationChar = arguments.length > 4 ? arguments[4] : undefined;
|
|
139
|
-
|
|
140
117
|
if (width <= 0 || str.length <= 0) {
|
|
141
118
|
return '';
|
|
142
|
-
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Estimate the possible low and high boundaries for truncating the text
|
|
143
122
|
// Use the width of the space divided by the estimated width of each character,
|
|
144
123
|
// and take half that as the low (minus 5 just to be extra safe), and double that as the high.
|
|
145
|
-
|
|
146
|
-
|
|
147
124
|
var lo = Math.min(Math.max(0, Math.floor(width / fontWidth / 2) - 5), str.length);
|
|
148
125
|
var hi = Math.min(Math.ceil(width / fontWidth * 2), str.length);
|
|
149
126
|
return GridRenderer.binaryTruncateToWidth(context, str, width, lo, hi, truncationChar);
|
|
150
127
|
}
|
|
128
|
+
|
|
151
129
|
/**
|
|
152
130
|
* Draw the grid canvas with the state provided
|
|
153
131
|
* @param state The state of the grid
|
|
154
132
|
*/
|
|
155
|
-
|
|
156
|
-
|
|
157
133
|
drawCanvas(state) {
|
|
158
134
|
var {
|
|
159
135
|
context
|
|
@@ -169,7 +145,6 @@ export class GridRenderer {
|
|
|
169
145
|
this.drawScrollBars(context, state);
|
|
170
146
|
context.restore();
|
|
171
147
|
}
|
|
172
|
-
|
|
173
148
|
configureContext(context, state) {
|
|
174
149
|
var {
|
|
175
150
|
theme
|
|
@@ -178,7 +153,6 @@ export class GridRenderer {
|
|
|
178
153
|
context.textBaseline = 'middle';
|
|
179
154
|
context.lineCap = 'butt';
|
|
180
155
|
}
|
|
181
|
-
|
|
182
156
|
drawBackground(context, state) {
|
|
183
157
|
var {
|
|
184
158
|
theme,
|
|
@@ -191,7 +165,6 @@ export class GridRenderer {
|
|
|
191
165
|
context.fillStyle = theme.backgroundColor;
|
|
192
166
|
context.fillRect(0, 0, width, height);
|
|
193
167
|
}
|
|
194
|
-
|
|
195
168
|
drawGrid(context, state) {
|
|
196
169
|
var {
|
|
197
170
|
metrics,
|
|
@@ -209,7 +182,6 @@ export class GridRenderer {
|
|
|
209
182
|
this.drawFloatingColumns(context, state);
|
|
210
183
|
context.translate(-gridX, -gridY);
|
|
211
184
|
}
|
|
212
|
-
|
|
213
185
|
drawFloatingRows(context, state) {
|
|
214
186
|
var {
|
|
215
187
|
draggingRow,
|
|
@@ -226,23 +198,20 @@ export class GridRenderer {
|
|
|
226
198
|
visibleRowYs,
|
|
227
199
|
visibleRowHeights
|
|
228
200
|
} = metrics;
|
|
229
|
-
|
|
230
201
|
if (floatingRows.length === 0) {
|
|
231
202
|
return;
|
|
232
203
|
}
|
|
233
|
-
|
|
234
204
|
if (theme.floatingRowBackgroundColors) {
|
|
235
205
|
this.drawRowStripesForRows(context, state, floatingRows, theme.floatingRowBackgroundColors);
|
|
236
206
|
}
|
|
237
|
-
|
|
238
207
|
if (draggingRow == null && draggingColumn == null) {
|
|
239
208
|
this.drawFloatingMouseRowHover(context, state);
|
|
240
209
|
}
|
|
241
|
-
|
|
242
210
|
this.drawGridLinesForItems(context, state, visibleColumns, floatingRows, theme.floatingGridColumnColor, theme.floatingGridRowColor);
|
|
243
211
|
this.drawCellBackgroundsForItems(context, state, visibleColumns, floatingRows);
|
|
244
|
-
this.drawFloatingBorders(context, state);
|
|
212
|
+
this.drawFloatingBorders(context, state);
|
|
245
213
|
|
|
214
|
+
// Draw the floating row selection...
|
|
246
215
|
if (floatingTopRowCount > 0) {
|
|
247
216
|
this.drawSelectedRanges(context, state, {
|
|
248
217
|
top: 0,
|
|
@@ -250,7 +219,6 @@ export class GridRenderer {
|
|
|
250
219
|
maxY: getOrThrow(visibleRowYs, floatingTopRowCount - 1) + getOrThrow(visibleRowHeights, floatingTopRowCount - 1) - 0.5
|
|
251
220
|
});
|
|
252
221
|
}
|
|
253
|
-
|
|
254
222
|
if (floatingBottomRowCount > 0) {
|
|
255
223
|
this.drawSelectedRanges(context, state, {
|
|
256
224
|
top: rowCount - floatingBottomRowCount - 1,
|
|
@@ -258,19 +226,17 @@ export class GridRenderer {
|
|
|
258
226
|
minY: getOrThrow(visibleRowYs, rowCount - floatingBottomRowCount) + 0.5,
|
|
259
227
|
maxY: getOrThrow(visibleRowYs, rowCount - 1) + getOrThrow(visibleRowHeights, rowCount - 1) - 0.5
|
|
260
228
|
});
|
|
261
|
-
}
|
|
262
|
-
|
|
229
|
+
}
|
|
263
230
|
|
|
231
|
+
// Draw the cell content...
|
|
264
232
|
for (var c = 0; c < visibleColumns.length; c += 1) {
|
|
265
233
|
var column = visibleColumns[c];
|
|
266
|
-
|
|
267
234
|
for (var r = 0; r < floatingRows.length; r += 1) {
|
|
268
235
|
var row = floatingRows[r];
|
|
269
236
|
this.drawCellContent(context, state, column, row);
|
|
270
237
|
}
|
|
271
238
|
}
|
|
272
239
|
}
|
|
273
|
-
|
|
274
240
|
drawFloatingColumns(context, state) {
|
|
275
241
|
var {
|
|
276
242
|
draggingRow,
|
|
@@ -293,21 +259,18 @@ export class GridRenderer {
|
|
|
293
259
|
width,
|
|
294
260
|
height
|
|
295
261
|
} = metrics;
|
|
296
|
-
|
|
297
262
|
if (floatingColumns.length === 0) {
|
|
298
263
|
return;
|
|
299
264
|
}
|
|
300
|
-
|
|
301
265
|
if (theme.floatingRowBackgroundColors) {
|
|
302
266
|
this.drawRowStripesForRows(context, state, visibleRows, theme.floatingRowBackgroundColors, 0, floatingLeftWidth);
|
|
303
267
|
this.drawRowStripesForRows(context, state, visibleRows, theme.floatingRowBackgroundColors, width - gridX - floatingRightWidth, maxX);
|
|
304
268
|
}
|
|
305
|
-
|
|
306
269
|
if (draggingRow == null && draggingColumn == null) {
|
|
307
270
|
this.drawFloatingMouseRowHover(context, state);
|
|
308
|
-
}
|
|
309
|
-
|
|
271
|
+
}
|
|
310
272
|
|
|
273
|
+
// Clip floated column grid lines.
|
|
311
274
|
context.save();
|
|
312
275
|
context.beginPath();
|
|
313
276
|
context.rect(0, 0, floatingLeftWidth, height);
|
|
@@ -315,15 +278,15 @@ export class GridRenderer {
|
|
|
315
278
|
this.drawGridLinesForItems(context, state, floatingColumns, visibleRows, theme.floatingGridColumnColor, theme.floatingGridRowColor);
|
|
316
279
|
context.restore();
|
|
317
280
|
this.drawCellBackgroundsForItems(context, state, floatingColumns, visibleRows);
|
|
318
|
-
this.drawFloatingBorders(context, state);
|
|
281
|
+
this.drawFloatingBorders(context, state);
|
|
319
282
|
|
|
283
|
+
// Draw the floating column selection...
|
|
320
284
|
if (floatingLeftColumnCount > 0) {
|
|
321
285
|
this.drawSelectedRanges(context, state, {
|
|
322
286
|
left: 0,
|
|
323
287
|
maxX: getOrThrow(visibleColumnXs, floatingLeftColumnCount - 1) + getOrThrow(visibleColumnWidths, floatingLeftColumnCount - 1)
|
|
324
288
|
});
|
|
325
289
|
}
|
|
326
|
-
|
|
327
290
|
if (floatingRightColumnCount > 0) {
|
|
328
291
|
this.drawSelectedRanges(context, state, {
|
|
329
292
|
left: columnCount - floatingRightColumnCount,
|
|
@@ -331,19 +294,17 @@ export class GridRenderer {
|
|
|
331
294
|
minX: getOrThrow(visibleColumnXs, columnCount - floatingRightColumnCount) + 0.5,
|
|
332
295
|
maxX: getOrThrow(visibleColumnXs, columnCount - 1) + getOrThrow(visibleColumnWidths, columnCount - 1)
|
|
333
296
|
});
|
|
334
|
-
}
|
|
335
|
-
|
|
297
|
+
}
|
|
336
298
|
|
|
299
|
+
// Draw the cell content...
|
|
337
300
|
for (var c = 0; c < floatingColumns.length; c += 1) {
|
|
338
301
|
var column = floatingColumns[c];
|
|
339
|
-
|
|
340
302
|
for (var r = 0; r < visibleRows.length; r += 1) {
|
|
341
303
|
var row = visibleRows[r];
|
|
342
304
|
this.drawCellContent(context, state, column, row);
|
|
343
305
|
}
|
|
344
306
|
}
|
|
345
307
|
}
|
|
346
|
-
|
|
347
308
|
drawFloatingBorders(context, state) {
|
|
348
309
|
var {
|
|
349
310
|
metrics,
|
|
@@ -370,78 +331,59 @@ export class GridRenderer {
|
|
|
370
331
|
context.lineWidth = 3;
|
|
371
332
|
context.beginPath();
|
|
372
333
|
context.strokeStyle = floatingDividerOuterColor;
|
|
373
|
-
|
|
374
334
|
if (floatingTopRowCount > 0) {
|
|
375
335
|
var y = getOrThrow(visibleRowYs, floatingTopRowCount - 1) + getOrThrow(visibleRowHeights, floatingTopRowCount - 1) + 0.5;
|
|
376
336
|
context.moveTo(0, y);
|
|
377
337
|
context.lineTo(maxX, y);
|
|
378
338
|
}
|
|
379
|
-
|
|
380
339
|
if (floatingBottomRowCount > 0) {
|
|
381
340
|
var _y = getOrThrow(visibleRowYs, rowCount - floatingBottomRowCount) - 0.5;
|
|
382
|
-
|
|
383
341
|
context.moveTo(0, _y);
|
|
384
342
|
context.lineTo(maxX, _y);
|
|
385
343
|
}
|
|
386
|
-
|
|
387
344
|
if (floatingLeftColumnCount > 0) {
|
|
388
345
|
var x = getOrThrow(visibleColumnXs, floatingLeftColumnCount - 1) + getOrThrow(visibleColumnWidths, floatingLeftColumnCount - 1) + 0.5;
|
|
389
346
|
context.moveTo(x, 0);
|
|
390
347
|
context.lineTo(x, maxY);
|
|
391
348
|
}
|
|
392
|
-
|
|
393
349
|
if (floatingRightColumnCount > 0) {
|
|
394
350
|
var _x = getOrThrow(visibleColumnXs, columnCount - floatingRightColumnCount) - 0.5;
|
|
395
|
-
|
|
396
351
|
context.moveTo(_x, 0);
|
|
397
352
|
context.lineTo(_x, maxY);
|
|
398
353
|
}
|
|
399
|
-
|
|
400
354
|
context.stroke();
|
|
401
355
|
context.beginPath();
|
|
402
356
|
context.lineWidth = 1;
|
|
403
357
|
context.strokeStyle = floatingDividerInnerColor;
|
|
404
|
-
|
|
405
358
|
if (floatingTopRowCount > 0) {
|
|
406
359
|
var _y2 = getOrThrow(visibleRowYs, floatingTopRowCount - 1) + getOrThrow(visibleRowHeights, floatingTopRowCount - 1) + 0.5;
|
|
407
|
-
|
|
408
360
|
context.moveTo(0, _y2);
|
|
409
361
|
context.lineTo(maxX, _y2);
|
|
410
362
|
}
|
|
411
|
-
|
|
412
363
|
if (floatingBottomRowCount > 0) {
|
|
413
364
|
var _y3 = getOrThrow(visibleRowYs, rowCount - floatingBottomRowCount) - 0.5;
|
|
414
|
-
|
|
415
365
|
context.moveTo(0, _y3);
|
|
416
366
|
context.lineTo(maxX, _y3);
|
|
417
367
|
}
|
|
418
|
-
|
|
419
368
|
if (floatingLeftColumnCount > 0) {
|
|
420
369
|
var _x2 = getOrThrow(visibleColumnXs, floatingLeftColumnCount - 1) + getOrThrow(visibleColumnWidths, floatingLeftColumnCount - 1) + 0.5;
|
|
421
|
-
|
|
422
370
|
context.moveTo(_x2, 0);
|
|
423
371
|
context.lineTo(_x2, maxY);
|
|
424
372
|
}
|
|
425
|
-
|
|
426
373
|
if (floatingRightColumnCount > 0) {
|
|
427
374
|
var _x3 = getOrThrow(visibleColumnXs, columnCount - floatingRightColumnCount) - 0.5;
|
|
428
|
-
|
|
429
375
|
context.moveTo(_x3, 0);
|
|
430
376
|
context.lineTo(_x3, maxY);
|
|
431
377
|
}
|
|
432
|
-
|
|
433
378
|
context.stroke();
|
|
434
379
|
}
|
|
435
|
-
|
|
436
380
|
drawGridBackground(context, state) {
|
|
437
381
|
var drawHover = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
438
382
|
this.drawRowStripes(context, state);
|
|
439
|
-
|
|
440
383
|
if (drawHover) {
|
|
441
384
|
this.drawMouseColumnHover(context, state);
|
|
442
385
|
this.drawMouseRowHover(context, state);
|
|
443
386
|
}
|
|
444
|
-
|
|
445
387
|
this.drawGridLines(context, state);
|
|
446
388
|
this.drawCellBackgrounds(context, state);
|
|
447
389
|
var {
|
|
@@ -472,7 +414,6 @@ export class GridRenderer {
|
|
|
472
414
|
maxY: floatingBottomRowCount > 0 && visibleRowYs.has(rowCount - floatingBottomRowCount - 1) ? getOrThrow(visibleRowYs, rowCount - floatingBottomRowCount - 1) + getOrThrow(visibleRowHeights, rowCount - floatingBottomRowCount - 1) - 0.5 : height + 10
|
|
473
415
|
});
|
|
474
416
|
}
|
|
475
|
-
|
|
476
417
|
drawRowStripes(context, state) {
|
|
477
418
|
var {
|
|
478
419
|
metrics,
|
|
@@ -484,14 +425,11 @@ export class GridRenderer {
|
|
|
484
425
|
var {
|
|
485
426
|
rowBackgroundColors
|
|
486
427
|
} = theme;
|
|
487
|
-
|
|
488
428
|
if (!rowBackgroundColors) {
|
|
489
429
|
return;
|
|
490
430
|
}
|
|
491
|
-
|
|
492
431
|
this.drawRowStripesForRows(context, state, visibleRows, rowBackgroundColors);
|
|
493
432
|
}
|
|
494
|
-
|
|
495
433
|
drawRowStripesForRows(context, state, rows, rowBackgroundColors) {
|
|
496
434
|
var minX = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
|
|
497
435
|
var maxX = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : state.metrics.maxX;
|
|
@@ -509,56 +447,47 @@ export class GridRenderer {
|
|
|
509
447
|
var {
|
|
510
448
|
visibleRowYs,
|
|
511
449
|
visibleRowHeights
|
|
512
|
-
} = metrics;
|
|
450
|
+
} = metrics;
|
|
513
451
|
|
|
452
|
+
// Optimize by grouping together all rows that end up with the same color
|
|
514
453
|
var colorRowMap = new Map();
|
|
515
454
|
var topShadowRows = []; // Rows that are deeper than the row above them
|
|
516
|
-
|
|
517
455
|
var bottomShadowRows = [];
|
|
518
|
-
|
|
519
456
|
var addRowToColorMap = (row, rowAbove) => {
|
|
520
457
|
var depth = isExpandableGridModel(model) ? model.depthForRow(row) : 0;
|
|
521
458
|
var colorSet = colorSets[row % colorSets.length];
|
|
522
459
|
var color = colorSet[Math.min(depth, colorSet.length - 1)];
|
|
523
|
-
|
|
524
460
|
if (!colorRowMap.has(color)) {
|
|
525
461
|
colorRowMap.set(color, []);
|
|
526
462
|
}
|
|
527
|
-
|
|
528
463
|
colorRowMap.get(color).push(row);
|
|
529
|
-
|
|
530
464
|
if (rowAbove != null) {
|
|
531
465
|
var depthAbove = isExpandableGridModel(model) ? model.depthForRow(rowAbove) : 0;
|
|
532
|
-
|
|
533
466
|
if (depthAbove < depth) {
|
|
534
467
|
topShadowRows.push(row);
|
|
535
468
|
} else if (depthAbove > depth) {
|
|
536
469
|
bottomShadowRows.push(rowAbove);
|
|
537
470
|
}
|
|
538
471
|
}
|
|
539
|
-
};
|
|
540
|
-
|
|
472
|
+
};
|
|
541
473
|
|
|
474
|
+
// Add all the regular row stripes
|
|
542
475
|
for (var i = 0; i < rows.length; i += 1) {
|
|
543
476
|
var row = rows[i];
|
|
544
477
|
var rowAbove = i > 0 ? rows[i - 1] : undefined;
|
|
545
478
|
addRowToColorMap(row, rowAbove);
|
|
546
479
|
}
|
|
547
|
-
|
|
548
480
|
colorRowMap.forEach((colorRows, color) => {
|
|
549
481
|
context.fillStyle = color;
|
|
550
482
|
context.beginPath();
|
|
551
|
-
|
|
552
483
|
for (var _i = 0; _i < colorRows.length; _i += 1) {
|
|
553
484
|
var _row = colorRows[_i];
|
|
554
485
|
var y = getOrThrow(visibleRowYs, _row);
|
|
555
486
|
var rowHeight = getOrThrow(visibleRowHeights, _row);
|
|
556
487
|
context.rect(minX, y, maxX, rowHeight);
|
|
557
488
|
}
|
|
558
|
-
|
|
559
489
|
context.fill();
|
|
560
490
|
});
|
|
561
|
-
|
|
562
491
|
if (topShadowRows.length > 0) {
|
|
563
492
|
context.save();
|
|
564
493
|
var startColor = this.getCachedColorWithAlpha(shadowColor, 0.15);
|
|
@@ -567,51 +496,37 @@ export class GridRenderer {
|
|
|
567
496
|
gradient.addColorStop(0, startColor);
|
|
568
497
|
gradient.addColorStop(1, endColor);
|
|
569
498
|
context.fillStyle = gradient;
|
|
570
|
-
|
|
571
499
|
for (var _i2 = 0; _i2 < topShadowRows.length; _i2 += 1) {
|
|
572
500
|
var _row2 = topShadowRows[_i2];
|
|
573
|
-
var y = getOrThrow(visibleRowYs, _row2);
|
|
574
|
-
|
|
501
|
+
var y = getOrThrow(visibleRowYs, _row2);
|
|
502
|
+
// Use a translate so we can reuse the gradient
|
|
575
503
|
context.translate(0, y);
|
|
576
504
|
context.fillRect(minX, 0, maxX, shadowBlur);
|
|
577
505
|
context.translate(0, -y);
|
|
578
506
|
}
|
|
579
|
-
|
|
580
507
|
context.restore();
|
|
581
508
|
}
|
|
582
|
-
|
|
583
509
|
if (bottomShadowRows.length > 0) {
|
|
584
510
|
context.save();
|
|
585
|
-
|
|
586
511
|
var _startColor = this.getCachedColorWithAlpha(shadowColor, 0);
|
|
587
|
-
|
|
588
512
|
var _endColor = this.getCachedColorWithAlpha(shadowColor, 0.15);
|
|
589
|
-
|
|
590
513
|
var _gradient = context.createLinearGradient(0, 0, 0, shadowBlur);
|
|
591
|
-
|
|
592
514
|
_gradient.addColorStop(0, _startColor);
|
|
593
|
-
|
|
594
515
|
_gradient.addColorStop(1, _endColor);
|
|
595
|
-
|
|
596
516
|
context.fillStyle = _gradient;
|
|
597
|
-
|
|
598
517
|
for (var _i3 = 0; _i3 < bottomShadowRows.length; _i3 += 1) {
|
|
599
518
|
var _row3 = bottomShadowRows[_i3];
|
|
600
|
-
|
|
601
519
|
var _y4 = getOrThrow(visibleRowYs, _row3);
|
|
602
|
-
|
|
603
520
|
var rowHeight = getOrThrow(visibleRowHeights, _row3);
|
|
604
|
-
var gradientY = _y4 + rowHeight - shadowBlur;
|
|
605
|
-
|
|
521
|
+
var gradientY = _y4 + rowHeight - shadowBlur;
|
|
522
|
+
// Use a translate so we can reuse the gradient
|
|
606
523
|
context.translate(0, gradientY);
|
|
607
524
|
context.fillRect(minX, 0, maxX, shadowBlur);
|
|
608
525
|
context.translate(0, -gradientY);
|
|
609
526
|
}
|
|
610
|
-
|
|
611
527
|
context.restore();
|
|
612
528
|
}
|
|
613
529
|
}
|
|
614
|
-
|
|
615
530
|
drawMouseColumnHover(context, state) {
|
|
616
531
|
var {
|
|
617
532
|
mouseX,
|
|
@@ -621,27 +536,22 @@ export class GridRenderer {
|
|
|
621
536
|
} = state;
|
|
622
537
|
if (mouseX == null || mouseY == null) return;
|
|
623
538
|
var mouseColumn = GridUtils.getColumnAtX(mouseX, metrics);
|
|
624
|
-
|
|
625
539
|
if (mouseColumn == null || theme.columnHoverBackgroundColor == null) {
|
|
626
540
|
return;
|
|
627
541
|
}
|
|
628
|
-
|
|
629
542
|
var {
|
|
630
543
|
visibleColumnWidths,
|
|
631
544
|
visibleColumnXs,
|
|
632
545
|
maxY
|
|
633
546
|
} = metrics;
|
|
634
|
-
|
|
635
547
|
if (mouseY > maxY) {
|
|
636
548
|
return;
|
|
637
549
|
}
|
|
638
|
-
|
|
639
550
|
var x = getOrThrow(visibleColumnXs, mouseColumn);
|
|
640
551
|
var columnWidth = getOrThrow(visibleColumnWidths, mouseColumn);
|
|
641
552
|
context.fillStyle = theme.columnHoverBackgroundColor;
|
|
642
553
|
context.fillRect(x, 0, columnWidth, maxY);
|
|
643
554
|
}
|
|
644
|
-
|
|
645
555
|
drawMouseRowHover(context, state) {
|
|
646
556
|
var {
|
|
647
557
|
mouseX,
|
|
@@ -653,20 +563,15 @@ export class GridRenderer {
|
|
|
653
563
|
var {
|
|
654
564
|
maxX
|
|
655
565
|
} = metrics;
|
|
656
|
-
|
|
657
566
|
if (mouseX > maxX || theme.rowHoverBackgroundColor == null) {
|
|
658
567
|
return;
|
|
659
568
|
}
|
|
660
|
-
|
|
661
569
|
var mouseRow = GridUtils.getRowAtY(mouseY, metrics);
|
|
662
|
-
|
|
663
570
|
if (mouseRow == null) {
|
|
664
571
|
return;
|
|
665
572
|
}
|
|
666
|
-
|
|
667
573
|
this.drawMouseRowHoverForRow(context, state, mouseRow);
|
|
668
574
|
}
|
|
669
|
-
|
|
670
575
|
drawFloatingMouseRowHover(context, state) {
|
|
671
576
|
var {
|
|
672
577
|
mouseX,
|
|
@@ -681,18 +586,14 @@ export class GridRenderer {
|
|
|
681
586
|
rowCount,
|
|
682
587
|
rowFooterWidth
|
|
683
588
|
} = metrics;
|
|
684
|
-
|
|
685
589
|
if (mouseX == null || mouseY == null || mouseX > maxX + rowFooterWidth || theme.rowHoverBackgroundColor == null) {
|
|
686
590
|
return;
|
|
687
591
|
}
|
|
688
|
-
|
|
689
592
|
var mouseRow = GridUtils.getRowAtY(mouseY, metrics);
|
|
690
|
-
|
|
691
593
|
if (mouseRow != null && (mouseRow < floatingTopRowCount || rowCount - floatingBottomRowCount <= mouseRow)) {
|
|
692
594
|
this.drawMouseRowHoverForRow(context, state, mouseRow);
|
|
693
595
|
}
|
|
694
596
|
}
|
|
695
|
-
|
|
696
597
|
drawMouseRowHoverForRow(context, state, row) {
|
|
697
598
|
var {
|
|
698
599
|
metrics,
|
|
@@ -706,29 +607,23 @@ export class GridRenderer {
|
|
|
706
607
|
} = metrics;
|
|
707
608
|
var y = getOrThrow(visibleRowYs, row);
|
|
708
609
|
var rowHeight = getOrThrow(visibleRowHeights, row);
|
|
709
|
-
|
|
710
610
|
if (theme.rowHoverBackgroundColor != null) {
|
|
711
611
|
context.fillStyle = theme.rowHoverBackgroundColor;
|
|
712
612
|
}
|
|
713
|
-
|
|
714
613
|
for (var i = 0; i < selectedRanges.length; i += 1) {
|
|
715
614
|
var {
|
|
716
615
|
startRow,
|
|
717
616
|
endRow
|
|
718
617
|
} = selectedRanges[i];
|
|
719
|
-
|
|
720
618
|
if (startRow != null && endRow != null && startRow <= row && endRow >= row) {
|
|
721
619
|
if (theme.selectedRowHoverBackgroundColor != null) {
|
|
722
620
|
context.fillStyle = theme.selectedRowHoverBackgroundColor;
|
|
723
621
|
}
|
|
724
|
-
|
|
725
622
|
break;
|
|
726
623
|
}
|
|
727
624
|
}
|
|
728
|
-
|
|
729
625
|
context.fillRect(0, y, maxX, rowHeight);
|
|
730
626
|
}
|
|
731
|
-
|
|
732
627
|
drawGridLines(context, state) {
|
|
733
628
|
var {
|
|
734
629
|
metrics,
|
|
@@ -740,28 +635,22 @@ export class GridRenderer {
|
|
|
740
635
|
} = metrics;
|
|
741
636
|
this.drawGridLinesForItems(context, state, visibleColumns, visibleRows, theme.gridColumnColor, theme.gridRowColor);
|
|
742
637
|
}
|
|
743
|
-
|
|
744
638
|
drawGridLinesForItems(context, state, columns, rows, columnColor, rowColor) {
|
|
745
639
|
if (columnColor == null && rowColor == null) {
|
|
746
640
|
return;
|
|
747
641
|
}
|
|
748
|
-
|
|
749
642
|
context.lineWidth = 1;
|
|
750
643
|
context.beginPath();
|
|
751
|
-
|
|
752
644
|
if (columnColor != null) {
|
|
753
645
|
context.strokeStyle = columnColor;
|
|
754
646
|
this.drawGridLinesForColumns(context, state, columns);
|
|
755
647
|
}
|
|
756
|
-
|
|
757
648
|
if (rowColor != null) {
|
|
758
649
|
context.strokeStyle = rowColor;
|
|
759
650
|
this.drawGridLinesForRows(context, state, rows);
|
|
760
651
|
}
|
|
761
|
-
|
|
762
652
|
context.stroke();
|
|
763
653
|
}
|
|
764
|
-
|
|
765
654
|
drawGridLinesForColumns(context, state, columns) {
|
|
766
655
|
var {
|
|
767
656
|
metrics
|
|
@@ -770,7 +659,6 @@ export class GridRenderer {
|
|
|
770
659
|
visibleColumnXs,
|
|
771
660
|
maxY
|
|
772
661
|
} = metrics;
|
|
773
|
-
|
|
774
662
|
for (var i = 0; i < columns.length; i += 1) {
|
|
775
663
|
var column = columns[i];
|
|
776
664
|
var x = getOrThrow(visibleColumnXs, column) + 0.5;
|
|
@@ -778,7 +666,6 @@ export class GridRenderer {
|
|
|
778
666
|
context.lineTo(x, maxY);
|
|
779
667
|
}
|
|
780
668
|
}
|
|
781
|
-
|
|
782
669
|
drawGridLinesForRows(context, state, rows) {
|
|
783
670
|
var {
|
|
784
671
|
metrics
|
|
@@ -787,8 +674,9 @@ export class GridRenderer {
|
|
|
787
674
|
visibleRowYs,
|
|
788
675
|
maxX: metricsMaxX
|
|
789
676
|
} = metrics;
|
|
790
|
-
var maxX = metricsMaxX;
|
|
677
|
+
var maxX = metricsMaxX;
|
|
791
678
|
|
|
679
|
+
// Draw row lines
|
|
792
680
|
for (var i = 0; i < rows.length; i += 1) {
|
|
793
681
|
var row = rows[i];
|
|
794
682
|
var y = getOrThrow(visibleRowYs, row) + 0.5;
|
|
@@ -796,7 +684,6 @@ export class GridRenderer {
|
|
|
796
684
|
context.lineTo(maxX - 0.5, y);
|
|
797
685
|
}
|
|
798
686
|
}
|
|
799
|
-
|
|
800
687
|
drawCellBackgrounds(context, state) {
|
|
801
688
|
var {
|
|
802
689
|
metrics
|
|
@@ -807,23 +694,18 @@ export class GridRenderer {
|
|
|
807
694
|
} = metrics;
|
|
808
695
|
this.drawCellBackgroundsForItems(context, state, visibleColumns, visibleRows);
|
|
809
696
|
}
|
|
810
|
-
|
|
811
697
|
drawCellBackgroundsForItems(context, state, columns, rows) {
|
|
812
698
|
context.save();
|
|
813
|
-
|
|
814
699
|
for (var i = 0; i < columns.length; i += 1) {
|
|
815
700
|
var column = columns[i];
|
|
816
|
-
|
|
817
701
|
for (var j = 0; j < rows.length; j += 1) {
|
|
818
702
|
var row = rows[j];
|
|
819
703
|
var rowAfter = j + 1 < rows.length ? rows[j + 1] : undefined;
|
|
820
704
|
this.drawCellBackground(context, state, column, row, rowAfter);
|
|
821
705
|
}
|
|
822
706
|
}
|
|
823
|
-
|
|
824
707
|
context.restore();
|
|
825
708
|
}
|
|
826
|
-
|
|
827
709
|
drawCellBackground(context, state, column, row, rowAfter) {
|
|
828
710
|
var {
|
|
829
711
|
metrics,
|
|
@@ -844,7 +726,6 @@ export class GridRenderer {
|
|
|
844
726
|
var backgroundColor = model.backgroundColorForCell(modelColumn, modelRow, theme);
|
|
845
727
|
var isFirstColumn = column === firstColumn;
|
|
846
728
|
var hasExpandableRows = isExpandableGridModel(model) && model.hasExpandableRows;
|
|
847
|
-
|
|
848
729
|
if (backgroundColor != null) {
|
|
849
730
|
var x = getOrThrow(visibleColumnXs, column) + 1;
|
|
850
731
|
var y = getOrThrow(visibleRowYs, row) + 1;
|
|
@@ -853,12 +734,10 @@ export class GridRenderer {
|
|
|
853
734
|
context.fillStyle = backgroundColor;
|
|
854
735
|
context.fillRect(x, y, columnWidth, rowHeight);
|
|
855
736
|
}
|
|
856
|
-
|
|
857
737
|
if (isFirstColumn && hasExpandableRows) {
|
|
858
738
|
this.drawCellRowTreeDepthLines(context, state, row, rowAfter);
|
|
859
739
|
}
|
|
860
740
|
}
|
|
861
|
-
|
|
862
741
|
drawCellContents(context, state) {
|
|
863
742
|
var {
|
|
864
743
|
metrics
|
|
@@ -866,13 +745,11 @@ export class GridRenderer {
|
|
|
866
745
|
var {
|
|
867
746
|
visibleColumns
|
|
868
747
|
} = metrics;
|
|
869
|
-
|
|
870
748
|
for (var i = 0; i < visibleColumns.length; i += 1) {
|
|
871
749
|
var column = visibleColumns[i];
|
|
872
750
|
this.drawColumnCellContents(context, state, column);
|
|
873
751
|
}
|
|
874
752
|
}
|
|
875
|
-
|
|
876
753
|
drawColumnCellContents(context, state, column) {
|
|
877
754
|
var {
|
|
878
755
|
metrics
|
|
@@ -889,14 +766,13 @@ export class GridRenderer {
|
|
|
889
766
|
context.beginPath();
|
|
890
767
|
context.rect(x, 0, columnWidth, height);
|
|
891
768
|
context.clip();
|
|
892
|
-
|
|
893
769
|
for (var i = 0; i < visibleRows.length; i += 1) {
|
|
894
770
|
var row = visibleRows[i];
|
|
895
771
|
this.drawCellContent(context, state, column, row);
|
|
896
772
|
}
|
|
897
|
-
|
|
898
773
|
context.restore();
|
|
899
774
|
}
|
|
775
|
+
|
|
900
776
|
/**
|
|
901
777
|
* Gets textWidth and X-Y position for a specific cell
|
|
902
778
|
* The textWidth returned is the width that the text can occupy accounting for any other cell markings
|
|
@@ -908,8 +784,6 @@ export class GridRenderer {
|
|
|
908
784
|
* @param row Row of cell to get text metrics for
|
|
909
785
|
* @returns Object with width, x, and y of the text
|
|
910
786
|
*/
|
|
911
|
-
|
|
912
|
-
|
|
913
787
|
getTextRenderMetrics(context, state, column, row) {
|
|
914
788
|
var {
|
|
915
789
|
textAlign
|
|
@@ -937,21 +811,17 @@ export class GridRenderer {
|
|
|
937
811
|
var rowHeight = getOrThrow(visibleRowHeights, row);
|
|
938
812
|
var isFirstColumn = column === firstColumn;
|
|
939
813
|
var treeIndent = 0;
|
|
940
|
-
|
|
941
814
|
if (isExpandableGridModel(model) && model.hasExpandableRows && isFirstColumn) {
|
|
942
815
|
treeIndent = treeDepthIndent * (model.depthForRow(row) + 1) + treeHorizontalPadding;
|
|
943
816
|
}
|
|
944
|
-
|
|
945
817
|
var textWidth = columnWidth - treeIndent;
|
|
946
818
|
var textX = x + cellHorizontalPadding;
|
|
947
819
|
var textY = y + rowHeight * 0.5;
|
|
948
|
-
|
|
949
820
|
if (textAlign === 'right') {
|
|
950
821
|
textX = x + textWidth - cellHorizontalPadding;
|
|
951
822
|
} else if (textAlign === 'center') {
|
|
952
823
|
textX = x + textWidth * 0.5;
|
|
953
824
|
}
|
|
954
|
-
|
|
955
825
|
textX += treeIndent;
|
|
956
826
|
return {
|
|
957
827
|
width: textWidth - cellHorizontalPadding * 2,
|
|
@@ -959,7 +829,6 @@ export class GridRenderer {
|
|
|
959
829
|
y: textY
|
|
960
830
|
};
|
|
961
831
|
}
|
|
962
|
-
|
|
963
832
|
drawCellContent(context, state, column, row, textOverride) {
|
|
964
833
|
var {
|
|
965
834
|
metrics,
|
|
@@ -982,10 +851,8 @@ export class GridRenderer {
|
|
|
982
851
|
var text = textOverride !== null && textOverride !== void 0 ? textOverride : model.textForCell(modelColumn, modelRow);
|
|
983
852
|
var truncationChar = model.truncationCharForCell(modelColumn, modelRow);
|
|
984
853
|
var isFirstColumn = column === firstColumn;
|
|
985
|
-
|
|
986
854
|
if (text && rowHeight > 0) {
|
|
987
855
|
var _fontWidths$get;
|
|
988
|
-
|
|
989
856
|
var textAlign = model.textAlignForCell(modelColumn, modelRow) || 'left';
|
|
990
857
|
context.textAlign = textAlign;
|
|
991
858
|
var color = model.colorForCell(modelColumn, modelRow, theme) || textColor;
|
|
@@ -997,17 +864,14 @@ export class GridRenderer {
|
|
|
997
864
|
} = this.getTextRenderMetrics(context, state, column, row);
|
|
998
865
|
var fontWidth = (_fontWidths$get = fontWidths.get(context.font)) !== null && _fontWidths$get !== void 0 ? _fontWidths$get : GridRenderer.DEFAULT_FONT_WIDTH;
|
|
999
866
|
var truncatedText = this.getCachedTruncatedString(context, text, textWidth, fontWidth, truncationChar);
|
|
1000
|
-
|
|
1001
867
|
if (truncatedText) {
|
|
1002
868
|
context.fillText(truncatedText, textX, textY);
|
|
1003
869
|
}
|
|
1004
870
|
}
|
|
1005
|
-
|
|
1006
871
|
if (isFirstColumn && isExpandableGridModel(model) && model.hasExpandableRows) {
|
|
1007
872
|
this.drawCellRowTreeMarker(context, state, row);
|
|
1008
873
|
}
|
|
1009
874
|
}
|
|
1010
|
-
|
|
1011
875
|
drawCellRowTreeMarker(context, state, row) {
|
|
1012
876
|
var {
|
|
1013
877
|
metrics,
|
|
@@ -1034,16 +898,13 @@ export class GridRenderer {
|
|
|
1034
898
|
var columnWidth = getOrThrow(visibleColumnWidths, firstColumn);
|
|
1035
899
|
var rowY = getOrThrow(visibleRowYs, row);
|
|
1036
900
|
var rowHeight = getOrThrow(visibleRowHeights, row);
|
|
1037
|
-
|
|
1038
901
|
if (!isExpandableGridModel(model) || !model.isRowExpandable(row)) {
|
|
1039
902
|
return;
|
|
1040
903
|
}
|
|
1041
|
-
|
|
1042
904
|
var treeBox = getOrThrow(visibleRowTreeBoxes, row);
|
|
1043
905
|
var color = mouseX != null && mouseY != null && mouseX >= gridX + columnX && mouseX <= gridX + columnX + columnWidth && mouseY >= gridY + rowY && mouseY <= gridY + rowY + rowHeight ? treeMarkerHoverColor : treeMarkerColor;
|
|
1044
906
|
this.drawTreeMarker(context, state, columnX, rowY, treeBox, color, model.isRowExpanded(row));
|
|
1045
907
|
}
|
|
1046
|
-
|
|
1047
908
|
drawTreeMarker(context, state, columnX, rowY, treeBox, color, isExpanded) {
|
|
1048
909
|
var {
|
|
1049
910
|
x1,
|
|
@@ -1058,7 +919,6 @@ export class GridRenderer {
|
|
|
1058
919
|
context.textAlign = 'center';
|
|
1059
920
|
context.fillText(markerText, textX, textY);
|
|
1060
921
|
}
|
|
1061
|
-
|
|
1062
922
|
drawCellRowTreeDepthLines(context, state, row, rowAfter) {
|
|
1063
923
|
var {
|
|
1064
924
|
metrics,
|
|
@@ -1085,38 +945,33 @@ export class GridRenderer {
|
|
|
1085
945
|
var depthRowAfter = rowAfter !== undefined ? model.depthForRow(rowAfter) : 0;
|
|
1086
946
|
var depthDiff = depth > depthRowAfter ? depth - depthRowAfter : 0;
|
|
1087
947
|
context.strokeStyle = treeLineColor;
|
|
1088
|
-
context.lineWidth = 1;
|
|
948
|
+
context.lineWidth = 1;
|
|
1089
949
|
|
|
950
|
+
// draw normal depth lines
|
|
1090
951
|
if (depth - depthDiff > 0) {
|
|
1091
952
|
context.beginPath();
|
|
1092
|
-
|
|
1093
953
|
for (var i = 0; i < depth - depthDiff; i += 1) {
|
|
1094
954
|
var lineX = columnX + i * treeDepthIndent + treeDepthIndent * 0.5 + treeHorizontalPadding + 0.5;
|
|
1095
955
|
context.moveTo(lineX, rowY);
|
|
1096
956
|
context.lineTo(lineX, rowY + rowHeight);
|
|
1097
957
|
}
|
|
1098
|
-
|
|
1099
958
|
context.stroke();
|
|
1100
|
-
}
|
|
1101
|
-
|
|
959
|
+
}
|
|
1102
960
|
|
|
961
|
+
// draw as hockey stick if last row at depth
|
|
1103
962
|
if (depthDiff > 0) {
|
|
1104
963
|
context.beginPath();
|
|
1105
|
-
|
|
1106
964
|
for (var _i4 = depth - depthDiff; _i4 < depth; _i4 += 1) {
|
|
1107
965
|
var _lineX = columnX + _i4 * treeDepthIndent + treeDepthIndent * 0.5 + treeHorizontalPadding + 0.5;
|
|
1108
|
-
|
|
1109
966
|
context.moveTo(_lineX, rowY);
|
|
1110
|
-
context.lineTo(_lineX, rowY + Math.ceil(rowHeight / 2));
|
|
1111
|
-
|
|
967
|
+
context.lineTo(_lineX, rowY + Math.ceil(rowHeight / 2));
|
|
968
|
+
// extra moveTo prevents halfpixel in corner
|
|
1112
969
|
context.moveTo(_lineX - 0.5, rowY + Math.ceil(rowHeight / 2) + 0.5);
|
|
1113
970
|
context.lineTo(_lineX + treeDepthIndent - 0.5, rowY + Math.ceil(rowHeight / 2) + 0.5);
|
|
1114
971
|
}
|
|
1115
|
-
|
|
1116
972
|
context.stroke();
|
|
1117
973
|
}
|
|
1118
974
|
}
|
|
1119
|
-
|
|
1120
975
|
drawHeaders(context, state) {
|
|
1121
976
|
var {
|
|
1122
977
|
theme
|
|
@@ -1125,7 +980,6 @@ export class GridRenderer {
|
|
|
1125
980
|
this.drawColumnHeaders(context, state);
|
|
1126
981
|
this.drawRowHeaders(context, state);
|
|
1127
982
|
}
|
|
1128
|
-
|
|
1129
983
|
drawFooters(context, state) {
|
|
1130
984
|
var {
|
|
1131
985
|
theme
|
|
@@ -1133,7 +987,6 @@ export class GridRenderer {
|
|
|
1133
987
|
context.font = theme.headerFont;
|
|
1134
988
|
this.drawRowFooters(context, state);
|
|
1135
989
|
}
|
|
1136
|
-
|
|
1137
990
|
drawColumnHeaders(context, state) {
|
|
1138
991
|
var {
|
|
1139
992
|
mouseX,
|
|
@@ -1158,11 +1011,9 @@ export class GridRenderer {
|
|
|
1158
1011
|
modelColumns,
|
|
1159
1012
|
columnHeaderMaxDepth
|
|
1160
1013
|
} = metrics;
|
|
1161
|
-
|
|
1162
1014
|
if (columnHeaderHeight <= 0) {
|
|
1163
1015
|
return;
|
|
1164
1016
|
}
|
|
1165
|
-
|
|
1166
1017
|
var {
|
|
1167
1018
|
headerHiddenSeparatorSize,
|
|
1168
1019
|
headerHiddenSeparatorHoverColor,
|
|
@@ -1177,14 +1028,12 @@ export class GridRenderer {
|
|
|
1177
1028
|
minX: gridX + floatingLeftWidth,
|
|
1178
1029
|
maxX: width - floatingRightWidth
|
|
1179
1030
|
});
|
|
1180
|
-
|
|
1181
1031
|
if (containsFrozenColumns) {
|
|
1182
1032
|
this.drawColumnHeadersForRange(context, state, [floatingColumns[0], floatingColumns[floatingColumns.length - 1]], {
|
|
1183
1033
|
minX: gridX,
|
|
1184
1034
|
maxX: gridX + floatingLeftWidth
|
|
1185
1035
|
});
|
|
1186
1036
|
}
|
|
1187
|
-
|
|
1188
1037
|
if (headerSeparatorColor) {
|
|
1189
1038
|
context.strokeStyle = headerSeparatorColor;
|
|
1190
1039
|
var hiddenColumns = [...visibleColumnWidths.entries()].filter(_ref => {
|
|
@@ -1193,11 +1042,11 @@ export class GridRenderer {
|
|
|
1193
1042
|
}).map(_ref2 => {
|
|
1194
1043
|
var [index] = _ref2;
|
|
1195
1044
|
return index;
|
|
1196
|
-
});
|
|
1045
|
+
});
|
|
1197
1046
|
|
|
1047
|
+
// Now draw the hidden column separator boxes
|
|
1198
1048
|
context.beginPath();
|
|
1199
1049
|
context.fillStyle = headerSeparatorColor;
|
|
1200
|
-
|
|
1201
1050
|
for (var i = 0; i < hiddenColumns.length; i += 1) {
|
|
1202
1051
|
var column = hiddenColumns[i];
|
|
1203
1052
|
var columnX = getOrThrow(visibleColumnXs, column);
|
|
@@ -1205,51 +1054,40 @@ export class GridRenderer {
|
|
|
1205
1054
|
var minX = gridX + columnX + columnWidth + 0.5 - headerHiddenSeparatorSize * 0.5;
|
|
1206
1055
|
context.rect(minX, hiddenY, headerHiddenSeparatorSize, hiddenSeparatorHeight);
|
|
1207
1056
|
}
|
|
1208
|
-
|
|
1209
1057
|
context.fill();
|
|
1210
1058
|
}
|
|
1211
|
-
|
|
1212
1059
|
if (headerSeparatorHoverColor) {
|
|
1213
1060
|
var {
|
|
1214
1061
|
index: highlightedSeparator,
|
|
1215
1062
|
depth
|
|
1216
1063
|
} = draggingColumnSeparator !== null && draggingColumnSeparator !== void 0 ? draggingColumnSeparator : {};
|
|
1217
|
-
|
|
1218
1064
|
if (highlightedSeparator == null && mouseX != null && mouseY != null) {
|
|
1219
1065
|
var separator = GridColumnSeparatorMouseHandler.getColumnSeparator(GridUtils.getGridPointFromXY(mouseX, mouseY, metrics), metrics, model, theme);
|
|
1220
1066
|
highlightedSeparator = separator === null || separator === void 0 ? void 0 : separator.index;
|
|
1221
1067
|
depth = separator === null || separator === void 0 ? void 0 : separator.depth;
|
|
1222
1068
|
}
|
|
1223
|
-
|
|
1224
1069
|
var shouldDrawSeparator;
|
|
1225
|
-
|
|
1226
1070
|
if (highlightedSeparator == null) {
|
|
1227
1071
|
shouldDrawSeparator = false;
|
|
1228
1072
|
} else {
|
|
1229
1073
|
var columnIndex = modelColumns.get(highlightedSeparator);
|
|
1230
1074
|
var nextColumnIndex = modelColumns.get(highlightedSeparator + 1);
|
|
1231
|
-
|
|
1232
1075
|
if (columnIndex == null || nextColumnIndex == null) {
|
|
1233
1076
|
shouldDrawSeparator = false;
|
|
1234
1077
|
} else {
|
|
1235
1078
|
shouldDrawSeparator = model.textForColumnHeader(columnIndex, depth) !== model.textForColumnHeader(nextColumnIndex, depth);
|
|
1236
1079
|
}
|
|
1237
1080
|
}
|
|
1238
|
-
|
|
1239
1081
|
if (shouldDrawSeparator && highlightedSeparator != null && depth != null && (!isDragging || draggingColumnSeparator != null)) {
|
|
1240
1082
|
context.strokeStyle = headerSeparatorHoverColor;
|
|
1241
|
-
|
|
1242
1083
|
var _columnX = getOrThrow(visibleColumnXs, highlightedSeparator);
|
|
1243
|
-
|
|
1244
1084
|
var _columnWidth = getOrThrow(visibleColumnWidths, highlightedSeparator);
|
|
1245
|
-
|
|
1246
1085
|
var x = gridX + _columnX + _columnWidth + 0.5;
|
|
1247
1086
|
var visibleColumnIndex = visibleColumns.indexOf(highlightedSeparator);
|
|
1248
1087
|
var nextColumn = visibleColumnIndex < visibleColumns.length - 1 ? visibleColumns[visibleColumnIndex + 1] : null;
|
|
1249
1088
|
var nextColumnWidth = nextColumn != null ? visibleColumnWidths.get(nextColumn) : null;
|
|
1250
1089
|
var isColumnHidden = _columnWidth === 0;
|
|
1251
1090
|
var isNextColumnHidden = nextColumnWidth != null && nextColumnWidth === 0;
|
|
1252
|
-
|
|
1253
1091
|
if (isColumnHidden) {
|
|
1254
1092
|
context.strokeStyle = headerHiddenSeparatorHoverColor;
|
|
1255
1093
|
context.fillStyle = headerHiddenSeparatorHoverColor;
|
|
@@ -1257,19 +1095,17 @@ export class GridRenderer {
|
|
|
1257
1095
|
} else if (isNextColumnHidden) {
|
|
1258
1096
|
context.fillStyle = headerSeparatorHoverColor;
|
|
1259
1097
|
context.fillRect(x - headerHiddenSeparatorSize * 0.5, hiddenY, headerHiddenSeparatorSize * 0.5, hiddenSeparatorHeight);
|
|
1260
|
-
}
|
|
1261
|
-
|
|
1098
|
+
}
|
|
1262
1099
|
|
|
1100
|
+
// column seperator hover line
|
|
1263
1101
|
context.beginPath();
|
|
1264
1102
|
context.moveTo(x, (columnHeaderMaxDepth - depth - 1) * columnHeaderHeight);
|
|
1265
1103
|
context.lineTo(x, (columnHeaderMaxDepth - depth) * columnHeaderHeight - 1);
|
|
1266
1104
|
context.stroke();
|
|
1267
1105
|
}
|
|
1268
1106
|
}
|
|
1269
|
-
|
|
1270
1107
|
context.restore();
|
|
1271
1108
|
}
|
|
1272
|
-
|
|
1273
1109
|
drawColumnHeadersForRange(context, state, range, bounds) {
|
|
1274
1110
|
var {
|
|
1275
1111
|
model
|
|
@@ -1277,16 +1113,13 @@ export class GridRenderer {
|
|
|
1277
1113
|
var {
|
|
1278
1114
|
columnHeaderMaxDepth
|
|
1279
1115
|
} = model;
|
|
1280
|
-
|
|
1281
1116
|
if (columnHeaderMaxDepth === 0) {
|
|
1282
1117
|
return;
|
|
1283
1118
|
}
|
|
1284
|
-
|
|
1285
1119
|
for (var d = 0; d <= columnHeaderMaxDepth; d += 1) {
|
|
1286
1120
|
this.drawColumnHeadersAtDepth(context, state, range, bounds, d);
|
|
1287
1121
|
}
|
|
1288
1122
|
}
|
|
1289
|
-
|
|
1290
1123
|
drawColumnHeadersAtDepth(context, state, range, bounds, depth) {
|
|
1291
1124
|
var {
|
|
1292
1125
|
metrics,
|
|
@@ -1314,29 +1147,26 @@ export class GridRenderer {
|
|
|
1314
1147
|
maxX
|
|
1315
1148
|
} = bounds;
|
|
1316
1149
|
var visibleWidth = maxX - minX;
|
|
1317
|
-
|
|
1318
1150
|
if (columnHeaderMaxDepth === 0) {
|
|
1319
1151
|
return;
|
|
1320
1152
|
}
|
|
1321
|
-
|
|
1322
1153
|
var startIndex = range[0];
|
|
1323
1154
|
var endIndex = range[1];
|
|
1324
1155
|
context.save();
|
|
1325
1156
|
context.translate(0, (columnHeaderMaxDepth - depth - 1) * columnHeaderHeight);
|
|
1326
|
-
|
|
1327
1157
|
if (depth === 0) {
|
|
1328
1158
|
// Make sure base column header background always goes to the right edge
|
|
1329
|
-
this.drawColumnHeader(context, state, '', minX, maxX);
|
|
1159
|
+
this.drawColumnHeader(context, state, '', minX, maxX);
|
|
1330
1160
|
|
|
1161
|
+
// Draw base column headers
|
|
1331
1162
|
for (var i = startIndex; i <= endIndex; i += 1) {
|
|
1332
1163
|
this.drawColumnHeaderAtIndex(context, state, i, bounds);
|
|
1333
1164
|
}
|
|
1334
|
-
}
|
|
1335
|
-
|
|
1165
|
+
}
|
|
1336
1166
|
|
|
1167
|
+
// Draw column header group
|
|
1337
1168
|
if (depth > 0) {
|
|
1338
1169
|
var columnIndex = startIndex;
|
|
1339
|
-
|
|
1340
1170
|
while (columnIndex <= endIndex) {
|
|
1341
1171
|
var {
|
|
1342
1172
|
columnCount
|
|
@@ -1346,52 +1176,43 @@ export class GridRenderer {
|
|
|
1346
1176
|
var columnGroupColor = model.colorForColumnHeader(modelColumn, depth);
|
|
1347
1177
|
var columnGroupLeft = getOrThrow(visibleColumnXs, columnIndex) + gridX;
|
|
1348
1178
|
var columnGroupRight = columnGroupLeft + getOrThrow(visibleColumnWidths, columnIndex);
|
|
1349
|
-
|
|
1350
1179
|
if (columnGroupName != null) {
|
|
1351
1180
|
// Need to determine if the column group is at least the width of the bounds
|
|
1352
1181
|
// And if the left/right of the group extend past the bounds
|
|
1353
1182
|
// The group will be drawn as if it were a column with a max width of the bounds width
|
|
1354
1183
|
var prevColumnIndex = columnIndex - 1;
|
|
1355
|
-
|
|
1356
1184
|
while (prevColumnIndex >= 0 && (columnGroupRight - columnGroupLeft < visibleWidth || columnGroupLeft > minX)) {
|
|
1357
1185
|
var _modelColumns$get, _ref3, _userColumnWidths$get;
|
|
1358
|
-
|
|
1359
1186
|
var prevModelIndex = (_modelColumns$get = modelColumns.get(prevColumnIndex)) !== null && _modelColumns$get !== void 0 ? _modelColumns$get : GridUtils.getModelIndex(prevColumnIndex, movedColumns);
|
|
1360
|
-
|
|
1361
1187
|
if (prevModelIndex == null || model.textForColumnHeader(prevModelIndex, depth) !== columnGroupName) {
|
|
1362
1188
|
// Previous column not in the same group
|
|
1363
1189
|
break;
|
|
1364
|
-
}
|
|
1365
|
-
|
|
1190
|
+
}
|
|
1366
1191
|
|
|
1192
|
+
// Use this instead of visibleColumnWidths b/c the columns may be off screen
|
|
1367
1193
|
var prevColumnWidth = (_ref3 = (_userColumnWidths$get = userColumnWidths.get(prevModelIndex)) !== null && _userColumnWidths$get !== void 0 ? _userColumnWidths$get : calculatedColumnWidths.get(prevModelIndex)) !== null && _ref3 !== void 0 ? _ref3 : columnWidth;
|
|
1368
1194
|
columnGroupLeft -= prevColumnWidth;
|
|
1369
1195
|
prevColumnIndex -= 1;
|
|
1370
1196
|
}
|
|
1371
|
-
|
|
1372
1197
|
var nextColumnIndex = columnIndex + 1;
|
|
1373
|
-
|
|
1374
1198
|
while (nextColumnIndex < columnCount && (columnGroupRight - columnGroupLeft < visibleWidth || columnGroupRight < maxX)) {
|
|
1375
1199
|
var _modelColumns$get2, _ref4, _userColumnWidths$get2;
|
|
1376
|
-
|
|
1377
1200
|
var nextModelIndex = (_modelColumns$get2 = modelColumns.get(nextColumnIndex)) !== null && _modelColumns$get2 !== void 0 ? _modelColumns$get2 : GridUtils.getModelIndex(nextColumnIndex, movedColumns);
|
|
1378
|
-
|
|
1379
1201
|
if (model.textForColumnHeader(nextModelIndex, depth) !== columnGroupName) {
|
|
1380
1202
|
// Next column not in the same group
|
|
1381
1203
|
break;
|
|
1382
|
-
}
|
|
1383
|
-
|
|
1204
|
+
}
|
|
1384
1205
|
|
|
1206
|
+
// Use this instead of visibleColumnWidths b/c the columns may be off screen
|
|
1385
1207
|
var nextColumnWidth = (_ref4 = (_userColumnWidths$get2 = userColumnWidths.get(nextModelIndex)) !== null && _userColumnWidths$get2 !== void 0 ? _userColumnWidths$get2 : calculatedColumnWidths.get(nextModelIndex)) !== null && _ref4 !== void 0 ? _ref4 : columnWidth;
|
|
1386
1208
|
columnGroupRight += nextColumnWidth;
|
|
1387
1209
|
nextColumnIndex += 1;
|
|
1388
|
-
}
|
|
1389
|
-
|
|
1210
|
+
}
|
|
1390
1211
|
|
|
1212
|
+
// Set column index to end of the current group
|
|
1391
1213
|
columnIndex = nextColumnIndex - 1;
|
|
1392
1214
|
var isFullWidth = columnGroupRight - columnGroupLeft >= visibleWidth;
|
|
1393
1215
|
var x = columnGroupLeft;
|
|
1394
|
-
|
|
1395
1216
|
if (isFullWidth) {
|
|
1396
1217
|
if (columnGroupRight < maxX) {
|
|
1397
1218
|
x = columnGroupRight - visibleWidth;
|
|
@@ -1399,18 +1220,16 @@ export class GridRenderer {
|
|
|
1399
1220
|
x = minX;
|
|
1400
1221
|
}
|
|
1401
1222
|
}
|
|
1402
|
-
|
|
1403
1223
|
this.drawColumnHeader(context, state, columnGroupName, x, Math.min(columnGroupRight - columnGroupLeft, visibleWidth), {
|
|
1404
1224
|
backgroundColor: columnGroupColor !== null && columnGroupColor !== void 0 ? columnGroupColor : undefined
|
|
1405
1225
|
}, bounds);
|
|
1406
1226
|
}
|
|
1407
|
-
|
|
1408
1227
|
columnIndex += 1;
|
|
1409
1228
|
}
|
|
1410
1229
|
}
|
|
1411
|
-
|
|
1412
1230
|
context.restore();
|
|
1413
1231
|
}
|
|
1232
|
+
|
|
1414
1233
|
/**
|
|
1415
1234
|
* Draws the column header for the given visible index
|
|
1416
1235
|
* @param context Canvas context
|
|
@@ -1418,11 +1237,8 @@ export class GridRenderer {
|
|
|
1418
1237
|
* @param index Visible index of the column header to draw
|
|
1419
1238
|
* @param bounds The horizontal bounds the header can be drawn in
|
|
1420
1239
|
*/
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
1240
|
drawColumnHeaderAtIndex(context, state, index, bounds) {
|
|
1424
1241
|
var _model$colorForColumn;
|
|
1425
|
-
|
|
1426
1242
|
var {
|
|
1427
1243
|
metrics,
|
|
1428
1244
|
model
|
|
@@ -1437,23 +1253,18 @@ export class GridRenderer {
|
|
|
1437
1253
|
var x = getOrThrow(visibleColumnXs, index) + gridX;
|
|
1438
1254
|
var modelColumn = getOrThrow(modelColumns, index);
|
|
1439
1255
|
var text = model.textForColumnHeader(modelColumn);
|
|
1440
|
-
|
|
1441
1256
|
if (text == null) {
|
|
1442
1257
|
return;
|
|
1443
1258
|
}
|
|
1444
|
-
|
|
1445
1259
|
this.drawColumnHeader(context, state, text, x, width, {
|
|
1446
1260
|
backgroundColor: (_model$colorForColumn = model.colorForColumnHeader(modelColumn)) !== null && _model$colorForColumn !== void 0 ? _model$colorForColumn : undefined
|
|
1447
1261
|
}, bounds);
|
|
1448
1262
|
}
|
|
1449
|
-
|
|
1450
1263
|
drawColumnHeader(context, state, columnText, columnX, columnWidth, style, bounds) {
|
|
1451
1264
|
var _fontWidths$get2;
|
|
1452
|
-
|
|
1453
1265
|
if (columnWidth <= 0) {
|
|
1454
1266
|
return;
|
|
1455
1267
|
}
|
|
1456
|
-
|
|
1457
1268
|
var {
|
|
1458
1269
|
metrics,
|
|
1459
1270
|
theme
|
|
@@ -1481,62 +1292,58 @@ export class GridRenderer {
|
|
|
1481
1292
|
var {
|
|
1482
1293
|
textColor = headerColor
|
|
1483
1294
|
} = style !== null && style !== void 0 ? style : {};
|
|
1484
|
-
|
|
1485
1295
|
try {
|
|
1486
1296
|
var isDarkBackground = this.getCachedColorIsDark(backgroundColor);
|
|
1487
1297
|
var isDarkText = this.getCachedColorIsDark(textColor);
|
|
1488
|
-
|
|
1489
1298
|
if (isDarkBackground && isDarkText) {
|
|
1490
1299
|
textColor = white;
|
|
1491
1300
|
} else if (!isDarkBackground && !isDarkText) {
|
|
1492
1301
|
textColor = black;
|
|
1493
1302
|
}
|
|
1494
|
-
} catch (_unused) {
|
|
1303
|
+
} catch (_unused) {
|
|
1304
|
+
// Invalid color provided
|
|
1495
1305
|
// no-op since we don't use logging in base grid
|
|
1496
1306
|
}
|
|
1497
|
-
|
|
1498
1307
|
var {
|
|
1499
1308
|
minX = 0,
|
|
1500
1309
|
maxX = width
|
|
1501
1310
|
} = bounds !== null && bounds !== void 0 ? bounds : {};
|
|
1502
1311
|
context.save();
|
|
1503
1312
|
context.rect(minX, 0, maxX - minX, columnHeaderHeight);
|
|
1504
|
-
context.clip();
|
|
1313
|
+
context.clip();
|
|
1505
1314
|
|
|
1315
|
+
// Fill background color if specified
|
|
1506
1316
|
if (backgroundColor != null) {
|
|
1507
1317
|
context.fillStyle = backgroundColor;
|
|
1508
1318
|
context.fillRect(columnX, 0, columnWidth, columnHeaderHeight);
|
|
1509
1319
|
}
|
|
1510
|
-
|
|
1511
1320
|
if (separatorColor != null) {
|
|
1512
1321
|
context.strokeStyle = separatorColor;
|
|
1513
|
-
context.beginPath();
|
|
1322
|
+
context.beginPath();
|
|
1514
1323
|
|
|
1324
|
+
// Don't draw left separator if column touches the left edge
|
|
1515
1325
|
if (columnX > 0) {
|
|
1516
1326
|
context.moveTo(columnX + 0.5, 0);
|
|
1517
1327
|
context.lineTo(columnX + 0.5, columnHeaderHeight);
|
|
1518
1328
|
}
|
|
1519
|
-
|
|
1520
1329
|
context.moveTo(columnX + columnWidth + 0.5, 0);
|
|
1521
|
-
context.lineTo(columnX + columnWidth + 0.5, columnHeaderHeight);
|
|
1330
|
+
context.lineTo(columnX + columnWidth + 0.5, columnHeaderHeight);
|
|
1522
1331
|
|
|
1332
|
+
// Bottom Border, should be interior to the header height
|
|
1523
1333
|
context.moveTo(columnX, columnHeaderHeight - 0.5);
|
|
1524
1334
|
context.lineTo(columnX + columnWidth, columnHeaderHeight - 0.5);
|
|
1525
1335
|
context.stroke();
|
|
1526
1336
|
}
|
|
1527
|
-
|
|
1528
1337
|
context.beginPath();
|
|
1529
1338
|
context.rect(columnX, 0, columnWidth, columnHeaderHeight);
|
|
1530
1339
|
context.clip();
|
|
1531
1340
|
context.fillStyle = textColor;
|
|
1532
1341
|
var renderText = columnText;
|
|
1533
|
-
|
|
1534
1342
|
if (maxLength <= 0) {
|
|
1535
1343
|
renderText = '';
|
|
1536
1344
|
} else if (renderText.length > maxLength) {
|
|
1537
1345
|
renderText = "".concat(renderText.substring(0, maxLength - 1), "\u2026");
|
|
1538
1346
|
}
|
|
1539
|
-
|
|
1540
1347
|
var textWidth = renderText.length * fontWidth;
|
|
1541
1348
|
var x = columnX + columnWidth * 0.5;
|
|
1542
1349
|
var y = columnHeaderHeight * 0.5;
|
|
@@ -1549,7 +1356,6 @@ export class GridRenderer {
|
|
|
1549
1356
|
var visibleWidth = visibleRight - visibleLeft;
|
|
1550
1357
|
var isBeyondLeft = x - textWidth * 0.5 < minX;
|
|
1551
1358
|
var isBeyondRight = x + textWidth * 0.5 > maxX;
|
|
1552
|
-
|
|
1553
1359
|
if (isBeyondLeft) {
|
|
1554
1360
|
// Column name would be off the left side of the canvas
|
|
1555
1361
|
if (textWidth < visibleWidth) {
|
|
@@ -1566,12 +1372,10 @@ export class GridRenderer {
|
|
|
1566
1372
|
x = columnLeft + textWidth * 0.5;
|
|
1567
1373
|
}
|
|
1568
1374
|
}
|
|
1569
|
-
|
|
1570
1375
|
context.textAlign = 'center';
|
|
1571
1376
|
context.fillText(renderText, x, y);
|
|
1572
1377
|
context.restore();
|
|
1573
1378
|
}
|
|
1574
|
-
|
|
1575
1379
|
drawRowHeaders(context, state) {
|
|
1576
1380
|
var {
|
|
1577
1381
|
mouseX,
|
|
@@ -1588,11 +1392,9 @@ export class GridRenderer {
|
|
|
1588
1392
|
visibleRowHeights,
|
|
1589
1393
|
visibleRowYs
|
|
1590
1394
|
} = metrics;
|
|
1591
|
-
|
|
1592
1395
|
if (rowHeaderWidth <= 0) {
|
|
1593
1396
|
return;
|
|
1594
1397
|
}
|
|
1595
|
-
|
|
1596
1398
|
var {
|
|
1597
1399
|
headerBackgroundColor,
|
|
1598
1400
|
headerColor,
|
|
@@ -1604,11 +1406,13 @@ export class GridRenderer {
|
|
|
1604
1406
|
var hiddenSeparatorWidth = rowHeaderWidth * 0.5;
|
|
1605
1407
|
var hiddenX = rowHeaderWidth * 0.5 - hiddenSeparatorWidth * 0.5;
|
|
1606
1408
|
context.save();
|
|
1607
|
-
context.beginPath();
|
|
1409
|
+
context.beginPath();
|
|
1608
1410
|
|
|
1411
|
+
// Fill in the background
|
|
1609
1412
|
context.fillStyle = headerBackgroundColor;
|
|
1610
|
-
context.fillRect(0, 0, rowHeaderWidth, height);
|
|
1413
|
+
context.fillRect(0, 0, rowHeaderWidth, height);
|
|
1611
1414
|
|
|
1415
|
+
// Draw the separators
|
|
1612
1416
|
if (headerSeparatorColor) {
|
|
1613
1417
|
context.strokeStyle = headerSeparatorColor;
|
|
1614
1418
|
context.beginPath();
|
|
@@ -1616,12 +1420,10 @@ export class GridRenderer {
|
|
|
1616
1420
|
context.lineTo(rowHeaderWidth, gridY + 0.5);
|
|
1617
1421
|
var hiddenRows = [];
|
|
1618
1422
|
var isPreviousRowHidden = false;
|
|
1619
|
-
|
|
1620
1423
|
for (var i = 0; i < visibleRows.length; i += 1) {
|
|
1621
1424
|
var row = visibleRows[i];
|
|
1622
1425
|
var rowY = getOrThrow(visibleRowYs, row);
|
|
1623
1426
|
var rowHeight = getOrThrow(visibleRowHeights, row);
|
|
1624
|
-
|
|
1625
1427
|
if (rowHeight > 0) {
|
|
1626
1428
|
var y = gridY + rowY + rowHeight + 0.5;
|
|
1627
1429
|
context.moveTo(0, y);
|
|
@@ -1631,54 +1433,42 @@ export class GridRenderer {
|
|
|
1631
1433
|
isPreviousRowHidden = true;
|
|
1632
1434
|
hiddenRows.push(row);
|
|
1633
1435
|
}
|
|
1634
|
-
}
|
|
1635
|
-
|
|
1436
|
+
}
|
|
1636
1437
|
|
|
1438
|
+
// border right, interior to the headerWidth
|
|
1637
1439
|
context.moveTo(rowHeaderWidth - 0.5, 0);
|
|
1638
1440
|
context.lineTo(rowHeaderWidth - 0.5, height);
|
|
1639
|
-
context.stroke();
|
|
1441
|
+
context.stroke();
|
|
1640
1442
|
|
|
1443
|
+
// Draw the hidden column separators
|
|
1641
1444
|
context.beginPath();
|
|
1642
1445
|
context.fillStyle = headerSeparatorColor;
|
|
1643
|
-
|
|
1644
1446
|
for (var _i5 = 0; _i5 < hiddenRows.length; _i5 += 1) {
|
|
1645
1447
|
var _row4 = hiddenRows[_i5];
|
|
1646
|
-
|
|
1647
1448
|
var _rowY = getOrThrow(visibleRowYs, _row4);
|
|
1648
|
-
|
|
1649
1449
|
var _rowHeight = getOrThrow(visibleRowHeights, _row4);
|
|
1650
|
-
|
|
1651
1450
|
var minY = gridY + _rowY + _rowHeight + 0.5 - headerHiddenSeparatorSize * 0.5;
|
|
1652
1451
|
context.rect(hiddenX, minY, hiddenSeparatorWidth, headerHiddenSeparatorSize);
|
|
1653
1452
|
}
|
|
1654
|
-
|
|
1655
1453
|
context.fill();
|
|
1656
1454
|
}
|
|
1657
|
-
|
|
1658
1455
|
if (headerSeparatorHoverColor) {
|
|
1659
1456
|
var {
|
|
1660
1457
|
index: highlightedSeparator = null
|
|
1661
1458
|
} = draggingRowSeparator !== null && draggingRowSeparator !== void 0 ? draggingRowSeparator : {};
|
|
1662
|
-
|
|
1663
1459
|
if (highlightedSeparator == null && mouseX != null && mouseY != null) {
|
|
1664
1460
|
highlightedSeparator = GridUtils.getRowSeparatorIndex(mouseX, mouseY, metrics, theme);
|
|
1665
1461
|
}
|
|
1666
|
-
|
|
1667
1462
|
if (highlightedSeparator != null) {
|
|
1668
1463
|
context.strokeStyle = headerSeparatorHoverColor;
|
|
1669
|
-
|
|
1670
1464
|
var _rowY2 = getOrThrow(visibleRowYs, highlightedSeparator);
|
|
1671
|
-
|
|
1672
1465
|
var _rowHeight2 = getOrThrow(visibleRowHeights, highlightedSeparator);
|
|
1673
|
-
|
|
1674
1466
|
var _y5 = gridY + _rowY2 + _rowHeight2 + 0.5;
|
|
1675
|
-
|
|
1676
1467
|
var visibleRowIndex = visibleRows.indexOf(highlightedSeparator);
|
|
1677
1468
|
var nextRow = visibleRowIndex < visibleRows.length - 1 ? visibleRows[visibleRowIndex + 1] : null;
|
|
1678
1469
|
var nextRowHeight = nextRow != null ? visibleRowHeights.get(nextRow) : null;
|
|
1679
1470
|
var isRowHidden = _rowHeight2 === 0;
|
|
1680
1471
|
var isNextRowHidden = nextRowHeight != null && nextRowHeight === 0;
|
|
1681
|
-
|
|
1682
1472
|
if (isRowHidden) {
|
|
1683
1473
|
context.strokeStyle = headerHiddenSeparatorHoverColor;
|
|
1684
1474
|
context.fillStyle = headerHiddenSeparatorHoverColor;
|
|
@@ -1687,39 +1477,31 @@ export class GridRenderer {
|
|
|
1687
1477
|
context.fillStyle = headerSeparatorHoverColor;
|
|
1688
1478
|
context.fillRect(hiddenX, _y5 - headerHiddenSeparatorSize * 0.5, hiddenSeparatorWidth, headerHiddenSeparatorSize * 0.5);
|
|
1689
1479
|
}
|
|
1690
|
-
|
|
1691
1480
|
context.beginPath();
|
|
1692
1481
|
context.moveTo(0.5, _y5);
|
|
1693
1482
|
context.lineTo(rowHeaderWidth + 0.5, _y5);
|
|
1694
1483
|
context.stroke();
|
|
1695
1484
|
}
|
|
1696
|
-
}
|
|
1697
|
-
|
|
1485
|
+
}
|
|
1698
1486
|
|
|
1487
|
+
// Fill in the text
|
|
1699
1488
|
context.beginPath();
|
|
1700
1489
|
context.rect(0, gridY, rowHeaderWidth, height);
|
|
1701
1490
|
context.clip();
|
|
1702
1491
|
context.fillStyle = headerColor;
|
|
1703
1492
|
context.textAlign = 'right';
|
|
1704
|
-
|
|
1705
1493
|
for (var _i6 = 0; _i6 < visibleRows.length; _i6 += 1) {
|
|
1706
1494
|
var _row5 = visibleRows[_i6];
|
|
1707
|
-
|
|
1708
1495
|
var _rowHeight3 = getOrThrow(visibleRowHeights, _row5);
|
|
1709
|
-
|
|
1710
1496
|
var _y6 = getOrThrow(visibleRowYs, _row5) + gridY;
|
|
1711
|
-
|
|
1712
1497
|
this.drawRowHeader(context, state, _row5, _y6, _rowHeight3);
|
|
1713
1498
|
}
|
|
1714
|
-
|
|
1715
1499
|
context.restore();
|
|
1716
1500
|
}
|
|
1717
|
-
|
|
1718
1501
|
drawRowHeader(context, state, row, rowY, rowHeight) {
|
|
1719
1502
|
if (rowHeight <= 0) {
|
|
1720
1503
|
return;
|
|
1721
1504
|
}
|
|
1722
|
-
|
|
1723
1505
|
var {
|
|
1724
1506
|
metrics,
|
|
1725
1507
|
model,
|
|
@@ -1734,7 +1516,6 @@ export class GridRenderer {
|
|
|
1734
1516
|
var y = rowY + rowHeight * 0.5;
|
|
1735
1517
|
context.fillText(model.textForRowHeader(modelRow), x, y);
|
|
1736
1518
|
}
|
|
1737
|
-
|
|
1738
1519
|
drawRowFooters(context, state) {
|
|
1739
1520
|
var {
|
|
1740
1521
|
mouseX,
|
|
@@ -1757,11 +1538,9 @@ export class GridRenderer {
|
|
|
1757
1538
|
visibleRowYs,
|
|
1758
1539
|
width
|
|
1759
1540
|
} = metrics;
|
|
1760
|
-
|
|
1761
1541
|
if (rowFooterWidth <= 0) {
|
|
1762
1542
|
return;
|
|
1763
1543
|
}
|
|
1764
|
-
|
|
1765
1544
|
var {
|
|
1766
1545
|
cellHorizontalPadding,
|
|
1767
1546
|
headerBackgroundColor,
|
|
@@ -1775,11 +1554,13 @@ export class GridRenderer {
|
|
|
1775
1554
|
var hiddenX = rowFooterWidth * 0.5 - hiddenSeparatorWidth * 0.5;
|
|
1776
1555
|
var x = Math.min(gridX + maxX, width - rowFooterWidth - verticalBarWidth);
|
|
1777
1556
|
context.save();
|
|
1778
|
-
context.beginPath();
|
|
1557
|
+
context.beginPath();
|
|
1779
1558
|
|
|
1559
|
+
// Fill in the background
|
|
1780
1560
|
context.fillStyle = headerBackgroundColor;
|
|
1781
|
-
context.fillRect(x, gridY, rowFooterWidth, height);
|
|
1561
|
+
context.fillRect(x, gridY, rowFooterWidth, height);
|
|
1782
1562
|
|
|
1563
|
+
// Draw the separators
|
|
1783
1564
|
if (headerSeparatorColor) {
|
|
1784
1565
|
context.strokeStyle = headerSeparatorColor;
|
|
1785
1566
|
context.beginPath();
|
|
@@ -1787,12 +1568,10 @@ export class GridRenderer {
|
|
|
1787
1568
|
context.lineTo(rowFooterWidth, gridY + 0.5);
|
|
1788
1569
|
var hiddenRows = [];
|
|
1789
1570
|
var isPreviousRowHidden = false;
|
|
1790
|
-
|
|
1791
1571
|
for (var i = 0; i < visibleRows.length; i += 1) {
|
|
1792
1572
|
var row = visibleRows[i];
|
|
1793
1573
|
var rowY = getOrThrow(visibleRowYs, row);
|
|
1794
1574
|
var rowHeight = getOrThrow(visibleRowHeights, row);
|
|
1795
|
-
|
|
1796
1575
|
if (rowHeight > 0) {
|
|
1797
1576
|
var y = gridY + rowY + rowHeight + 0.5;
|
|
1798
1577
|
context.moveTo(x + 0.5, y);
|
|
@@ -1802,54 +1581,42 @@ export class GridRenderer {
|
|
|
1802
1581
|
isPreviousRowHidden = true;
|
|
1803
1582
|
hiddenRows.push(row);
|
|
1804
1583
|
}
|
|
1805
|
-
}
|
|
1806
|
-
|
|
1584
|
+
}
|
|
1807
1585
|
|
|
1586
|
+
// border left, interior to the headerWidth
|
|
1808
1587
|
context.moveTo(x + 0.5, gridY);
|
|
1809
1588
|
context.lineTo(x + 0.5, height);
|
|
1810
|
-
context.stroke();
|
|
1589
|
+
context.stroke();
|
|
1811
1590
|
|
|
1591
|
+
// Draw the hidden column separators
|
|
1812
1592
|
context.beginPath();
|
|
1813
1593
|
context.fillStyle = headerSeparatorColor;
|
|
1814
|
-
|
|
1815
1594
|
for (var _i7 = 0; _i7 < hiddenRows.length; _i7 += 1) {
|
|
1816
1595
|
var _row6 = hiddenRows[_i7];
|
|
1817
|
-
|
|
1818
1596
|
var _rowY3 = getOrThrow(visibleRowYs, _row6);
|
|
1819
|
-
|
|
1820
1597
|
var _rowHeight4 = getOrThrow(visibleRowHeights, _row6);
|
|
1821
|
-
|
|
1822
1598
|
var minY = gridY + _rowY3 + _rowHeight4 + 0.5 - headerHiddenSeparatorSize * 0.5;
|
|
1823
1599
|
context.rect(x + hiddenX, minY, hiddenSeparatorWidth, headerHiddenSeparatorSize);
|
|
1824
1600
|
}
|
|
1825
|
-
|
|
1826
1601
|
context.fill();
|
|
1827
1602
|
}
|
|
1828
|
-
|
|
1829
1603
|
if (headerSeparatorHoverColor) {
|
|
1830
1604
|
var {
|
|
1831
1605
|
index: highlightedSeparator = null
|
|
1832
1606
|
} = draggingRowSeparator !== null && draggingRowSeparator !== void 0 ? draggingRowSeparator : {};
|
|
1833
|
-
|
|
1834
1607
|
if (highlightedSeparator == null && mouseX != null && mouseY != null) {
|
|
1835
1608
|
highlightedSeparator = GridUtils.getRowSeparatorIndex(mouseX, mouseY, metrics, theme);
|
|
1836
1609
|
}
|
|
1837
|
-
|
|
1838
1610
|
if (highlightedSeparator != null) {
|
|
1839
1611
|
context.strokeStyle = headerSeparatorHoverColor;
|
|
1840
|
-
|
|
1841
1612
|
var _rowY4 = getOrThrow(visibleRowYs, highlightedSeparator);
|
|
1842
|
-
|
|
1843
1613
|
var _rowHeight5 = getOrThrow(visibleRowHeights, highlightedSeparator);
|
|
1844
|
-
|
|
1845
1614
|
var _y7 = gridY + _rowY4 + _rowHeight5 + 0.5;
|
|
1846
|
-
|
|
1847
1615
|
var visibleRowIndex = visibleRows.indexOf(highlightedSeparator);
|
|
1848
1616
|
var nextRow = visibleRowIndex < visibleRows.length - 1 ? visibleRows[visibleRowIndex + 1] : null;
|
|
1849
1617
|
var nextRowHeight = nextRow != null ? visibleRowHeights.get(nextRow) : null;
|
|
1850
1618
|
var isRowHidden = _rowHeight5 === 0;
|
|
1851
1619
|
var isNextRowHidden = nextRowHeight != null && nextRowHeight === 0;
|
|
1852
|
-
|
|
1853
1620
|
if (isRowHidden) {
|
|
1854
1621
|
context.strokeStyle = headerHiddenSeparatorHoverColor;
|
|
1855
1622
|
context.fillStyle = headerHiddenSeparatorHoverColor;
|
|
@@ -1858,39 +1625,32 @@ export class GridRenderer {
|
|
|
1858
1625
|
context.fillStyle = headerSeparatorHoverColor;
|
|
1859
1626
|
context.fillRect(hiddenX, _y7 - headerHiddenSeparatorSize * 0.5, hiddenSeparatorWidth, headerHiddenSeparatorSize * 0.5);
|
|
1860
1627
|
}
|
|
1861
|
-
|
|
1862
1628
|
context.beginPath();
|
|
1863
1629
|
context.moveTo(x + 0.5, _y7);
|
|
1864
1630
|
context.lineTo(x + rowFooterWidth + 0.5, _y7);
|
|
1865
1631
|
context.stroke();
|
|
1866
1632
|
}
|
|
1867
|
-
}
|
|
1868
|
-
|
|
1633
|
+
}
|
|
1869
1634
|
|
|
1635
|
+
// Fill in the text
|
|
1870
1636
|
context.beginPath();
|
|
1871
1637
|
context.rect(x, gridY, rowFooterWidth, height);
|
|
1872
1638
|
context.clip();
|
|
1873
1639
|
context.fillStyle = headerColor;
|
|
1874
1640
|
context.textAlign = 'left';
|
|
1875
1641
|
var textX = x + cellHorizontalPadding;
|
|
1876
|
-
|
|
1877
1642
|
for (var _i8 = 0; _i8 < visibleRows.length; _i8 += 1) {
|
|
1878
1643
|
var _row7 = visibleRows[_i8];
|
|
1879
|
-
|
|
1880
1644
|
var _rowHeight6 = getOrThrow(visibleRowHeights, _row7);
|
|
1881
|
-
|
|
1882
1645
|
if (_rowHeight6 > 0) {
|
|
1883
1646
|
var _rowY5 = getOrThrow(visibleRowYs, _row7) + gridY;
|
|
1884
|
-
|
|
1885
1647
|
var modelRow = getOrThrow(modelRows, _row7);
|
|
1886
1648
|
var textY = _rowY5 + _rowHeight6 * 0.5;
|
|
1887
1649
|
context.fillText(model.textForRowFooter(modelRow), textX, textY);
|
|
1888
1650
|
}
|
|
1889
1651
|
}
|
|
1890
|
-
|
|
1891
1652
|
context.restore();
|
|
1892
1653
|
}
|
|
1893
|
-
|
|
1894
1654
|
drawSelectedRanges(context, state) {
|
|
1895
1655
|
var viewport = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1896
1656
|
var {
|
|
@@ -1922,13 +1682,10 @@ export class GridRenderer {
|
|
|
1922
1682
|
minX = -10,
|
|
1923
1683
|
maxX = width + 10
|
|
1924
1684
|
} = viewport;
|
|
1925
|
-
|
|
1926
1685
|
if (selectedRanges.length === 0) {
|
|
1927
1686
|
return;
|
|
1928
1687
|
}
|
|
1929
|
-
|
|
1930
1688
|
var isCursorVisible = isEditableGridModel(model) && model.isEditable && editingCell == null && draggingRow == null && draggingColumn == null && column != null && row != null && visibleColumnXs.has(column) && visibleRowYs.has(row);
|
|
1931
|
-
|
|
1932
1689
|
if (isCursorVisible) {
|
|
1933
1690
|
// Punch a hole out where the active cell is, it gets styled differently.
|
|
1934
1691
|
var x = getOrThrow(visibleColumnXs, column);
|
|
@@ -1940,32 +1697,29 @@ export class GridRenderer {
|
|
|
1940
1697
|
context.rect(0, 0, width, height);
|
|
1941
1698
|
context.rect(x, y, w, h);
|
|
1942
1699
|
context.clip('evenodd');
|
|
1943
|
-
}
|
|
1944
|
-
|
|
1700
|
+
}
|
|
1945
1701
|
|
|
1702
|
+
// Draw selection ranges
|
|
1946
1703
|
context.beginPath();
|
|
1947
|
-
|
|
1948
1704
|
for (var i = 0; i < selectedRanges.length; i += 1) {
|
|
1949
1705
|
var selectedRange = selectedRanges[i];
|
|
1950
1706
|
var startColumn = selectedRange.startColumn !== null ? selectedRange.startColumn : left;
|
|
1951
1707
|
var startRow = selectedRange.startRow !== null ? selectedRange.startRow : top;
|
|
1952
1708
|
var endColumn = selectedRange.endColumn !== null ? selectedRange.endColumn : right;
|
|
1953
1709
|
var endRow = selectedRange.endRow !== null ? selectedRange.endRow : bottom;
|
|
1954
|
-
|
|
1955
1710
|
if (endRow >= top && bottom >= startRow && endColumn >= left && right >= startColumn) {
|
|
1956
1711
|
// Need to offset the x/y coordinates so that the line draws nice and crisp
|
|
1957
1712
|
var _x4 = startColumn >= left && visibleColumnXs.has(startColumn) ? Math.round(getOrThrow(visibleColumnXs, startColumn)) + 0.5 : minX;
|
|
1958
|
-
|
|
1959
1713
|
var _y8 = startRow >= top && visibleRowYs.has(startRow) ? Math.max(Math.round(getOrThrow(visibleRowYs, startRow)) + 0.5, 0.5) : minY;
|
|
1960
|
-
|
|
1961
1714
|
var endX = endColumn <= right && visibleColumnXs.has(endColumn) ? Math.round(getOrThrow(visibleColumnXs, endColumn) + getOrThrow(visibleColumnWidths, endColumn)) - 0.5 : maxX;
|
|
1962
1715
|
var endY = endRow <= bottom && visibleRowYs.has(endRow) ? Math.round(getOrThrow(visibleRowYs, endRow) + getOrThrow(visibleRowHeights, endRow)) - 0.5 : maxY;
|
|
1963
1716
|
context.rect(_x4, _y8, endX - _x4, endY - _y8);
|
|
1964
|
-
}
|
|
1965
|
-
|
|
1717
|
+
}
|
|
1966
1718
|
|
|
1719
|
+
// draw the inner transparent fill
|
|
1967
1720
|
context.fillStyle = theme.selectionColor;
|
|
1968
1721
|
context.fill();
|
|
1722
|
+
|
|
1969
1723
|
/**
|
|
1970
1724
|
* draw an "inner stroke" that's clipped to just inside of the rects
|
|
1971
1725
|
* to act as a casing to the outer stroke. 3px width because 1px is outside
|
|
@@ -1973,25 +1727,23 @@ export class GridRenderer {
|
|
|
1973
1727
|
* a half pixel clip as well due to rects offset, but we are immediately painting
|
|
1974
1728
|
* over it), and then the 1px inside (which is the desired pixel).
|
|
1975
1729
|
*/
|
|
1976
|
-
|
|
1977
1730
|
context.save();
|
|
1978
1731
|
context.clip();
|
|
1979
1732
|
context.strokeStyle = theme.selectionOutlineCasingColor;
|
|
1980
1733
|
context.lineWidth = 3;
|
|
1981
1734
|
context.stroke();
|
|
1982
|
-
context.restore();
|
|
1735
|
+
context.restore();
|
|
1983
1736
|
|
|
1737
|
+
// draw the outerstroke border on top of the inner stroke
|
|
1984
1738
|
context.strokeStyle = theme.selectionOutlineColor;
|
|
1985
1739
|
context.lineWidth = 1;
|
|
1986
1740
|
context.stroke();
|
|
1987
1741
|
}
|
|
1988
|
-
|
|
1989
1742
|
if (isCursorVisible && column != null && row != null) {
|
|
1990
1743
|
context.restore();
|
|
1991
1744
|
this.drawActiveCell(context, state, column, row);
|
|
1992
1745
|
}
|
|
1993
1746
|
}
|
|
1994
|
-
|
|
1995
1747
|
drawActiveCell(context, state, column, row) {
|
|
1996
1748
|
var borderWidth = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : GridRenderer.ACTIVE_CELL_BORDER_WIDTH;
|
|
1997
1749
|
var {
|
|
@@ -2007,23 +1759,23 @@ export class GridRenderer {
|
|
|
2007
1759
|
var cellX = getOrThrow(visibleColumnXs, column);
|
|
2008
1760
|
var cellY = getOrThrow(visibleRowYs, row);
|
|
2009
1761
|
var cellW = getOrThrow(visibleColumnWidths, column);
|
|
2010
|
-
var cellH = getOrThrow(visibleRowHeights, row);
|
|
1762
|
+
var cellH = getOrThrow(visibleRowHeights, row);
|
|
2011
1763
|
|
|
1764
|
+
// Now get the outline for the active cell
|
|
2012
1765
|
var x = cellX - borderWidth * 0.5;
|
|
2013
1766
|
var y = cellY - borderWidth * 0.5;
|
|
2014
1767
|
var w = cellW + borderWidth;
|
|
2015
|
-
var h = cellH + borderWidth;
|
|
1768
|
+
var h = cellH + borderWidth;
|
|
2016
1769
|
|
|
1770
|
+
// Make sure the outline is interior on the edge
|
|
2017
1771
|
if (x <= 0) {
|
|
2018
1772
|
w += x - 1;
|
|
2019
1773
|
x = 1;
|
|
2020
1774
|
}
|
|
2021
|
-
|
|
2022
1775
|
if (y <= 0) {
|
|
2023
1776
|
h += y - 1;
|
|
2024
1777
|
y = 1;
|
|
2025
1778
|
}
|
|
2026
|
-
|
|
2027
1779
|
var {
|
|
2028
1780
|
lineWidth
|
|
2029
1781
|
} = context;
|
|
@@ -2034,6 +1786,7 @@ export class GridRenderer {
|
|
|
2034
1786
|
context.stroke();
|
|
2035
1787
|
context.lineWidth = lineWidth;
|
|
2036
1788
|
}
|
|
1789
|
+
|
|
2037
1790
|
/**
|
|
2038
1791
|
* Draws a rounded rectangle using the current state of the canvas.
|
|
2039
1792
|
*
|
|
@@ -2044,8 +1797,6 @@ export class GridRenderer {
|
|
|
2044
1797
|
* @param h height of the rectangle
|
|
2045
1798
|
* @param r corner radius of the rectangle
|
|
2046
1799
|
*/
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
1800
|
drawRoundedRect(context, x, y, w, h) {
|
|
2050
1801
|
var r = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : GridRenderer.DEFAULT_EDGE_RADIUS;
|
|
2051
1802
|
context.beginPath();
|
|
@@ -2060,10 +1811,8 @@ export class GridRenderer {
|
|
|
2060
1811
|
context.quadraticCurveTo(x, y, x + r, y);
|
|
2061
1812
|
context.closePath();
|
|
2062
1813
|
}
|
|
2063
|
-
|
|
2064
1814
|
drawDraggingColumn(context, state) {
|
|
2065
1815
|
var _modelColumns$get3;
|
|
2066
|
-
|
|
2067
1816
|
var {
|
|
2068
1817
|
draggingColumn,
|
|
2069
1818
|
metrics,
|
|
@@ -2071,11 +1820,9 @@ export class GridRenderer {
|
|
|
2071
1820
|
theme,
|
|
2072
1821
|
model
|
|
2073
1822
|
} = state;
|
|
2074
|
-
|
|
2075
1823
|
if (draggingColumn == null || mouseX == null) {
|
|
2076
1824
|
return;
|
|
2077
1825
|
}
|
|
2078
|
-
|
|
2079
1826
|
var {
|
|
2080
1827
|
range: draggingColumnVisibleRange,
|
|
2081
1828
|
depth: draggingColumnDepth
|
|
@@ -2095,11 +1842,9 @@ export class GridRenderer {
|
|
|
2095
1842
|
} = metrics;
|
|
2096
1843
|
var draggingModelIndex = (_modelColumns$get3 = modelColumns.get(draggingColumnVisibleRange[0])) !== null && _modelColumns$get3 !== void 0 ? _modelColumns$get3 : GridUtils.getModelIndex(draggingColumnVisibleRange[0], movedColumns);
|
|
2097
1844
|
var draggingGroup = model.getColumnHeaderGroup(draggingModelIndex, draggingColumnDepth);
|
|
2098
|
-
|
|
2099
1845
|
if (draggingColumnDepth > 0 && !draggingGroup) {
|
|
2100
1846
|
return;
|
|
2101
1847
|
}
|
|
2102
|
-
|
|
2103
1848
|
var [startIndex, endIndex] = draggingColumnVisibleRange;
|
|
2104
1849
|
var originalLeft = getOrThrow(visibleColumnXs, startIndex);
|
|
2105
1850
|
var originalRight = getOrThrow(visibleColumnXs, endIndex) + getOrThrow(visibleColumnWidths, endIndex);
|
|
@@ -2117,15 +1862,18 @@ export class GridRenderer {
|
|
|
2117
1862
|
context.save();
|
|
2118
1863
|
context.translate(gridX, 0);
|
|
2119
1864
|
context.save();
|
|
2120
|
-
context.beginPath();
|
|
1865
|
+
context.beginPath();
|
|
2121
1866
|
|
|
1867
|
+
// Don't draw over frozen columns
|
|
2122
1868
|
context.rect(floatingLeftWidth, 0, width, height);
|
|
2123
|
-
context.clip();
|
|
1869
|
+
context.clip();
|
|
2124
1870
|
|
|
1871
|
+
// First, we need to draw over where the column is coming from
|
|
2125
1872
|
context.fillStyle = backgroundColor;
|
|
2126
1873
|
context.fillRect(originalLeft, columnHeaderOffset, originalWidth, height);
|
|
2127
|
-
context.restore();
|
|
1874
|
+
context.restore();
|
|
2128
1875
|
|
|
1876
|
+
// Then draw the shadow of the moving column
|
|
2129
1877
|
context.translate(0, reorderOffset);
|
|
2130
1878
|
context.save();
|
|
2131
1879
|
context.shadowColor = shadowColor;
|
|
@@ -2133,26 +1881,25 @@ export class GridRenderer {
|
|
|
2133
1881
|
context.fillStyle = backgroundColor;
|
|
2134
1882
|
context.fillRect(draggingColumn.left, columnHeaderOffset + reorderOffset, draggingColumn.width, height);
|
|
2135
1883
|
context.restore(); // Reset style
|
|
2136
|
-
// Now set the clipping region and pretty much just redraw this column and all it's contents
|
|
2137
1884
|
|
|
1885
|
+
// Now set the clipping region and pretty much just redraw this column and all it's contents
|
|
2138
1886
|
context.beginPath();
|
|
2139
1887
|
context.rect(draggingColumn.left, columnHeaderOffset, draggingColumn.width + 1, height);
|
|
2140
1888
|
context.clip();
|
|
2141
1889
|
context.translate(draggingLeft - originalLeft, 0);
|
|
2142
1890
|
context.font = headerFont;
|
|
2143
1891
|
var visibleColumns = [];
|
|
2144
|
-
|
|
2145
1892
|
for (var i = draggingColumn.range[0]; i <= draggingColumn.range[1]; i += 1) {
|
|
2146
1893
|
visibleColumns.push(i);
|
|
2147
1894
|
}
|
|
1895
|
+
|
|
2148
1896
|
/**
|
|
2149
1897
|
* This will not draw the header text properly, but extensions of Grid
|
|
2150
1898
|
* may draw extra things in the header like sorts and filters
|
|
2151
1899
|
*/
|
|
1900
|
+
this.drawColumnHeaders(context, state);
|
|
2152
1901
|
|
|
2153
|
-
|
|
2154
|
-
this.drawColumnHeaders(context, state); // Ensure the column header gets drawn
|
|
2155
|
-
|
|
1902
|
+
// Ensure the column header gets drawn
|
|
2156
1903
|
this.drawColumnHeadersForRange(context, state, [visibleColumns[0], visibleColumns[visibleColumns.length - 1]], {
|
|
2157
1904
|
minX: originalLeft,
|
|
2158
1905
|
maxX: width
|
|
@@ -2160,14 +1907,11 @@ export class GridRenderer {
|
|
|
2160
1907
|
context.translate(0, gridY);
|
|
2161
1908
|
context.font = font;
|
|
2162
1909
|
this.drawGridBackground(context, state);
|
|
2163
|
-
|
|
2164
1910
|
for (var _i9 = startIndex; _i9 <= endIndex; _i9 += 1) {
|
|
2165
1911
|
this.drawColumnCellContents(context, state, _i9);
|
|
2166
1912
|
}
|
|
2167
|
-
|
|
2168
1913
|
context.restore();
|
|
2169
1914
|
}
|
|
2170
|
-
|
|
2171
1915
|
drawDraggingRow(context, state) {
|
|
2172
1916
|
var {
|
|
2173
1917
|
draggingRow,
|
|
@@ -2176,11 +1920,9 @@ export class GridRenderer {
|
|
|
2176
1920
|
mouseY,
|
|
2177
1921
|
theme
|
|
2178
1922
|
} = state;
|
|
2179
|
-
|
|
2180
1923
|
if (draggingRow == null || mouseY == null) {
|
|
2181
1924
|
return;
|
|
2182
1925
|
}
|
|
2183
|
-
|
|
2184
1926
|
var {
|
|
2185
1927
|
gridX,
|
|
2186
1928
|
gridY,
|
|
@@ -2199,32 +1941,35 @@ export class GridRenderer {
|
|
|
2199
1941
|
shadowColor
|
|
2200
1942
|
} = theme;
|
|
2201
1943
|
context.save();
|
|
2202
|
-
context.translate(0, gridY);
|
|
1944
|
+
context.translate(0, gridY);
|
|
2203
1945
|
|
|
1946
|
+
// First, we need to draw over the row stripes where the row is coming from
|
|
2204
1947
|
context.fillStyle = backgroundColor;
|
|
2205
1948
|
context.fillRect(0, y, width, rowHeight);
|
|
2206
|
-
context.translate(gridX + reorderOffset, mouseY - y - gridY - (draggingRowOffset !== null && draggingRowOffset !== void 0 ? draggingRowOffset : 0));
|
|
1949
|
+
context.translate(gridX + reorderOffset, mouseY - y - gridY - (draggingRowOffset !== null && draggingRowOffset !== void 0 ? draggingRowOffset : 0));
|
|
2207
1950
|
|
|
1951
|
+
// Then draw the shadow of the moving row
|
|
2208
1952
|
context.save();
|
|
2209
1953
|
context.shadowColor = shadowColor;
|
|
2210
1954
|
context.shadowBlur = shadowBlur;
|
|
2211
1955
|
context.fillStyle = backgroundColor;
|
|
2212
1956
|
context.fillRect(-gridX, y, width, rowHeight);
|
|
2213
|
-
context.restore();
|
|
1957
|
+
context.restore();
|
|
2214
1958
|
|
|
1959
|
+
// Now set the clipping region and pretty much just redraw this row and all it's contents
|
|
2215
1960
|
context.beginPath();
|
|
2216
1961
|
context.rect(-gridX, y, width, rowHeight);
|
|
2217
1962
|
context.clip();
|
|
2218
1963
|
context.font = font;
|
|
2219
1964
|
this.drawGridBackground(context, state);
|
|
2220
|
-
this.drawCellContents(context, state);
|
|
1965
|
+
this.drawCellContents(context, state);
|
|
2221
1966
|
|
|
1967
|
+
// Now translate it back up and draw the header
|
|
2222
1968
|
context.translate(-gridX, -gridY);
|
|
2223
1969
|
context.font = headerFont;
|
|
2224
1970
|
this.drawRowHeaders(context, state);
|
|
2225
1971
|
context.restore();
|
|
2226
1972
|
}
|
|
2227
|
-
|
|
2228
1973
|
drawScrollBars(context, state) {
|
|
2229
1974
|
var {
|
|
2230
1975
|
isDraggingHorizontalScrollBar,
|
|
@@ -2235,11 +1980,9 @@ export class GridRenderer {
|
|
|
2235
1980
|
mouseY,
|
|
2236
1981
|
theme
|
|
2237
1982
|
} = state;
|
|
2238
|
-
|
|
2239
1983
|
if (theme.scrollBarSize <= 0) {
|
|
2240
1984
|
return;
|
|
2241
1985
|
}
|
|
2242
|
-
|
|
2243
1986
|
var {
|
|
2244
1987
|
rowHeaderWidth,
|
|
2245
1988
|
columnHeaderHeight,
|
|
@@ -2273,12 +2016,12 @@ export class GridRenderer {
|
|
|
2273
2016
|
} = theme;
|
|
2274
2017
|
var isInbounds = mouseX != null && mouseY != null && mouseX <= width && mouseY <= height;
|
|
2275
2018
|
var isVerticalBarHover = isDraggingVerticalScrollBar || hasVerticalBar && !isDraggingHorizontalScrollBar && !isDragging && mouseX != null && mouseY != null && mouseX >= width - scrollBarHoverSize && mouseY <= barHeight + columnHeaderHeight && isInbounds;
|
|
2276
|
-
var isHorizontalBarHover = isDraggingHorizontalScrollBar || hasHorizontalBar && !isDraggingVerticalScrollBar && !isDragging && !isVerticalBarHover &&
|
|
2019
|
+
var isHorizontalBarHover = isDraggingHorizontalScrollBar || hasHorizontalBar && !isDraggingVerticalScrollBar && !isDragging && !isVerticalBarHover &&
|
|
2020
|
+
// vert bar gets priorty in overlapped corner hover area
|
|
2277
2021
|
mouseX != null && mouseY != null && mouseY >= height - scrollBarHoverSize && mouseX <= barWidth - rowHeaderWidth && isInbounds;
|
|
2278
2022
|
var hScrollBarSize = isHorizontalBarHover ? scrollBarHoverSize : scrollBarSize;
|
|
2279
2023
|
var vScrollBarSize = isVerticalBarHover ? scrollBarHoverSize : scrollBarSize;
|
|
2280
2024
|
context.translate(rowHeaderWidth, columnHeaderHeight);
|
|
2281
|
-
|
|
2282
2025
|
if (hasHorizontalBar && hasVerticalBar) {
|
|
2283
2026
|
// That little corner in the bottom right
|
|
2284
2027
|
context.fillStyle = scrollBarCasingColor;
|
|
@@ -2286,17 +2029,19 @@ export class GridRenderer {
|
|
|
2286
2029
|
context.fillStyle = scrollBarCornerColor;
|
|
2287
2030
|
context.fillRect(width - rowHeaderWidth - scrollBarSize + scrollBarCasingWidth, height - columnHeaderHeight - scrollBarSize + scrollBarCasingWidth, scrollBarSize - scrollBarCasingWidth, scrollBarSize - scrollBarCasingWidth);
|
|
2288
2031
|
}
|
|
2289
|
-
|
|
2290
2032
|
if (hasHorizontalBar) {
|
|
2291
2033
|
var x = scrollX;
|
|
2292
|
-
var y = height - columnHeaderHeight - hScrollBarSize;
|
|
2034
|
+
var y = height - columnHeaderHeight - hScrollBarSize;
|
|
2293
2035
|
|
|
2036
|
+
// scrollbar casing
|
|
2294
2037
|
context.fillStyle = scrollBarCasingColor;
|
|
2295
|
-
context.fillRect(0, y, barWidth, hScrollBarSize - scrollBarCasingWidth);
|
|
2038
|
+
context.fillRect(0, y, barWidth, hScrollBarSize - scrollBarCasingWidth);
|
|
2296
2039
|
|
|
2040
|
+
// scrollbar track
|
|
2297
2041
|
context.fillStyle = isHorizontalBarHover ? scrollBarHoverBackgroundColor : scrollBarBackgroundColor;
|
|
2298
|
-
context.fillRect(0, y + scrollBarCasingWidth, barWidth, hScrollBarSize - scrollBarCasingWidth);
|
|
2042
|
+
context.fillRect(0, y + scrollBarCasingWidth, barWidth, hScrollBarSize - scrollBarCasingWidth);
|
|
2299
2043
|
|
|
2044
|
+
// scrollbar thumb
|
|
2300
2045
|
if (isDraggingHorizontalScrollBar) {
|
|
2301
2046
|
context.fillStyle = scrollBarActiveColor;
|
|
2302
2047
|
} else if (isHorizontalBarHover) {
|
|
@@ -2304,12 +2049,10 @@ export class GridRenderer {
|
|
|
2304
2049
|
} else {
|
|
2305
2050
|
context.fillStyle = scrollBarColor;
|
|
2306
2051
|
}
|
|
2307
|
-
|
|
2308
2052
|
context.fillRect(x, y + scrollBarCasingWidth, handleWidth, hScrollBarSize - scrollBarCasingWidth);
|
|
2309
|
-
|
|
2310
2053
|
if (!autoSelectRow && scrollBarSelectionTick && scrollBarSelectionTickColor != null && scrollBarActiveSelectionTickColor != null) {
|
|
2311
|
-
context.fillStyle = scrollBarSelectionTickColor;
|
|
2312
|
-
|
|
2054
|
+
context.fillStyle = scrollBarSelectionTickColor;
|
|
2055
|
+
// Scrollbar Selection Tick
|
|
2313
2056
|
var {
|
|
2314
2057
|
selectedRanges,
|
|
2315
2058
|
cursorColumn
|
|
@@ -2321,53 +2064,47 @@ export class GridRenderer {
|
|
|
2321
2064
|
var filteredRanges = [...selectedRanges].filter(value => value.startColumn != null && value.endColumn != null);
|
|
2322
2065
|
var sortedRanges = filteredRanges.map(value => [value.startColumn, value.endColumn]).sort(GridUtils.compareRanges);
|
|
2323
2066
|
var mergedRanges = GridUtils.mergeSortedRanges(sortedRanges);
|
|
2324
|
-
|
|
2325
2067
|
var getTickX = index => {
|
|
2326
2068
|
if (index <= lastLeft) {
|
|
2327
2069
|
return index / lastLeft * (barWidth - handleWidth);
|
|
2328
2070
|
}
|
|
2329
|
-
|
|
2330
2071
|
return barWidth - handleWidth + (index - lastLeft) / (columnCount - lastLeft) * handleWidth;
|
|
2331
2072
|
};
|
|
2332
|
-
|
|
2333
2073
|
for (var i = 0; i < mergedRanges.length; i += 1) {
|
|
2334
2074
|
var range = mergedRanges[i];
|
|
2335
2075
|
var startColumn = range[0];
|
|
2336
2076
|
var endColumn = range[1];
|
|
2337
|
-
|
|
2338
2077
|
if (startColumn != null && endColumn != null && (startColumn !== cursorColumn || endColumn !== cursorColumn)) {
|
|
2339
2078
|
var tickX = getTickX(startColumn);
|
|
2340
2079
|
var tickWidth = Math.max(1, Math.round(getTickX(endColumn + 1) - tickX));
|
|
2341
2080
|
var trackHeight = hScrollBarSize - scrollBarCasingWidth;
|
|
2342
2081
|
context.fillRect(tickX, y + scrollBarCasingWidth + Math.round(trackHeight / 3), tickWidth, Math.round(trackHeight / 3));
|
|
2343
2082
|
}
|
|
2344
|
-
}
|
|
2345
|
-
|
|
2083
|
+
}
|
|
2346
2084
|
|
|
2085
|
+
// Current Active Tick
|
|
2347
2086
|
if (cursorColumn != null) {
|
|
2348
2087
|
var _tickX = getTickX(cursorColumn);
|
|
2349
|
-
|
|
2350
2088
|
var _tickWidth = 2;
|
|
2351
|
-
|
|
2352
2089
|
var _trackHeight = hScrollBarSize - scrollBarCasingWidth;
|
|
2353
|
-
|
|
2354
2090
|
context.fillStyle = scrollBarActiveSelectionTickColor;
|
|
2355
2091
|
context.fillRect(_tickX, y + scrollBarCasingWidth, _tickWidth, _trackHeight);
|
|
2356
2092
|
}
|
|
2357
2093
|
}
|
|
2358
2094
|
}
|
|
2359
|
-
|
|
2360
2095
|
if (hasVerticalBar) {
|
|
2361
2096
|
var _x5 = width - rowHeaderWidth - vScrollBarSize;
|
|
2097
|
+
var _y9 = scrollY;
|
|
2362
2098
|
|
|
2363
|
-
|
|
2364
|
-
|
|
2099
|
+
// scrollbar casing
|
|
2365
2100
|
context.fillStyle = scrollBarCasingColor;
|
|
2366
|
-
context.fillRect(_x5, 0, vScrollBarSize - scrollBarCasingWidth, barHeight);
|
|
2101
|
+
context.fillRect(_x5, 0, vScrollBarSize - scrollBarCasingWidth, barHeight);
|
|
2367
2102
|
|
|
2103
|
+
// scrollbar track
|
|
2368
2104
|
context.fillStyle = isVerticalBarHover ? scrollBarHoverBackgroundColor : scrollBarBackgroundColor;
|
|
2369
|
-
context.fillRect(_x5 + scrollBarCasingWidth, 0, vScrollBarSize - scrollBarCasingWidth, barHeight);
|
|
2105
|
+
context.fillRect(_x5 + scrollBarCasingWidth, 0, vScrollBarSize - scrollBarCasingWidth, barHeight);
|
|
2370
2106
|
|
|
2107
|
+
// scrollbar thumb
|
|
2371
2108
|
if (isDraggingVerticalScrollBar) {
|
|
2372
2109
|
context.fillStyle = scrollBarActiveColor;
|
|
2373
2110
|
} else if (isVerticalBarHover) {
|
|
@@ -2375,9 +2112,7 @@ export class GridRenderer {
|
|
|
2375
2112
|
} else {
|
|
2376
2113
|
context.fillStyle = scrollBarColor;
|
|
2377
2114
|
}
|
|
2378
|
-
|
|
2379
2115
|
context.fillRect(_x5 + scrollBarCasingWidth, _y9, vScrollBarSize - scrollBarCasingWidth, handleHeight);
|
|
2380
|
-
|
|
2381
2116
|
if (!autoSelectColumn && scrollBarSelectionTick && scrollBarSelectionTickColor != null && scrollBarActiveSelectionTickColor != null) {
|
|
2382
2117
|
// Scrollbar Selection Tick
|
|
2383
2118
|
var {
|
|
@@ -2388,59 +2123,43 @@ export class GridRenderer {
|
|
|
2388
2123
|
lastTop,
|
|
2389
2124
|
rowCount
|
|
2390
2125
|
} = metrics;
|
|
2391
|
-
|
|
2392
2126
|
var getTickY = index => {
|
|
2393
2127
|
if (index <= lastTop) {
|
|
2394
2128
|
return index / lastTop * (barHeight - handleHeight);
|
|
2395
2129
|
}
|
|
2396
|
-
|
|
2397
2130
|
return barHeight - handleHeight + (index - lastTop) / (rowCount - lastTop) * handleHeight;
|
|
2398
2131
|
};
|
|
2399
|
-
|
|
2400
2132
|
context.fillStyle = scrollBarSelectionTickColor;
|
|
2401
|
-
|
|
2402
2133
|
var _filteredRanges = [..._selectedRanges].filter(value => value.startRow != null && value.endRow != null);
|
|
2403
|
-
|
|
2404
2134
|
var _sortedRanges = _filteredRanges.map(value => [value.startRow, value.endRow]).sort(GridUtils.compareRanges);
|
|
2405
|
-
|
|
2406
2135
|
var _mergedRanges = GridUtils.mergeSortedRanges(_sortedRanges);
|
|
2407
|
-
|
|
2408
2136
|
for (var _i10 = 0; _i10 < _mergedRanges.length; _i10 += 1) {
|
|
2409
2137
|
var _range = _mergedRanges[_i10];
|
|
2410
2138
|
var startRow = _range[0];
|
|
2411
2139
|
var endRow = _range[1];
|
|
2412
|
-
|
|
2413
2140
|
if (startRow != null && endRow != null && (startRow !== cursorRow || endRow !== cursorRow)) {
|
|
2414
2141
|
var tickY = getTickY(startRow);
|
|
2415
2142
|
var trackWidth = vScrollBarSize - scrollBarCasingWidth;
|
|
2416
2143
|
var tickHeight = Math.max(1, Math.round(getTickY(endRow + 1) - tickY));
|
|
2417
2144
|
context.fillRect(_x5 + scrollBarCasingWidth + Math.round(trackWidth / 3), tickY, Math.round(trackWidth / 3), tickHeight);
|
|
2418
2145
|
}
|
|
2419
|
-
}
|
|
2420
|
-
|
|
2146
|
+
}
|
|
2421
2147
|
|
|
2148
|
+
// Current Active Tick
|
|
2422
2149
|
if (cursorRow != null) {
|
|
2423
2150
|
var _tickY = Math.round(getTickY(cursorRow));
|
|
2424
|
-
|
|
2425
2151
|
var _trackWidth = vScrollBarSize - scrollBarCasingWidth;
|
|
2426
|
-
|
|
2427
2152
|
var _tickHeight = 2;
|
|
2428
2153
|
context.fillStyle = scrollBarActiveSelectionTickColor;
|
|
2429
2154
|
context.fillRect(_x5 + scrollBarCasingWidth, _tickY, _trackWidth, _tickHeight);
|
|
2430
2155
|
}
|
|
2431
2156
|
}
|
|
2432
2157
|
}
|
|
2433
|
-
|
|
2434
2158
|
context.translate(-rowHeaderWidth, -columnHeaderHeight);
|
|
2435
2159
|
}
|
|
2436
|
-
|
|
2437
2160
|
}
|
|
2438
|
-
|
|
2439
2161
|
_defineProperty(GridRenderer, "DEFAULT_FONT_WIDTH", 10);
|
|
2440
|
-
|
|
2441
2162
|
_defineProperty(GridRenderer, "DEFAULT_EDGE_RADIUS", 2);
|
|
2442
|
-
|
|
2443
2163
|
_defineProperty(GridRenderer, "ACTIVE_CELL_BORDER_WIDTH", 2);
|
|
2444
|
-
|
|
2445
2164
|
export default GridRenderer;
|
|
2446
2165
|
//# sourceMappingURL=GridRenderer.js.map
|