@babylonjs/gui 5.0.0-alpha.59 → 5.0.0-alpha.62
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/advancedDynamicTexture.d.ts +151 -134
- package/2D/advancedDynamicTexture.js +212 -153
- package/2D/advancedDynamicTexture.js.map +1 -1
- package/2D/controls/control.d.ts +45 -32
- package/2D/controls/control.js +56 -43
- package/2D/controls/control.js.map +1 -1
- package/2D/controls/inputText.js +1 -1
- package/2D/controls/inputText.js.map +1 -1
- package/2D/controls/textBlock.js +1 -1
- package/2D/controls/textBlock.js.map +1 -1
- package/package.json +2 -2
package/2D/controls/control.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { Observable } from "@babylonjs/core/Misc/observable.js";
|
|
3
3
|
import { Vector2, Vector3, Matrix } from "@babylonjs/core/Maths/math.vector.js";
|
|
4
|
-
import { PointerEventTypes } from
|
|
4
|
+
import { PointerEventTypes } from "@babylonjs/core/Events/pointerEvents.js";
|
|
5
5
|
import { Logger } from "@babylonjs/core/Misc/logger.js";
|
|
6
6
|
import { Tools } from "@babylonjs/core/Misc/tools.js";
|
|
7
7
|
import { ValueAndUnit } from "../valueAndUnit.js";
|
|
8
8
|
import { Measure } from "../measure.js";
|
|
9
9
|
import { Matrix2D, Vector2WithInfo } from "../math2D.js";
|
|
10
|
-
import { RegisterClass } from
|
|
11
|
-
import { SerializationHelper, serialize } from
|
|
10
|
+
import { RegisterClass } from "@babylonjs/core/Misc/typeStore.js";
|
|
11
|
+
import { SerializationHelper, serialize } from "@babylonjs/core/Misc/decorators.js";
|
|
12
12
|
import { Engine } from "@babylonjs/core/Engines/engine.js";
|
|
13
13
|
/**
|
|
14
14
|
* Root class used for all 2D controls
|
|
@@ -83,6 +83,8 @@ var Control = /** @class */ (function () {
|
|
|
83
83
|
this._enterCount = -1;
|
|
84
84
|
this._doNotRender = false;
|
|
85
85
|
this._downPointerIds = {};
|
|
86
|
+
this._evaluatedMeasure = new Measure(0, 0, 0, 0);
|
|
87
|
+
this._evaluatedParentMeasure = new Measure(0, 0, 0, 0);
|
|
86
88
|
this._isEnabled = true;
|
|
87
89
|
this._disabledColor = "#9a9a9a";
|
|
88
90
|
this._disabledColorItem = "#6a6a6a";
|
|
@@ -123,7 +125,7 @@ var Control = /** @class */ (function () {
|
|
|
123
125
|
this._shadowOffsetY = 0;
|
|
124
126
|
this._shadowBlur = 0;
|
|
125
127
|
this._previousShadowBlur = 0;
|
|
126
|
-
this._shadowColor =
|
|
128
|
+
this._shadowColor = "black";
|
|
127
129
|
/** Gets or sets the cursor to use when the control is hovered */
|
|
128
130
|
this.hoverCursor = "";
|
|
129
131
|
/** @hidden */
|
|
@@ -131,36 +133,36 @@ var Control = /** @class */ (function () {
|
|
|
131
133
|
/** @hidden */
|
|
132
134
|
this._linkOffsetY = new ValueAndUnit(0);
|
|
133
135
|
/**
|
|
134
|
-
|
|
135
|
-
|
|
136
|
+
* An event triggered when pointer wheel is scrolled
|
|
137
|
+
*/
|
|
136
138
|
this.onWheelObservable = new Observable();
|
|
137
139
|
/**
|
|
138
|
-
|
|
139
|
-
|
|
140
|
+
* An event triggered when the pointer moves over the control.
|
|
141
|
+
*/
|
|
140
142
|
this.onPointerMoveObservable = new Observable();
|
|
141
143
|
/**
|
|
142
|
-
|
|
143
|
-
|
|
144
|
+
* An event triggered when the pointer moves out of the control.
|
|
145
|
+
*/
|
|
144
146
|
this.onPointerOutObservable = new Observable();
|
|
145
147
|
/**
|
|
146
|
-
|
|
147
|
-
|
|
148
|
+
* An event triggered when the pointer taps the control
|
|
149
|
+
*/
|
|
148
150
|
this.onPointerDownObservable = new Observable();
|
|
149
151
|
/**
|
|
150
|
-
|
|
151
|
-
|
|
152
|
+
* An event triggered when pointer up
|
|
153
|
+
*/
|
|
152
154
|
this.onPointerUpObservable = new Observable();
|
|
153
155
|
/**
|
|
154
|
-
|
|
155
|
-
|
|
156
|
+
* An event triggered when a control is clicked on
|
|
157
|
+
*/
|
|
156
158
|
this.onPointerClickObservable = new Observable();
|
|
157
159
|
/**
|
|
158
|
-
|
|
159
|
-
|
|
160
|
+
* An event triggered when pointer enters the control
|
|
161
|
+
*/
|
|
160
162
|
this.onPointerEnterObservable = new Observable();
|
|
161
163
|
/**
|
|
162
|
-
|
|
163
|
-
|
|
164
|
+
* An event triggered when the control is marked as dirty
|
|
165
|
+
*/
|
|
164
166
|
this.onDirtyObservable = new Observable();
|
|
165
167
|
/**
|
|
166
168
|
* An event triggered before drawing the control
|
|
@@ -171,8 +173,8 @@ var Control = /** @class */ (function () {
|
|
|
171
173
|
*/
|
|
172
174
|
this.onAfterDrawObservable = new Observable();
|
|
173
175
|
/**
|
|
174
|
-
|
|
175
|
-
|
|
176
|
+
* An event triggered when the control has been disposed
|
|
177
|
+
*/
|
|
176
178
|
this.onDisposeObservable = new Observable();
|
|
177
179
|
/**
|
|
178
180
|
* Gets or sets a fixed ratio for this control.
|
|
@@ -366,7 +368,7 @@ var Control = /** @class */ (function () {
|
|
|
366
368
|
Object.defineProperty(Control.prototype, "scaleX", {
|
|
367
369
|
/** Gets or sets a value indicating the scale factor on X axis (1 by default)
|
|
368
370
|
* @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
|
|
369
|
-
|
|
371
|
+
*/
|
|
370
372
|
get: function () {
|
|
371
373
|
return this._scaleX;
|
|
372
374
|
},
|
|
@@ -384,7 +386,7 @@ var Control = /** @class */ (function () {
|
|
|
384
386
|
Object.defineProperty(Control.prototype, "scaleY", {
|
|
385
387
|
/** Gets or sets a value indicating the scale factor on Y axis (1 by default)
|
|
386
388
|
* @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
|
|
387
|
-
|
|
389
|
+
*/
|
|
388
390
|
get: function () {
|
|
389
391
|
return this._scaleY;
|
|
390
392
|
},
|
|
@@ -402,7 +404,7 @@ var Control = /** @class */ (function () {
|
|
|
402
404
|
Object.defineProperty(Control.prototype, "rotation", {
|
|
403
405
|
/** Gets or sets the rotation angle (0 by default)
|
|
404
406
|
* @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
|
|
405
|
-
|
|
407
|
+
*/
|
|
406
408
|
get: function () {
|
|
407
409
|
return this._rotation;
|
|
408
410
|
},
|
|
@@ -420,7 +422,7 @@ var Control = /** @class */ (function () {
|
|
|
420
422
|
Object.defineProperty(Control.prototype, "transformCenterY", {
|
|
421
423
|
/** Gets or sets the transformation center on Y axis (0 by default)
|
|
422
424
|
* @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
|
|
423
|
-
|
|
425
|
+
*/
|
|
424
426
|
get: function () {
|
|
425
427
|
return this._transformCenterY;
|
|
426
428
|
},
|
|
@@ -438,7 +440,7 @@ var Control = /** @class */ (function () {
|
|
|
438
440
|
Object.defineProperty(Control.prototype, "transformCenterX", {
|
|
439
441
|
/** Gets or sets the transformation center on X axis (0 by default)
|
|
440
442
|
* @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
|
|
441
|
-
|
|
443
|
+
*/
|
|
442
444
|
get: function () {
|
|
443
445
|
return this._transformCenterX;
|
|
444
446
|
},
|
|
@@ -1202,7 +1204,7 @@ var Control = /** @class */ (function () {
|
|
|
1202
1204
|
* @see https://doc.babylonjs.com/how_to/gui#tracking-positions
|
|
1203
1205
|
*/
|
|
1204
1206
|
Control.prototype.linkWithMesh = function (mesh) {
|
|
1205
|
-
if (!this._host || this.parent && this.parent !== this._host._rootContainer) {
|
|
1207
|
+
if (!this._host || (this.parent && this.parent !== this._host._rootContainer)) {
|
|
1206
1208
|
if (mesh) {
|
|
1207
1209
|
Tools.Error("Cannot link a control to a mesh if the control is not at root level");
|
|
1208
1210
|
}
|
|
@@ -1225,13 +1227,13 @@ var Control = /** @class */ (function () {
|
|
|
1225
1227
|
this._host._linkedControls.push(this);
|
|
1226
1228
|
};
|
|
1227
1229
|
/**
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1230
|
+
* Shorthand funtion to set the top, right, bottom, and left padding values on the control.
|
|
1231
|
+
* @param { string | number} paddingTop - The value of the top padding.
|
|
1232
|
+
* @param { string | number} paddingRight - The value of the right padding. If omitted, top is used.
|
|
1233
|
+
* @param { string | number} paddingBottom - The value of the bottom padding. If omitted, top is used.
|
|
1234
|
+
* @param { string | number} paddingLeft - The value of the left padding. If omitted, right is used.
|
|
1235
|
+
* @see https://doc.babylonjs.com/how_to/gui#position-and-size
|
|
1236
|
+
*/
|
|
1235
1237
|
Control.prototype.setPadding = function (paddingTop, paddingRight, paddingBottom, paddingLeft) {
|
|
1236
1238
|
var top = paddingTop;
|
|
1237
1239
|
var right = paddingRight !== null && paddingRight !== void 0 ? paddingRight : top;
|
|
@@ -1271,8 +1273,8 @@ var Control = /** @class */ (function () {
|
|
|
1271
1273
|
this._processMeasures(parentMeasure, this._host.getContext());
|
|
1272
1274
|
}
|
|
1273
1275
|
}
|
|
1274
|
-
var newLeft =
|
|
1275
|
-
var newTop =
|
|
1276
|
+
var newLeft = projectedPosition.x + this._linkOffsetX.getValue(this._host) - this._currentMeasure.width / 2;
|
|
1277
|
+
var newTop = projectedPosition.y + this._linkOffsetY.getValue(this._host) - this._currentMeasure.height / 2;
|
|
1276
1278
|
if (this._left.ignoreAdaptiveScaling && this._top.ignoreAdaptiveScaling) {
|
|
1277
1279
|
if (Math.abs(newLeft - oldLeft) < 0.5) {
|
|
1278
1280
|
newLeft = oldLeft;
|
|
@@ -1441,7 +1443,7 @@ var Control = /** @class */ (function () {
|
|
|
1441
1443
|
context.globalAlpha *= this._alpha;
|
|
1442
1444
|
}
|
|
1443
1445
|
else if (this._alphaSet) {
|
|
1444
|
-
context.globalAlpha =
|
|
1446
|
+
context.globalAlpha = this.parent && !this.parent.renderToIntermediateTexture ? this.parent.alpha * this._alpha : this._alpha;
|
|
1445
1447
|
}
|
|
1446
1448
|
};
|
|
1447
1449
|
/** @hidden */
|
|
@@ -1491,21 +1493,23 @@ var Control = /** @class */ (function () {
|
|
|
1491
1493
|
}
|
|
1492
1494
|
};
|
|
1493
1495
|
Control.prototype._evaluateClippingState = function (parentMeasure) {
|
|
1496
|
+
this._currentMeasure.transformToRef(this._transformMatrix, this._evaluatedMeasure);
|
|
1494
1497
|
if (this.parent && this.parent.clipChildren) {
|
|
1498
|
+
parentMeasure.transformToRef(this.parent._transformMatrix, this._evaluatedParentMeasure);
|
|
1495
1499
|
// Early clip
|
|
1496
|
-
if (this.
|
|
1500
|
+
if (this._evaluatedMeasure.left > this._evaluatedParentMeasure.left + this._evaluatedParentMeasure.width) {
|
|
1497
1501
|
this._isClipped = true;
|
|
1498
1502
|
return;
|
|
1499
1503
|
}
|
|
1500
|
-
if (this.
|
|
1504
|
+
if (this._evaluatedMeasure.left + this._evaluatedMeasure.width < this._evaluatedParentMeasure.left) {
|
|
1501
1505
|
this._isClipped = true;
|
|
1502
1506
|
return;
|
|
1503
1507
|
}
|
|
1504
|
-
if (this.
|
|
1508
|
+
if (this._evaluatedMeasure.top > this._evaluatedParentMeasure.top + this._evaluatedParentMeasure.height) {
|
|
1505
1509
|
this._isClipped = true;
|
|
1506
1510
|
return;
|
|
1507
1511
|
}
|
|
1508
|
-
if (this.
|
|
1512
|
+
if (this._evaluatedMeasure.top + this._evaluatedMeasure.height < this._evaluatedParentMeasure.top) {
|
|
1509
1513
|
this._isClipped = true;
|
|
1510
1514
|
return;
|
|
1511
1515
|
}
|
|
@@ -1747,7 +1751,8 @@ var Control = /** @class */ (function () {
|
|
|
1747
1751
|
if (this._enterCount > 0) {
|
|
1748
1752
|
return false;
|
|
1749
1753
|
}
|
|
1750
|
-
if (this._enterCount === -1) {
|
|
1754
|
+
if (this._enterCount === -1) {
|
|
1755
|
+
// -1 is for touch input, we are now sure we are with a mouse or pencil
|
|
1751
1756
|
this._enterCount = 0;
|
|
1752
1757
|
}
|
|
1753
1758
|
this._enterCount++;
|
|
@@ -1878,6 +1883,8 @@ var Control = /** @class */ (function () {
|
|
|
1878
1883
|
this._font = this._fontStyle + " " + this._fontWeight + " " + this.fontSizeInPixels + "px " + this._fontFamily;
|
|
1879
1884
|
}
|
|
1880
1885
|
this._fontOffset = Control._GetFontOffset(this._font);
|
|
1886
|
+
//children need to be refreshed
|
|
1887
|
+
this.getDescendants().forEach(function (child) { return child._markAllAsDirty(); });
|
|
1881
1888
|
};
|
|
1882
1889
|
/**
|
|
1883
1890
|
* Serializes the current control
|
|
@@ -2167,6 +2174,12 @@ var Control = /** @class */ (function () {
|
|
|
2167
2174
|
__decorate([
|
|
2168
2175
|
serialize()
|
|
2169
2176
|
], Control.prototype, "disabledColorItem", null);
|
|
2177
|
+
__decorate([
|
|
2178
|
+
serialize()
|
|
2179
|
+
], Control.prototype, "overlapGroup", void 0);
|
|
2180
|
+
__decorate([
|
|
2181
|
+
serialize()
|
|
2182
|
+
], Control.prototype, "overlapDeltaMultiplier", void 0);
|
|
2170
2183
|
return Control;
|
|
2171
2184
|
}());
|
|
2172
2185
|
export { Control };
|