babylonjs-gui 6.4.0 → 6.5.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/babylon.gui.d.ts CHANGED
@@ -2997,12 +2997,25 @@ declare module BABYLON.GUI {
2997
2997
  name?: string | undefined;
2998
2998
  private _thickness;
2999
2999
  private _cornerRadius;
3000
+ private _cachedRadius;
3000
3001
  /** Gets or sets border thickness */
3001
3002
  get thickness(): number;
3002
3003
  set thickness(value: number);
3003
- /** Gets or sets the corner radius angle */
3004
+ /** Gets or sets the corner radius of all angles */
3004
3005
  get cornerRadius(): number;
3005
3006
  set cornerRadius(value: number);
3007
+ /** Gets or sets the corner radius top left angle */
3008
+ get cornerRadiusX(): number;
3009
+ set cornerRadiusX(value: number);
3010
+ /** Gets or sets the corner radius top right angle */
3011
+ get cornerRadiusY(): number;
3012
+ set cornerRadiusY(value: number);
3013
+ /** Gets or sets the corner radius bottom left angle */
3014
+ get cornerRadiusZ(): number;
3015
+ set cornerRadiusZ(value: number);
3016
+ /** Gets or sets the corner radius bottom right angle */
3017
+ get cornerRadiusW(): number;
3018
+ set cornerRadiusW(value: number);
3006
3019
  /**
3007
3020
  * Creates a new Rectangle
3008
3021
  * @param name defines the control name
@@ -3857,6 +3870,7 @@ declare module BABYLON.GUI {
3857
3870
  private _lineThrough;
3858
3871
  private _wordDivider;
3859
3872
  private _forceResizeWidth;
3873
+ private _applyOutlineToUnderline;
3860
3874
  /**
3861
3875
  * An event triggered after the text is changed
3862
3876
  */
@@ -3945,6 +3959,11 @@ declare module BABYLON.GUI {
3945
3959
  * Gets or sets an boolean indicating that text must be crossed out
3946
3960
  */
3947
3961
  set lineThrough(value: boolean);
3962
+ /**
3963
+ * If the outline should be applied to the underline/strike-through too. Has different behavior in Edge/Chrome vs Firefox.
3964
+ */
3965
+ get applyOutlineToUnderline(): boolean;
3966
+ set applyOutlineToUnderline(value: boolean);
3948
3967
  /**
3949
3968
  * Gets or sets outlineColor of the text to display
3950
3969
  */
@@ -3981,6 +4000,7 @@ declare module BABYLON.GUI {
3981
4000
  protected _getTypeName(): string;
3982
4001
  protected _processMeasures(parentMeasure: Measure, context: BABYLON.ICanvasRenderingContext): void;
3983
4002
  private _drawText;
4003
+ private _drawLine;
3984
4004
  /**
3985
4005
  * @internal
3986
4006
  */
package/babylon.gui.js CHANGED
@@ -12700,7 +12700,8 @@ var Rectangle = /** @class */ (function (_super) {
12700
12700
  var _this = _super.call(this, name) || this;
12701
12701
  _this.name = name;
12702
12702
  _this._thickness = 1;
12703
- _this._cornerRadius = 0;
12703
+ _this._cornerRadius = [0, 0, 0, 0];
12704
+ _this._cachedRadius = [0, 0, 0, 0];
12704
12705
  return _this;
12705
12706
  }
12706
12707
  Object.defineProperty(Rectangle.prototype, "thickness", {
@@ -12719,29 +12720,85 @@ var Rectangle = /** @class */ (function (_super) {
12719
12720
  configurable: true
12720
12721
  });
12721
12722
  Object.defineProperty(Rectangle.prototype, "cornerRadius", {
12722
- /** Gets or sets the corner radius angle */
12723
+ /** Gets or sets the corner radius of all angles */
12723
12724
  get: function () {
12724
- return this._cornerRadius;
12725
+ return this._cornerRadius[0];
12725
12726
  },
12726
12727
  set: function (value) {
12727
12728
  if (value < 0) {
12728
12729
  value = 0;
12729
12730
  }
12730
- if (this._cornerRadius === value) {
12731
+ if (this._cornerRadius[0] === value && this._cornerRadius[1] === value && this._cornerRadius[2] === value && this._cornerRadius[3] === value) {
12731
12732
  return;
12732
12733
  }
12733
- this._cornerRadius = value;
12734
+ this._cornerRadius[0] = this._cornerRadius[1] = this._cornerRadius[2] = this._cornerRadius[3] = value;
12734
12735
  this._markAsDirty();
12735
12736
  },
12736
12737
  enumerable: false,
12737
12738
  configurable: true
12738
12739
  });
12740
+ Object.defineProperty(Rectangle.prototype, "cornerRadiusX", {
12741
+ /** Gets or sets the corner radius top left angle */
12742
+ get: function () {
12743
+ return this._cornerRadius[0];
12744
+ },
12745
+ set: function (value) {
12746
+ if (this._cornerRadius[0] === value) {
12747
+ return;
12748
+ }
12749
+ this._cornerRadius[0] = value;
12750
+ },
12751
+ enumerable: false,
12752
+ configurable: true
12753
+ });
12754
+ Object.defineProperty(Rectangle.prototype, "cornerRadiusY", {
12755
+ /** Gets or sets the corner radius top right angle */
12756
+ get: function () {
12757
+ return this._cornerRadius[1];
12758
+ },
12759
+ set: function (value) {
12760
+ if (this._cornerRadius[1] === value) {
12761
+ return;
12762
+ }
12763
+ this._cornerRadius[1] = value;
12764
+ },
12765
+ enumerable: false,
12766
+ configurable: true
12767
+ });
12768
+ Object.defineProperty(Rectangle.prototype, "cornerRadiusZ", {
12769
+ /** Gets or sets the corner radius bottom left angle */
12770
+ get: function () {
12771
+ return this._cornerRadius[2];
12772
+ },
12773
+ set: function (value) {
12774
+ if (this._cornerRadius[2] === value) {
12775
+ return;
12776
+ }
12777
+ this._cornerRadius[2] = value;
12778
+ },
12779
+ enumerable: false,
12780
+ configurable: true
12781
+ });
12782
+ Object.defineProperty(Rectangle.prototype, "cornerRadiusW", {
12783
+ /** Gets or sets the corner radius bottom right angle */
12784
+ get: function () {
12785
+ return this._cornerRadius[3];
12786
+ },
12787
+ set: function (value) {
12788
+ if (this._cornerRadius[3] === value) {
12789
+ return;
12790
+ }
12791
+ this._cornerRadius[3] = value;
12792
+ },
12793
+ enumerable: false,
12794
+ configurable: true
12795
+ });
12739
12796
  Rectangle.prototype._getTypeName = function () {
12740
12797
  return "Rectangle";
12741
12798
  };
12742
12799
  /** @internal */
12743
12800
  Rectangle.prototype._computeAdditionnalOffsetX = function () {
12744
- if (this._cornerRadius) {
12801
+ if (this._cornerRadius[0] !== 0 || this._cornerRadius[1] !== 0 || this._cornerRadius[2] !== 0 || this._cornerRadius[3] !== 0) {
12745
12802
  // Take in account the aliasing
12746
12803
  return 1;
12747
12804
  }
@@ -12749,7 +12806,7 @@ var Rectangle = /** @class */ (function (_super) {
12749
12806
  };
12750
12807
  /** @internal */
12751
12808
  Rectangle.prototype._computeAdditionnalOffsetY = function () {
12752
- if (this._cornerRadius) {
12809
+ if (this._cornerRadius[0] !== 0 || this._cornerRadius[1] !== 0 || this._cornerRadius[2] !== 0 || this._cornerRadius[3] !== 0) {
12753
12810
  // Take in account the aliasing
12754
12811
  return 1;
12755
12812
  }
@@ -12768,7 +12825,7 @@ var Rectangle = /** @class */ (function (_super) {
12768
12825
  }
12769
12826
  if (this._background || this._backgroundGradient) {
12770
12827
  context.fillStyle = this._getRectangleFill(context);
12771
- if (this._cornerRadius) {
12828
+ if (this._cornerRadius[0] !== 0 || this._cornerRadius[1] !== 0 || this._cornerRadius[2] !== 0 || this._cornerRadius[3] !== 0) {
12772
12829
  this._drawRoundedRect(context, this._thickness / 2);
12773
12830
  context.fill();
12774
12831
  }
@@ -12786,7 +12843,7 @@ var Rectangle = /** @class */ (function (_super) {
12786
12843
  context.strokeStyle = this.gradient ? this.gradient.getCanvasGradient(context) : this.color;
12787
12844
  }
12788
12845
  context.lineWidth = this._thickness;
12789
- if (this._cornerRadius) {
12846
+ if (this._cornerRadius[0] !== 0 || this._cornerRadius[1] !== 0 || this._cornerRadius[2] !== 0 || this._cornerRadius[3] !== 0) {
12790
12847
  this._drawRoundedRect(context, this._thickness / 2);
12791
12848
  context.stroke();
12792
12849
  }
@@ -12809,22 +12866,23 @@ var Rectangle = /** @class */ (function (_super) {
12809
12866
  var y = this._currentMeasure.top + offset;
12810
12867
  var width = this._currentMeasure.width - offset * 2;
12811
12868
  var height = this._currentMeasure.height - offset * 2;
12812
- var radius = Math.min(height / 2, Math.min(width / 2, this._cornerRadius));
12813
- radius = Math.abs(radius);
12869
+ for (var index = 0; index < this._cornerRadius.length; index++) {
12870
+ this._cachedRadius[index] = Math.abs(Math.min(height / 2, Math.min(width / 2, this._cornerRadius[index])));
12871
+ }
12814
12872
  context.beginPath();
12815
- context.moveTo(x + radius, y);
12816
- context.lineTo(x + width - radius, y);
12817
- context.arc(x + width - radius, y + radius, radius, (3 * Math.PI) / 2, Math.PI * 2);
12818
- context.lineTo(x + width, y + height - radius);
12819
- context.arc(x + width - radius, y + height - radius, radius, 0, Math.PI / 2);
12820
- context.lineTo(x + radius, y + height);
12821
- context.arc(x + radius, y + height - radius, radius, Math.PI / 2, Math.PI);
12822
- context.lineTo(x, y + radius);
12823
- context.arc(x + radius, y + radius, radius, Math.PI, (3 * Math.PI) / 2);
12873
+ context.moveTo(x + this._cachedRadius[0], y);
12874
+ context.lineTo(x + width - this._cachedRadius[1], y);
12875
+ context.arc(x + width - this._cachedRadius[1], y + this._cachedRadius[1], this._cachedRadius[1], (3 * Math.PI) / 2, Math.PI * 2);
12876
+ context.lineTo(x + width, y + height - this._cachedRadius[2]);
12877
+ context.arc(x + width - this._cachedRadius[2], y + height - this._cachedRadius[2], this._cachedRadius[2], 0, Math.PI / 2);
12878
+ context.lineTo(x + this._cachedRadius[3], y + height);
12879
+ context.arc(x + this._cachedRadius[3], y + height - this._cachedRadius[3], this._cachedRadius[3], Math.PI / 2, Math.PI);
12880
+ context.lineTo(x, y + this._cachedRadius[0]);
12881
+ context.arc(x + this._cachedRadius[0], y + this._cachedRadius[0], this._cachedRadius[0], Math.PI, (3 * Math.PI) / 2);
12824
12882
  context.closePath();
12825
12883
  };
12826
12884
  Rectangle.prototype._clipForChildren = function (context) {
12827
- if (this._cornerRadius) {
12885
+ if (this._cornerRadius[0] !== 0 || this._cornerRadius[1] !== 0 || this._cornerRadius[2] !== 0 || this._cornerRadius[3] !== 0) {
12828
12886
  this._drawRoundedRect(context, this._thickness);
12829
12887
  context.clip();
12830
12888
  }
@@ -12835,6 +12893,18 @@ var Rectangle = /** @class */ (function (_super) {
12835
12893
  (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__decorate)([
12836
12894
  (0,core_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__.serialize)()
12837
12895
  ], Rectangle.prototype, "cornerRadius", null);
12896
+ (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__decorate)([
12897
+ (0,core_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__.serialize)()
12898
+ ], Rectangle.prototype, "cornerRadiusX", null);
12899
+ (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__decorate)([
12900
+ (0,core_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__.serialize)()
12901
+ ], Rectangle.prototype, "cornerRadiusY", null);
12902
+ (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__decorate)([
12903
+ (0,core_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__.serialize)()
12904
+ ], Rectangle.prototype, "cornerRadiusZ", null);
12905
+ (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__decorate)([
12906
+ (0,core_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__.serialize)()
12907
+ ], Rectangle.prototype, "cornerRadiusW", null);
12838
12908
  return Rectangle;
12839
12909
  }(_container__WEBPACK_IMPORTED_MODULE_1__.Container));
12840
12910
 
@@ -16355,6 +16425,7 @@ var TextBlock = /** @class */ (function (_super) {
16355
16425
  _this._lineThrough = false;
16356
16426
  _this._wordDivider = " ";
16357
16427
  _this._forceResizeWidth = false;
16428
+ _this._applyOutlineToUnderline = false;
16358
16429
  /**
16359
16430
  * An event triggered after the text is changed
16360
16431
  */
@@ -16560,6 +16631,23 @@ var TextBlock = /** @class */ (function (_super) {
16560
16631
  enumerable: false,
16561
16632
  configurable: true
16562
16633
  });
16634
+ Object.defineProperty(TextBlock.prototype, "applyOutlineToUnderline", {
16635
+ /**
16636
+ * If the outline should be applied to the underline/strike-through too. Has different behavior in Edge/Chrome vs Firefox.
16637
+ */
16638
+ get: function () {
16639
+ return this._applyOutlineToUnderline;
16640
+ },
16641
+ set: function (value) {
16642
+ if (this._applyOutlineToUnderline === value) {
16643
+ return;
16644
+ }
16645
+ this._applyOutlineToUnderline = value;
16646
+ this._markAsDirty();
16647
+ },
16648
+ enumerable: false,
16649
+ configurable: true
16650
+ });
16563
16651
  Object.defineProperty(TextBlock.prototype, "outlineColor", {
16564
16652
  /**
16565
16653
  * Gets or sets outlineColor of the text to display
@@ -16687,21 +16775,28 @@ var TextBlock = /** @class */ (function (_super) {
16687
16775
  }
16688
16776
  context.fillText(text, this._currentMeasure.left + x, y);
16689
16777
  if (this._underline) {
16690
- context.beginPath();
16691
- context.lineWidth = Math.round(this.fontSizeInPixels * 0.05);
16692
- context.moveTo(this._currentMeasure.left + x, y + 3);
16693
- context.lineTo(this._currentMeasure.left + x + textWidth, y + 3);
16694
- context.stroke();
16695
- context.closePath();
16778
+ this._drawLine(this._currentMeasure.left + x, y + 3, this._currentMeasure.left + x + textWidth, y + 3, context);
16696
16779
  }
16697
16780
  if (this._lineThrough) {
16698
- context.beginPath();
16699
- context.lineWidth = Math.round(this.fontSizeInPixels * 0.05);
16700
- context.moveTo(this._currentMeasure.left + x, y - this.fontSizeInPixels / 3);
16701
- context.lineTo(this._currentMeasure.left + x + textWidth, y - this.fontSizeInPixels / 3);
16781
+ this._drawLine(this._currentMeasure.left + x, y - this.fontSizeInPixels / 3, this._currentMeasure.left + x + textWidth, y - this.fontSizeInPixels / 3, context);
16782
+ }
16783
+ };
16784
+ TextBlock.prototype._drawLine = function (xFrom, yFrom, xTo, yTo, context) {
16785
+ context.beginPath();
16786
+ context.lineWidth = Math.round(this.fontSizeInPixels * 0.05);
16787
+ context.moveTo(xFrom, yFrom);
16788
+ context.lineTo(xTo, yTo);
16789
+ if (this.outlineWidth && this.applyOutlineToUnderline) {
16790
+ context.stroke();
16791
+ context.fill();
16792
+ }
16793
+ else {
16794
+ var currentStroke = context.strokeStyle;
16795
+ context.strokeStyle = context.fillStyle;
16702
16796
  context.stroke();
16703
- context.closePath();
16797
+ context.strokeStyle = currentStroke;
16704
16798
  }
16799
+ context.closePath();
16705
16800
  };
16706
16801
  /**
16707
16802
  * @internal
@@ -16935,6 +17030,9 @@ var TextBlock = /** @class */ (function (_super) {
16935
17030
  (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__decorate)([
16936
17031
  (0,core_Misc_observable__WEBPACK_IMPORTED_MODULE_1__.serialize)()
16937
17032
  ], TextBlock.prototype, "lineThrough", null);
17033
+ (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__decorate)([
17034
+ (0,core_Misc_observable__WEBPACK_IMPORTED_MODULE_1__.serialize)()
17035
+ ], TextBlock.prototype, "applyOutlineToUnderline", null);
16938
17036
  (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__decorate)([
16939
17037
  (0,core_Misc_observable__WEBPACK_IMPORTED_MODULE_1__.serialize)()
16940
17038
  ], TextBlock.prototype, "outlineColor", null);