babylonjs-gui 5.43.0 → 5.43.2

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/babylon.gui.js CHANGED
@@ -2092,6 +2092,14 @@ var Button = /** @class */ (function (_super) {
2092
2092
  }
2093
2093
  return true;
2094
2094
  };
2095
+ Button.prototype._getRectangleFill = function (context) {
2096
+ if (this.isEnabled) {
2097
+ return this._getBackgroundColor(context);
2098
+ }
2099
+ else {
2100
+ return this._disabledColor;
2101
+ }
2102
+ };
2095
2103
  /**
2096
2104
  * @internal
2097
2105
  */
@@ -3869,7 +3877,7 @@ __webpack_require__.r(__webpack_exports__);
3869
3877
  /* harmony export */ "Container": () => (/* binding */ Container)
3870
3878
  /* harmony export */ });
3871
3879
  /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../../../node_modules/tslib/tslib.es6.js");
3872
- /* harmony import */ var core_Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! core/Misc/observable */ "core/Misc/observable");
3880
+ /* harmony import */ var core_Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! core/Misc/tools */ "core/Misc/observable");
3873
3881
  /* harmony import */ var core_Misc_logger__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(core_Misc_logger__WEBPACK_IMPORTED_MODULE_1__);
3874
3882
  /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "../../../lts/gui/dist/2D/controls/control.js");
3875
3883
  /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../measure */ "../../../lts/gui/dist/2D/measure.js");
@@ -3883,6 +3891,7 @@ __webpack_require__.r(__webpack_exports__);
3883
3891
 
3884
3892
 
3885
3893
 
