@babylonjs/gui 5.0.0-alpha.60 → 5.0.0-alpha.61
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 +149 -134
- package/2D/advancedDynamicTexture.js +209 -152
- package/2D/advancedDynamicTexture.js.map +1 -1
- package/2D/controls/control.d.ts +43 -32
- package/2D/controls/control.js +48 -39
- 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
|
|
@@ -123,7 +123,7 @@ var Control = /** @class */ (function () {
|
|
|
123
123
|
this._shadowOffsetY = 0;
|
|
124
124
|
this._shadowBlur = 0;
|
|
125
125
|
this._previousShadowBlur = 0;
|
|
126
|
-
this._shadowColor =
|
|
126
|
+
this._shadowColor = "black";
|
|
127
127
|
/** Gets or sets the cursor to use when the control is hovered */
|
|
128
128
|
this.hoverCursor = "";
|
|
129
129
|
/** @hidden */
|
|
@@ -131,36 +131,36 @@ var Control = /** @class */ (function () {
|
|
|
131
131
|
/** @hidden */
|
|
132
132
|
this._linkOffsetY = new ValueAndUnit(0);
|
|
133
133
|
/**
|
|
134
|
-
|
|
135
|
-
|
|
134
|
+
* An event triggered when pointer wheel is scrolled
|
|
135
|
+
*/
|
|
136
136
|
this.onWheelObservable = new Observable();
|
|
137
137
|
/**
|
|
138
|
-
|
|
139
|
-
|
|
138
|
+
* An event triggered when the pointer moves over the control.
|
|
139
|
+
*/
|
|
140
140
|
this.onPointerMoveObservable = new Observable();
|
|
141
141
|
/**
|
|
142
|
-
|
|
143
|
-
|
|
142
|
+
* An event triggered when the pointer moves out of the control.
|
|
143
|
+
*/
|
|
144
144
|
this.onPointerOutObservable = new Observable();
|
|
145
145
|
/**
|
|
146
|
-
|
|
147
|
-
|
|
146
|
+
* An event triggered when the pointer taps the control
|
|
147
|
+
*/
|
|
148
148
|
this.onPointerDownObservable = new Observable();
|
|
149
149
|
/**
|
|
150
|
-
|
|
151
|
-
|
|
150
|
+
* An event triggered when pointer up
|
|
151
|
+
*/
|
|
152
152
|
this.onPointerUpObservable = new Observable();
|
|
153
153
|
/**
|
|
154
|
-
|
|
155
|
-
|
|
154
|
+
* An event triggered when a control is clicked on
|
|
155
|
+
*/
|
|
156
156
|
this.onPointerClickObservable = new Observable();
|
|
157
157
|
/**
|
|
158
|
-
|
|
159
|
-
|
|
158
|
+
* An event triggered when pointer enters the control
|
|
159
|
+
*/
|
|
160
160
|
this.onPointerEnterObservable = new Observable();
|
|
161
161
|
/**
|
|
162
|
-
|
|
163
|
-
|
|
162
|
+
* An event triggered when the control is marked as dirty
|
|
163
|
+
*/
|
|
164
164
|
this.onDirtyObservable = new Observable();
|
|
165
165
|
/**
|
|
166
166
|
* An event triggered before drawing the control
|
|
@@ -171,8 +171,8 @@ var Control = /** @class */ (function () {
|
|
|
171
171
|
*/
|
|
172
172
|
this.onAfterDrawObservable = new Observable();
|
|
173
173
|
/**
|
|
174
|
-
|
|
175
|
-
|
|
174
|
+
* An event triggered when the control has been disposed
|
|
175
|
+
*/
|
|
176
176
|
this.onDisposeObservable = new Observable();
|
|
177
177
|
/**
|
|
178
178
|
* Gets or sets a fixed ratio for this control.
|
|
@@ -366,7 +366,7 @@ var Control = /** @class */ (function () {
|
|
|
366
366
|
Object.defineProperty(Control.prototype, "scaleX", {
|
|
367
367
|
/** Gets or sets a value indicating the scale factor on X axis (1 by default)
|
|
368
368
|
* @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
|
|
369
|
-
|
|
369
|
+
*/
|
|
370
370
|
get: function () {
|
|
371
371
|
return this._scaleX;
|
|
372
372
|
},
|
|
@@ -384,7 +384,7 @@ var Control = /** @class */ (function () {
|
|
|
384
384
|
Object.defineProperty(Control.prototype, "scaleY", {
|
|
385
385
|
/** Gets or sets a value indicating the scale factor on Y axis (1 by default)
|
|
386
386
|
* @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
|
|
387
|
-
|
|
387
|
+
*/
|
|
388
388
|
get: function () {
|
|
389
389
|
return this._scaleY;
|
|
390
390
|
},
|
|
@@ -402,7 +402,7 @@ var Control = /** @class */ (function () {
|
|
|
402
402
|
Object.defineProperty(Control.prototype, "rotation", {
|
|
403
403
|
/** Gets or sets the rotation angle (0 by default)
|
|
404
404
|
* @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
|
|
405
|
-
|
|
405
|
+
*/
|
|
406
406
|
get: function () {
|
|
407
407
|
return this._rotation;
|
|
408
408
|
},
|
|
@@ -420,7 +420,7 @@ var Control = /** @class */ (function () {
|
|
|
420
420
|
Object.defineProperty(Control.prototype, "transformCenterY", {
|
|
421
421
|
/** Gets or sets the transformation center on Y axis (0 by default)
|
|
422
422
|
* @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
|
|
423
|
-
|
|
423
|
+
*/
|
|
424
424
|
get: function () {
|
|
425
425
|
return this._transformCenterY;
|
|
426
426
|
},
|
|
@@ -438,7 +438,7 @@ var Control = /** @class */ (function () {
|
|
|
438
438
|
Object.defineProperty(Control.prototype, "transformCenterX", {
|
|
439
439
|
/** Gets or sets the transformation center on X axis (0 by default)
|
|
440
440
|
* @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
|
|
441
|
-
|
|
441
|
+
*/
|
|
442
442
|
get: function () {
|
|
443
443
|
return this._transformCenterX;
|
|
444
444
|
},
|
|
@@ -1202,7 +1202,7 @@ var Control = /** @class */ (function () {
|
|
|
1202
1202
|
* @see https://doc.babylonjs.com/how_to/gui#tracking-positions
|
|
1203
1203
|
*/
|
|
1204
1204
|
Control.prototype.linkWithMesh = function (mesh) {
|
|
1205
|
-
if (!this._host || this.parent && this.parent !== this._host._rootContainer) {
|
|
1205
|
+
if (!this._host || (this.parent && this.parent !== this._host._rootContainer)) {
|
|
1206
1206
|
if (mesh) {
|
|
1207
1207
|
Tools.Error("Cannot link a control to a mesh if the control is not at root level");
|
|
1208
1208
|
}
|
|
@@ -1225,13 +1225,13 @@ var Control = /** @class */ (function () {
|
|
|
1225
1225
|
this._host._linkedControls.push(this);
|
|
1226
1226
|
};
|
|
1227
1227
|
/**
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1228
|
+
* Shorthand funtion to set the top, right, bottom, and left padding values on the control.
|
|
1229
|
+
* @param { string | number} paddingTop - The value of the top padding.
|
|
1230
|
+
* @param { string | number} paddingRight - The value of the right padding. If omitted, top is used.
|
|
1231
|
+
* @param { string | number} paddingBottom - The value of the bottom padding. If omitted, top is used.
|
|
1232
|
+
* @param { string | number} paddingLeft - The value of the left padding. If omitted, right is used.
|
|
1233
|
+
* @see https://doc.babylonjs.com/how_to/gui#position-and-size
|
|
1234
|
+
*/
|
|
1235
1235
|
Control.prototype.setPadding = function (paddingTop, paddingRight, paddingBottom, paddingLeft) {
|
|
1236
1236
|
var top = paddingTop;
|
|
1237
1237
|
var right = paddingRight !== null && paddingRight !== void 0 ? paddingRight : top;
|
|
@@ -1271,8 +1271,8 @@ var Control = /** @class */ (function () {
|
|
|
1271
1271
|
this._processMeasures(parentMeasure, this._host.getContext());
|
|
1272
1272
|
}
|
|
1273
1273
|
}
|
|
1274
|
-
var newLeft =
|
|
1275
|
-
var newTop =
|
|
1274
|
+
var newLeft = projectedPosition.x + this._linkOffsetX.getValue(this._host) - this._currentMeasure.width / 2;
|
|
1275
|
+
var newTop = projectedPosition.y + this._linkOffsetY.getValue(this._host) - this._currentMeasure.height / 2;
|
|
1276
1276
|
if (this._left.ignoreAdaptiveScaling && this._top.ignoreAdaptiveScaling) {
|
|
1277
1277
|
if (Math.abs(newLeft - oldLeft) < 0.5) {
|
|
1278
1278
|
newLeft = oldLeft;
|
|
@@ -1441,7 +1441,7 @@ var Control = /** @class */ (function () {
|
|
|
1441
1441
|
context.globalAlpha *= this._alpha;
|
|
1442
1442
|
}
|
|
1443
1443
|
else if (this._alphaSet) {
|
|
1444
|
-
context.globalAlpha =
|
|
1444
|
+
context.globalAlpha = this.parent && !this.parent.renderToIntermediateTexture ? this.parent.alpha * this._alpha : this._alpha;
|
|
1445
1445
|
}
|
|
1446
1446
|
};
|
|
1447
1447
|
/** @hidden */
|
|
@@ -1747,7 +1747,8 @@ var Control = /** @class */ (function () {
|
|
|
1747
1747
|
if (this._enterCount > 0) {
|
|
1748
1748
|
return false;
|
|
1749
1749
|
}
|
|
1750
|
-
if (this._enterCount === -1) {
|
|
1750
|
+
if (this._enterCount === -1) {
|
|
1751
|
+
// -1 is for touch input, we are now sure we are with a mouse or pencil
|
|
1751
1752
|
this._enterCount = 0;
|
|
1752
1753
|
}
|
|
1753
1754
|
this._enterCount++;
|
|
@@ -1878,6 +1879,8 @@ var Control = /** @class */ (function () {
|
|
|
1878
1879
|
this._font = this._fontStyle + " " + this._fontWeight + " " + this.fontSizeInPixels + "px " + this._fontFamily;
|
|
1879
1880
|
}
|
|
1880
1881
|
this._fontOffset = Control._GetFontOffset(this._font);
|
|
1882
|
+
//children need to be refreshed
|
|
1883
|
+
this.getDescendants().forEach(function (child) { return child._markAllAsDirty(); });
|
|
1881
1884
|
};
|
|
1882
1885
|
/**
|
|
1883
1886
|
* Serializes the current control
|
|
@@ -2167,6 +2170,12 @@ var Control = /** @class */ (function () {
|
|
|
2167
2170
|
__decorate([
|
|
2168
2171
|
serialize()
|
|
2169
2172
|
], Control.prototype, "disabledColorItem", null);
|
|
2173
|
+
__decorate([
|
|
2174
|
+
serialize()
|
|
2175
|
+
], Control.prototype, "overlapGroup", void 0);
|
|
2176
|
+
__decorate([
|
|
2177
|
+
serialize()
|
|
2178
|
+
], Control.prototype, "overlapDeltaMultiplier", void 0);
|
|
2170
2179
|
return Control;
|
|
2171
2180
|
}());
|
|
2172
2181
|
export { Control };
|