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.
@@ -555,6 +555,7 @@ import { TextBlock } from "babylonjs-gui/2D/controls/textBlock";
555
555
  import { Image } from "babylonjs-gui/2D/controls/image";
556
556
  import { PointerInfoBase } from "babylonjs/Events/pointerEvents";
557
557
  import { AdvancedDynamicTexture } from "babylonjs-gui/2D/advancedDynamicTexture";
558
+ import { ICanvasRenderingContext } from "babylonjs/Engines/ICanvas";
558
559
  /**
559
560
  * Class used to create 2D buttons
560
561
  */
@@ -612,6 +613,7 @@ export class Button extends Rectangle {
612
613
  * @internal
613
614
  */
614
615
  _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, pi: PointerInfoBase): boolean;
616
+ protected _getRectangleFill(context: ICanvasRenderingContext): string | import("babylonjs/Engines/ICanvas").ICanvasGradient;
615
617
  /**
616
618
  * @internal
617
619
  */
@@ -824,9 +826,10 @@ import { Control } from "babylonjs-gui/2D/controls/control";
824
826
  import { Measure } from "babylonjs-gui/2D/measure";
825
827
  import { AdvancedDynamicTexture } from "babylonjs-gui/2D/advancedDynamicTexture";
826
828
  import { PointerInfoBase } from "babylonjs/Events/pointerEvents";
827
- import { ICanvasRenderingContext } from "babylonjs/Engines/ICanvas";
829
+ import { ICanvasGradient, ICanvasRenderingContext } from "babylonjs/Engines/ICanvas";
828
830
  import { DynamicTexture } from "babylonjs/Materials/Textures/dynamicTexture";
829
831
  import { Observable } from "babylonjs/Misc/observable";
832
+ import { BaseGradient } from "babylonjs-gui/2D/controls/gradient/BaseGradient";
830
833
  /**
831
834
  * Root class for 2D containers
832
835
  * @see https://doc.babylonjs.com/features/featuresDeepDive/gui/gui#containers
@@ -840,6 +843,8 @@ export class Container extends Control {
840
843
  /** @internal */
841
844
  protected _background: string;
842
845
  /** @internal */
846
+ protected _backgroundGradient: Nullable<BaseGradient>;
847
+ /** @internal */
843
848
  protected _adaptWidthToChildren: boolean;
844
849
  /** @internal */
845
850
  protected _adaptHeightToChildren: boolean;
