@babylonjs/gui 9.15.0 → 9.16.1
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/2D/controls/checkbox.pure.js +164 -153
- package/2D/controls/checkbox.pure.js.map +1 -1
- package/2D/controls/colorpicker.pure.js +1300 -1289
- package/2D/controls/colorpicker.pure.js.map +1 -1
- package/2D/controls/container.pure.js +597 -582
- package/2D/controls/container.pure.js.map +1 -1
- package/2D/controls/control.pure.js +2474 -2434
- package/2D/controls/control.pure.js.map +1 -1
- package/2D/controls/displayGrid.pure.js +201 -190
- package/2D/controls/displayGrid.pure.js.map +1 -1
- package/2D/controls/ellipse.pure.js +96 -85
- package/2D/controls/ellipse.pure.js.map +1 -1
- package/2D/controls/grid.pure.js +511 -500
- package/2D/controls/grid.pure.js.map +1 -1
- package/2D/controls/image.pure.js +888 -877
- package/2D/controls/image.pure.js.map +1 -1
- package/2D/controls/inputText.pure.js +988 -973
- package/2D/controls/inputText.pure.js.map +1 -1
- package/2D/controls/inputTextArea.pure.js +955 -944
- package/2D/controls/inputTextArea.pure.js.map +1 -1
- package/2D/controls/line.pure.js +237 -226
- package/2D/controls/line.pure.js.map +1 -1
- package/2D/controls/multiLine.pure.js +233 -222
- package/2D/controls/multiLine.pure.js.map +1 -1
- package/2D/controls/radioButton.pure.js +182 -169
- package/2D/controls/radioButton.pure.js.map +1 -1
- package/2D/controls/rectangle.pure.js +211 -200
- package/2D/controls/rectangle.pure.js.map +1 -1
- package/2D/controls/scrollViewers/scrollViewer.pure.js +579 -567
- package/2D/controls/scrollViewers/scrollViewer.pure.js.map +1 -1
- package/2D/controls/sliders/baseSlider.js +291 -280
- package/2D/controls/sliders/baseSlider.js.map +1 -1
- package/2D/controls/sliders/imageBasedSlider.pure.js +158 -147
- package/2D/controls/sliders/imageBasedSlider.pure.js.map +1 -1
- package/2D/controls/sliders/imageScrollBar.js +237 -223
- package/2D/controls/sliders/imageScrollBar.js.map +1 -1
- package/2D/controls/sliders/scrollBar.pure.js +169 -158
- package/2D/controls/sliders/scrollBar.pure.js.map +1 -1
- package/2D/controls/sliders/slider.pure.js +251 -240
- package/2D/controls/sliders/slider.pure.js.map +1 -1
- package/2D/controls/stackPanel.pure.js +236 -221
- package/2D/controls/stackPanel.pure.js.map +1 -1
- package/2D/controls/textBlock.pure.js +637 -626
- package/2D/controls/textBlock.pure.js.map +1 -1
- package/3D/materials/fluent/fluentMaterial.pure.d.ts +4 -4
- package/3D/materials/fluent/fluentMaterial.pure.js +322 -273
- package/3D/materials/fluent/fluentMaterial.pure.js.map +1 -1
- package/3D/materials/fluentBackplate/fluentBackplateMaterial.pure.js +510 -454
- package/3D/materials/fluentBackplate/fluentBackplateMaterial.pure.js.map +1 -1
- package/3D/materials/fluentButton/fluentButtonMaterial.pure.js +612 -529
- package/3D/materials/fluentButton/fluentButtonMaterial.pure.js.map +1 -1
- package/3D/materials/mrdl/mrdlBackglowMaterial.pure.js +313 -274
- package/3D/materials/mrdl/mrdlBackglowMaterial.pure.js.map +1 -1
- package/3D/materials/mrdl/mrdlBackplateMaterial.pure.js +462 -405
- package/3D/materials/mrdl/mrdlBackplateMaterial.pure.js.map +1 -1
- package/3D/materials/mrdl/mrdlFrontplateMaterial.pure.js +583 -501
- package/3D/materials/mrdl/mrdlFrontplateMaterial.pure.js.map +1 -1
- package/3D/materials/mrdl/mrdlInnerquadMaterial.pure.js +226 -203
- package/3D/materials/mrdl/mrdlInnerquadMaterial.pure.js.map +1 -1
- package/3D/materials/mrdl/mrdlSliderBarMaterial.pure.js +961 -825
- package/3D/materials/mrdl/mrdlSliderBarMaterial.pure.js.map +1 -1
- package/3D/materials/mrdl/mrdlSliderThumbMaterial.pure.js +961 -825
- package/3D/materials/mrdl/mrdlSliderThumbMaterial.pure.js.map +1 -1
- package/package.json +2 -2
package/2D/controls/grid.pure.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __esDecorate, __runInitializers } from "@babylonjs/core/tslib.es6.js";
|
|
2
2
|
import { Container } from "./container.pure.js";
|
|
3
3
|
import { ValueAndUnit } from "../valueAndUnit.js";
|
|
4
4
|
import { Control } from "./control.pure.js";
|
|
@@ -8,522 +8,533 @@ import { serialize } from "@babylonjs/core/Misc/decorators.js";
|
|
|
8
8
|
/**
|
|
9
9
|
* Class used to create a 2D grid container
|
|
10
10
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
* Sets/Gets a boolean indicating if the children are clipped to the current control bounds.
|
|
28
|
-
* Please note that not clipping children may generate issues with adt.useInvalidateRectOptimization so it is recommended to turn this optimization off if you want to use unclipped children
|
|
29
|
-
*/
|
|
30
|
-
set clipChildren(value) {
|
|
31
|
-
this._clipChildren = value;
|
|
32
|
-
// This value has to be replicated on all of the container cells
|
|
33
|
-
for (const key in this._cells) {
|
|
34
|
-
this._cells[key].clipChildren = value;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
get clipChildren() {
|
|
38
|
-
return this._clipChildren;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Gets the number of columns
|
|
42
|
-
*/
|
|
43
|
-
get columnCount() {
|
|
44
|
-
return this._columnDefinitions.length;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Gets the number of rows
|
|
48
|
-
*/
|
|
49
|
-
get rowCount() {
|
|
50
|
-
return this._rowDefinitions.length;
|
|
51
|
-
}
|
|
52
|
-
/** Gets the list of children */
|
|
53
|
-
get children() {
|
|
54
|
-
return this._childControls;
|
|
55
|
-
}
|
|
56
|
-
/** Gets the list of cells (e.g. the containers) */
|
|
57
|
-
get cells() {
|
|
58
|
-
return this._cells;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Gets the definition of a specific row
|
|
62
|
-
* @param index defines the index of the row
|
|
63
|
-
* @returns the row definition
|
|
64
|
-
*/
|
|
65
|
-
getRowDefinition(index) {
|
|
66
|
-
if (index < 0 || index >= this._rowDefinitions.length) {
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
return this._rowDefinitions[index];
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Gets the definition of a specific column
|
|
73
|
-
* @param index defines the index of the column
|
|
74
|
-
* @returns the column definition
|
|
75
|
-
*/
|
|
76
|
-
getColumnDefinition(index) {
|
|
77
|
-
if (index < 0 || index >= this._columnDefinitions.length) {
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
return this._columnDefinitions[index];
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Adds a new row to the grid
|
|
84
|
-
* @param height defines the height of the row (either in pixel or a value between 0 and 1)
|
|
85
|
-
* @param isPixel defines if the height is expressed in pixel (or in percentage)
|
|
86
|
-
* @returns the current grid
|
|
87
|
-
*/
|
|
88
|
-
addRowDefinition(height, isPixel = false) {
|
|
89
|
-
this._rowDefinitions.push(new ValueAndUnit(height, isPixel ? ValueAndUnit.UNITMODE_PIXEL : ValueAndUnit.UNITMODE_PERCENTAGE));
|
|
90
|
-
this._rowDefinitionObservers.push(this._rowDefinitions[this.rowCount - 1].onChangedObservable.add(() => this._markAsDirty()));
|
|
91
|
-
this._markAsDirty();
|
|
92
|
-
return this;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Adds a new column to the grid
|
|
96
|
-
* @param width defines the width of the column (either in pixel or a value between 0 and 1)
|
|
97
|
-
* @param isPixel defines if the width is expressed in pixel (or in percentage)
|
|
98
|
-
* @returns the current grid
|
|
99
|
-
*/
|
|
100
|
-
addColumnDefinition(width, isPixel = false) {
|
|
101
|
-
this._columnDefinitions.push(new ValueAndUnit(width, isPixel ? ValueAndUnit.UNITMODE_PIXEL : ValueAndUnit.UNITMODE_PERCENTAGE));
|
|
102
|
-
this._columnDefinitionObservers.push(this._columnDefinitions[this.columnCount - 1].onChangedObservable.add(() => this._markAsDirty()));
|
|
103
|
-
this._markAsDirty();
|
|
104
|
-
return this;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Update a row definition
|
|
108
|
-
* @param index defines the index of the row to update
|
|
109
|
-
* @param height defines the height of the row (either in pixel or a value between 0 and 1)
|
|
110
|
-
* @param isPixel defines if the weight is expressed in pixel (or in percentage)
|
|
111
|
-
* @returns the current grid
|
|
112
|
-
*/
|
|
113
|
-
setRowDefinition(index, height, isPixel = false) {
|
|
114
|
-
if (index < 0 || index >= this._rowDefinitions.length) {
|
|
115
|
-
return this;
|
|
116
|
-
}
|
|
117
|
-
const current = this._rowDefinitions[index];
|
|
118
|
-
if (current && current.isPixel === isPixel && current.value === height) {
|
|
119
|
-
return this;
|
|
120
|
-
}
|
|
121
|
-
this._rowDefinitions[index].onChangedObservable.remove(this._rowDefinitionObservers[index]);
|
|
122
|
-
this._rowDefinitions[index] = new ValueAndUnit(height, isPixel ? ValueAndUnit.UNITMODE_PIXEL : ValueAndUnit.UNITMODE_PERCENTAGE);
|
|
123
|
-
this._rowDefinitionObservers[index] = this._rowDefinitions[index].onChangedObservable.add(() => this._markAsDirty());
|
|
124
|
-
this._markAsDirty();
|
|
125
|
-
return this;
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Update a column definition
|
|
129
|
-
* @param index defines the index of the column to update
|
|
130
|
-
* @param width defines the width of the column (either in pixel or a value between 0 and 1)
|
|
131
|
-
* @param isPixel defines if the width is expressed in pixel (or in percentage)
|
|
132
|
-
* @returns the current grid
|
|
133
|
-
*/
|
|
134
|
-
setColumnDefinition(index, width, isPixel = false) {
|
|
135
|
-
if (index < 0 || index >= this._columnDefinitions.length) {
|
|
136
|
-
return this;
|
|
137
|
-
}
|
|
138
|
-
const current = this._columnDefinitions[index];
|
|
139
|
-
if (current && current.isPixel === isPixel && current.value === width) {
|
|
140
|
-
return this;
|
|
141
|
-
}
|
|
142
|
-
this._columnDefinitions[index].onChangedObservable.remove(this._columnDefinitionObservers[index]);
|
|
143
|
-
this._columnDefinitions[index] = new ValueAndUnit(width, isPixel ? ValueAndUnit.UNITMODE_PIXEL : ValueAndUnit.UNITMODE_PERCENTAGE);
|
|
144
|
-
this._columnDefinitionObservers[index] = this._columnDefinitions[index].onChangedObservable.add(() => this._markAsDirty());
|
|
145
|
-
this._markAsDirty();
|
|
146
|
-
return this;
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Gets the list of children stored in a specific cell
|
|
150
|
-
* @param row defines the row to check
|
|
151
|
-
* @param column defines the column to check
|
|
152
|
-
* @returns the list of controls
|
|
153
|
-
*/
|
|
154
|
-
getChildrenAt(row, column) {
|
|
155
|
-
const cell = this._cells[`${row}:${column}`];
|
|
156
|
-
if (!cell) {
|
|
157
|
-
return null;
|
|
158
|
-
}
|
|
159
|
-
return cell.children;
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Gets a string representing the child cell info (row x column)
|
|
163
|
-
* @param child defines the control to get info from
|
|
164
|
-
* @returns a string containing the child cell info (row x column)
|
|
165
|
-
*/
|
|
166
|
-
getChildCellInfo(child) {
|
|
167
|
-
return child._tag;
|
|
168
|
-
}
|
|
169
|
-
_removeCell(cell, key) {
|
|
170
|
-
if (!cell) {
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
super.removeControl(cell);
|
|
174
|
-
for (const control of cell.children) {
|
|
175
|
-
const childIndex = this._childControls.indexOf(control);
|
|
176
|
-
if (childIndex !== -1) {
|
|
177
|
-
this._childControls.splice(childIndex, 1);
|
|
11
|
+
let Grid = (() => {
|
|
12
|
+
var _a;
|
|
13
|
+
let _classSuper = Container;
|
|
14
|
+
let _instanceExtraInitializers = [];
|
|
15
|
+
let _get_clipContent_decorators;
|
|
16
|
+
return _a = class Grid extends _classSuper {
|
|
17
|
+
/**
|
|
18
|
+
* Sets/Gets a boolean indicating that control content must be clipped
|
|
19
|
+
* Please note that not clipping content may generate issues with adt.useInvalidateRectOptimization so it is recommended to turn this optimization off if you want to use unclipped children
|
|
20
|
+
*/
|
|
21
|
+
set clipContent(value) {
|
|
22
|
+
this._clipContent = value;
|
|
23
|
+
// This value has to be replicated on all of the container cells
|
|
24
|
+
for (const key in this._cells) {
|
|
25
|
+
this._cells[key].clipContent = value;
|
|
26
|
+
}
|
|
178
27
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
_offsetCell(previousKey, key) {
|
|
183
|
-
if (!this._cells[key]) {
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
this._cells[previousKey] = this._cells[key];
|
|
187
|
-
for (const control of this._cells[previousKey].children) {
|
|
188
|
-
control._tag = previousKey;
|
|
189
|
-
}
|
|
190
|
-
delete this._cells[key];
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* Remove a column definition at specified index
|
|
194
|
-
* @param index defines the index of the column to remove
|
|
195
|
-
* @returns the current grid
|
|
196
|
-
*/
|
|
197
|
-
removeColumnDefinition(index) {
|
|
198
|
-
if (index < 0 || index >= this._columnDefinitions.length) {
|
|
199
|
-
return this;
|
|
200
|
-
}
|
|
201
|
-
for (let x = 0; x < this._rowDefinitions.length; x++) {
|
|
202
|
-
const key = `${x}:${index}`;
|
|
203
|
-
const cell = this._cells[key];
|
|
204
|
-
this._removeCell(cell, key);
|
|
205
|
-
}
|
|
206
|
-
for (let x = 0; x < this._rowDefinitions.length; x++) {
|
|
207
|
-
for (let y = index + 1; y < this._columnDefinitions.length; y++) {
|
|
208
|
-
const previousKey = `${x}:${y - 1}`;
|
|
209
|
-
const key = `${x}:${y}`;
|
|
210
|
-
this._offsetCell(previousKey, key);
|
|
28
|
+
get clipContent() {
|
|
29
|
+
return this._clipContent;
|
|
211
30
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
* @returns the current grid
|
|
223
|
-
*/
|
|
224
|
-
removeRowDefinition(index) {
|
|
225
|
-
if (index < 0 || index >= this._rowDefinitions.length) {
|
|
226
|
-
return this;
|
|
227
|
-
}
|
|
228
|
-
for (let y = 0; y < this._columnDefinitions.length; y++) {
|
|
229
|
-
const key = `${index}:${y}`;
|
|
230
|
-
const cell = this._cells[key];
|
|
231
|
-
this._removeCell(cell, key);
|
|
232
|
-
}
|
|
233
|
-
for (let y = 0; y < this._columnDefinitions.length; y++) {
|
|
234
|
-
for (let x = index + 1; x < this._rowDefinitions.length; x++) {
|
|
235
|
-
const previousKey = `${x - 1}:${y}`;
|
|
236
|
-
const key = `${x}:${y}`;
|
|
237
|
-
this._offsetCell(previousKey, key);
|
|
31
|
+
/**
|
|
32
|
+
* Sets/Gets a boolean indicating if the children are clipped to the current control bounds.
|
|
33
|
+
* Please note that not clipping children may generate issues with adt.useInvalidateRectOptimization so it is recommended to turn this optimization off if you want to use unclipped children
|
|
34
|
+
*/
|
|
35
|
+
set clipChildren(value) {
|
|
36
|
+
this._clipChildren = value;
|
|
37
|
+
// This value has to be replicated on all of the container cells
|
|
38
|
+
for (const key in this._cells) {
|
|
39
|
+
this._cells[key].clipChildren = value;
|
|
40
|
+
}
|
|
238
41
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
this._rowDefinitions.splice(index, 1);
|
|
242
|
-
this._rowDefinitionObservers.splice(index, 1);
|
|
243
|
-
this._markAsDirty();
|
|
244
|
-
return this;
|
|
245
|
-
}
|
|
246
|
-
/**
|
|
247
|
-
* Adds a new control to the current grid
|
|
248
|
-
* @param control defines the control to add
|
|
249
|
-
* @param row defines the row where to add the control (0 by default)
|
|
250
|
-
* @param column defines the column where to add the control (0 by default)
|
|
251
|
-
* @returns the current grid
|
|
252
|
-
*/
|
|
253
|
-
addControl(control, row = 0, column = 0) {
|
|
254
|
-
if (this._rowDefinitions.length === 0) {
|
|
255
|
-
// Add default row definition
|
|
256
|
-
this.addRowDefinition(1, false);
|
|
257
|
-
}
|
|
258
|
-
if (this._columnDefinitions.length === 0) {
|
|
259
|
-
// Add default column definition
|
|
260
|
-
this.addColumnDefinition(1, false);
|
|
261
|
-
}
|
|
262
|
-
if (this._childControls.indexOf(control) !== -1) {
|
|
263
|
-
Tools.Warn(`Control (Name:${control.name}, UniqueId:${control.uniqueId}) is already associated with this grid. You must remove it before reattaching it`);
|
|
264
|
-
return this;
|
|
265
|
-
}
|
|
266
|
-
const x = Math.min(row, this._rowDefinitions.length - 1);
|
|
267
|
-
const y = Math.min(column, this._columnDefinitions.length - 1);
|
|
268
|
-
const key = `${x}:${y}`;
|
|
269
|
-
let goodContainer = this._cells[key];
|
|
270
|
-
if (!goodContainer) {
|
|
271
|
-
goodContainer = new Container(key);
|
|
272
|
-
this._cells[key] = goodContainer;
|
|
273
|
-
goodContainer.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
|
|
274
|
-
goodContainer.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
|
|
275
|
-
goodContainer.clipContent = this.clipContent;
|
|
276
|
-
goodContainer.clipChildren = this.clipChildren;
|
|
277
|
-
super.addControl(goodContainer);
|
|
278
|
-
}
|
|
279
|
-
goodContainer.addControl(control);
|
|
280
|
-
this._childControls.push(control);
|
|
281
|
-
control._tag = key;
|
|
282
|
-
control.parent = this;
|
|
283
|
-
this._markAsDirty();
|
|
284
|
-
return this;
|
|
285
|
-
}
|
|
286
|
-
/**
|
|
287
|
-
* Removes a control from the current container
|
|
288
|
-
* @param control defines the control to remove
|
|
289
|
-
* @returns the current container
|
|
290
|
-
*/
|
|
291
|
-
removeControl(control) {
|
|
292
|
-
const index = this._childControls.indexOf(control);
|
|
293
|
-
if (index !== -1) {
|
|
294
|
-
this._childControls.splice(index, 1);
|
|
295
|
-
}
|
|
296
|
-
const cell = this._cells[control._tag];
|
|
297
|
-
if (cell) {
|
|
298
|
-
cell.removeControl(control);
|
|
299
|
-
control._tag = null;
|
|
300
|
-
}
|
|
301
|
-
this._markAsDirty();
|
|
302
|
-
return this;
|
|
303
|
-
}
|
|
304
|
-
/**
|
|
305
|
-
* Creates a new Grid
|
|
306
|
-
* @param name defines control name
|
|
307
|
-
*/
|
|
308
|
-
constructor(name) {
|
|
309
|
-
super(name);
|
|
310
|
-
this.name = name;
|
|
311
|
-
this._rowDefinitions = new Array();
|
|
312
|
-
this._rowDefinitionObservers = [];
|
|
313
|
-
this._columnDefinitions = new Array();
|
|
314
|
-
this._columnDefinitionObservers = [];
|
|
315
|
-
this._cells = {};
|
|
316
|
-
this._childControls = new Array();
|
|
317
|
-
}
|
|
318
|
-
_getTypeName() {
|
|
319
|
-
return "Grid";
|
|
320
|
-
}
|
|
321
|
-
_getGridDefinitions(definitionCallback) {
|
|
322
|
-
const widths = [];
|
|
323
|
-
const heights = [];
|
|
324
|
-
const lefts = [];
|
|
325
|
-
const tops = [];
|
|
326
|
-
let availableWidth = this._currentMeasure.width;
|
|
327
|
-
let globalWidthPercentage = 0;
|
|
328
|
-
let availableHeight = this._currentMeasure.height;
|
|
329
|
-
let globalHeightPercentage = 0;
|
|
330
|
-
// Heights
|
|
331
|
-
let index = 0;
|
|
332
|
-
for (const rowDefinition of this._rowDefinitions) {
|
|
333
|
-
if (rowDefinition.isPixel) {
|
|
334
|
-
const height = rowDefinition.getValue(this._host);
|
|
335
|
-
availableHeight -= height;
|
|
336
|
-
heights[index] = height;
|
|
42
|
+
get clipChildren() {
|
|
43
|
+
return this._clipChildren;
|
|
337
44
|
}
|
|
338
|
-
|
|
339
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Gets the number of columns
|
|
47
|
+
*/
|
|
48
|
+
get columnCount() {
|
|
49
|
+
return this._columnDefinitions.length;
|
|
340
50
|
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
tops.push(top);
|
|
347
|
-
if (!rowDefinition.isPixel) {
|
|
348
|
-
const height = Math.round((rowDefinition.value / globalHeightPercentage) * availableHeight);
|
|
349
|
-
top += height;
|
|
350
|
-
heights[index] = height;
|
|
51
|
+
/**
|
|
52
|
+
* Gets the number of rows
|
|
53
|
+
*/
|
|
54
|
+
get rowCount() {
|
|
55
|
+
return this._rowDefinitions.length;
|
|
351
56
|
}
|
|
352
|
-
|
|
353
|
-
|
|
57
|
+
/** Gets the list of children */
|
|
58
|
+
get children() {
|
|
59
|
+
return this._childControls;
|
|
354
60
|
}
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
index = 0;
|
|
359
|
-
for (const columnDefinition of this._columnDefinitions) {
|
|
360
|
-
if (columnDefinition.isPixel) {
|
|
361
|
-
const width = columnDefinition.getValue(this._host);
|
|
362
|
-
availableWidth -= width;
|
|
363
|
-
widths[index] = width;
|
|
61
|
+
/** Gets the list of cells (e.g. the containers) */
|
|
62
|
+
get cells() {
|
|
63
|
+
return this._cells;
|
|
364
64
|
}
|
|
365
|
-
|
|
366
|
-
|
|
65
|
+
/**
|
|
66
|
+
* Gets the definition of a specific row
|
|
67
|
+
* @param index defines the index of the row
|
|
68
|
+
* @returns the row definition
|
|
69
|
+
*/
|
|
70
|
+
getRowDefinition(index) {
|
|
71
|
+
if (index < 0 || index >= this._rowDefinitions.length) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
return this._rowDefinitions[index];
|
|
367
75
|
}
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Gets the definition of a specific column
|
|
78
|
+
* @param index defines the index of the column
|
|
79
|
+
* @returns the column definition
|
|
80
|
+
*/
|
|
81
|
+
getColumnDefinition(index) {
|
|
82
|
+
if (index < 0 || index >= this._columnDefinitions.length) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
return this._columnDefinitions[index];
|
|
378
86
|
}
|
|
379
|
-
|
|
380
|
-
|
|
87
|
+
/**
|
|
88
|
+
* Adds a new row to the grid
|
|
89
|
+
* @param height defines the height of the row (either in pixel or a value between 0 and 1)
|
|
90
|
+
* @param isPixel defines if the height is expressed in pixel (or in percentage)
|
|
91
|
+
* @returns the current grid
|
|
92
|
+
*/
|
|
93
|
+
addRowDefinition(height, isPixel = false) {
|
|
94
|
+
this._rowDefinitions.push(new ValueAndUnit(height, isPixel ? ValueAndUnit.UNITMODE_PIXEL : ValueAndUnit.UNITMODE_PERCENTAGE));
|
|
95
|
+
this._rowDefinitionObservers.push(this._rowDefinitions[this.rowCount - 1].onChangedObservable.add(() => this._markAsDirty()));
|
|
96
|
+
this._markAsDirty();
|
|
97
|
+
return this;
|
|
381
98
|
}
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
const split = key.split(":");
|
|
394
|
-
const x = parseInt(split[0]);
|
|
395
|
-
const y = parseInt(split[1]);
|
|
396
|
-
const cell = this._cells[key];
|
|
397
|
-
cell.leftInPixels = lefts[y];
|
|
398
|
-
cell.topInPixels = tops[x];
|
|
399
|
-
cell.widthInPixels = widths[y];
|
|
400
|
-
cell.heightInPixels = heights[x];
|
|
401
|
-
cell._left.ignoreAdaptiveScaling = true;
|
|
402
|
-
cell._top.ignoreAdaptiveScaling = true;
|
|
403
|
-
cell._width.ignoreAdaptiveScaling = true;
|
|
404
|
-
cell._height.ignoreAdaptiveScaling = true;
|
|
99
|
+
/**
|
|
100
|
+
* Adds a new column to the grid
|
|
101
|
+
* @param width defines the width of the column (either in pixel or a value between 0 and 1)
|
|
102
|
+
* @param isPixel defines if the width is expressed in pixel (or in percentage)
|
|
103
|
+
* @returns the current grid
|
|
104
|
+
*/
|
|
105
|
+
addColumnDefinition(width, isPixel = false) {
|
|
106
|
+
this._columnDefinitions.push(new ValueAndUnit(width, isPixel ? ValueAndUnit.UNITMODE_PIXEL : ValueAndUnit.UNITMODE_PERCENTAGE));
|
|
107
|
+
this._columnDefinitionObservers.push(this._columnDefinitions[this.columnCount - 1].onChangedObservable.add(() => this._markAsDirty()));
|
|
108
|
+
this._markAsDirty();
|
|
109
|
+
return this;
|
|
405
110
|
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
111
|
+
/**
|
|
112
|
+
* Update a row definition
|
|
113
|
+
* @param index defines the index of the row to update
|
|
114
|
+
* @param height defines the height of the row (either in pixel or a value between 0 and 1)
|
|
115
|
+
* @param isPixel defines if the weight is expressed in pixel (or in percentage)
|
|
116
|
+
* @returns the current grid
|
|
117
|
+
*/
|
|
118
|
+
setRowDefinition(index, height, isPixel = false) {
|
|
119
|
+
if (index < 0 || index >= this._rowDefinitions.length) {
|
|
120
|
+
return this;
|
|
121
|
+
}
|
|
122
|
+
const current = this._rowDefinitions[index];
|
|
123
|
+
if (current && current.isPixel === isPixel && current.value === height) {
|
|
124
|
+
return this;
|
|
125
|
+
}
|
|
126
|
+
this._rowDefinitions[index].onChangedObservable.remove(this._rowDefinitionObservers[index]);
|
|
127
|
+
this._rowDefinitions[index] = new ValueAndUnit(height, isPixel ? ValueAndUnit.UNITMODE_PIXEL : ValueAndUnit.UNITMODE_PERCENTAGE);
|
|
128
|
+
this._rowDefinitionObservers[index] = this._rowDefinitions[index].onChangedObservable.add(() => this._markAsDirty());
|
|
129
|
+
this._markAsDirty();
|
|
130
|
+
return this;
|
|
413
131
|
}
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
132
|
+
/**
|
|
133
|
+
* Update a column definition
|
|
134
|
+
* @param index defines the index of the column to update
|
|
135
|
+
* @param width defines the width of the column (either in pixel or a value between 0 and 1)
|
|
136
|
+
* @param isPixel defines if the width is expressed in pixel (or in percentage)
|
|
137
|
+
* @returns the current grid
|
|
138
|
+
*/
|
|
139
|
+
setColumnDefinition(index, width, isPixel = false) {
|
|
140
|
+
if (index < 0 || index >= this._columnDefinitions.length) {
|
|
141
|
+
return this;
|
|
142
|
+
}
|
|
143
|
+
const current = this._columnDefinitions[index];
|
|
144
|
+
if (current && current.isPixel === isPixel && current.value === width) {
|
|
145
|
+
return this;
|
|
146
|
+
}
|
|
147
|
+
this._columnDefinitions[index].onChangedObservable.remove(this._columnDefinitionObservers[index]);
|
|
148
|
+
this._columnDefinitions[index] = new ValueAndUnit(width, isPixel ? ValueAndUnit.UNITMODE_PIXEL : ValueAndUnit.UNITMODE_PERCENTAGE);
|
|
149
|
+
this._columnDefinitionObservers[index] = this._columnDefinitions[index].onChangedObservable.add(() => this._markAsDirty());
|
|
150
|
+
this._markAsDirty();
|
|
151
|
+
return this;
|
|
428
152
|
}
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
153
|
+
/**
|
|
154
|
+
* Gets the list of children stored in a specific cell
|
|
155
|
+
* @param row defines the row to check
|
|
156
|
+
* @param column defines the column to check
|
|
157
|
+
* @returns the list of controls
|
|
158
|
+
*/
|
|
159
|
+
getChildrenAt(row, column) {
|
|
160
|
+
const cell = this._cells[`${row}:${column}`];
|
|
161
|
+
if (!cell) {
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
return cell.children;
|
|
436
165
|
}
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
control.dispose();
|
|
445
|
-
}
|
|
446
|
-
for (let index = 0; index < this._rowDefinitions.length; index++) {
|
|
447
|
-
this._rowDefinitions[index].onChangedObservable.remove(this._rowDefinitionObservers[index]);
|
|
448
|
-
}
|
|
449
|
-
for (let index = 0; index < this._columnDefinitions.length; index++) {
|
|
450
|
-
this._columnDefinitions[index].onChangedObservable.remove(this._columnDefinitionObservers[index]);
|
|
451
|
-
}
|
|
452
|
-
this._rowDefinitionObservers.length = 0;
|
|
453
|
-
this._rowDefinitions.length = 0;
|
|
454
|
-
this._columnDefinitionObservers.length = 0;
|
|
455
|
-
this._columnDefinitions.length = 0;
|
|
456
|
-
this._cells = {};
|
|
457
|
-
this._childControls.length = 0;
|
|
458
|
-
}
|
|
459
|
-
/**
|
|
460
|
-
* Serializes the current control
|
|
461
|
-
* @param serializationObject defined the JSON serialized object
|
|
462
|
-
* @param force force serialization even if isSerializable === false
|
|
463
|
-
* @param allowCanvas defines if the control is allowed to use a Canvas2D object to serialize
|
|
464
|
-
*/
|
|
465
|
-
serialize(serializationObject, force, allowCanvas) {
|
|
466
|
-
super.serialize(serializationObject, force, allowCanvas);
|
|
467
|
-
if (!this.isSerializable && !force) {
|
|
468
|
-
return;
|
|
469
|
-
}
|
|
470
|
-
serializationObject.columnCount = this.columnCount;
|
|
471
|
-
serializationObject.rowCount = this.rowCount;
|
|
472
|
-
serializationObject.columns = [];
|
|
473
|
-
serializationObject.rows = [];
|
|
474
|
-
serializationObject.tags = [];
|
|
475
|
-
for (let i = 0; i < this.columnCount; ++i) {
|
|
476
|
-
const cd = this.getColumnDefinition(i);
|
|
477
|
-
const childSerializationObject = { value: cd?.getValue(this.host), unit: cd?.unit };
|
|
478
|
-
serializationObject.columns.push(childSerializationObject);
|
|
479
|
-
}
|
|
480
|
-
for (let i = 0; i < this.rowCount; ++i) {
|
|
481
|
-
const rd = this.getRowDefinition(i);
|
|
482
|
-
const childSerializationObject = { value: rd?.getValue(this.host), unit: rd?.unit };
|
|
483
|
-
serializationObject.rows.push(childSerializationObject);
|
|
484
|
-
}
|
|
485
|
-
for (const child of this.children) {
|
|
486
|
-
serializationObject.tags.push(child._tag);
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
/**
|
|
490
|
-
* @internal
|
|
491
|
-
*/
|
|
492
|
-
_parseFromContent(serializedObject, host) {
|
|
493
|
-
super._parseFromContent(serializedObject, host);
|
|
494
|
-
const children = [];
|
|
495
|
-
for (const child of this.children) {
|
|
496
|
-
children.push(child);
|
|
497
|
-
}
|
|
498
|
-
this.removeRowDefinition(0);
|
|
499
|
-
this.removeColumnDefinition(0);
|
|
500
|
-
for (let i = 0; i < serializedObject.columnCount; ++i) {
|
|
501
|
-
const columnValue = serializedObject.columns[i].value;
|
|
502
|
-
const unit = serializedObject.columns[i].unit;
|
|
503
|
-
this.addColumnDefinition(columnValue, unit === 1 ? true : false);
|
|
504
|
-
}
|
|
505
|
-
for (let i = 0; i < serializedObject.rowCount; ++i) {
|
|
506
|
-
const rowValue = serializedObject.rows[i].value;
|
|
507
|
-
const unit = serializedObject.rows[i].unit;
|
|
508
|
-
this.addRowDefinition(rowValue, unit === 1 ? true : false);
|
|
509
|
-
}
|
|
510
|
-
for (let i = 0; i < children.length; ++i) {
|
|
511
|
-
const cellInfo = serializedObject.tags[i];
|
|
512
|
-
let rowNumber = parseInt(cellInfo.substring(0, cellInfo.search(":")));
|
|
513
|
-
if (isNaN(rowNumber)) {
|
|
514
|
-
rowNumber = 0;
|
|
166
|
+
/**
|
|
167
|
+
* Gets a string representing the child cell info (row x column)
|
|
168
|
+
* @param child defines the control to get info from
|
|
169
|
+
* @returns a string containing the child cell info (row x column)
|
|
170
|
+
*/
|
|
171
|
+
getChildCellInfo(child) {
|
|
172
|
+
return child._tag;
|
|
515
173
|
}
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
174
|
+
_removeCell(cell, key) {
|
|
175
|
+
if (!cell) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
super.removeControl(cell);
|
|
179
|
+
for (const control of cell.children) {
|
|
180
|
+
const childIndex = this._childControls.indexOf(control);
|
|
181
|
+
if (childIndex !== -1) {
|
|
182
|
+
this._childControls.splice(childIndex, 1);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
delete this._cells[key];
|
|
519
186
|
}
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
187
|
+
_offsetCell(previousKey, key) {
|
|
188
|
+
if (!this._cells[key]) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
this._cells[previousKey] = this._cells[key];
|
|
192
|
+
for (const control of this._cells[previousKey].children) {
|
|
193
|
+
control._tag = previousKey;
|
|
194
|
+
}
|
|
195
|
+
delete this._cells[key];
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Remove a column definition at specified index
|
|
199
|
+
* @param index defines the index of the column to remove
|
|
200
|
+
* @returns the current grid
|
|
201
|
+
*/
|
|
202
|
+
removeColumnDefinition(index) {
|
|
203
|
+
if (index < 0 || index >= this._columnDefinitions.length) {
|
|
204
|
+
return this;
|
|
205
|
+
}
|
|
206
|
+
for (let x = 0; x < this._rowDefinitions.length; x++) {
|
|
207
|
+
const key = `${x}:${index}`;
|
|
208
|
+
const cell = this._cells[key];
|
|
209
|
+
this._removeCell(cell, key);
|
|
210
|
+
}
|
|
211
|
+
for (let x = 0; x < this._rowDefinitions.length; x++) {
|
|
212
|
+
for (let y = index + 1; y < this._columnDefinitions.length; y++) {
|
|
213
|
+
const previousKey = `${x}:${y - 1}`;
|
|
214
|
+
const key = `${x}:${y}`;
|
|
215
|
+
this._offsetCell(previousKey, key);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
this._columnDefinitions[index].onChangedObservable.remove(this._columnDefinitionObservers[index]);
|
|
219
|
+
this._columnDefinitions.splice(index, 1);
|
|
220
|
+
this._columnDefinitionObservers.splice(index, 1);
|
|
221
|
+
this._markAsDirty();
|
|
222
|
+
return this;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Remove a row definition at specified index
|
|
226
|
+
* @param index defines the index of the row to remove
|
|
227
|
+
* @returns the current grid
|
|
228
|
+
*/
|
|
229
|
+
removeRowDefinition(index) {
|
|
230
|
+
if (index < 0 || index >= this._rowDefinitions.length) {
|
|
231
|
+
return this;
|
|
232
|
+
}
|
|
233
|
+
for (let y = 0; y < this._columnDefinitions.length; y++) {
|
|
234
|
+
const key = `${index}:${y}`;
|
|
235
|
+
const cell = this._cells[key];
|
|
236
|
+
this._removeCell(cell, key);
|
|
237
|
+
}
|
|
238
|
+
for (let y = 0; y < this._columnDefinitions.length; y++) {
|
|
239
|
+
for (let x = index + 1; x < this._rowDefinitions.length; x++) {
|
|
240
|
+
const previousKey = `${x - 1}:${y}`;
|
|
241
|
+
const key = `${x}:${y}`;
|
|
242
|
+
this._offsetCell(previousKey, key);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
this._rowDefinitions[index].onChangedObservable.remove(this._rowDefinitionObservers[index]);
|
|
246
|
+
this._rowDefinitions.splice(index, 1);
|
|
247
|
+
this._rowDefinitionObservers.splice(index, 1);
|
|
248
|
+
this._markAsDirty();
|
|
249
|
+
return this;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Adds a new control to the current grid
|
|
253
|
+
* @param control defines the control to add
|
|
254
|
+
* @param row defines the row where to add the control (0 by default)
|
|
255
|
+
* @param column defines the column where to add the control (0 by default)
|
|
256
|
+
* @returns the current grid
|
|
257
|
+
*/
|
|
258
|
+
addControl(control, row = 0, column = 0) {
|
|
259
|
+
if (this._rowDefinitions.length === 0) {
|
|
260
|
+
// Add default row definition
|
|
261
|
+
this.addRowDefinition(1, false);
|
|
262
|
+
}
|
|
263
|
+
if (this._columnDefinitions.length === 0) {
|
|
264
|
+
// Add default column definition
|
|
265
|
+
this.addColumnDefinition(1, false);
|
|
266
|
+
}
|
|
267
|
+
if (this._childControls.indexOf(control) !== -1) {
|
|
268
|
+
Tools.Warn(`Control (Name:${control.name}, UniqueId:${control.uniqueId}) is already associated with this grid. You must remove it before reattaching it`);
|
|
269
|
+
return this;
|
|
270
|
+
}
|
|
271
|
+
const x = Math.min(row, this._rowDefinitions.length - 1);
|
|
272
|
+
const y = Math.min(column, this._columnDefinitions.length - 1);
|
|
273
|
+
const key = `${x}:${y}`;
|
|
274
|
+
let goodContainer = this._cells[key];
|
|
275
|
+
if (!goodContainer) {
|
|
276
|
+
goodContainer = new Container(key);
|
|
277
|
+
this._cells[key] = goodContainer;
|
|
278
|
+
goodContainer.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
|
|
279
|
+
goodContainer.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
|
|
280
|
+
goodContainer.clipContent = this.clipContent;
|
|
281
|
+
goodContainer.clipChildren = this.clipChildren;
|
|
282
|
+
super.addControl(goodContainer);
|
|
283
|
+
}
|
|
284
|
+
goodContainer.addControl(control);
|
|
285
|
+
this._childControls.push(control);
|
|
286
|
+
control._tag = key;
|
|
287
|
+
control.parent = this;
|
|
288
|
+
this._markAsDirty();
|
|
289
|
+
return this;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Removes a control from the current container
|
|
293
|
+
* @param control defines the control to remove
|
|
294
|
+
* @returns the current container
|
|
295
|
+
*/
|
|
296
|
+
removeControl(control) {
|
|
297
|
+
const index = this._childControls.indexOf(control);
|
|
298
|
+
if (index !== -1) {
|
|
299
|
+
this._childControls.splice(index, 1);
|
|
300
|
+
}
|
|
301
|
+
const cell = this._cells[control._tag];
|
|
302
|
+
if (cell) {
|
|
303
|
+
cell.removeControl(control);
|
|
304
|
+
control._tag = null;
|
|
305
|
+
}
|
|
306
|
+
this._markAsDirty();
|
|
307
|
+
return this;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Creates a new Grid
|
|
311
|
+
* @param name defines control name
|
|
312
|
+
*/
|
|
313
|
+
constructor(name) {
|
|
314
|
+
super(name);
|
|
315
|
+
this.name = (__runInitializers(this, _instanceExtraInitializers), name);
|
|
316
|
+
this._rowDefinitions = new Array();
|
|
317
|
+
this._rowDefinitionObservers = [];
|
|
318
|
+
this._columnDefinitions = new Array();
|
|
319
|
+
this._columnDefinitionObservers = [];
|
|
320
|
+
this._cells = {};
|
|
321
|
+
this._childControls = new Array();
|
|
322
|
+
}
|
|
323
|
+
_getTypeName() {
|
|
324
|
+
return "Grid";
|
|
325
|
+
}
|
|
326
|
+
_getGridDefinitions(definitionCallback) {
|
|
327
|
+
const widths = [];
|
|
328
|
+
const heights = [];
|
|
329
|
+
const lefts = [];
|
|
330
|
+
const tops = [];
|
|
331
|
+
let availableWidth = this._currentMeasure.width;
|
|
332
|
+
let globalWidthPercentage = 0;
|
|
333
|
+
let availableHeight = this._currentMeasure.height;
|
|
334
|
+
let globalHeightPercentage = 0;
|
|
335
|
+
// Heights
|
|
336
|
+
let index = 0;
|
|
337
|
+
for (const rowDefinition of this._rowDefinitions) {
|
|
338
|
+
if (rowDefinition.isPixel) {
|
|
339
|
+
const height = rowDefinition.getValue(this._host);
|
|
340
|
+
availableHeight -= height;
|
|
341
|
+
heights[index] = height;
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
globalHeightPercentage += rowDefinition.value;
|
|
345
|
+
}
|
|
346
|
+
index++;
|
|
347
|
+
}
|
|
348
|
+
let top = 0;
|
|
349
|
+
index = 0;
|
|
350
|
+
for (const rowDefinition of this._rowDefinitions) {
|
|
351
|
+
tops.push(top);
|
|
352
|
+
if (!rowDefinition.isPixel) {
|
|
353
|
+
const height = Math.round((rowDefinition.value / globalHeightPercentage) * availableHeight);
|
|
354
|
+
top += height;
|
|
355
|
+
heights[index] = height;
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
358
|
+
top += rowDefinition.getValue(this._host);
|
|
359
|
+
}
|
|
360
|
+
index++;
|
|
361
|
+
}
|
|
362
|
+
// Widths
|
|
363
|
+
index = 0;
|
|
364
|
+
for (const columnDefinition of this._columnDefinitions) {
|
|
365
|
+
if (columnDefinition.isPixel) {
|
|
366
|
+
const width = columnDefinition.getValue(this._host);
|
|
367
|
+
availableWidth -= width;
|
|
368
|
+
widths[index] = width;
|
|
369
|
+
}
|
|
370
|
+
else {
|
|
371
|
+
globalWidthPercentage += columnDefinition.value;
|
|
372
|
+
}
|
|
373
|
+
index++;
|
|
374
|
+
}
|
|
375
|
+
let left = 0;
|
|
376
|
+
index = 0;
|
|
377
|
+
for (const columnDefinition of this._columnDefinitions) {
|
|
378
|
+
lefts.push(left);
|
|
379
|
+
if (!columnDefinition.isPixel) {
|
|
380
|
+
const width = Math.round((columnDefinition.value / globalWidthPercentage) * availableWidth);
|
|
381
|
+
left += width;
|
|
382
|
+
widths[index] = width;
|
|
383
|
+
}
|
|
384
|
+
else {
|
|
385
|
+
left += columnDefinition.getValue(this._host);
|
|
386
|
+
}
|
|
387
|
+
index++;
|
|
388
|
+
}
|
|
389
|
+
definitionCallback(lefts, tops, widths, heights);
|
|
390
|
+
}
|
|
391
|
+
_additionalProcessing(parentMeasure, context) {
|
|
392
|
+
this._getGridDefinitions((lefts, tops, widths, heights) => {
|
|
393
|
+
// Setting child sizes
|
|
394
|
+
for (const key in this._cells) {
|
|
395
|
+
if (!Object.prototype.hasOwnProperty.call(this._cells, key)) {
|
|
396
|
+
continue;
|
|
397
|
+
}
|
|
398
|
+
const split = key.split(":");
|
|
399
|
+
const x = parseInt(split[0]);
|
|
400
|
+
const y = parseInt(split[1]);
|
|
401
|
+
const cell = this._cells[key];
|
|
402
|
+
cell.leftInPixels = lefts[y];
|
|
403
|
+
cell.topInPixels = tops[x];
|
|
404
|
+
cell.widthInPixels = widths[y];
|
|
405
|
+
cell.heightInPixels = heights[x];
|
|
406
|
+
cell._left.ignoreAdaptiveScaling = true;
|
|
407
|
+
cell._top.ignoreAdaptiveScaling = true;
|
|
408
|
+
cell._width.ignoreAdaptiveScaling = true;
|
|
409
|
+
cell._height.ignoreAdaptiveScaling = true;
|
|
410
|
+
}
|
|
411
|
+
});
|
|
412
|
+
super._additionalProcessing(parentMeasure, context);
|
|
413
|
+
}
|
|
414
|
+
_flagDescendantsAsMatrixDirty() {
|
|
415
|
+
for (const key in this._cells) {
|
|
416
|
+
if (!Object.prototype.hasOwnProperty.call(this._cells, key)) {
|
|
417
|
+
continue;
|
|
418
|
+
}
|
|
419
|
+
const child = this._cells[key];
|
|
420
|
+
child._markMatrixAsDirty();
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
_renderHighlightSpecific(context) {
|
|
424
|
+
super._renderHighlightSpecific(context);
|
|
425
|
+
this._getGridDefinitions((lefts, tops, widths, heights) => {
|
|
426
|
+
// Columns
|
|
427
|
+
for (let index = 0; index < lefts.length; index++) {
|
|
428
|
+
const left = this._currentMeasure.left + lefts[index] + widths[index];
|
|
429
|
+
context.beginPath();
|
|
430
|
+
context.moveTo(left, this._currentMeasure.top);
|
|
431
|
+
context.lineTo(left, this._currentMeasure.top + this._currentMeasure.height);
|
|
432
|
+
context.stroke();
|
|
433
|
+
}
|
|
434
|
+
// Rows
|
|
435
|
+
for (let index = 0; index < tops.length; index++) {
|
|
436
|
+
const top = this._currentMeasure.top + tops[index] + heights[index];
|
|
437
|
+
context.beginPath();
|
|
438
|
+
context.moveTo(this._currentMeasure.left, top);
|
|
439
|
+
context.lineTo(this._currentMeasure.left + this._currentMeasure.width, top);
|
|
440
|
+
context.stroke();
|
|
441
|
+
}
|
|
442
|
+
});
|
|
443
|
+
context.restore();
|
|
444
|
+
}
|
|
445
|
+
/** Releases associated resources */
|
|
446
|
+
dispose() {
|
|
447
|
+
super.dispose();
|
|
448
|
+
for (const control of this._childControls) {
|
|
449
|
+
control.dispose();
|
|
450
|
+
}
|
|
451
|
+
for (let index = 0; index < this._rowDefinitions.length; index++) {
|
|
452
|
+
this._rowDefinitions[index].onChangedObservable.remove(this._rowDefinitionObservers[index]);
|
|
453
|
+
}
|
|
454
|
+
for (let index = 0; index < this._columnDefinitions.length; index++) {
|
|
455
|
+
this._columnDefinitions[index].onChangedObservable.remove(this._columnDefinitionObservers[index]);
|
|
456
|
+
}
|
|
457
|
+
this._rowDefinitionObservers.length = 0;
|
|
458
|
+
this._rowDefinitions.length = 0;
|
|
459
|
+
this._columnDefinitionObservers.length = 0;
|
|
460
|
+
this._columnDefinitions.length = 0;
|
|
461
|
+
this._cells = {};
|
|
462
|
+
this._childControls.length = 0;
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Serializes the current control
|
|
466
|
+
* @param serializationObject defined the JSON serialized object
|
|
467
|
+
* @param force force serialization even if isSerializable === false
|
|
468
|
+
* @param allowCanvas defines if the control is allowed to use a Canvas2D object to serialize
|
|
469
|
+
*/
|
|
470
|
+
serialize(serializationObject, force, allowCanvas) {
|
|
471
|
+
super.serialize(serializationObject, force, allowCanvas);
|
|
472
|
+
if (!this.isSerializable && !force) {
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
serializationObject.columnCount = this.columnCount;
|
|
476
|
+
serializationObject.rowCount = this.rowCount;
|
|
477
|
+
serializationObject.columns = [];
|
|
478
|
+
serializationObject.rows = [];
|
|
479
|
+
serializationObject.tags = [];
|
|
480
|
+
for (let i = 0; i < this.columnCount; ++i) {
|
|
481
|
+
const cd = this.getColumnDefinition(i);
|
|
482
|
+
const childSerializationObject = { value: cd?.getValue(this.host), unit: cd?.unit };
|
|
483
|
+
serializationObject.columns.push(childSerializationObject);
|
|
484
|
+
}
|
|
485
|
+
for (let i = 0; i < this.rowCount; ++i) {
|
|
486
|
+
const rd = this.getRowDefinition(i);
|
|
487
|
+
const childSerializationObject = { value: rd?.getValue(this.host), unit: rd?.unit };
|
|
488
|
+
serializationObject.rows.push(childSerializationObject);
|
|
489
|
+
}
|
|
490
|
+
for (const child of this.children) {
|
|
491
|
+
serializationObject.tags.push(child._tag);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* @internal
|
|
496
|
+
*/
|
|
497
|
+
_parseFromContent(serializedObject, host) {
|
|
498
|
+
super._parseFromContent(serializedObject, host);
|
|
499
|
+
const children = [];
|
|
500
|
+
for (const child of this.children) {
|
|
501
|
+
children.push(child);
|
|
502
|
+
}
|
|
503
|
+
this.removeRowDefinition(0);
|
|
504
|
+
this.removeColumnDefinition(0);
|
|
505
|
+
for (let i = 0; i < serializedObject.columnCount; ++i) {
|
|
506
|
+
const columnValue = serializedObject.columns[i].value;
|
|
507
|
+
const unit = serializedObject.columns[i].unit;
|
|
508
|
+
this.addColumnDefinition(columnValue, unit === 1 ? true : false);
|
|
509
|
+
}
|
|
510
|
+
for (let i = 0; i < serializedObject.rowCount; ++i) {
|
|
511
|
+
const rowValue = serializedObject.rows[i].value;
|
|
512
|
+
const unit = serializedObject.rows[i].unit;
|
|
513
|
+
this.addRowDefinition(rowValue, unit === 1 ? true : false);
|
|
514
|
+
}
|
|
515
|
+
for (let i = 0; i < children.length; ++i) {
|
|
516
|
+
const cellInfo = serializedObject.tags[i];
|
|
517
|
+
let rowNumber = parseInt(cellInfo.substring(0, cellInfo.search(":")));
|
|
518
|
+
if (isNaN(rowNumber)) {
|
|
519
|
+
rowNumber = 0;
|
|
520
|
+
}
|
|
521
|
+
let columnNumber = parseInt(cellInfo.substring(cellInfo.search(":") + 1));
|
|
522
|
+
if (isNaN(columnNumber)) {
|
|
523
|
+
columnNumber = 0;
|
|
524
|
+
}
|
|
525
|
+
this.addControl(children[i], rowNumber, columnNumber);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
},
|
|
529
|
+
(() => {
|
|
530
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
531
|
+
_get_clipContent_decorators = [serialize()];
|
|
532
|
+
__esDecorate(_a, null, _get_clipContent_decorators, { kind: "getter", name: "clipContent", static: false, private: false, access: { has: obj => "clipContent" in obj, get: obj => obj.clipContent }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
533
|
+
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
534
|
+
})(),
|
|
535
|
+
_a;
|
|
536
|
+
})();
|
|
537
|
+
export { Grid };
|
|
527
538
|
let _Registered = false;
|
|
528
539
|
/**
|
|
529
540
|
* Registers the Grid class with the type store for serialization support.
|