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