3894
+
3886
3895
  /**
3887
3896
  * Root class for 2D containers
3888
3897
  * @see https://doc.babylonjs.com/features/featuresDeepDive/gui/gui#containers
@@ -3903,6 +3912,8 @@ var Container = /** @class */ (function (_super) {
3903
3912
  /** @internal */
3904
3913
  _this._background = "";
3905
3914
  /** @internal */
3915
+ _this._backgroundGradient = null;
3916
+ /** @internal */
3906
3917
  _this._adaptWidthToChildren = false;
3907
3918
  /** @internal */
3908
3919
  _this._adaptHeightToChildren = false;
@@ -3994,6 +4005,21 @@ var Container = /** @class */ (function (_super) {
3994
4005
  enumerable: false,
3995
4006
  configurable: true
3996
4007
  });
4008
+ Object.defineProperty(Container.prototype, "backgroundGradient", {
4009
+ /** Gets or sets background gradient color. Takes precedence over background */
4010
+ get: function () {
4011
+ return this._backgroundGradient;
4012
+ },
4013
+ set: function (value) {
4014
+ if (this._backgroundGradient === value) {
4015
+ return;
4016
+ }
4017
+ this._backgroundGradient = value;
4018
+ this._markAsDirty();
4019
+ },
4020
+ enumerable: false,
4021
+ configurable: true
4022
+ });
3997
4023
  Object.defineProperty(Container.prototype, "children", {
3998
4024
  /** Gets the list of children */
3999
4025
  get: function () {
@@ -4164,11 +4190,14 @@ var Container = /** @class */ (function (_super) {
4164
4190
  this._children[index]._markAllAsDirty();
4165
4191
  }
4166
4192
  };
4193
+ Container.prototype._getBackgroundColor = function (context) {
4194
+ return this._backgroundGradient ? this._backgroundGradient.getCanvasGradient(context) : this._background;
4195
+ };
4167
4196
  /**
4168
4197
  * @internal
4169
4198
  */
4170
4199
  Container.prototype._localDraw = function (context) {
4171
- if (this._background) {
4200
+ if (this._background || this._backgroundGradient) {
4172
4201
  context.save();
4173
4202
  if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
4174
4203
  context.shadowColor = this.shadowColor;
@@ -4176,7 +4205,7 @@ var Container = /** @class */ (function (_super) {
4176
4205
  context.shadowOffsetX = this.shadowOffsetX;
4177
4206
  context.shadowOffsetY = this.shadowOffsetY;
4178
4207
  }
4179
- context.fillStyle = this._background;
4208
+ context.fillStyle = this._getBackgroundColor(context);
4180
4209
  context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
4181
4210
  context.restore();
4182
4211
  }
@@ -4387,6 +4416,10 @@ var Container = /** @class */ (function (_super) {
4387
4416
  */
4388
4417
  Container.prototype.serialize = function (serializationObject) {
4389
4418
  _super.prototype.serialize.call(this, serializationObject);
4419
+ if (this.backgroundGradient) {
4420
+ serializationObject.backgroundGradient = {};
4421
+ this.backgroundGradient.serialize(serializationObject.backgroundGradient);
4422
+ }
4390
4423
  if (!this.children.length) {
4391
4424
  return;
4392
4425
  }
@@ -4411,13 +4444,20 @@ var Container = /** @class */ (function (_super) {
4411
4444
  * @internal
4412
4445
  */
4413
4446
  Container.prototype._parseFromContent = function (serializedObject, host) {
4447
+ var _a;
4414
4448
  _super.prototype._parseFromContent.call(this, serializedObject, host);
4415
4449
  this._link(host);
4450
+ // Gradient
4451
+ if (serializedObject.backgroundGradient) {
4452
+ var className = core_Misc_logger__WEBPACK_IMPORTED_MODULE_1__.Tools.Instantiate("BABYLON.GUI." + serializedObject.backgroundGradient.className);
4453
+ this._backgroundGradient = new className();
4454
+ (_a = this._backgroundGradient) === null || _a === void 0 ? void 0 : _a.parse(serializedObject.backgroundGradient);
4455
+ }
4416
4456
  if (!serializedObject.children) {
4417
4457
  return;
4418
4458
  }
4419
- for (var _i = 0, _a = serializedObject.children; _i < _a.length; _i++) {
4420
- var childData = _a[_i];
4459
+ for (var _i = 0, _b = serializedObject.children; _i < _b.length; _i++) {
4460
+ var childData = _b[_i];
4421
4461
  this.addControl(_control__WEBPACK_IMPORTED_MODULE_2__.Control.Parse(childData, host));
4422
4462
  }
4423
4463
  };
@@ -4436,6 +4476,9 @@ var Container = /** @class */ (function (_super) {
4436
4476
  (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__decorate)([
4437
4477
  (0,core_Misc_logger__WEBPACK_IMPORTED_MODULE_1__.serialize)()
4438
4478
  ], Container.prototype, "background", null);
4479
+ (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__decorate)([
4480
+ (0,core_Misc_logger__WEBPACK_IMPORTED_MODULE_1__.serialize)()
4481
+ ], Container.prototype, "backgroundGradient", null);
4439
4482
  return Container;
4440
4483
  }(_control__WEBPACK_IMPORTED_MODULE_2__.Control));
4441
4484
 
@@ -4554,6 +4597,7 @@ var Control = /** @class */ (function () {
4554
4597
  this._disabledColor = "#9a9a9a";
4555
4598
  this._disabledColorItem = "#6a6a6a";
4556
4599
  this._isReadOnly = false;
4600
+ this._gradient = null;
4557
4601
  /** @internal */
4558
4602
  this._rebuildLayout = false;
4559
4603
  /** @internal */
@@ -5203,6 +5247,21 @@ var Control = /** @class */ (function () {
5203
5247
  enumerable: false,
5204
5248
  configurable: true
5205
5249
  });
5250
+ Object.defineProperty(Control.prototype, "gradient", {
5251
+ /** Gets or sets gradient. Setting a gradient will override the color */
5252
+ get: function () {
5253
+ return this._gradient;
5254
+ },
5255
+ set: function (value) {
5256
+ if (this._gradient === value) {
5257
+ return;
5258
+ }
5259
+ this._gradient = value;
5260
+ this._markAsDirty();
5261
+ },
5262
+ enumerable: false,
5263
+ configurable: true
5264
+ });
5206
5265
  Object.defineProperty(Control.prototype, "zIndex", {
5207
5266
  /** Gets or sets z index which is used to reorder controls on the z axis */
5208
5267
  get: function () {
@@ -6046,6 +6105,9 @@ var Control = /** @class */ (function () {
6046
6105
  Control.prototype._renderHighlightSpecific = function (context) {
6047
6106
  context.strokeRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
6048
6107
  };
6108
+ Control.prototype._getColor = function (context) {
6109
+ return this.gradient ? this.gradient.getCanvasGradient(context) : this.color;
6110
+ };
6049
6111
  /**
6050
6112
  * @internal
6051
6113
  */
@@ -6063,8 +6125,8 @@ var Control = /** @class */ (function () {
6063
6125
  if (this._font) {
6064
6126
  context.font = this._font;
6065
6127
  }
6066
- if (this._color) {
6067
- context.fillStyle = this._color;
6128
+ if (this._color || this.gradient) {
6129
+ context.fillStyle = this._getColor(context);
6068
6130
  }
6069
6131
  if (Control.AllowAlphaInheritance) {
6070
6132
  context.globalAlpha *= this._alpha;
@@ -6604,6 +6666,10 @@ var Control = /** @class */ (function () {
6604
6666
  serializationObject.fontWeight = this.fontWeight;
6605
6667
  serializationObject.fontStyle = this.fontStyle;
6606
6668
  }
6669
+ if (this._gradient) {
6670
+ serializationObject.gradient = {};
6671
+ this._gradient.serialize(serializationObject.gradient);
6672
+ }
6607
6673
  // Animations
6608
6674
  core_Misc_observable__WEBPACK_IMPORTED_MODULE_1__.SerializationHelper.AppendSerializedAnimations(this, serializationObject);
6609
6675
  };
@@ -6611,6 +6677,7 @@ var Control = /** @class */ (function () {
6611
6677
  * @internal
6612
6678
  */
6613
6679
  Control.prototype._parseFromContent = function (serializedObject, host) {
6680
+ var _a;
6614
6681
  if (serializedObject.fontFamily) {
6615
6682
  this.fontFamily = serializedObject.fontFamily;
6616
6683
  }
@@ -6623,6 +6690,12 @@ var Control = /** @class */ (function () {
6623
6690
  if (serializedObject.fontStyle) {
6624
6691
  this.fontStyle = serializedObject.fontStyle;
6625
6692
  }
6693
+ // Gradient
6694
+ if (serializedObject.gradient) {
6695
+ var className = core_Misc_observable__WEBPACK_IMPORTED_MODULE_1__.Tools.Instantiate("BABYLON.GUI." + serializedObject.gradient.className);
6696
+ this._gradient = new className();
6697
+ (_a = this._gradient) === null || _a === void 0 ? void 0 : _a.parse(serializedObject.gradient);
6698
+ }
6626
6699
  // Animations
6627
6700
  if (serializedObject.animations) {
6628
6701
  this.animations = [];
@@ -6850,6 +6923,9 @@ var Control = /** @class */ (function () {
6850
6923
  (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__decorate)([
6851
6924
  (0,core_Misc_observable__WEBPACK_IMPORTED_MODULE_1__.serialize)()
6852
6925
  ], Control.prototype, "color", null);
6926
+ (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__decorate)([
6927
+ (0,core_Misc_observable__WEBPACK_IMPORTED_MODULE_1__.serialize)()
6928
+ ], Control.prototype, "gradient", null);
6853
6929
  (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__decorate)([
6854
6930
  (0,core_Misc_observable__WEBPACK_IMPORTED_MODULE_1__.serialize)()
6855
6931
  ], Control.prototype, "zIndex", null);
@@ -7232,8 +7308,8 @@ var Ellipse = /** @class */ (function (_super) {
7232
7308
  context.shadowOffsetY = this.shadowOffsetY;
7233
7309
  }
7234
7310
  _control__WEBPACK_IMPORTED_MODULE_2__.Control.drawEllipse(this._currentMeasure.left + this._currentMeasure.width / 2, this._currentMeasure.top + this._currentMeasure.height / 2, this._currentMeasure.width / 2 - this._thickness / 2, this._currentMeasure.height / 2 - this._thickness / 2, context);
7235
- if (this._background) {
7236
- context.fillStyle = this._background;
7311
+ if (this._backgroundGradient || this._background) {
7312
+ context.fillStyle = this._getBackgroundColor(context);
7237
7313
  context.fill();
7238
7314
  }
7239
7315
  if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
@@ -7398,6 +7474,344 @@ __webpack_require__.r(__webpack_exports__);
7398
7474
 
7399
7475
 
7400
7476
 
7477
+ /***/ }),
7478
+
7479
+ /***/ "../../../lts/gui/dist/2D/controls/gradient/BaseGradient.js":
7480
+ /*!******************************************************************!*\
7481
+ !*** ../../../lts/gui/dist/2D/controls/gradient/BaseGradient.js ***!
7482
+ \******************************************************************/
7483
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
7484
+
7485
+ __webpack_require__.r(__webpack_exports__);
7486
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
7487
+ /* harmony export */ "BaseGradient": () => (/* binding */ BaseGradient)
7488
+ /* harmony export */ });
7489
+ /*
7490
+ * Base Gradient class. Should not be used directly.
7491
+ */
7492
+ /**
7493
+ * Class that serves as a base for all the gradients created from context.
7494
+ */
7495
+ var BaseGradient = /** @class */ (function () {
7496
+ function BaseGradient() {
7497
+ this._colorStops = [];
7498
+ this._gradientDirty = true;
7499
+ }
7500
+ BaseGradient.prototype._addColorStopsToCanvasGradient = function () {
7501
+ for (var _i = 0, _a = this._colorStops; _i < _a.length; _i++) {
7502
+ var stop_1 = _a[_i];
7503
+ this._canvasGradient.addColorStop(stop_1.offset, stop_1.color);
7504
+ }
7505
+ };
7506
+ /**
7507
+ * If there are any changes or the context changed, regenerate the canvas gradient object. Else,
7508
+ * reuse the existing gradient.
7509
+ **/
7510
+ BaseGradient.prototype.getCanvasGradient = function (context) {
7511
+ if (this._gradientDirty || this._context !== context) {
7512
+ this._context = context;
7513
+ this._canvasGradient = this._createCanvasGradient(context);
7514
+ this._addColorStopsToCanvasGradient();
7515
+ this._gradientDirty = false;
7516
+ }
7517
+ return this._canvasGradient;
7518
+ };
7519
+ /**
7520
+ * Adds a new color stop to the gradient.
7521
+ * @param offset the offset of the stop on the gradient. Should be between 0 and 1
7522
+ * @param color the color of the stop
7523
+ */
7524
+ BaseGradient.prototype.addColorStop = function (offset, color) {
7525
+ this._colorStops.push({ offset: offset, color: color });
7526
+ this._gradientDirty = true;
7527
+ };
7528
+ /**
7529
+ * Removes an existing color stop with the specified offset from the gradient
7530
+ * @param offset the offset of the stop to be removed
7531
+ */
7532
+ BaseGradient.prototype.removeColorStop = function (offset) {
7533
+ this._colorStops = this._colorStops.filter(function (colorStop) { return colorStop.offset !== offset; });
7534
+ this._gradientDirty = true;
7535
+ };
7536
+ /**
7537
+ * Removes all color stops from the gradient
7538
+ */
7539
+ BaseGradient.prototype.clearColorStops = function () {
7540
+ this._colorStops = [];
7541
+ this._gradientDirty = true;
7542
+ };
7543
+ Object.defineProperty(BaseGradient.prototype, "colorStops", {
7544
+ /** Color stops of the gradient */
7545
+ get: function () {
7546
+ return this._colorStops;
7547
+ },
7548
+ enumerable: false,
7549
+ configurable: true
7550
+ });
7551
+ /** Type of the gradient */
7552
+ BaseGradient.prototype.getClassName = function () {
7553
+ return "BaseGradient";
7554
+ };
7555
+ /** Serialize into a json object */
7556
+ BaseGradient.prototype.serialize = function (serializationObject) {
7557
+ serializationObject.colorStops = this._colorStops;
7558
+ serializationObject.className = this.getClassName();
7559
+ };
7560
+ /** Parse from json object */
7561
+ BaseGradient.prototype.parse = function (serializationObject) {
7562
+ this._colorStops = serializationObject.colorStops;
7563
+ };
7564
+ return BaseGradient;
7565
+ }());
7566
+
7567
+
7568
+
7569
+ /***/ }),
7570
+
7571
+ /***/ "../../../lts/gui/dist/2D/controls/gradient/LinearGradient.js":
7572
+ /*!********************************************************************!*\
7573
+ !*** ../../../lts/gui/dist/2D/controls/gradient/LinearGradient.js ***!
7574
+ \********************************************************************/
7575
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
7576
+
7577
+ __webpack_require__.r(__webpack_exports__);
7578
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
7579
+ /* harmony export */ "LinearGradient": () => (/* binding */ LinearGradient)
7580
+ /* harmony export */ });
7581
+ /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../../../node_modules/tslib/tslib.es6.js");
7582
+ /* harmony import */ var _BaseGradient__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./BaseGradient */ "../../../lts/gui/dist/2D/controls/gradient/BaseGradient.js");
7583
+ /* harmony import */ var core_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! core/Misc/typeStore */ "core/Misc/observable");
7584
+ /* harmony import */ var core_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(core_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
7585
+
7586
+
7587
+
7588
+ /**
7589
+ * Gradient along a line that connects two coordinates.
7590
+ * These coordinates are relative to the canvas' space, not to any control's space.
7591
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/createLinearGradient
7592
+ */
7593
+ var LinearGradient = /** @class */ (function (_super) {
7594
+ (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__extends)(LinearGradient, _super);
7595
+ /**
7596
+ * Creates a new linear gradient
7597
+ * @param x0
7598
+ * @param y0
7599
+ * @param x1
7600
+ * @param y1
7601
+ */
7602
+ function LinearGradient(x0, y0, x1, y1) {
7603
+ var _this = _super.call(this) || this;
7604
+ _this._x0 = x0 !== null && x0 !== void 0 ? x0 : 0;
7605
+ _this._y0 = y0 !== null && y0 !== void 0 ? y0 : 0;
7606
+ _this._x1 = x1 !== null && x1 !== void 0 ? x1 : 0;
7607
+ _this._y1 = y1 !== null && y1 !== void 0 ? y1 : 0;
7608
+ return _this;
7609
+ }
7610
+ LinearGradient.prototype._createCanvasGradient = function (context) {
7611
+ return context.createLinearGradient(this._x0, this._y0, this._x1, this._y1);
7612
+ };
7613
+ Object.defineProperty(LinearGradient.prototype, "x0", {
7614
+ /** X axis coordinate of the starting point in the line */
7615
+ get: function () {
7616
+ return this._x0;
7617
+ },
7618
+ enumerable: false,
7619
+ configurable: true
7620
+ });
7621
+ Object.defineProperty(LinearGradient.prototype, "x1", {
7622
+ /** X axis coordinate of the ending point in the line */
7623
+ get: function () {
7624
+ return this._x1;
7625
+ },
7626
+ enumerable: false,
7627
+ configurable: true
7628
+ });
7629
+ Object.defineProperty(LinearGradient.prototype, "y0", {
7630
+ /** Y axis coordinate of the starting point in the line */
7631
+ get: function () {
7632
+ return this._y0;
7633
+ },
7634
+ enumerable: false,
7635
+ configurable: true
7636
+ });
7637
+ Object.defineProperty(LinearGradient.prototype, "y1", {
7638
+ /** Y axis coordinate of the ending point in the line */
7639
+ get: function () {
7640
+ return this._y1;
7641
+ },
7642
+ enumerable: false,
7643
+ configurable: true
7644
+ });
7645
+ /**
7646
+ * Class name of the gradient
7647
+ * @returns the class name of the gradient
7648
+ */
7649
+ LinearGradient.prototype.getClassName = function () {
7650
+ return "LinearGradient";
7651
+ };
7652
+ /**
7653
+ * Serializes this gradient
7654
+ * @param serializationObject the object to serialize to
7655
+ */
7656
+ LinearGradient.prototype.serialize = function (serializationObject) {
7657
+ _super.prototype.serialize.call(this, serializationObject);
7658
+ serializationObject.x0 = this._x0;
7659
+ serializationObject.y0 = this._y0;
7660
+ serializationObject.x1 = this._x1;
7661
+ serializationObject.y1 = this._y1;
7662
+ };
7663
+ /**
7664
+ * Parses a gradient from a serialization object
7665
+ * @param serializationObject the object to parse from
7666
+ */
7667
+ LinearGradient.prototype.parse = function (serializationObject) {
7668
+ _super.prototype.parse.call(this, serializationObject);
7669
+ this._x0 = serializationObject.x0;
7670
+ this._y0 = serializationObject.y0;
7671
+ this._x1 = serializationObject.x1;
7672
+ this._y1 = serializationObject.y1;
7673
+ };
7674
+ return LinearGradient;
7675
+ }(_BaseGradient__WEBPACK_IMPORTED_MODULE_1__.BaseGradient));
7676
+
7677
+ (0,core_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__.RegisterClass)("BABYLON.GUI.LinearGradient", LinearGradient);
7678
+
7679
+
7680
+ /***/ }),
7681
+
7682
+ /***/ "../../../lts/gui/dist/2D/controls/gradient/RadialGradient.js":
7683
+ /*!********************************************************************!*\
7684
+ !*** ../../../lts/gui/dist/2D/controls/gradient/RadialGradient.js ***!
7685
+ \********************************************************************/
7686
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
7687
+
7688
+ __webpack_require__.r(__webpack_exports__);
7689
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
7690
+ /* harmony export */ "RadialGradient": () => (/* binding */ RadialGradient)
7691
+ /* harmony export */ });
7692
+ /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../../../node_modules/tslib/tslib.es6.js");
7693
+ /* harmony import */ var _BaseGradient__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./BaseGradient */ "../../../lts/gui/dist/2D/controls/gradient/BaseGradient.js");
7694
+ /* harmony import */ var core_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! core/Misc/typeStore */ "core/Misc/observable");
7695
+ /* harmony import */ var core_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(core_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
7696
+
7697
+
7698
+
7699
+ /**
7700
+ * Gradient formed from two circles with their own centers and radius.
7701
+ * The coordinates of the circles centers are relative to the canvas' space, not to any control's space.
7702
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/createRadialGradient
7703
+ */
7704
+ var RadialGradient = /** @class */ (function (_super) {
7705
+ (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__extends)(RadialGradient, _super);
7706
+ /**
7707
+ * Creates a new radial gradient
7708
+ * @param x0 x coordinate of the first circle's center
7709
+ * @param y0 y coordinate of the first circle's center
7710
+ * @param r0 radius of the first circle
7711
+ * @param x1 x coordinate of the second circle's center
7712
+ * @param y1 y coordinate of the second circle's center
7713
+ * @param r1 radius of the second circle
7714
+ */
7715
+ function RadialGradient(x0, y0, r0, x1, y1, r1) {
7716
+ var _this = _super.call(this) || this;
7717
+ _this._x0 = x0 !== null && x0 !== void 0 ? x0 : 0;
7718
+ _this._y0 = y0 !== null && y0 !== void 0 ? y0 : 0;
7719
+ _this._r0 = r0 !== null && r0 !== void 0 ? r0 : 0;
7720
+ _this._x1 = x1 !== null && x1 !== void 0 ? x1 : 0;
7721
+ _this._y1 = y1 !== null && y1 !== void 0 ? y1 : 0;
7722
+ _this._r1 = r1 !== null && r1 !== void 0 ? r1 : 0;
7723
+ return _this;
7724
+ }
7725
+ RadialGradient.prototype._createCanvasGradient = function (context) {
7726
+ return context.createRadialGradient(this._x0, this._y0, this._r0, this._x1, this._y1, this._r1);
7727
+ };
7728
+ Object.defineProperty(RadialGradient.prototype, "x0", {
7729
+ /** x coordinate of the first circle's center */
7730
+ get: function () {
7731
+ return this._x0;
7732
+ },
7733
+ enumerable: false,
7734
+ configurable: true
7735
+ });
7736
+ Object.defineProperty(RadialGradient.prototype, "x1", {
7737
+ /** x coordinate of the second circle's center */
7738
+ get: function () {
7739
+ return this._x1;
7740
+ },
7741
+ enumerable: false,
7742
+ configurable: true
7743
+ });
7744
+ Object.defineProperty(RadialGradient.prototype, "y0", {
7745
+ /** y coordinate of the first circle's center */
7746
+ get: function () {
7747
+ return this._y0;
7748
+ },
7749
+ enumerable: false,
7750
+ configurable: true
7751
+ });
7752
+ Object.defineProperty(RadialGradient.prototype, "y1", {
7753
+ /** y coordinate of the second circle's center */
7754
+ get: function () {
7755
+ return this._y1;
7756
+ },
7757
+ enumerable: false,
7758
+ configurable: true
7759
+ });
7760
+ Object.defineProperty(RadialGradient.prototype, "r0", {
7761
+ /** radius of the first circle */
7762
+ get: function () {
7763
+ return this._r0;
7764
+ },
7765
+ enumerable: false,
7766
+ configurable: true
7767
+ });
7768
+ Object.defineProperty(RadialGradient.prototype, "r1", {
7769
+ /** radius of the second circle */
7770
+ get: function () {
7771
+ return this._r1;
7772
+ },
7773
+ enumerable: false,
7774
+ configurable: true
7775
+ });
7776
+ /**
7777
+ * Class name of the gradient
7778
+ * @returns the class name of the gradient
7779
+ */
7780
+ RadialGradient.prototype.getClassName = function () {
7781
+ return "RadialGradient";
7782
+ };
7783
+ /**
7784
+ * Serializes this gradient
7785
+ * @param serializationObject the object to serialize to
7786
+ */
7787
+ RadialGradient.prototype.serialize = function (serializationObject) {
7788
+ _super.prototype.serialize.call(this, serializationObject);
7789
+ serializationObject.x0 = this._x0;
7790
+ serializationObject.y0 = this._y0;
7791
+ serializationObject.r0 = this._r0;
7792
+ serializationObject.x1 = this._x1;
7793
+ serializationObject.y1 = this._y1;
7794
+ serializationObject.r1 = this._r1;
7795
+ };
7796
+ /**
7797
+ * Parses a gradient from a serialization object
7798
+ * @param serializationObject the object to parse from
7799
+ */
7800
+ RadialGradient.prototype.parse = function (serializationObject) {
7801
+ _super.prototype.parse.call(this, serializationObject);
7802
+ this._x0 = serializationObject.x0;
7803
+ this._y0 = serializationObject.y0;
7804
+ this._r0 = serializationObject.r0;
7805
+ this._x1 = serializationObject.x1;
7806
+ this._y1 = serializationObject.y1;
7807
+ this._r1 = serializationObject.r1;
7808
+ };
7809
+ return RadialGradient;
7810
+ }(_BaseGradient__WEBPACK_IMPORTED_MODULE_1__.BaseGradient));
7811
+
7812
+ (0,core_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__.RegisterClass)("BABYLON.GUI.RadialGradient", RadialGradient);
7813
+
7814
+
7401
7815
  /***/ }),
7402
7816
 
7403
7817
  /***/ "../../../lts/gui/dist/2D/controls/grid.js":
@@ -8449,14 +8863,31 @@ var Image = /** @class */ (function (_super) {
8449
8863
  var cachedData = Image.SourceImgCache.get(value);
8450
8864
  this._domImage = cachedData.img;
8451
8865
  cachedData.timesUsed += 1;
8452
- this._onImageLoaded();
8866
+ if (cachedData.loaded) {
8867
+ this._onImageLoaded();
8868
+ }
8869
+ else {
8870
+ cachedData.waitingForLoadCallback.push(this._onImageLoaded.bind(this));
8871
+ }
8453
8872
  return;
8454
8873
  }
8455
8874
  this._domImage = engine.createCanvasImage();
8456
8875
  if (value) {
8457
- Image.SourceImgCache.set(value, { img: this._domImage, timesUsed: 1 });
8876
+ Image.SourceImgCache.set(value, { img: this._domImage, timesUsed: 1, loaded: false, waitingForLoadCallback: [this._onImageLoaded.bind(this)] });
8458
8877
  }
8459
8878
  this._domImage.onload = function () {
8879
+ if (value) {
8880
+ var cachedData = Image.SourceImgCache.get(value);
8881
+ if (cachedData) {
8882
+ cachedData.loaded = true;
8883
+ for (var _i = 0, _a = cachedData.waitingForLoadCallback; _i < _a.length; _i++) {
8884
+ var waitingCallback = _a[_i];
8885
+ waitingCallback();
8886
+ }
8887
+ cachedData.waitingForLoadCallback.length = 0;
8888
+ return;
8889
+ }
8890
+ }
8460
8891
  _this._onImageLoaded();
8461
8892
  };
8462
8893
  if (value) {
@@ -8820,6 +9251,9 @@ var Image = /** @class */ (function (_super) {
8820
9251
  this.onSVGAttributesComputedObservable.clear();
8821
9252
  this._removeCacheUsage(this._source);
8822
9253
  };
9254
+ /**
9255
+ * Cache of images to avoid loading the same image multiple times
9256
+ */
8823
9257
  Image.SourceImgCache = new Map();
8824
9258
  // Static
8825
9259
  /** STRETCH_NONE */
@@ -8896,6 +9330,7 @@ var Image = /** @class */ (function (_super) {
8896
9330
 
8897
9331
  __webpack_require__.r(__webpack_exports__);
8898
9332
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9333
+ /* harmony export */ "BaseGradient": () => (/* reexport safe */ _gradient_BaseGradient__WEBPACK_IMPORTED_MODULE_31__.BaseGradient),
8899
9334
  /* harmony export */ "BaseSlider": () => (/* reexport safe */ _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_25__.BaseSlider),
8900
9335
  /* harmony export */ "Button": () => (/* reexport safe */ _button__WEBPACK_IMPORTED_MODULE_0__.Button),
8901
9336
  /* harmony export */ "Checkbox": () => (/* reexport safe */ _checkbox__WEBPACK_IMPORTED_MODULE_1__.Checkbox),
@@ -8915,7 +9350,9 @@ __webpack_require__.r(__webpack_exports__);
8915
9350
  /* harmony export */ "InputTextArea": () => (/* reexport safe */ _inputTextArea__WEBPACK_IMPORTED_MODULE_11__.InputTextArea),
8916
9351
  /* harmony export */ "KeyPropertySet": () => (/* reexport safe */ _virtualKeyboard__WEBPACK_IMPORTED_MODULE_22__.KeyPropertySet),
8917
9352
  /* harmony export */ "Line": () => (/* reexport safe */ _line__WEBPACK_IMPORTED_MODULE_13__.Line),
9353
+ /* harmony export */ "LinearGradient": () => (/* reexport safe */ _gradient_LinearGradient__WEBPACK_IMPORTED_MODULE_32__.LinearGradient),
8918
9354
  /* harmony export */ "MultiLine": () => (/* reexport safe */ _multiLine__WEBPACK_IMPORTED_MODULE_14__.MultiLine),
9355
+ /* harmony export */ "RadialGradient": () => (/* reexport safe */ _gradient_RadialGradient__WEBPACK_IMPORTED_MODULE_33__.RadialGradient),
8919
9356
  /* harmony export */ "RadioButton": () => (/* reexport safe */ _radioButton__WEBPACK_IMPORTED_MODULE_15__.RadioButton),
8920
9357
  /* harmony export */ "RadioGroup": () => (/* reexport safe */ _selector__WEBPACK_IMPORTED_MODULE_17__.RadioGroup),
8921
9358
  /* harmony export */ "Rectangle": () => (/* reexport safe */ _rectangle__WEBPACK_IMPORTED_MODULE_23__.Rectangle),
@@ -8964,6 +9401,12 @@ __webpack_require__.r(__webpack_exports__);
8964
9401
  /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./sliders/scrollBar */ "../../../lts/gui/dist/2D/controls/sliders/scrollBar.js");
8965
9402
  /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./sliders/imageScrollBar */ "../../../lts/gui/dist/2D/controls/sliders/imageScrollBar.js");
8966
9403
  /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./statics */ "../../../lts/gui/dist/2D/controls/statics.js");
9404
+ /* harmony import */ var _gradient_BaseGradient__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./gradient/BaseGradient */ "../../../lts/gui/dist/2D/controls/gradient/BaseGradient.js");
9405
+ /* harmony import */ var _gradient_LinearGradient__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./gradient/LinearGradient */ "../../../lts/gui/dist/2D/controls/gradient/LinearGradient.js");
9406
+ /* harmony import */ var _gradient_RadialGradient__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ./gradient/RadialGradient */ "../../../lts/gui/dist/2D/controls/gradient/RadialGradient.js");
9407
+
9408
+
9409
+
8967
9410
 
8968
9411
 
8969
9412
 
@@ -11474,7 +11917,7 @@ var Line = /** @class */ (function (_super) {
11474
11917
  context.shadowOffsetY = this.shadowOffsetY;
11475
11918
  }
11476
11919
  this._applyStates(context);
11477
- context.strokeStyle = this.color;
11920
+ context.strokeStyle = this._getColor(context);
11478
11921
  context.lineWidth = this._lineWidth;
11479
11922
  context.setLineDash(this._dash);
11480
11923
  context.beginPath();
@@ -12151,6 +12594,9 @@ var Rectangle = /** @class */ (function (_super) {
12151
12594
  }
12152
12595
  return 0;
12153
12596
  };
12597
+ Rectangle.prototype._getRectangleFill = function (context) {
12598
+ return this._getBackgroundColor(context);
12599
+ };
12154
12600
  Rectangle.prototype._localDraw = function (context) {
12155
12601
  context.save();
12156
12602
  if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
@@ -12159,8 +12605,8 @@ var Rectangle = /** @class */ (function (_super) {
12159
12605
  context.shadowOffsetX = this.shadowOffsetX;
12160
12606
  context.shadowOffsetY = this.shadowOffsetY;
12161
12607
  }
12162
- if (this._background) {
12163
- context.fillStyle = this.typeName === "Button" ? (this.isEnabled ? this._background : this.disabledColor) : this._background;
12608
+ if (this._background || this._backgroundGradient) {
12609
+ context.fillStyle = this._getRectangleFill(context);
12164
12610
  if (this._cornerRadius) {
12165
12611
  this._drawRoundedRect(context, this._thickness / 2);
12166
12612
  context.fill();
@@ -12175,8 +12621,8 @@ var Rectangle = /** @class */ (function (_super) {
12175
12621
  context.shadowOffsetX = 0;
12176
12622
  context.shadowOffsetY = 0;
12177
12623
  }
12178
- if (this.color) {
12179
- context.strokeStyle = this.color;
12624
+ if (this.color || this.gradient) {
12625
+ context.strokeStyle = this.gradient ? this.gradient.getCanvasGradient(context) : this.color;
12180
12626
  }
12181
12627
  context.lineWidth = this._thickness;
12182
12628
  if (this._cornerRadius) {
@@ -14815,12 +15261,14 @@ __webpack_require__.r(__webpack_exports__);
14815
15261
  /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../../../node_modules/tslib/tslib.es6.js");
14816
15262
  /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "../../../lts/gui/dist/2D/controls/sliders/baseSlider.js");
14817
15263
  /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "../../../lts/gui/dist/2D/measure.js");
14818
- /* harmony import */ var core_Misc_decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! core/Misc/decorators */ "core/Misc/observable");
15264
+ /* harmony import */ var core_Misc_decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! core/Misc/typeStore */ "core/Misc/observable");
14819
15265
  /* harmony import */ var core_Misc_decorators__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(core_Misc_decorators__WEBPACK_IMPORTED_MODULE_3__);
14820
15266
 
14821
15267
 
14822
15268
 
14823
15269
 
15270
+
15271
+
14824
15272
  /**
14825
15273
  * Class used to create slider controls
14826
15274
  */
@@ -14837,6 +15285,7 @@ var ScrollBar = /** @class */ (function (_super) {
14837
15285
  _this._borderColor = "white";
14838
15286
  _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__.Measure(0, 0, 0, 0);
14839
15287
  _this._invertScrollDirection = false;
15288
+ _this._backgroundGradient = null;
14840
15289
  return _this;
14841
15290
  }
14842
15291
  Object.defineProperty(ScrollBar.prototype, "borderColor", {
@@ -14869,6 +15318,21 @@ var ScrollBar = /** @class */ (function (_super) {
14869
15318
  enumerable: false,
14870
15319
  configurable: true
14871
15320
  });
15321
+ Object.defineProperty(ScrollBar.prototype, "backgroundGradient", {
15322
+ /** Gets or sets background gradient. Takes precedence over gradient. */
15323
+ get: function () {
15324
+ return this._backgroundGradient;
15325
+ },
15326
+ set: function (value) {
15327
+ if (this._backgroundGradient === value) {
15328
+ return;
15329
+ }
15330
+ this._backgroundGradient = value;
15331
+ this._markAsDirty();
15332
+ },
15333
+ enumerable: false,
15334
+ configurable: true
15335
+ });
14872
15336
  Object.defineProperty(ScrollBar.prototype, "invertScrollDirection", {
14873
15337
  /** Inverts the scrolling direction (default: false) */
14874
15338
  get: function () {
@@ -14893,16 +15357,19 @@ var ScrollBar = /** @class */ (function (_super) {
14893
15357
  }
14894
15358
  return thumbThickness;
14895
15359
  };
15360
+ ScrollBar.prototype._getBackgroundColor = function (context) {
15361
+ return this._backgroundGradient ? this._backgroundGradient.getCanvasGradient(context) : this._background;
15362
+ };
14896
15363
  ScrollBar.prototype._draw = function (context) {
14897
15364
  context.save();
14898
15365
  this._applyStates(context);
14899
15366
  this._prepareRenderingData("rectangle");
14900
15367
  var left = this._renderLeft;
14901
15368
  var thumbPosition = this._getThumbPosition();
14902
- context.fillStyle = this._background;
15369
+ context.fillStyle = this._getBackgroundColor(context);
14903
15370
  context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
14904
15371
  // Value bar
14905
- context.fillStyle = this.color;
15372
+ context.fillStyle = this._getColor(context);
14906
15373
  // Thumb
14907
15374
  if (this.isVertical) {
14908
15375
  this._tempMeasure.left = left - this._effectiveBarOffset;
@@ -14962,6 +15429,21 @@ var ScrollBar = /** @class */ (function (_super) {
14962
15429
  this._first = true;
14963
15430
  return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi);
14964
15431
  };
15432
+ ScrollBar.prototype.serialize = function (serializationObject) {
15433
+ _super.prototype.serialize.call(this, serializationObject);
15434
+ if (this.backgroundGradient) {
15435
+ serializationObject.backgroundGradient = {};
15436
+ this.backgroundGradient.serialize(serializationObject.backgroundGradient);
15437
+ }
15438
+ };
15439
+ ScrollBar.prototype._parseFromContent = function (serializationObject, host) {
15440
+ _super.prototype._parseFromContent.call(this, serializationObject, host);
15441
+ if (serializationObject.backgroundGradient) {
15442
+ var className = core_Misc_decorators__WEBPACK_IMPORTED_MODULE_3__.Tools.Instantiate("BABYLON.GUI." + serializationObject.backgroundGradient.className);
15443
+ this.backgroundGradient = new className();
15444
+ this.backgroundGradient.parse(serializationObject.backgroundGradient);
15445
+ }
15446
+ };
14965
15447
  (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__decorate)([
14966
15448
  (0,core_Misc_decorators__WEBPACK_IMPORTED_MODULE_3__.serialize)()
14967
15449
  ], ScrollBar.prototype, "borderColor", null);
@@ -14974,6 +15456,7 @@ var ScrollBar = /** @class */ (function (_super) {
14974
15456
  return ScrollBar;
14975
15457
  }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__.BaseSlider));
14976
15458
 
15459
+ (0,core_Misc_decorators__WEBPACK_IMPORTED_MODULE_3__.RegisterClass)("BABYLON.GUI.Scrollbar", ScrollBar);
14977
15460
 
14978
15461
 
14979
15462
  /***/ }),
@@ -14990,12 +15473,13 @@ __webpack_require__.r(__webpack_exports__);
14990
15473
  /* harmony export */ });
14991
15474
  /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../../../node_modules/tslib/tslib.es6.js");
14992
15475
  /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "../../../lts/gui/dist/2D/controls/sliders/baseSlider.js");
14993
- /* harmony import */ var core_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! core/Misc/decorators */ "core/Misc/observable");
15476
+ /* harmony import */ var core_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! core/Misc/tools */ "core/Misc/observable");
14994
15477
  /* harmony import */ var core_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(core_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
14995
15478
 
14996
15479
 
14997
15480
 
14998
15481
 
15482
+
14999
15483
  /**
15000
15484
  * Class used to create slider controls
15001
15485
  */
@@ -15013,6 +15497,7 @@ var Slider = /** @class */ (function (_super) {
15013
15497
  _this._thumbColor = "";
15014
15498
  _this._isThumbCircle = false;
15015
15499
  _this._displayValueBar = true;
15500
+ _this._backgroundGradient = null;
15016
15501
  return _this;
15017
15502
  }
15018
15503
  Object.defineProperty(Slider.prototype, "displayValueBar", {
@@ -15060,6 +15545,21 @@ var Slider = /** @class */ (function (_super) {
15060
15545
  enumerable: false,
15061
15546
  configurable: true
15062
15547
  });
15548
+ Object.defineProperty(Slider.prototype, "backgroundGradient", {
15549
+ /** Gets or sets background gradient */
15550
+ get: function () {
15551
+ return this._backgroundGradient;
15552
+ },
15553
+ set: function (value) {
15554
+ if (this._backgroundGradient === value) {
15555
+ return;
15556
+ }
15557
+ this._backgroundGradient = value;
15558
+ this._markAsDirty();
15559
+ },
15560
+ enumerable: false,
15561
+ configurable: true
15562
+ });
15063
15563
  Object.defineProperty(Slider.prototype, "thumbColor", {
15064
15564
  /** Gets or sets thumb's color */
15065
15565
  get: function () {
@@ -15093,6 +15593,9 @@ var Slider = /** @class */ (function (_super) {
15093
15593
  Slider.prototype._getTypeName = function () {
15094
15594
  return "Slider";
15095
15595
  };
15596
+ Slider.prototype._getBackgroundColor = function (context) {
15597
+ return this._backgroundGradient ? this._backgroundGradient.getCanvasGradient(context) : this._background;
15598
+ };
15096
15599
  Slider.prototype._draw = function (context) {
15097
15600
  context.save();
15098
15601
  this._applyStates(context);
@@ -15121,7 +15624,7 @@ var Slider = /** @class */ (function (_super) {
15121
15624
  context.shadowOffsetY = this.shadowOffsetY;
15122
15625
  }
15123
15626
  var thumbPosition = this._getThumbPosition();
15124
- context.fillStyle = this._background;
15627
+ context.fillStyle = this._getBackgroundColor(context);
15125
15628
  if (this.isVertical) {
15126
15629
  if (this.isThumbClamped) {
15127
15630
  if (this.isThumbCircle) {
@@ -15160,7 +15663,7 @@ var Slider = /** @class */ (function (_super) {
15160
15663
  context.shadowOffsetY = 0;
15161
15664
  }
15162
15665
  // Value bar
15163
- context.fillStyle = this.color;
15666
+ context.fillStyle = this._getColor(context);
15164
15667
  if (this._displayValueBar) {
15165
15668
  if (this.isVertical) {
15166
15669
  if (this.isThumbClamped) {
@@ -15196,7 +15699,7 @@ var Slider = /** @class */ (function (_super) {
15196
15699
  }
15197
15700
  }
15198
15701
  // Thumb
15199
- context.fillStyle = this._thumbColor || this.color;
15702
+ context.fillStyle = this._thumbColor || this._getColor(context);
15200
15703
  if (this.displayThumb) {
15201
15704
  if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
15202
15705
  context.shadowColor = this.shadowColor;
@@ -15244,6 +15747,22 @@ var Slider = /** @class */ (function (_super) {
15244
15747
  }
15245
15748
  context.restore();
15246
15749
  };
15750
+ Slider.prototype.serialize = function (serializationObject) {
15751
+ _super.prototype.serialize.call(this, serializationObject);
15752
+ if (this.backgroundGradient) {
15753
+ serializationObject.backgroundGradient = {};
15754
+ this.backgroundGradient.serialize(serializationObject.backgroundGradient);
15755
+ }
15756
+ };
15757
+ /** @internal */
15758
+ Slider.prototype._parseFromContent = function (serializedObject, host) {
15759
+ _super.prototype._parseFromContent.call(this, serializedObject, host);
15760
+ if (serializedObject.backgroundGradient) {
15761
+ var className = core_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__.Tools.Instantiate("BABYLON.GUI." + serializedObject.backgroundGradient.className);
15762
+ this.backgroundGradient = new className();
15763
+ this.backgroundGradient.parse(serializedObject.backgroundGradient);
15764
+ }
15765
+ };
15247
15766
  (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__decorate)([
15248
15767
  (0,core_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__.serialize)()
15249
15768
  ], Slider.prototype, "displayValueBar", null);
@@ -15668,6 +16187,7 @@ var TextBlock = /** @class */ (function (_super) {
15668
16187
  _this._underline = false;
15669
16188
  _this._lineThrough = false;
15670
16189
  _this._wordDivider = " ";
16190
+ _this._forceResizeWidth = false;
15671
16191
  /**
15672
16192
  * An event triggered after the text is changed
15673
16193
  */
@@ -15913,6 +16433,25 @@ var TextBlock = /** @class */ (function (_super) {
15913
16433
  enumerable: false,
15914
16434
  configurable: true
15915
16435
  });
16436
+ Object.defineProperty(TextBlock.prototype, "forceResizeWidth", {
16437
+ /**
16438
+ * By default, if a text block has text wrapping other than Clip, its width
16439
+ * is not resized even if resizeToFit = true. This parameter forces the width
16440
+ * to be resized.
16441
+ */
16442
+ get: function () {
16443
+ return this._forceResizeWidth;
16444
+ },
16445
+ set: function (value) {
16446
+ if (this._forceResizeWidth === value) {
16447
+ return;
16448
+ }
16449
+ this._forceResizeWidth = value;
16450
+ this._markAsDirty();
16451
+ },
16452
+ enumerable: false,
16453
+ configurable: true
16454
+ });
15916
16455
  TextBlock.prototype._getTypeName = function () {
15917
16456
  return "TextBlock";
15918
16457
  };
@@ -15932,9 +16471,9 @@ var TextBlock = /** @class */ (function (_super) {
15932
16471
  }
15933
16472
  }
15934
16473
  if (this._resizeToFit) {
15935
- if (this._textWrapping === TextWrapping.Clip) {
15936
- var newWidth = (this._paddingLeftInPixels + this._paddingRightInPixels + maxLineWidth) | 0;
15937
- if (newWidth !== this._width.internalValue) {
16474
+ if (this._textWrapping === TextWrapping.Clip || this._forceResizeWidth) {
16475
+ var newWidth = Math.ceil(this._paddingLeftInPixels + this._paddingRightInPixels + maxLineWidth);
16476
+ if (newWidth !== this._width.getValueInPixel(this._host, this._tempParentMeasure.width)) {
15938
16477
  this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__.ValueAndUnit.UNITMODE_PIXEL);
15939
16478
  this._rebuildLayout = true;
15940
16479
  }
@@ -16235,6 +16774,9 @@ var TextBlock = /** @class */ (function (_super) {
16235
16774
  (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__decorate)([
16236
16775
  (0,core_Misc_observable__WEBPACK_IMPORTED_MODULE_1__.serialize)()
16237
16776
  ], TextBlock.prototype, "wordDivider", null);
16777
+ (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__decorate)([
16778
+ (0,core_Misc_observable__WEBPACK_IMPORTED_MODULE_1__.serialize)()
16779
+ ], TextBlock.prototype, "forceResizeWidth", null);
16238
16780
  return TextBlock;
16239
16781
  }(_control__WEBPACK_IMPORTED_MODULE_3__.Control));
16240
16782
 
@@ -16948,6 +17490,7 @@ __webpack_require__.r(__webpack_exports__);
16948
17490
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
16949
17491
  /* harmony export */ "AdvancedDynamicTexture": () => (/* reexport safe */ _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__.AdvancedDynamicTexture),
16950
17492
  /* harmony export */ "AdvancedDynamicTextureInstrumentation": () => (/* reexport safe */ _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__.AdvancedDynamicTextureInstrumentation),
17493
+ /* harmony export */ "BaseGradient": () => (/* reexport safe */ _controls_index__WEBPACK_IMPORTED_MODULE_0__.BaseGradient),
16951
17494
  /* harmony export */ "BaseSlider": () => (/* reexport safe */ _controls_index__WEBPACK_IMPORTED_MODULE_0__.BaseSlider),
16952
17495
  /* harmony export */ "Button": () => (/* reexport safe */ _controls_index__WEBPACK_IMPORTED_MODULE_0__.Button),
16953
17496
  /* harmony export */ "Checkbox": () => (/* reexport safe */ _controls_index__WEBPACK_IMPORTED_MODULE_0__.Checkbox),
@@ -16967,11 +17510,13 @@ __webpack_require__.r(__webpack_exports__);
16967
17510
  /* harmony export */ "InputTextArea": () => (/* reexport safe */ _controls_index__WEBPACK_IMPORTED_MODULE_0__.InputTextArea),
16968
17511
  /* harmony export */ "KeyPropertySet": () => (/* reexport safe */ _controls_index__WEBPACK_IMPORTED_MODULE_0__.KeyPropertySet),
16969
17512
  /* harmony export */ "Line": () => (/* reexport safe */ _controls_index__WEBPACK_IMPORTED_MODULE_0__.Line),
17513
+ /* harmony export */ "LinearGradient": () => (/* reexport safe */ _controls_index__WEBPACK_IMPORTED_MODULE_0__.LinearGradient),
16970
17514
  /* harmony export */ "MathTools": () => (/* reexport safe */ _math2D__WEBPACK_IMPORTED_MODULE_3__.MathTools),
16971
17515
  /* harmony export */ "Matrix2D": () => (/* reexport safe */ _math2D__WEBPACK_IMPORTED_MODULE_3__.Matrix2D),
16972
17516
  /* harmony export */ "Measure": () => (/* reexport safe */ _measure__WEBPACK_IMPORTED_MODULE_4__.Measure),
16973
17517
  /* harmony export */ "MultiLine": () => (/* reexport safe */ _controls_index__WEBPACK_IMPORTED_MODULE_0__.MultiLine),
16974
17518
  /* harmony export */ "MultiLinePoint": () => (/* reexport safe */ _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__.MultiLinePoint),
17519
+ /* harmony export */ "RadialGradient": () => (/* reexport safe */ _controls_index__WEBPACK_IMPORTED_MODULE_0__.RadialGradient),
16975
17520
  /* harmony export */ "RadioButton": () => (/* reexport safe */ _controls_index__WEBPACK_IMPORTED_MODULE_0__.RadioButton),
16976
17521
  /* harmony export */ "RadioGroup": () => (/* reexport safe */ _controls_index__WEBPACK_IMPORTED_MODULE_0__.RadioGroup),
16977
17522
  /* harmony export */ "Rectangle": () => (/* reexport safe */ _controls_index__WEBPACK_IMPORTED_MODULE_0__.Rectangle),
@@ -29976,6 +30521,7 @@ __webpack_require__.r(__webpack_exports__);
29976
30521
  /* harmony export */ "AbstractButton3D": () => (/* reexport safe */ _3D_index__WEBPACK_IMPORTED_MODULE_1__.AbstractButton3D),
29977
30522
  /* harmony export */ "AdvancedDynamicTexture": () => (/* reexport safe */ _2D_index__WEBPACK_IMPORTED_MODULE_0__.AdvancedDynamicTexture),
29978
30523
  /* harmony export */ "AdvancedDynamicTextureInstrumentation": () => (/* reexport safe */ _2D_index__WEBPACK_IMPORTED_MODULE_0__.AdvancedDynamicTextureInstrumentation),
30524
+ /* harmony export */ "BaseGradient": () => (/* reexport safe */ _2D_index__WEBPACK_IMPORTED_MODULE_0__.BaseGradient),
29979
30525
  /* harmony export */ "BaseSlider": () => (/* reexport safe */ _2D_index__WEBPACK_IMPORTED_MODULE_0__.BaseSlider),
29980
30526
  /* harmony export */ "Button": () => (/* reexport safe */ _2D_index__WEBPACK_IMPORTED_MODULE_0__.Button),
29981
30527
  /* harmony export */ "Button3D": () => (/* reexport safe */ _3D_index__WEBPACK_IMPORTED_MODULE_1__.Button3D),
@@ -30012,6 +30558,7 @@ __webpack_require__.r(__webpack_exports__);
30012
30558
  /* harmony export */ "InputTextArea": () => (/* reexport safe */ _2D_index__WEBPACK_IMPORTED_MODULE_0__.InputTextArea),
30013
30559
  /* harmony export */ "KeyPropertySet": () => (/* reexport safe */ _2D_index__WEBPACK_IMPORTED_MODULE_0__.KeyPropertySet),
30014
30560
  /* harmony export */ "Line": () => (/* reexport safe */ _2D_index__WEBPACK_IMPORTED_MODULE_0__.Line),
30561
+ /* harmony export */ "LinearGradient": () => (/* reexport safe */ _2D_index__WEBPACK_IMPORTED_MODULE_0__.LinearGradient),
30015
30562
  /* harmony export */ "MRDLBackplateMaterial": () => (/* reexport safe */ _3D_index__WEBPACK_IMPORTED_MODULE_1__.MRDLBackplateMaterial),
30016
30563
  /* harmony export */ "MRDLSliderBarMaterial": () => (/* reexport safe */ _3D_index__WEBPACK_IMPORTED_MODULE_1__.MRDLSliderBarMaterial),
30017
30564
  /* harmony export */ "MRDLSliderThumbMaterial": () => (/* reexport safe */ _3D_index__WEBPACK_IMPORTED_MODULE_1__.MRDLSliderThumbMaterial),
@@ -30023,6 +30570,7 @@ __webpack_require__.r(__webpack_exports__);
30023
30570
  /* harmony export */ "MultiLinePoint": () => (/* reexport safe */ _2D_index__WEBPACK_IMPORTED_MODULE_0__.MultiLinePoint),
30024
30571
  /* harmony export */ "NearMenu": () => (/* reexport safe */ _3D_index__WEBPACK_IMPORTED_MODULE_1__.NearMenu),
30025
30572
  /* harmony export */ "PlanePanel": () => (/* reexport safe */ _3D_index__WEBPACK_IMPORTED_MODULE_1__.PlanePanel),
30573
+ /* harmony export */ "RadialGradient": () => (/* reexport safe */ _2D_index__WEBPACK_IMPORTED_MODULE_0__.RadialGradient),
30026
30574
  /* harmony export */ "RadioButton": () => (/* reexport safe */ _2D_index__WEBPACK_IMPORTED_MODULE_0__.RadioButton),
30027
30575
  /* harmony export */ "RadioGroup": () => (/* reexport safe */ _2D_index__WEBPACK_IMPORTED_MODULE_0__.RadioGroup),
30028
30576
  /* harmony export */ "Rectangle": () => (/* reexport safe */ _2D_index__WEBPACK_IMPORTED_MODULE_0__.Rectangle),
@@ -30077,6 +30625,7 @@ __webpack_require__.r(__webpack_exports__);
30077
30625
  /* harmony export */ "AbstractButton3D": () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_0__.AbstractButton3D),
30078
30626
  /* harmony export */ "AdvancedDynamicTexture": () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_0__.AdvancedDynamicTexture),
30079
30627
  /* harmony export */ "AdvancedDynamicTextureInstrumentation": () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_0__.AdvancedDynamicTextureInstrumentation),
30628
+ /* harmony export */ "BaseGradient": () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_0__.BaseGradient),
30080
30629
  /* harmony export */ "BaseSlider": () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_0__.BaseSlider),
30081
30630
  /* harmony export */ "Button": () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_0__.Button),
30082
30631
  /* harmony export */ "Button3D": () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_0__.Button3D),
@@ -30113,6 +30662,7 @@ __webpack_require__.r(__webpack_exports__);
30113
30662
  /* harmony export */ "InputTextArea": () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_0__.InputTextArea),
30114
30663
  /* harmony export */ "KeyPropertySet": () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_0__.KeyPropertySet),
30115
30664
  /* harmony export */ "Line": () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_0__.Line),
30665
+ /* harmony export */ "LinearGradient": () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_0__.LinearGradient),
30116
30666
  /* harmony export */ "MRDLBackplateMaterial": () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_0__.MRDLBackplateMaterial),
30117
30667
  /* harmony export */ "MRDLSliderBarMaterial": () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_0__.MRDLSliderBarMaterial),
30118
30668
  /* harmony export */ "MRDLSliderThumbMaterial": () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_0__.MRDLSliderThumbMaterial),
@@ -30124,6 +30674,7 @@ __webpack_require__.r(__webpack_exports__);
30124
30674
  /* harmony export */ "MultiLinePoint": () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_0__.MultiLinePoint),
30125
30675
  /* harmony export */ "NearMenu": () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_0__.NearMenu),
30126
30676
  /* harmony export */ "PlanePanel": () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_0__.PlanePanel),
30677
+ /* harmony export */ "RadialGradient": () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_0__.RadialGradient),
30127
30678
  /* harmony export */ "RadioButton": () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_0__.RadioButton),
30128
30679
  /* harmony export */ "RadioGroup": () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_0__.RadioGroup),
30129
30680
  /* harmony export */ "Rectangle": () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_0__.Rectangle),