@babylonjs/gui 7.21.3 → 7.21.5
Sign up to get free protection for your applications and to get access to all the features.
@@ -114,6 +114,7 @@ export class Slider extends BaseSlider {
|
|
114
114
|
else {
|
115
115
|
radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
|
116
116
|
}
|
117
|
+
radius = Math.max(0, radius);
|
117
118
|
if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
|
118
119
|
context.shadowColor = this.shadowColor;
|
119
120
|
context.shadowBlur = this.shadowBlur;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"slider.js","sourceRoot":"","sources":["../../../../../../dev/gui/src/2D/controls/sliders/slider.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,0CAA4B;AACpD,OAAO,EAAE,SAAS,EAAE,2CAA6B;AAKjD,OAAO,EAAE,KAAK,EAAE,sCAAwB;AAExC;;GAEG;AACH,MAAM,OAAO,MAAO,SAAQ,UAAU;IAQlC,0EAA0E;IAE1E,IAAW,eAAe;QACtB,OAAO,IAAI,CAAC,gBAAgB,CAAC;IACjC,CAAC;IAED,IAAW,eAAe,CAAC,KAAc;QACrC,IAAI,IAAI,CAAC,gBAAgB,KAAK,KAAK,EAAE;YACjC,OAAO;SACV;QAED,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC;QAC9B,IAAI,CAAC,YAAY,EAAE,CAAC;IACxB,CAAC;IAED,gCAAgC;IAEhC,IAAW,WAAW;QAClB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IAED,IAAW,WAAW,CAAC,KAAa;QAChC,IAAI,IAAI,CAAC,YAAY,KAAK,KAAK,EAAE;YAC7B,OAAO;SACV;QAED,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;QAC1B,IAAI,CAAC,YAAY,EAAE,CAAC;IACxB,CAAC;IAED,oCAAoC;IAEpC,IAAW,UAAU;QACjB,OAAO,IAAI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B,GAAG,EAAE,CAAC;YAC5C,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,CAAC;SAC7E;IACL,CAAC;IAED,gBAAgB;IACA,iBAAiB,CAAC,gBAAqB,EAAE,IAA4B;QACjF,KAAK,CAAC,iBAAiB,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;QAEhD,IAAI,gBAAgB,CAAC,kBAAkB,EAAE;YACrC,MAAM,SAAS,GAAG,KAAK,CAAC,WAAW,CAAC,cAAc,GAAG,gBAAgB,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC;YACpG,IAAI,CAAC,kBAAkB,GAAG,IAAI,SAAS,EAAE,CAAC;YAC1C,IAAI,CAAC,kBAAmB,CAAC,KAAK,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,CAAC;SACvE;IACL,CAAC;CACJ;AA5QG;IADC,SAAS,EAAE;6CAGX;AAaD;IADC,SAAS,EAAE;yCAGX;AAaD;IADC,SAAS,EAAE;wCAGX;AA2BD;IADC,SAAS,EAAE;wCAGX;AAaD;IADC,SAAS,EAAE;2CAGX;AAiML,aAAa,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC","sourcesContent":["import { BaseSlider } from \"./baseSlider\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport { serialize } from \"core/Misc/decorators\";\r\nimport type { ICanvasRenderingContext } from \"core/Engines/ICanvas\";\r\nimport type { Nullable } from \"core/types\";\r\nimport type { BaseGradient } from \"../gradient/BaseGradient\";\r\nimport type { AdvancedDynamicTexture } from \"gui/2D/advancedDynamicTexture\";\r\nimport { Tools } from \"core/Misc/tools\";\r\n\r\n/**\r\n * Class used to create slider controls\r\n */\r\nexport class Slider extends BaseSlider {\r\n private _background = \"black\";\r\n private _borderColor = \"white\";\r\n private _thumbColor = \"\";\r\n private _isThumbCircle = false;\r\n protected _displayValueBar = true;\r\n private _backgroundGradient: Nullable<BaseGradient> = null;\r\n\r\n /** Gets or sets a boolean indicating if the value bar must be rendered */\r\n @serialize()\r\n public get displayValueBar(): boolean {\r\n return this._displayValueBar;\r\n }\r\n\r\n public set displayValueBar(value: boolean) {\r\n if (this._displayValueBar === value) {\r\n return;\r\n }\r\n\r\n this._displayValueBar = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /** Gets or sets border color */\r\n @serialize()\r\n public get borderColor(): string {\r\n return this._borderColor;\r\n }\r\n\r\n public set borderColor(value: string) {\r\n if (this._borderColor === value) {\r\n return;\r\n }\r\n\r\n this._borderColor = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /** Gets or sets background color */\r\n @serialize()\r\n public get background(): string {\r\n return this._background;\r\n }\r\n\r\n public set background(value: string) {\r\n if (this._background === value) {\r\n return;\r\n }\r\n\r\n this._background = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /** Gets or sets background gradient */\r\n public get backgroundGradient(): Nullable<BaseGradient> {\r\n return this._backgroundGradient;\r\n }\r\n\r\n public set backgroundGradient(value: Nullable<BaseGradient>) {\r\n if (this._backgroundGradient === value) {\r\n return;\r\n }\r\n\r\n this._backgroundGradient = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /** Gets or sets thumb's color */\r\n @serialize()\r\n public get thumbColor(): string {\r\n return this._thumbColor;\r\n }\r\n\r\n public set thumbColor(value: string) {\r\n if (this._thumbColor === value) {\r\n return;\r\n }\r\n\r\n this._thumbColor = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /** Gets or sets a boolean indicating if the thumb should be round or square */\r\n @serialize()\r\n public get isThumbCircle(): boolean {\r\n return this._isThumbCircle;\r\n }\r\n\r\n public set isThumbCircle(value: boolean) {\r\n if (this._isThumbCircle === value) {\r\n return;\r\n }\r\n\r\n this._isThumbCircle = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Creates a new Slider\r\n * @param name defines the control name\r\n */\r\n constructor(public override name?: string) {\r\n super(name);\r\n }\r\n\r\n protected override _getTypeName(): string {\r\n return \"Slider\";\r\n }\r\n\r\n protected _getBackgroundColor(context: ICanvasRenderingContext) {\r\n return this._backgroundGradient ? this._backgroundGradient.getCanvasGradient(context) : this._background;\r\n }\r\n\r\n public override _draw(context: ICanvasRenderingContext): void {\r\n context.save();\r\n\r\n this._applyStates(context);\r\n this._prepareRenderingData(this.isThumbCircle ? \"circle\" : \"rectangle\");\r\n let left = this._renderLeft;\r\n let top = this._renderTop;\r\n const width = this._renderWidth;\r\n const height = this._renderHeight;\r\n\r\n let radius = 0;\r\n\r\n if (this.isThumbClamped && this.isThumbCircle) {\r\n if (this.isVertical) {\r\n top += this._effectiveThumbThickness / 2;\r\n } else {\r\n left += this._effectiveThumbThickness / 2;\r\n }\r\n\r\n radius = this._backgroundBoxThickness / 2;\r\n } else {\r\n radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;\r\n }\r\n\r\n if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {\r\n context.shadowColor = this.shadowColor;\r\n context.shadowBlur = this.shadowBlur;\r\n context.shadowOffsetX = this.shadowOffsetX;\r\n context.shadowOffsetY = this.shadowOffsetY;\r\n }\r\n\r\n const thumbPosition = this._getThumbPosition();\r\n context.fillStyle = this._getBackgroundColor(context);\r\n\r\n if (this.isVertical) {\r\n if (this.isThumbClamped) {\r\n if (this.isThumbCircle) {\r\n context.beginPath();\r\n context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);\r\n context.fill();\r\n context.fillRect(left, top, width, height);\r\n } else {\r\n context.fillRect(left, top, width, height + this._effectiveThumbThickness);\r\n }\r\n } else {\r\n context.fillRect(left, top, width, height);\r\n }\r\n } else {\r\n if (this.isThumbClamped) {\r\n if (this.isThumbCircle) {\r\n context.beginPath();\r\n context.arc(left + this._backgroundBoxLength, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);\r\n context.fill();\r\n context.fillRect(left, top, width, height);\r\n } else {\r\n context.fillRect(left, top, width + this._effectiveThumbThickness, height);\r\n }\r\n } else {\r\n context.fillRect(left, top, width, height);\r\n }\r\n }\r\n\r\n if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {\r\n context.shadowBlur = 0;\r\n context.shadowOffsetX = 0;\r\n context.shadowOffsetY = 0;\r\n }\r\n\r\n // Value bar\r\n context.fillStyle = this._getColor(context);\r\n if (this._displayValueBar) {\r\n if (this.isVertical) {\r\n if (this.isThumbClamped) {\r\n if (this.isThumbCircle) {\r\n context.beginPath();\r\n context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);\r\n context.fill();\r\n context.fillRect(left, top + thumbPosition, width, height - thumbPosition);\r\n } else {\r\n context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);\r\n }\r\n } else {\r\n context.fillRect(left, top + thumbPosition, width, height - thumbPosition);\r\n }\r\n } else {\r\n if (this.isThumbClamped) {\r\n if (this.isThumbCircle) {\r\n context.beginPath();\r\n context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);\r\n context.fill();\r\n context.fillRect(left, top, thumbPosition, height);\r\n } else {\r\n context.fillRect(left, top, thumbPosition, height);\r\n }\r\n } else {\r\n context.fillRect(left, top, thumbPosition, height);\r\n }\r\n }\r\n }\r\n\r\n // Thumb\r\n context.fillStyle = this._thumbColor || this._getColor(context);\r\n if (this.displayThumb) {\r\n if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {\r\n context.shadowColor = this.shadowColor;\r\n context.shadowBlur = this.shadowBlur;\r\n context.shadowOffsetX = this.shadowOffsetX;\r\n context.shadowOffsetY = this.shadowOffsetY;\r\n }\r\n if (this._isThumbCircle) {\r\n context.beginPath();\r\n if (this.isVertical) {\r\n context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);\r\n } else {\r\n context.arc(left + thumbPosition, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);\r\n }\r\n context.fill();\r\n if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {\r\n context.shadowBlur = 0;\r\n context.shadowOffsetX = 0;\r\n context.shadowOffsetY = 0;\r\n }\r\n context.strokeStyle = this._borderColor;\r\n context.stroke();\r\n } else {\r\n if (this.isVertical) {\r\n context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);\r\n } else {\r\n context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);\r\n }\r\n if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {\r\n context.shadowBlur = 0;\r\n context.shadowOffsetX = 0;\r\n context.shadowOffsetY = 0;\r\n }\r\n context.strokeStyle = this._borderColor;\r\n if (this.isVertical) {\r\n context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);\r\n } else {\r\n context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);\r\n }\r\n }\r\n }\r\n context.restore();\r\n }\r\n\r\n public override serialize(serializationObject: any) {\r\n super.serialize(serializationObject);\r\n\r\n if (this.backgroundGradient) {\r\n serializationObject.backgroundGradient = {};\r\n this.backgroundGradient.serialize(serializationObject.backgroundGradient);\r\n }\r\n }\r\n\r\n /** @internal */\r\n public override _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture) {\r\n super._parseFromContent(serializedObject, host);\r\n\r\n if (serializedObject.backgroundGradient) {\r\n const className = Tools.Instantiate(\"BABYLON.GUI.\" + serializedObject.backgroundGradient.className);\r\n this.backgroundGradient = new className();\r\n this.backgroundGradient!.parse(serializedObject.backgroundGradient);\r\n }\r\n }\r\n}\r\nRegisterClass(\"BABYLON.GUI.Slider\", Slider);\r\n"]}
|
1
|
+
{"version":3,"file":"slider.js","sourceRoot":"","sources":["../../../../../../dev/gui/src/2D/controls/sliders/slider.ts"],"names":[],"m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,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC;YACpG,IAAI,CAAC,kBAAkB,GAAG,IAAI,SAAS,EAAE,CAAC;YAC1C,IAAI,CAAC,kBAAmB,CAAC,KAAK,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,CAAC;SACvE;IACL,CAAC;CACJ;AA7QG;IADC,SAAS,EAAE;6CAGX;AAaD;IADC,SAAS,EAAE;yCAGX;AAaD;IADC,SAAS,EAAE;wCAGX;AA2BD;IADC,SAAS,EAAE;wCAGX;AAaD;IADC,SAAS,EAAE;2CAGX;AAkML,aAAa,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC","sourcesContent":["import { BaseSlider } from \"./baseSlider\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport { serialize } from \"core/Misc/decorators\";\r\nimport type { ICanvasRenderingContext } from \"core/Engines/ICanvas\";\r\nimport type { Nullable } from \"core/types\";\r\nimport type { BaseGradient } from \"../gradient/BaseGradient\";\r\nimport type { AdvancedDynamicTexture } from \"gui/2D/advancedDynamicTexture\";\r\nimport { Tools } from \"core/Misc/tools\";\r\n\r\n/**\r\n * Class used to create slider controls\r\n */\r\nexport class Slider extends BaseSlider {\r\n private _background = \"black\";\r\n private _borderColor = \"white\";\r\n private _thumbColor = \"\";\r\n private _isThumbCircle = false;\r\n protected _displayValueBar = true;\r\n private _backgroundGradient: Nullable<BaseGradient> = null;\r\n\r\n /** Gets or sets a boolean indicating if the value bar must be rendered */\r\n @serialize()\r\n public get displayValueBar(): boolean {\r\n return this._displayValueBar;\r\n }\r\n\r\n public set displayValueBar(value: boolean) {\r\n if (this._displayValueBar === value) {\r\n return;\r\n }\r\n\r\n this._displayValueBar = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /** Gets or sets border color */\r\n @serialize()\r\n public get borderColor(): string {\r\n return this._borderColor;\r\n }\r\n\r\n public set borderColor(value: string) {\r\n if (this._borderColor === value) {\r\n return;\r\n }\r\n\r\n this._borderColor = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /** Gets or sets background color */\r\n @serialize()\r\n public get background(): string {\r\n return this._background;\r\n }\r\n\r\n public set background(value: string) {\r\n if (this._background === value) {\r\n return;\r\n }\r\n\r\n this._background = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /** Gets or sets background gradient */\r\n public get backgroundGradient(): Nullable<BaseGradient> {\r\n return this._backgroundGradient;\r\n }\r\n\r\n public set backgroundGradient(value: Nullable<BaseGradient>) {\r\n if (this._backgroundGradient === value) {\r\n return;\r\n }\r\n\r\n this._backgroundGradient = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /** Gets or sets thumb's color */\r\n @serialize()\r\n public get thumbColor(): string {\r\n return this._thumbColor;\r\n }\r\n\r\n public set thumbColor(value: string) {\r\n if (this._thumbColor === value) {\r\n return;\r\n }\r\n\r\n this._thumbColor = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /** Gets or sets a boolean indicating if the thumb should be round or square */\r\n @serialize()\r\n public get isThumbCircle(): boolean {\r\n return this._isThumbCircle;\r\n }\r\n\r\n public set isThumbCircle(value: boolean) {\r\n if (this._isThumbCircle === value) {\r\n return;\r\n }\r\n\r\n this._isThumbCircle = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Creates a new Slider\r\n * @param name defines the control name\r\n */\r\n constructor(public override name?: string) {\r\n super(name);\r\n }\r\n\r\n protected override _getTypeName(): string {\r\n return \"Slider\";\r\n }\r\n\r\n protected _getBackgroundColor(context: ICanvasRenderingContext) {\r\n return this._backgroundGradient ? this._backgroundGradient.getCanvasGradient(context) : this._background;\r\n }\r\n\r\n public override _draw(context: ICanvasRenderingContext): void {\r\n context.save();\r\n\r\n this._applyStates(context);\r\n this._prepareRenderingData(this.isThumbCircle ? \"circle\" : \"rectangle\");\r\n let left = this._renderLeft;\r\n let top = this._renderTop;\r\n const width = this._renderWidth;\r\n const height = this._renderHeight;\r\n\r\n let radius = 0;\r\n\r\n if (this.isThumbClamped && this.isThumbCircle) {\r\n if (this.isVertical) {\r\n top += this._effectiveThumbThickness / 2;\r\n } else {\r\n left += this._effectiveThumbThickness / 2;\r\n }\r\n\r\n radius = this._backgroundBoxThickness / 2;\r\n } else {\r\n radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;\r\n }\r\n radius = Math.max(0, radius);\r\n\r\n if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {\r\n context.shadowColor = this.shadowColor;\r\n context.shadowBlur = this.shadowBlur;\r\n context.shadowOffsetX = this.shadowOffsetX;\r\n context.shadowOffsetY = this.shadowOffsetY;\r\n }\r\n\r\n const thumbPosition = this._getThumbPosition();\r\n context.fillStyle = this._getBackgroundColor(context);\r\n\r\n if (this.isVertical) {\r\n if (this.isThumbClamped) {\r\n if (this.isThumbCircle) {\r\n context.beginPath();\r\n context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);\r\n context.fill();\r\n context.fillRect(left, top, width, height);\r\n } else {\r\n context.fillRect(left, top, width, height + this._effectiveThumbThickness);\r\n }\r\n } else {\r\n context.fillRect(left, top, width, height);\r\n }\r\n } else {\r\n if (this.isThumbClamped) {\r\n if (this.isThumbCircle) {\r\n context.beginPath();\r\n context.arc(left + this._backgroundBoxLength, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);\r\n context.fill();\r\n context.fillRect(left, top, width, height);\r\n } else {\r\n context.fillRect(left, top, width + this._effectiveThumbThickness, height);\r\n }\r\n } else {\r\n context.fillRect(left, top, width, height);\r\n }\r\n }\r\n\r\n if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {\r\n context.shadowBlur = 0;\r\n context.shadowOffsetX = 0;\r\n context.shadowOffsetY = 0;\r\n }\r\n\r\n // Value bar\r\n context.fillStyle = this._getColor(context);\r\n if (this._displayValueBar) {\r\n if (this.isVertical) {\r\n if (this.isThumbClamped) {\r\n if (this.isThumbCircle) {\r\n context.beginPath();\r\n context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);\r\n context.fill();\r\n context.fillRect(left, top + thumbPosition, width, height - thumbPosition);\r\n } else {\r\n context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);\r\n }\r\n } else {\r\n context.fillRect(left, top + thumbPosition, width, height - thumbPosition);\r\n }\r\n } else {\r\n if (this.isThumbClamped) {\r\n if (this.isThumbCircle) {\r\n context.beginPath();\r\n context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);\r\n context.fill();\r\n context.fillRect(left, top, thumbPosition, height);\r\n } else {\r\n context.fillRect(left, top, thumbPosition, height);\r\n }\r\n } else {\r\n context.fillRect(left, top, thumbPosition, height);\r\n }\r\n }\r\n }\r\n\r\n // Thumb\r\n context.fillStyle = this._thumbColor || this._getColor(context);\r\n if (this.displayThumb) {\r\n if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {\r\n context.shadowColor = this.shadowColor;\r\n context.shadowBlur = this.shadowBlur;\r\n context.shadowOffsetX = this.shadowOffsetX;\r\n context.shadowOffsetY = this.shadowOffsetY;\r\n }\r\n if (this._isThumbCircle) {\r\n context.beginPath();\r\n if (this.isVertical) {\r\n context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);\r\n } else {\r\n context.arc(left + thumbPosition, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);\r\n }\r\n context.fill();\r\n if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {\r\n context.shadowBlur = 0;\r\n context.shadowOffsetX = 0;\r\n context.shadowOffsetY = 0;\r\n }\r\n context.strokeStyle = this._borderColor;\r\n context.stroke();\r\n } else {\r\n if (this.isVertical) {\r\n context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);\r\n } else {\r\n context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);\r\n }\r\n if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {\r\n context.shadowBlur = 0;\r\n context.shadowOffsetX = 0;\r\n context.shadowOffsetY = 0;\r\n }\r\n context.strokeStyle = this._borderColor;\r\n if (this.isVertical) {\r\n context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);\r\n } else {\r\n context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);\r\n }\r\n }\r\n }\r\n context.restore();\r\n }\r\n\r\n public override serialize(serializationObject: any) {\r\n super.serialize(serializationObject);\r\n\r\n if (this.backgroundGradient) {\r\n serializationObject.backgroundGradient = {};\r\n this.backgroundGradient.serialize(serializationObject.backgroundGradient);\r\n }\r\n }\r\n\r\n /** @internal */\r\n public override _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture) {\r\n super._parseFromContent(serializedObject, host);\r\n\r\n if (serializedObject.backgroundGradient) {\r\n const className = Tools.Instantiate(\"BABYLON.GUI.\" + serializedObject.backgroundGradient.className);\r\n this.backgroundGradient = new className();\r\n this.backgroundGradient!.parse(serializedObject.backgroundGradient);\r\n }\r\n }\r\n}\r\nRegisterClass(\"BABYLON.GUI.Slider\", Slider);\r\n"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@babylonjs/gui",
|
3
|
-
"version": "7.21.
|
3
|
+
"version": "7.21.5",
|
4
4
|
"main": "index.js",
|
5
5
|
"module": "index.js",
|
6
6
|
"types": "index.d.ts",
|
@@ -18,7 +18,7 @@
|
|
18
18
|
"postcompile": "build-tools -c add-js-to-es6"
|
19
19
|
},
|
20
20
|
"devDependencies": {
|
21
|
-
"@babylonjs/core": "^7.21.
|
21
|
+
"@babylonjs/core": "^7.21.5",
|
22
22
|
"@dev/build-tools": "^1.0.0",
|
23
23
|
"@lts/gui": "1.0.0"
|
24
24
|
},
|