@@ -867,6 +872,9 @@ export class Container extends Control {
867
872
  /** Gets or sets background color */
868
873
  get background(): string;
869
874
  set background(value: string);
875
+ /** Gets or sets background gradient color. Takes precedence over background */
876
+ get backgroundGradient(): Nullable<BaseGradient>;
877
+ set backgroundGradient(value: Nullable<BaseGradient>);
870
878
  /** Gets the list of children */
871
879
  get children(): Control[];
872
880
  get isReadOnly(): boolean;
@@ -936,6 +944,7 @@ export class Container extends Control {
936
944
  _offsetTop(offset: number): void;
937
945
  /** @internal */
938
946
  _markAllAsDirty(): void;
947
+ protected _getBackgroundColor(context: ICanvasRenderingContext): string | ICanvasGradient;
939
948
  /**
940
949
  * @internal
941
950
  */
@@ -995,10 +1004,11 @@ import { ValueAndUnit } from "babylonjs-gui/2D/valueAndUnit";
995
1004
  import { Measure } from "babylonjs-gui/2D/measure";
996
1005
  import { Style } from "babylonjs-gui/2D/style";
997
1006
  import { Matrix2D, Vector2WithInfo } from "babylonjs-gui/2D/math2D";
998
- import { ICanvasRenderingContext } from "babylonjs/Engines/ICanvas";
1007
+ import { ICanvasGradient, ICanvasRenderingContext } from "babylonjs/Engines/ICanvas";
999
1008
  import { IAccessibilityTag } from "babylonjs/IAccessibilityTag";
1000
1009
  import { IAnimatable } from "babylonjs/Animations/animatable.interface";
1001
1010
  import { Animation } from "babylonjs/Animations/animation";
1011
+ import { BaseGradient } from "babylonjs-gui/2D/controls/gradient/BaseGradient";
1002
1012
  /**
1003
1013
  * Root class used for all 2D controls
1004
1014
  * @see https://doc.babylonjs.com/features/featuresDeepDive/gui/gui#controls
@@ -1094,6 +1104,7 @@ export class Control implements IAnimatable {
1094
1104
  protected _disabledColor: string;
1095
1105
  protected _disabledColorItem: string;
1096
1106
  protected _isReadOnly: boolean;
1107
+ private _gradient;
1097
1108
  /** @internal */
1098
1109
  protected _rebuildLayout: boolean;
1099
1110
  /** @internal */
@@ -1363,6 +1374,9 @@ export class Control implements IAnimatable {
1363
1374
  /** Gets or sets foreground color */
1364
1375
  get color(): string;
1365
1376
  set color(value: string);
1377
+ /** Gets or sets gradient. Setting a gradient will override the color */
1378
+ get gradient(): Nullable<BaseGradient>;
1379
+ set gradient(value: Nullable<BaseGradient>);
1366
1380
  /** Gets or sets z index which is used to reorder controls on the z axis */
1367
1381
  get zIndex(): number;
1368
1382
  set zIndex(value: number);
@@ -1659,6 +1673,7 @@ export class Control implements IAnimatable {
1659
1673
  * @internal
1660
1674
  */
1661
1675
  _renderHighlightSpecific(context: ICanvasRenderingContext): void;
1676
+ protected _getColor(context: ICanvasRenderingContext): string | ICanvasGradient;
1662
1677
  /**
1663
1678
  * @internal
1664
1679
  */
@@ -1989,6 +2004,170 @@ export interface IFocusableControl {
1989
2004
  blur(): void;
1990
2005
  }
1991
2006
 
2007
+ }
2008
+ declare module "babylonjs-gui/2D/controls/gradient/BaseGradient" {
2009
+ import { ICanvasGradient, ICanvasRenderingContext } from "babylonjs/Engines/ICanvas";
2010
+ /**
2011
+ * Type that represents a single stop on the gradient.
2012
+ */
2013
+ export type GradientColorStop = {
2014
+ /**
2015
+ * Offset from the start where the color will be applied.
2016
+ */
2017
+ offset: number;
2018
+ /**
2019
+ * Color to be applied.
2020
+ */
2021
+ color: string;
2022
+ };
2023
+ /**
2024
+ * Class that serves as a base for all the gradients created from context.
2025
+ */
2026
+ export abstract class BaseGradient {
2027
+ private _colorStops;
2028
+ private _canvasGradient;
2029
+ private _context;
2030
+ private _gradientDirty;
2031
+ /**
2032
+ * Overwritten by child classes to create the canvas gradient.
2033
+ * @param context
2034
+ */
2035
+ protected abstract _createCanvasGradient(context: ICanvasRenderingContext): ICanvasGradient;
2036
+ private _addColorStopsToCanvasGradient;
2037
+ /**
2038
+ * If there are any changes or the context changed, regenerate the canvas gradient object. Else,
2039
+ * reuse the existing gradient.
2040
+ **/
2041
+ getCanvasGradient(context: ICanvasRenderingContext): CanvasGradient;
2042
+ /**
2043
+ * Adds a new color stop to the gradient.
2044
+ * @param offset the offset of the stop on the gradient. Should be between 0 and 1
2045
+ * @param color the color of the stop
2046
+ */
2047
+ addColorStop(offset: number, color: string): void;
2048
+ /**
2049
+ * Removes an existing color stop with the specified offset from the gradient
2050
+ * @param offset the offset of the stop to be removed
2051
+ */
2052
+ removeColorStop(offset: number): void;
2053
+ /**
2054
+ * Removes all color stops from the gradient
2055
+ */
2056
+ clearColorStops(): void;
2057
+ /** Color stops of the gradient */
2058
+ get colorStops(): GradientColorStop[];
2059
+ /** Type of the gradient */
2060
+ getClassName(): string;
2061
+ /** Serialize into a json object */
2062
+ serialize(serializationObject: any): void;
2063
+ /** Parse from json object */
2064
+ parse(serializationObject: any): void;
2065
+ }
2066
+
2067
+ }
2068
+ declare module "babylonjs-gui/2D/controls/gradient/LinearGradient" {
2069
+ import { ICanvasGradient, ICanvasRenderingContext } from "babylonjs/Engines/ICanvas";
2070
+ import { BaseGradient } from "babylonjs-gui/2D/controls/gradient/BaseGradient";
2071
+ /**
2072
+ * Gradient along a line that connects two coordinates.
2073
+ * These coordinates are relative to the canvas' space, not to any control's space.
2074
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/createLinearGradient
2075
+ */
2076
+ export class LinearGradient extends BaseGradient {
2077
+ private _x0;
2078
+ private _y0;
2079
+ private _x1;
2080
+ private _y1;
2081
+ /**
2082
+ * Creates a new linear gradient
2083
+ * @param x0
2084
+ * @param y0
2085
+ * @param x1
2086
+ * @param y1
2087
+ */
2088
+ constructor(x0?: number, y0?: number, x1?: number, y1?: number);
2089
+ protected _createCanvasGradient(context: ICanvasRenderingContext): ICanvasGradient;
2090
+ /** X axis coordinate of the starting point in the line */
2091
+ get x0(): number;
2092
+ /** X axis coordinate of the ending point in the line */
2093
+ get x1(): number;
2094
+ /** Y axis coordinate of the starting point in the line */
2095
+ get y0(): number;
2096
+ /** Y axis coordinate of the ending point in the line */
2097
+ get y1(): number;
2098
+ /**
2099
+ * Class name of the gradient
2100
+ * @returns the class name of the gradient
2101
+ */
2102
+ getClassName(): string;
2103
+ /**
2104
+ * Serializes this gradient
2105
+ * @param serializationObject the object to serialize to
2106
+ */
2107
+ serialize(serializationObject: any): void;
2108
+ /**
2109
+ * Parses a gradient from a serialization object
2110
+ * @param serializationObject the object to parse from
2111
+ */
2112
+ parse(serializationObject: any): void;
2113
+ }
2114
+
2115
+ }
2116
+ declare module "babylonjs-gui/2D/controls/gradient/RadialGradient" {
2117
+ import { ICanvasGradient, ICanvasRenderingContext } from "babylonjs/Engines/ICanvas";
2118
+ import { BaseGradient } from "babylonjs-gui/2D/controls/gradient/BaseGradient";
2119
+ /**
2120
+ * Gradient formed from two circles with their own centers and radius.
2121
+ * The coordinates of the circles centers are relative to the canvas' space, not to any control's space.
2122
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/createRadialGradient
2123
+ */
2124
+ export class RadialGradient extends BaseGradient {
2125
+ private _x0;
2126
+ private _y0;
2127
+ private _r0;
2128
+ private _x1;
2129
+ private _y1;
2130
+ private _r1;
2131
+ /**
2132
+ * Creates a new radial gradient
2133
+ * @param x0 x coordinate of the first circle's center
2134
+ * @param y0 y coordinate of the first circle's center
2135
+ * @param r0 radius of the first circle
2136
+ * @param x1 x coordinate of the second circle's center
2137
+ * @param y1 y coordinate of the second circle's center
2138
+ * @param r1 radius of the second circle
2139
+ */
2140
+ constructor(x0?: number, y0?: number, r0?: number, x1?: number, y1?: number, r1?: number);
2141
+ protected _createCanvasGradient(context: ICanvasRenderingContext): ICanvasGradient;
2142
+ /** x coordinate of the first circle's center */
2143
+ get x0(): number;
2144
+ /** x coordinate of the second circle's center */
2145
+ get x1(): number;
2146
+ /** y coordinate of the first circle's center */
2147
+ get y0(): number;
2148
+ /** y coordinate of the second circle's center */
2149
+ get y1(): number;
2150
+ /** radius of the first circle */
2151
+ get r0(): number;
2152
+ /** radius of the second circle */
2153
+ get r1(): number;
2154
+ /**
2155
+ * Class name of the gradient
2156
+ * @returns the class name of the gradient
2157
+ */
2158
+ getClassName(): string;
2159
+ /**
2160
+ * Serializes this gradient
2161
+ * @param serializationObject the object to serialize to
2162
+ */
2163
+ serialize(serializationObject: any): void;
2164
+ /**
2165
+ * Parses a gradient from a serialization object
2166
+ * @param serializationObject the object to parse from
2167
+ */
2168
+ parse(serializationObject: any): void;
2169
+ }
2170
+
1992
2171
  }
1993
2172
  declare module "babylonjs-gui/2D/controls/grid" {
1994
2173
  import { Nullable } from "babylonjs/types";
@@ -2169,9 +2348,14 @@ export class Image extends Control {
2169
2348
  private _populateNinePatchSlicesFromImage;
2170
2349
  private _detectPointerOnOpaqueOnly;
2171
2350
  private _imageDataCache;
2351
+ /**
2352
+ * Cache of images to avoid loading the same image multiple times
2353
+ */
2172
2354
  static SourceImgCache: Map<string, {
2173
2355
  img: IImage;
2174
2356
  timesUsed: number;
2357
+ loaded: boolean;
2358
+ waitingForLoadCallback: Array<() => void>;
2175
2359
  }>;
2176
2360
  /**
2177
2361
  * Observable notified when the content is loaded
@@ -2385,6 +2569,9 @@ export * from "babylonjs-gui/2D/controls/sliders/imageBasedSlider";
2385
2569
  export * from "babylonjs-gui/2D/controls/sliders/scrollBar";
2386
2570
  export * from "babylonjs-gui/2D/controls/sliders/imageScrollBar";
2387
2571
  export * from "babylonjs-gui/2D/controls/statics";
2572
+ export * from "babylonjs-gui/2D/controls/gradient/BaseGradient";
2573
+ export * from "babylonjs-gui/2D/controls/gradient/LinearGradient";
2574
+ export * from "babylonjs-gui/2D/controls/gradient/RadialGradient";
2388
2575
 
2389
2576
  }
2390
2577
  declare module "babylonjs-gui/2D/controls/inputPassword" {
@@ -2973,7 +3160,7 @@ export class RadioButton extends Control {
2973
3160
  declare module "babylonjs-gui/2D/controls/rectangle" {
2974
3161
  import { Container } from "babylonjs-gui/2D/controls/container";
2975
3162
  import { Measure } from "babylonjs-gui/2D/measure";
2976
- import { ICanvasRenderingContext } from "babylonjs/Engines/ICanvas";
3163
+ import { ICanvasGradient, ICanvasRenderingContext } from "babylonjs/Engines/ICanvas";
2977
3164
  /** Class used to create rectangle container */
2978
3165
  export class Rectangle extends Container {
2979
3166
  name?: string | undefined;
@@ -2995,6 +3182,7 @@ export class Rectangle extends Container {
2995
3182
  protected _computeAdditionnalOffsetX(): 1 | 0;
2996
3183
  /** @internal */
2997
3184
  protected _computeAdditionnalOffsetY(): 1 | 0;
3185
+ protected _getRectangleFill(context: ICanvasRenderingContext): string | ICanvasGradient;
2998
3186
  protected _localDraw(context: ICanvasRenderingContext): void;
2999
3187
  protected _additionalProcessing(parentMeasure: Measure, context: ICanvasRenderingContext): void;
3000
3188
  private _drawRoundedRect;
@@ -3686,6 +3874,9 @@ import { BaseSlider } from "babylonjs-gui/2D/controls/sliders/baseSlider";
3686
3874
  import { Control } from "babylonjs-gui/2D/controls/control";
3687
3875
  import { PointerInfoBase } from "babylonjs/Events/pointerEvents";
3688
3876
  import { ICanvasRenderingContext } from "babylonjs/Engines/ICanvas";
3877
+ import { Nullable } from "babylonjs/types";
3878
+ import { BaseGradient } from "babylonjs-gui/2D/controls/gradient/BaseGradient";
3879
+ import { AdvancedDynamicTexture } from "babylonjs-gui/2D/advancedDynamicTexture";
3689
3880
  /**
3690
3881
  * Class used to create slider controls
3691
3882
  */
@@ -3695,12 +3886,16 @@ export class ScrollBar extends BaseSlider {
3695
3886
  private _borderColor;
3696
3887
  private _tempMeasure;
3697
3888
  private _invertScrollDirection;
3889
+ private _backgroundGradient;
3698
3890
  /** Gets or sets border color */
3699
3891
  get borderColor(): string;
3700
3892
  set borderColor(value: string);
3701
3893
  /** Gets or sets background color */
3702
3894
  get background(): string;
3703
3895
  set background(value: string);
3896
+ /** Gets or sets background gradient. Takes precedence over gradient. */
3897
+ get backgroundGradient(): Nullable<BaseGradient>;
3898
+ set backgroundGradient(value: Nullable<BaseGradient>);
3704
3899
  /** Inverts the scrolling direction (default: false) */
3705
3900
  get invertScrollDirection(): boolean;
3706
3901
  set invertScrollDirection(invert: boolean);
@@ -3711,6 +3906,7 @@ export class ScrollBar extends BaseSlider {
3711
3906
  constructor(name?: string | undefined);
3712
3907
  protected _getTypeName(): string;
3713
3908
  protected _getThumbThickness(): number;
3909
+ private _getBackgroundColor;
3714
3910
  _draw(context: ICanvasRenderingContext): void;
3715
3911
  private _first;
3716
3912
  private _originX;
@@ -3720,12 +3916,17 @@ export class ScrollBar extends BaseSlider {
3720
3916
  */
3721
3917
  protected _updateValueFromPointer(x: number, y: number): void;
3722
3918
  _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, pi: PointerInfoBase): boolean;
3919
+ serialize(serializationObject: any): void;
3920
+ _parseFromContent(serializationObject: any, host: AdvancedDynamicTexture): void;
3723
3921
  }
3724
3922
 
3725
3923
  }
3726
3924
  declare module "babylonjs-gui/2D/controls/sliders/slider" {
3727
3925
  import { BaseSlider } from "babylonjs-gui/2D/controls/sliders/baseSlider";
3728
3926
  import { ICanvasRenderingContext } from "babylonjs/Engines/ICanvas";
3927
+ import { Nullable } from "babylonjs/types";
3928
+ import { BaseGradient } from "babylonjs-gui/2D/controls/gradient/BaseGradient";
3929
+ import { AdvancedDynamicTexture } from "babylonjs-gui/2D/advancedDynamicTexture";
3729
3930
  /**
3730
3931
  * Class used to create slider controls
3731
3932
  */
@@ -3736,6 +3937,7 @@ export class Slider extends BaseSlider {
3736
3937
  private _thumbColor;
3737
3938
  private _isThumbCircle;
3738
3939
  protected _displayValueBar: boolean;
3940
+ private _backgroundGradient;
3739
3941
  /** Gets or sets a boolean indicating if the value bar must be rendered */
3740
3942
  get displayValueBar(): boolean;
3741
3943
  set displayValueBar(value: boolean);
@@ -3745,6 +3947,9 @@ export class Slider extends BaseSlider {
3745
3947
  /** Gets or sets background color */
3746
3948
  get background(): string;
3747
3949
  set background(value: string);
3950
+ /** Gets or sets background gradient */
3951
+ get backgroundGradient(): Nullable<BaseGradient>;
3952
+ set backgroundGradient(value: Nullable<BaseGradient>);
3748
3953
  /** Gets or sets thumb's color */
3749
3954
  get thumbColor(): string;
3750
3955
  set thumbColor(value: string);
@@ -3757,7 +3962,11 @@ export class Slider extends BaseSlider {
3757
3962
  */
3758
3963
  constructor(name?: string | undefined);
3759
3964
  protected _getTypeName(): string;
3965
+ protected _getBackgroundColor(context: ICanvasRenderingContext): string | CanvasGradient;
3760
3966
  _draw(context: ICanvasRenderingContext): void;
3967
+ serialize(serializationObject: any): void;
3968
+ /** @internal */
3969
+ _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
3761
3970
  }
3762
3971
 
3763
3972
  }
@@ -3880,6 +4089,7 @@ export class TextBlock extends Control {
3880
4089
  private _underline;
3881
4090
  private _lineThrough;
3882
4091
  private _wordDivider;
4092
+ private _forceResizeWidth;
3883
4093
  /**
3884
4094
  * An event triggered after the text is changed
3885
4095
  */
@@ -3984,6 +4194,13 @@ export class TextBlock extends Control {
3984
4194
  * Gets or sets word divider
3985
4195
  */
3986
4196
  set wordDivider(value: string);
4197
+ /**
4198
+ * By default, if a text block has text wrapping other than Clip, its width
4199
+ * is not resized even if resizeToFit = true. This parameter forces the width
4200
+ * to be resized.
4201
+ */
4202
+ get forceResizeWidth(): boolean;
4203
+ set forceResizeWidth(value: boolean);
3987
4204
  /**
3988
4205
  * Creates a new TextBlock object
3989
4206
  * @param name defines the name of the control
@@ -9067,6 +9284,7 @@ declare module BABYLON.GUI {
9067
9284
  * @internal
9068
9285
  */
9069
9286
  _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
9287
+ protected _getRectangleFill(context: BABYLON.ICanvasRenderingContext): string | import("core/Engines/ICanvas").ICanvasGradient;
9070
9288
  /**
9071
9289
  * @internal
9072
9290
  */
@@ -9270,6 +9488,8 @@ declare module BABYLON.GUI {
9270
9488
  /** @internal */
9271
9489
  protected _background: string;
9272
9490
  /** @internal */
9491
+ protected _backgroundGradient: BABYLON.Nullable<BaseGradient>;
9492
+ /** @internal */
9273
9493
  protected _adaptWidthToChildren: boolean;
9274
9494
  /** @internal */
9275
9495
  protected _adaptHeightToChildren: boolean;
@@ -9297,6 +9517,9 @@ declare module BABYLON.GUI {
9297
9517
  /** Gets or sets background color */
9298
9518
  get background(): string;
9299
9519
  set background(value: string);
9520
+ /** Gets or sets background gradient color. Takes precedence over background */
9521
+ get backgroundGradient(): BABYLON.Nullable<BaseGradient>;
9522
+ set backgroundGradient(value: BABYLON.Nullable<BaseGradient>);
9300
9523
  /** Gets the list of children */
9301
9524
  get children(): Control[];
9302
9525
  get isReadOnly(): boolean;
@@ -9366,6 +9589,7 @@ declare module BABYLON.GUI {
9366
9589
  _offsetTop(offset: number): void;
9367
9590
  /** @internal */
9368
9591
  _markAllAsDirty(): void;
9592
+ protected _getBackgroundColor(context: BABYLON.ICanvasRenderingContext): string | BABYLON.ICanvasGradient;
9369
9593
  /**
9370
9594
  * @internal
9371
9595
  */
@@ -9507,6 +9731,7 @@ declare module BABYLON.GUI {
9507
9731
  protected _disabledColor: string;
9508
9732
  protected _disabledColorItem: string;
9509
9733
  protected _isReadOnly: boolean;
9734
+ private _gradient;
9510
9735
  /** @internal */
9511
9736
  protected _rebuildLayout: boolean;
9512
9737
  /** @internal */
@@ -9776,6 +10001,9 @@ declare module BABYLON.GUI {
9776
10001
  /** Gets or sets foreground color */
9777
10002
  get color(): string;
9778
10003
  set color(value: string);
10004
+ /** Gets or sets gradient. Setting a gradient will override the color */
10005
+ get gradient(): BABYLON.Nullable<BaseGradient>;
10006
+ set gradient(value: BABYLON.Nullable<BaseGradient>);
9779
10007
  /** Gets or sets z index which is used to reorder controls on the z axis */
9780
10008
  get zIndex(): number;
9781
10009
  set zIndex(value: number);
@@ -10072,6 +10300,7 @@ declare module BABYLON.GUI {
10072
10300
  * @internal
10073
10301
  */
10074
10302
  _renderHighlightSpecific(context: BABYLON.ICanvasRenderingContext): void;
10303
+ protected _getColor(context: BABYLON.ICanvasRenderingContext): string | BABYLON.ICanvasGradient;
10075
10304
  /**
10076
10305
  * @internal
10077
10306
  */
@@ -10383,6 +10612,162 @@ declare module BABYLON.GUI {
10383
10612
  }
10384
10613
 
10385
10614
 
10615
+ /**
10616
+ * Type that represents a single stop on the gradient.
10617
+ */
10618
+ export type GradientColorStop = {
10619
+ /**
10620
+ * Offset from the start where the color will be applied.
10621
+ */
10622
+ offset: number;
10623
+ /**
10624
+ * Color to be applied.
10625
+ */
10626
+ color: string;
10627
+ };
10628
+ /**
10629
+ * Class that serves as a base for all the gradients created from context.
10630
+ */
10631
+ export abstract class BaseGradient {
10632
+ private _colorStops;
10633
+ private _canvasGradient;
10634
+ private _context;
10635
+ private _gradientDirty;
10636
+ /**
10637
+ * Overwritten by child classes to create the canvas gradient.
10638
+ * @param context
10639
+ */
10640
+ protected abstract _createCanvasGradient(context: BABYLON.ICanvasRenderingContext): BABYLON.ICanvasGradient;
10641
+ private _addColorStopsToCanvasGradient;
10642
+ /**
10643
+ * If there are any changes or the context changed, regenerate the canvas gradient object. Else,
10644
+ * reuse the existing gradient.
10645
+ **/
10646
+ getCanvasGradient(context: BABYLON.ICanvasRenderingContext): CanvasGradient;
10647
+ /**
10648
+ * Adds a new color stop to the gradient.
10649
+ * @param offset the offset of the stop on the gradient. Should be between 0 and 1
10650
+ * @param color the color of the stop
10651
+ */
10652
+ addColorStop(offset: number, color: string): void;
10653
+ /**
10654
+ * Removes an existing color stop with the specified offset from the gradient
10655
+ * @param offset the offset of the stop to be removed
10656
+ */
10657
+ removeColorStop(offset: number): void;
10658
+ /**
10659
+ * Removes all color stops from the gradient
10660
+ */
10661
+ clearColorStops(): void;
10662
+ /** Color stops of the gradient */
10663
+ get colorStops(): GradientColorStop[];
10664
+ /** Type of the gradient */
10665
+ getClassName(): string;
10666
+ /** Serialize into a json object */
10667
+ serialize(serializationObject: any): void;
10668
+ /** Parse from json object */
10669
+ parse(serializationObject: any): void;
10670
+ }
10671
+
10672
+
10673
+ /**
10674
+ * Gradient along a line that connects two coordinates.
10675
+ * These coordinates are relative to the canvas' space, not to any control's space.
10676
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/createLinearGradient
10677
+ */
10678
+ export class LinearGradient extends BaseGradient {
10679
+ private _x0;
10680
+ private _y0;
10681
+ private _x1;
10682
+ private _y1;
10683
+ /**
10684
+ * Creates a new linear gradient
10685
+ * @param x0
10686
+ * @param y0
10687
+ * @param x1
10688
+ * @param y1
10689
+ */
10690
+ constructor(x0?: number, y0?: number, x1?: number, y1?: number);
10691
+ protected _createCanvasGradient(context: BABYLON.ICanvasRenderingContext): BABYLON.ICanvasGradient;
10692
+ /** X axis coordinate of the starting point in the line */
10693
+ get x0(): number;
10694
+ /** X axis coordinate of the ending point in the line */
10695
+ get x1(): number;
10696
+ /** Y axis coordinate of the starting point in the line */
10697
+ get y0(): number;
10698
+ /** Y axis coordinate of the ending point in the line */
10699
+ get y1(): number;
10700
+ /**
10701
+ * Class name of the gradient
10702
+ * @returns the class name of the gradient
10703
+ */
10704
+ getClassName(): string;
10705
+ /**
10706
+ * Serializes this gradient
10707
+ * @param serializationObject the object to serialize to
10708
+ */
10709
+ serialize(serializationObject: any): void;
10710
+ /**
10711
+ * Parses a gradient from a serialization object
10712
+ * @param serializationObject the object to parse from
10713
+ */
10714
+ parse(serializationObject: any): void;
10715
+ }
10716
+
10717
+
10718
+ /**
10719
+ * Gradient formed from two circles with their own centers and radius.
10720
+ * The coordinates of the circles centers are relative to the canvas' space, not to any control's space.
10721
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/createRadialGradient
10722
+ */
10723
+ export class RadialGradient extends BaseGradient {
10724
+ private _x0;
10725
+ private _y0;
10726
+ private _r0;
10727
+ private _x1;
10728
+ private _y1;
10729
+ private _r1;
10730
+ /**
10731
+ * Creates a new radial gradient
10732
+ * @param x0 x coordinate of the first circle's center
10733
+ * @param y0 y coordinate of the first circle's center
10734
+ * @param r0 radius of the first circle
10735
+ * @param x1 x coordinate of the second circle's center
10736
+ * @param y1 y coordinate of the second circle's center
10737
+ * @param r1 radius of the second circle
10738
+ */
10739
+ constructor(x0?: number, y0?: number, r0?: number, x1?: number, y1?: number, r1?: number);
10740
+ protected _createCanvasGradient(context: BABYLON.ICanvasRenderingContext): BABYLON.ICanvasGradient;
10741
+ /** x coordinate of the first circle's center */
10742
+ get x0(): number;
10743
+ /** x coordinate of the second circle's center */
10744
+ get x1(): number;
10745
+ /** y coordinate of the first circle's center */
10746
+ get y0(): number;
10747
+ /** y coordinate of the second circle's center */
10748
+ get y1(): number;
10749
+ /** radius of the first circle */
10750
+ get r0(): number;
10751
+ /** radius of the second circle */
10752
+ get r1(): number;
10753
+ /**
10754
+ * Class name of the gradient
10755
+ * @returns the class name of the gradient
10756
+ */
10757
+ getClassName(): string;
10758
+ /**
10759
+ * Serializes this gradient
10760
+ * @param serializationObject the object to serialize to
10761
+ */
10762
+ serialize(serializationObject: any): void;
10763
+ /**
10764
+ * Parses a gradient from a serialization object
10765
+ * @param serializationObject the object to parse from
10766
+ */
10767
+ parse(serializationObject: any): void;
10768
+ }
10769
+
10770
+
10386
10771
  /**
10387
10772
  * Class used to create a 2D grid container
10388
10773
  */
@@ -10548,9 +10933,14 @@ declare module BABYLON.GUI {
10548
10933
  private _populateNinePatchSlicesFromImage;
10549
10934
  private _detectPointerOnOpaqueOnly;
10550
10935
  private _imageDataCache;
10936
+ /**
10937
+ * Cache of images to avoid loading the same image multiple times
10938
+ */
10551
10939
  static SourceImgCache: Map<string, {
10552
10940
  img: BABYLON.IImage;
10553
10941
  timesUsed: number;
10942
+ loaded: boolean;
10943
+ waitingForLoadCallback: Array<() => void>;
10554
10944
  }>;
10555
10945
  /**
10556
10946
  * BABYLON.Observable notified when the content is loaded
@@ -11291,6 +11681,7 @@ declare module BABYLON.GUI {
11291
11681
  protected _computeAdditionnalOffsetX(): 1 | 0;
11292
11682
  /** @internal */
11293
11683
  protected _computeAdditionnalOffsetY(): 1 | 0;
11684
+ protected _getRectangleFill(context: BABYLON.ICanvasRenderingContext): string | BABYLON.ICanvasGradient;
11294
11685
  protected _localDraw(context: BABYLON.ICanvasRenderingContext): void;
11295
11686
  protected _additionalProcessing(parentMeasure: Measure, context: BABYLON.ICanvasRenderingContext): void;
11296
11687
  private _drawRoundedRect;
@@ -11949,12 +12340,16 @@ declare module BABYLON.GUI {
11949
12340
  private _borderColor;
11950
12341
  private _tempMeasure;
11951
12342
  private _invertScrollDirection;
12343
+ private _backgroundGradient;
11952
12344
  /** Gets or sets border color */
11953
12345
  get borderColor(): string;
11954
12346
  set borderColor(value: string);
11955
12347
  /** Gets or sets background color */
11956
12348
  get background(): string;
11957
12349
  set background(value: string);
12350
+ /** Gets or sets background gradient. Takes precedence over gradient. */
12351
+ get backgroundGradient(): BABYLON.Nullable<BaseGradient>;
12352
+ set backgroundGradient(value: BABYLON.Nullable<BaseGradient>);
11958
12353
  /** Inverts the scrolling direction (default: false) */
11959
12354
  get invertScrollDirection(): boolean;
11960
12355
  set invertScrollDirection(invert: boolean);
@@ -11965,6 +12360,7 @@ declare module BABYLON.GUI {
11965
12360
  constructor(name?: string | undefined);
11966
12361
  protected _getTypeName(): string;
11967
12362
  protected _getThumbThickness(): number;
12363
+ private _getBackgroundColor;
11968
12364
  _draw(context: BABYLON.ICanvasRenderingContext): void;
11969
12365
  private _first;
11970
12366
  private _originX;
@@ -11974,6 +12370,8 @@ declare module BABYLON.GUI {
11974
12370
  */
11975
12371
  protected _updateValueFromPointer(x: number, y: number): void;
11976
12372
  _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
12373
+ serialize(serializationObject: any): void;
12374
+ _parseFromContent(serializationObject: any, host: AdvancedDynamicTexture): void;
11977
12375
  }
11978
12376
 
11979
12377
 
@@ -11987,6 +12385,7 @@ declare module BABYLON.GUI {
11987
12385
  private _thumbColor;
11988
12386
  private _isThumbCircle;
11989
12387
  protected _displayValueBar: boolean;
12388
+ private _backgroundGradient;
11990
12389
  /** Gets or sets a boolean indicating if the value bar must be rendered */
11991
12390
  get displayValueBar(): boolean;
11992
12391
  set displayValueBar(value: boolean);
@@ -11996,6 +12395,9 @@ declare module BABYLON.GUI {
11996
12395
  /** Gets or sets background color */
11997
12396
  get background(): string;
11998
12397
  set background(value: string);
12398
+ /** Gets or sets background gradient */
12399
+ get backgroundGradient(): BABYLON.Nullable<BaseGradient>;
12400
+ set backgroundGradient(value: BABYLON.Nullable<BaseGradient>);
11999
12401
  /** Gets or sets thumb's color */
12000
12402
  get thumbColor(): string;
12001
12403
  set thumbColor(value: string);
@@ -12008,7 +12410,11 @@ declare module BABYLON.GUI {
12008
12410
  */
12009
12411
  constructor(name?: string | undefined);
12010
12412
  protected _getTypeName(): string;
12413
+ protected _getBackgroundColor(context: BABYLON.ICanvasRenderingContext): string | CanvasGradient;
12011
12414
  _draw(context: BABYLON.ICanvasRenderingContext): void;
12415
+ serialize(serializationObject: any): void;
12416
+ /** @internal */
12417
+ _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
12012
12418
  }
12013
12419
 
12014
12420
 
@@ -12118,6 +12524,7 @@ declare module BABYLON.GUI {
12118
12524
  private _underline;
12119
12525
  private _lineThrough;
12120
12526
  private _wordDivider;
12527
+ private _forceResizeWidth;
12121
12528
  /**
12122
12529
  * An event triggered after the text is changed
12123
12530
  */
@@ -12222,6 +12629,13 @@ declare module BABYLON.GUI {
12222
12629
  * Gets or sets word divider
12223
12630
  */
12224
12631
  set wordDivider(value: string);
12632
+ /**
12633
+ * By default, if a text block has text wrapping other than Clip, its width
12634
+ * is not resized even if resizeToFit = true. This parameter forces the width
12635
+ * to be resized.
12636
+ */
12637
+ get forceResizeWidth(): boolean;
12638
+ set forceResizeWidth(value: boolean);
12225
12639
  /**
12226
12640
  * Creates a new TextBlock object
12227
12641
  * @param name defines the name of the control