@babylonjs/gui 8.34.0 → 8.35.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/2D/controls/checkbox.js +2 -2
- package/2D/controls/checkbox.js.map +1 -1
- package/2D/controls/colorpicker.js +2 -2
- package/2D/controls/colorpicker.js.map +1 -1
- package/2D/controls/container.js +2 -2
- package/2D/controls/container.js.map +1 -1
- package/2D/controls/control.d.ts +2 -2
- package/2D/controls/control.js +6 -6
- package/2D/controls/control.js.map +1 -1
- package/2D/controls/ellipse.js +2 -2
- package/2D/controls/ellipse.js.map +1 -1
- package/2D/controls/image.js +2 -2
- package/2D/controls/image.js.map +1 -1
- package/2D/controls/inputText.js +2 -2
- package/2D/controls/inputText.js.map +1 -1
- package/2D/controls/inputTextArea.js +4 -4
- package/2D/controls/inputTextArea.js.map +1 -1
- package/2D/controls/line.js +2 -2
- package/2D/controls/line.js.map +1 -1
- package/2D/controls/multiLine.js +2 -2
- package/2D/controls/multiLine.js.map +1 -1
- package/2D/controls/radioButton.js +2 -2
- package/2D/controls/radioButton.js.map +1 -1
- package/2D/controls/rectangle.js +2 -2
- package/2D/controls/rectangle.js.map +1 -1
- package/2D/controls/sliders/slider.js +4 -4
- package/2D/controls/sliders/slider.js.map +1 -1
- package/2D/controls/stackPanel.js +4 -2
- package/2D/controls/stackPanel.js.map +1 -1
- package/2D/controls/textBlock.js +3 -2
- package/2D/controls/textBlock.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multiLine.js","sourceRoot":"","sources":["../../../../../dev/gui/src/2D/controls/multiLine.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,+CAAiC;AAExD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,0CAA4B;AAEpD,OAAO,E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AAE,CAAC;IACpB,CAAC;CACJ;AAvPG;IADC,SAAS,EAAE;qCAGX;AAsPL,aAAa,CAAC,uBAAuB,EAAE,SAAS,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { AbstractMesh } from \"core/Meshes/abstractMesh\";\r\n\r\nimport { Control } from \"./control\";\r\nimport { MultiLinePoint } from \"../multiLinePoint\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport type { Vector3 } from \"core/Maths/math.vector\";\r\nimport { serialize } from \"core/Misc/decorators\";\r\nimport type { ICanvasRenderingContext } from \"core/Engines/ICanvas\";\r\n\r\n/**\r\n * Class used to create multi line control\r\n */\r\nexport class MultiLine extends Control {\r\n private _lineWidth: number = 1;\r\n private _dash: number[];\r\n private _points: Nullable<MultiLinePoint>[];\r\n\r\n private _minX: Nullable<number>;\r\n private _minY: Nullable<number>;\r\n private _maxX: Nullable<number>;\r\n private _maxY: Nullable<number>;\r\n\r\n /**\r\n * Creates a new MultiLine\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 this._automaticSize = true;\r\n this.isHitTestVisible = false;\r\n this._horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;\r\n this._verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;\r\n\r\n this._dash = [];\r\n this._points = [];\r\n }\r\n\r\n /** Gets or sets dash pattern */\r\n @serialize()\r\n public get dash(): Array<number> {\r\n return this._dash;\r\n }\r\n\r\n public set dash(value: Array<number>) {\r\n if (this._dash === value) {\r\n return;\r\n }\r\n\r\n this._dash = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets point stored at specified index\r\n * @param index defines the index to look for\r\n * @returns the requested point if found\r\n */\r\n public getAt(index: number): MultiLinePoint {\r\n if (!this._points[index]) {\r\n this._points[index] = new MultiLinePoint(this);\r\n }\r\n\r\n return this._points[index];\r\n }\r\n\r\n /** Function called when a point is updated */\r\n public onPointUpdate = (): void => {\r\n this._markAsDirty();\r\n };\r\n\r\n /**\r\n * Adds new points to the point collection\r\n * @param items defines the list of items (mesh, control or 2d coordinates) to add\r\n * @returns the list of created MultiLinePoint\r\n */\r\n public add(...items: (AbstractMesh | Control | { x: string | number; y: string | number })[]): MultiLinePoint[] {\r\n return items.map((item) => this.push(item));\r\n }\r\n\r\n /**\r\n * Adds a new point to the point collection\r\n * @param item defines the item (mesh, control or 2d coordinates) to add\r\n * @returns the created MultiLinePoint\r\n */\r\n public push(item?: AbstractMesh | Control | { x: string | number; y: string | number }): MultiLinePoint {\r\n const point: MultiLinePoint = this.getAt(this._points.length);\r\n\r\n if (item == null) {\r\n return point;\r\n }\r\n\r\n if (item instanceof AbstractMesh) {\r\n point.mesh = item;\r\n } else if (item instanceof Control) {\r\n point.control = item;\r\n } else if (item.x != null && item.y != null) {\r\n point.x = item.x;\r\n point.y = item.y;\r\n }\r\n\r\n return point;\r\n }\r\n\r\n /**\r\n * Remove a specific value or point from the active point collection\r\n * @param value defines the value or point to remove\r\n */\r\n public remove(value: number | MultiLinePoint): void {\r\n let index: number;\r\n\r\n if (value instanceof MultiLinePoint) {\r\n index = this._points.indexOf(value);\r\n\r\n if (index === -1) {\r\n return;\r\n }\r\n } else {\r\n index = value;\r\n }\r\n\r\n const point: Nullable<MultiLinePoint> = this._points[index];\r\n\r\n if (!point) {\r\n return;\r\n }\r\n\r\n point.dispose();\r\n\r\n this._points.splice(index, 1);\r\n }\r\n\r\n /**\r\n * Resets this object to initial state (no point)\r\n */\r\n public reset(): void {\r\n while (this._points.length > 0) {\r\n this.remove(this._points.length - 1);\r\n }\r\n }\r\n\r\n /**\r\n * Resets all links\r\n */\r\n public resetLinks(): void {\r\n for (const point of this._points) {\r\n if (point != null) {\r\n point.resetLinks();\r\n }\r\n }\r\n }\r\n\r\n /** Gets or sets line width */\r\n public get lineWidth(): number {\r\n return this._lineWidth;\r\n }\r\n\r\n public set lineWidth(value: number) {\r\n if (this._lineWidth === value) {\r\n return;\r\n }\r\n\r\n this._lineWidth = value;\r\n this._markAsDirty();\r\n }\r\n\r\n public override set horizontalAlignment(value: number) {\r\n return;\r\n }\r\n\r\n public override set verticalAlignment(value: number) {\r\n return;\r\n }\r\n\r\n protected override _getTypeName(): string {\r\n return \"MultiLine\";\r\n }\r\n\r\n public override _draw(context: ICanvasRenderingContext): void {\r\n context.save();\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 this._applyStates(context);\r\n\r\n context.strokeStyle = this.color;\r\n context.lineWidth = this._lineWidth;\r\n context.setLineDash(this._dash);\r\n\r\n context.beginPath();\r\n\r\n let first: boolean = true; //first index is not necessarily 0\r\n let previousPoint: Vector3;\r\n\r\n for (const point of this._points) {\r\n if (!point) {\r\n continue;\r\n }\r\n\r\n if (first) {\r\n context.moveTo(point._point.x, point._point.y);\r\n\r\n first = false;\r\n } else {\r\n if (point._point.z < 1 && previousPoint!.z < 1) {\r\n context.lineTo(point._point.x, point._point.y);\r\n } else {\r\n context.moveTo(point._point.x, point._point.y);\r\n }\r\n }\r\n previousPoint = point._point;\r\n }\r\n\r\n context.stroke();\r\n\r\n context.restore();\r\n }\r\n\r\n protected override _additionalProcessing(): void {\r\n this._minX = null;\r\n this._minY = null;\r\n this._maxX = null;\r\n this._maxY = null;\r\n\r\n for (const point of this._points) {\r\n if (!point) {\r\n continue;\r\n }\r\n\r\n point.translate();\r\n\r\n if (this._minX == null || point._point.x < this._minX) {\r\n this._minX = point._point.x;\r\n }\r\n if (this._minY == null || point._point.y < this._minY) {\r\n this._minY = point._point.y;\r\n }\r\n if (this._maxX == null || point._point.x > this._maxX) {\r\n this._maxX = point._point.x;\r\n }\r\n if (this._maxY == null || point._point.y > this._maxY) {\r\n this._maxY = point._point.y;\r\n }\r\n }\r\n\r\n if (this._minX == null) {\r\n this._minX = 0;\r\n }\r\n if (this._minY == null) {\r\n this._minY = 0;\r\n }\r\n if (this._maxX == null) {\r\n this._maxX = 0;\r\n }\r\n if (this._maxY == null) {\r\n this._maxY = 0;\r\n }\r\n }\r\n\r\n public override _measure(): void {\r\n if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {\r\n return;\r\n }\r\n\r\n this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;\r\n this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;\r\n }\r\n\r\n protected override _computeAlignment(): void {\r\n if (this._minX == null || this._minY == null) {\r\n return;\r\n }\r\n\r\n this._currentMeasure.left = this._minX - this._lineWidth / 2;\r\n this._currentMeasure.top = this._minY - this._lineWidth / 2;\r\n }\r\n\r\n public override dispose(): void {\r\n this.reset();\r\n\r\n super.dispose();\r\n }\r\n}\r\nRegisterClass(\"BABYLON.GUI.MultiLine\", MultiLine);\r\n"]}
|
|
1
|
+
{"version":3,"file":"multiLine.js","sourceRoot":"","sources":["../../../../../dev/gui/src/2D/controls/multiLine.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,+CAAiC;AAExD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,0CAA4B;AAEpD,OAAO,EAAE,SAAS,EAAE,2CAA6B;AAGjD;;GAEG;AACH,MAAM,OAAO,SAAU,SAAQ,OAAO;IAUlC;;;OAGG;IACH,YAA4B,IAAa;QACrC,KAAK,CAAC,IAAI,CAAC,CAAC;QADY,SAAI,GAAJ,IAAI,CAAS;QAbjC,eAAU,GAAW,CAAC,CAAC;QAqD/B,8CAA8C;QACvC,kBAAa,GAAG,GAAS,EAAE;YAC9B,IAAI,CAAC,YAAY,EAAE,CAAC;QACxB,CAAC,CAAC;QAxCE,IAAI,CAAC,cAAc,GA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AAK,GAAG,CAAC,CAAC;QACnB,CAAC;IACL,CAAC;IAEe,QAAQ;QACpB,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,EAAE,CAAC;YACvF,OAAO;QACX,CAAC;QAED,IAAI,CAAC,eAAe,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC;QACjF,IAAI,CAAC,eAAe,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC;IACtF,CAAC;IAEkB,iBAAiB;QAChC,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,EAAE,CAAC;YAC3C,OAAO;QACX,CAAC;QAED,IAAI,CAAC,eAAe,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;QAC7D,IAAI,CAAC,eAAe,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;IAChE,CAAC;IAEe,OAAO;QACnB,IAAI,CAAC,KAAK,EAAE,CAAC;QAEb,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ;AAvPG;IADC,SAAS,EAAE;qCAGX;AAsPL,aAAa,CAAC,uBAAuB,EAAE,SAAS,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { AbstractMesh } from \"core/Meshes/abstractMesh\";\r\n\r\nimport { Control } from \"./control\";\r\nimport { MultiLinePoint } from \"../multiLinePoint\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport type { Vector3 } from \"core/Maths/math.vector\";\r\nimport { serialize } from \"core/Misc/decorators\";\r\nimport type { ICanvasRenderingContext } from \"core/Engines/ICanvas\";\r\n\r\n/**\r\n * Class used to create multi line control\r\n */\r\nexport class MultiLine extends Control {\r\n private _lineWidth: number = 1;\r\n private _dash: number[];\r\n private _points: Nullable<MultiLinePoint>[];\r\n\r\n private _minX: Nullable<number>;\r\n private _minY: Nullable<number>;\r\n private _maxX: Nullable<number>;\r\n private _maxY: Nullable<number>;\r\n\r\n /**\r\n * Creates a new MultiLine\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 this._automaticSize = true;\r\n this.isHitTestVisible = false;\r\n this._horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;\r\n this._verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;\r\n\r\n this._dash = [];\r\n this._points = [];\r\n }\r\n\r\n /** Gets or sets dash pattern */\r\n @serialize()\r\n public get dash(): Array<number> {\r\n return this._dash;\r\n }\r\n\r\n public set dash(value: Array<number>) {\r\n if (this._dash === value) {\r\n return;\r\n }\r\n\r\n this._dash = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets point stored at specified index\r\n * @param index defines the index to look for\r\n * @returns the requested point if found\r\n */\r\n public getAt(index: number): MultiLinePoint {\r\n if (!this._points[index]) {\r\n this._points[index] = new MultiLinePoint(this);\r\n }\r\n\r\n return this._points[index];\r\n }\r\n\r\n /** Function called when a point is updated */\r\n public onPointUpdate = (): void => {\r\n this._markAsDirty();\r\n };\r\n\r\n /**\r\n * Adds new points to the point collection\r\n * @param items defines the list of items (mesh, control or 2d coordinates) to add\r\n * @returns the list of created MultiLinePoint\r\n */\r\n public add(...items: (AbstractMesh | Control | { x: string | number; y: string | number })[]): MultiLinePoint[] {\r\n return items.map((item) => this.push(item));\r\n }\r\n\r\n /**\r\n * Adds a new point to the point collection\r\n * @param item defines the item (mesh, control or 2d coordinates) to add\r\n * @returns the created MultiLinePoint\r\n */\r\n public push(item?: AbstractMesh | Control | { x: string | number; y: string | number }): MultiLinePoint {\r\n const point: MultiLinePoint = this.getAt(this._points.length);\r\n\r\n if (item == null) {\r\n return point;\r\n }\r\n\r\n if (item instanceof AbstractMesh) {\r\n point.mesh = item;\r\n } else if (item instanceof Control) {\r\n point.control = item;\r\n } else if (item.x != null && item.y != null) {\r\n point.x = item.x;\r\n point.y = item.y;\r\n }\r\n\r\n return point;\r\n }\r\n\r\n /**\r\n * Remove a specific value or point from the active point collection\r\n * @param value defines the value or point to remove\r\n */\r\n public remove(value: number | MultiLinePoint): void {\r\n let index: number;\r\n\r\n if (value instanceof MultiLinePoint) {\r\n index = this._points.indexOf(value);\r\n\r\n if (index === -1) {\r\n return;\r\n }\r\n } else {\r\n index = value;\r\n }\r\n\r\n const point: Nullable<MultiLinePoint> = this._points[index];\r\n\r\n if (!point) {\r\n return;\r\n }\r\n\r\n point.dispose();\r\n\r\n this._points.splice(index, 1);\r\n }\r\n\r\n /**\r\n * Resets this object to initial state (no point)\r\n */\r\n public reset(): void {\r\n while (this._points.length > 0) {\r\n this.remove(this._points.length - 1);\r\n }\r\n }\r\n\r\n /**\r\n * Resets all links\r\n */\r\n public resetLinks(): void {\r\n for (const point of this._points) {\r\n if (point != null) {\r\n point.resetLinks();\r\n }\r\n }\r\n }\r\n\r\n /** Gets or sets line width */\r\n public get lineWidth(): number {\r\n return this._lineWidth;\r\n }\r\n\r\n public set lineWidth(value: number) {\r\n if (this._lineWidth === value) {\r\n return;\r\n }\r\n\r\n this._lineWidth = value;\r\n this._markAsDirty();\r\n }\r\n\r\n public override set horizontalAlignment(value: number) {\r\n return;\r\n }\r\n\r\n public override set verticalAlignment(value: number) {\r\n return;\r\n }\r\n\r\n protected override _getTypeName(): string {\r\n return \"MultiLine\";\r\n }\r\n\r\n public override _draw(context: ICanvasRenderingContext): void {\r\n context.save();\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 * this._host.idealRatio;\r\n context.shadowOffsetY = this.shadowOffsetY * this._host.idealRatio;\r\n }\r\n\r\n this._applyStates(context);\r\n\r\n context.strokeStyle = this.color;\r\n context.lineWidth = this._lineWidth;\r\n context.setLineDash(this._dash);\r\n\r\n context.beginPath();\r\n\r\n let first: boolean = true; //first index is not necessarily 0\r\n let previousPoint: Vector3;\r\n\r\n for (const point of this._points) {\r\n if (!point) {\r\n continue;\r\n }\r\n\r\n if (first) {\r\n context.moveTo(point._point.x, point._point.y);\r\n\r\n first = false;\r\n } else {\r\n if (point._point.z < 1 && previousPoint!.z < 1) {\r\n context.lineTo(point._point.x, point._point.y);\r\n } else {\r\n context.moveTo(point._point.x, point._point.y);\r\n }\r\n }\r\n previousPoint = point._point;\r\n }\r\n\r\n context.stroke();\r\n\r\n context.restore();\r\n }\r\n\r\n protected override _additionalProcessing(): void {\r\n this._minX = null;\r\n this._minY = null;\r\n this._maxX = null;\r\n this._maxY = null;\r\n\r\n for (const point of this._points) {\r\n if (!point) {\r\n continue;\r\n }\r\n\r\n point.translate();\r\n\r\n if (this._minX == null || point._point.x < this._minX) {\r\n this._minX = point._point.x;\r\n }\r\n if (this._minY == null || point._point.y < this._minY) {\r\n this._minY = point._point.y;\r\n }\r\n if (this._maxX == null || point._point.x > this._maxX) {\r\n this._maxX = point._point.x;\r\n }\r\n if (this._maxY == null || point._point.y > this._maxY) {\r\n this._maxY = point._point.y;\r\n }\r\n }\r\n\r\n if (this._minX == null) {\r\n this._minX = 0;\r\n }\r\n if (this._minY == null) {\r\n this._minY = 0;\r\n }\r\n if (this._maxX == null) {\r\n this._maxX = 0;\r\n }\r\n if (this._maxY == null) {\r\n this._maxY = 0;\r\n }\r\n }\r\n\r\n public override _measure(): void {\r\n if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {\r\n return;\r\n }\r\n\r\n this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;\r\n this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;\r\n }\r\n\r\n protected override _computeAlignment(): void {\r\n if (this._minX == null || this._minY == null) {\r\n return;\r\n }\r\n\r\n this._currentMeasure.left = this._minX - this._lineWidth / 2;\r\n this._currentMeasure.top = this._minY - this._lineWidth / 2;\r\n }\r\n\r\n public override dispose(): void {\r\n this.reset();\r\n\r\n super.dispose();\r\n }\r\n}\r\nRegisterClass(\"BABYLON.GUI.MultiLine\", MultiLine);\r\n"]}
|
|
@@ -98,8 +98,8 @@ export class RadioButton extends Control {
|
|
|
98
98
|
if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
|
|
99
99
|
context.shadowColor = this.shadowColor;
|
|
100
100
|
context.shadowBlur = this.shadowBlur;
|
|
101
|
-
context.shadowOffsetX = this.shadowOffsetX;
|
|
102
|
-
context.shadowOffsetY = this.shadowOffsetY;
|
|
101
|
+
context.shadowOffsetX = this.shadowOffsetX * this._host.idealRatio;
|
|
102
|
+
context.shadowOffsetY = this.shadowOffsetY * this._host.idealRatio;
|
|
103
103
|
}
|
|
104
104
|
// Outer
|
|
105
105
|
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, 1, context);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radioButton.js","sourceRoot":"","sources":["../../../../../dev/gui/src/2D/controls/radioButton.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,2CAA6B;AAGlD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,0CAA4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OlB;IADC,SAAS,EAAE;iDAGX;AAeD;IADC,SAAS,EAAE;6CAGX;AAaD;IADC,SAAS,EAAE;4CAGX;AAwJL,aAAa,CAAC,yBAAyB,EAAE,WAAW,CAAC,CAAC","sourcesContent":["import { Observable } from \"core/Misc/observable\";\r\nimport type { Vector2 } from \"core/Maths/math.vector\";\r\n\r\nimport { Control } from \"./control\";\r\nimport { StackPanel } from \"./stackPanel\";\r\nimport { TextBlock } from \"./textBlock\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport type { PointerInfoBase } from \"core/Events/pointerEvents\";\r\nimport { serialize } from \"core/Misc/decorators\";\r\nimport type { ICanvasRenderingContext } from \"core/Engines/ICanvas\";\r\n\r\n/**\r\n * Class used to create radio button controls\r\n */\r\nexport class RadioButton extends Control {\r\n private _isChecked = false;\r\n private _background = \"black\";\r\n private _checkSizeRatio = 0.8;\r\n private _thickness = 1;\r\n\r\n /** Gets or sets border thickness */\r\n @serialize()\r\n public get thickness(): number {\r\n return this._thickness;\r\n }\r\n\r\n public set thickness(value: number) {\r\n if (this._thickness === value) {\r\n return;\r\n }\r\n\r\n this._thickness = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /** Gets or sets group name */\r\n @serialize()\r\n public group = \"\";\r\n\r\n /** Observable raised when isChecked is changed */\r\n public onIsCheckedChangedObservable = new Observable<boolean>();\r\n\r\n /** Gets or sets a value indicating the ratio between overall size and check size */\r\n @serialize()\r\n public get checkSizeRatio(): number {\r\n return this._checkSizeRatio;\r\n }\r\n\r\n public set checkSizeRatio(value: number) {\r\n value = Math.max(Math.min(1, value), 0);\r\n\r\n if (this._checkSizeRatio === value) {\r\n return;\r\n }\r\n\r\n this._checkSizeRatio = 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 a boolean indicating if the checkbox is checked or not */\r\n @serialize()\r\n public get isChecked(): boolean {\r\n return this._isChecked;\r\n }\r\n\r\n public set isChecked(value: boolean) {\r\n if (this._isChecked === value) {\r\n return;\r\n }\r\n\r\n this._isChecked = value;\r\n this._markAsDirty();\r\n\r\n this.onIsCheckedChangedObservable.notifyObservers(value);\r\n\r\n if (this._isChecked && this._host) {\r\n // Update all controls from same group\r\n this._host.executeOnAllControls((control) => {\r\n if (control === this) {\r\n return;\r\n }\r\n\r\n if ((<any>control).group === undefined) {\r\n return;\r\n }\r\n const childRadio = <RadioButton>control;\r\n if (childRadio.group === this.group) {\r\n childRadio.isChecked = false;\r\n }\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Creates a new RadioButton\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 this.isPointerBlocker = true;\r\n }\r\n\r\n protected override _getTypeName(): string {\r\n return \"RadioButton\";\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 const actualWidth = this._currentMeasure.width - this._thickness;\r\n const actualHeight = this._currentMeasure.height - this._thickness;\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 // Outer\r\n Control.drawEllipse(\r\n this._currentMeasure.left + this._currentMeasure.width / 2,\r\n this._currentMeasure.top + this._currentMeasure.height / 2,\r\n this._currentMeasure.width / 2 - this._thickness / 2,\r\n this._currentMeasure.height / 2 - this._thickness / 2,\r\n 1,\r\n context\r\n );\r\n\r\n context.fillStyle = this._isEnabled ? this._background : this._disabledColor;\r\n context.fill();\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 context.strokeStyle = this.color;\r\n context.lineWidth = this._thickness;\r\n\r\n context.stroke();\r\n\r\n // Inner\r\n if (this._isChecked) {\r\n context.fillStyle = this._isEnabled ? this.color : this._disabledColor;\r\n const offsetWidth = actualWidth * this._checkSizeRatio;\r\n const offseHeight = actualHeight * this._checkSizeRatio;\r\n\r\n Control.drawEllipse(\r\n this._currentMeasure.left + this._currentMeasure.width / 2,\r\n this._currentMeasure.top + this._currentMeasure.height / 2,\r\n offsetWidth / 2 - this._thickness / 2,\r\n offseHeight / 2 - this._thickness / 2,\r\n 1,\r\n context\r\n );\r\n\r\n context.fill();\r\n }\r\n context.restore();\r\n }\r\n\r\n // Events\r\n public override _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, pi: PointerInfoBase): boolean {\r\n if (!super._onPointerDown(target, coordinates, pointerId, buttonIndex, pi)) {\r\n return false;\r\n }\r\n\r\n if (this.isReadOnly) {\r\n return true;\r\n }\r\n\r\n if (!this.isChecked) {\r\n this.isChecked = true;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Utility function to easily create a radio button with a header\r\n * @param title defines the label to use for the header\r\n * @param group defines the group to use for the radio button\r\n * @param isChecked defines the initial state of the radio button\r\n * @param onValueChanged defines the callback to call when value changes\r\n * @returns a StackPanel containing the radio button and a textBlock\r\n */\r\n public static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel {\r\n const panel = new StackPanel();\r\n panel.isVertical = false;\r\n panel.height = \"30px\";\r\n\r\n const radio = new RadioButton();\r\n radio.width = \"20px\";\r\n radio.height = \"20px\";\r\n radio.isChecked = isChecked;\r\n radio.color = \"green\";\r\n radio.group = group;\r\n radio.onIsCheckedChangedObservable.add((value) => onValueChanged(radio, value));\r\n panel.addControl(radio);\r\n\r\n const header = new TextBlock();\r\n header.text = title;\r\n header.width = \"180px\";\r\n header.paddingLeft = \"5px\";\r\n header.textHorizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;\r\n header.color = \"white\";\r\n panel.addControl(header);\r\n\r\n return panel;\r\n }\r\n}\r\nRegisterClass(\"BABYLON.GUI.RadioButton\", RadioButton);\r\n"]}
|
|
1
|
+
{"version":3,"file":"radioButton.js","sourceRoot":"","sources":["../../../../../dev/gui/src/2D/controls/radioButton.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,2CAA6B;AAGlD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,0CAA4B;AAEpD,OAAO,EAAE,SAAS,EAAE,2CAA6B;AAGjD;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,OAAO;IAMpC,oCAAoC;IAEpC,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAED,IAAW,SAAS,CAAC,KAAa;QAC9B,IAAI,IAAI,CAAC,UAAU,KAAK,KAAK,EAAE,CAAC;YAC5B,OAAO;QACX,CAAC;QAED,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB,IAAI,CAAC,YAAY,EAAE,CAAC;IACxB,CAAC;IASD,oFAAoF;IAEpF,IAAW,cAAc;QACrB,OAAO,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;IAED,IAAW,cAAc,CAAC,KAAa;QACnC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;QAExC,IAAI,IAAI,CAAC,eAAe,KAAK,KAAK,EAAE,CAAC;YACjC,OAAO;QACX,CAAC;QAED,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC;QAC7B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4B,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;QAChF,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAExB,MAAM,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC;QAC/B,MAAM,CAAC,IAAI,GAAG,KAAK,CAAC;QACpB,MAAM,CAAC,KAAK,GAAG,OAAO,CAAC;QACvB,MAAM,CAAC,WAAW,GAAG,KAAK,CAAC;QAC3B,MAAM,CAAC,uBAAuB,GAAG,OAAO,CAAC,yBAAyB,CAAC;QACnE,MAAM,CAAC,KAAK,GAAG,OAAO,CAAC;QACvB,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAEzB,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ;AA/MG;IADC,SAAS,EAAE;4CAGX;AAaM;IADN,SAAS,EAAE;0CACM;AAOlB;IADC,SAAS,EAAE;iDAGX;AAeD;IADC,SAAS,EAAE;6CAGX;AAaD;IADC,SAAS,EAAE;4CAGX;AAwJL,aAAa,CAAC,yBAAyB,EAAE,WAAW,CAAC,CAAC","sourcesContent":["import { Observable } from \"core/Misc/observable\";\r\nimport type { Vector2 } from \"core/Maths/math.vector\";\r\n\r\nimport { Control } from \"./control\";\r\nimport { StackPanel } from \"./stackPanel\";\r\nimport { TextBlock } from \"./textBlock\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport type { PointerInfoBase } from \"core/Events/pointerEvents\";\r\nimport { serialize } from \"core/Misc/decorators\";\r\nimport type { ICanvasRenderingContext } from \"core/Engines/ICanvas\";\r\n\r\n/**\r\n * Class used to create radio button controls\r\n */\r\nexport class RadioButton extends Control {\r\n private _isChecked = false;\r\n private _background = \"black\";\r\n private _checkSizeRatio = 0.8;\r\n private _thickness = 1;\r\n\r\n /** Gets or sets border thickness */\r\n @serialize()\r\n public get thickness(): number {\r\n return this._thickness;\r\n }\r\n\r\n public set thickness(value: number) {\r\n if (this._thickness === value) {\r\n return;\r\n }\r\n\r\n this._thickness = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /** Gets or sets group name */\r\n @serialize()\r\n public group = \"\";\r\n\r\n /** Observable raised when isChecked is changed */\r\n public onIsCheckedChangedObservable = new Observable<boolean>();\r\n\r\n /** Gets or sets a value indicating the ratio between overall size and check size */\r\n @serialize()\r\n public get checkSizeRatio(): number {\r\n return this._checkSizeRatio;\r\n }\r\n\r\n public set checkSizeRatio(value: number) {\r\n value = Math.max(Math.min(1, value), 0);\r\n\r\n if (this._checkSizeRatio === value) {\r\n return;\r\n }\r\n\r\n this._checkSizeRatio = 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 a boolean indicating if the checkbox is checked or not */\r\n @serialize()\r\n public get isChecked(): boolean {\r\n return this._isChecked;\r\n }\r\n\r\n public set isChecked(value: boolean) {\r\n if (this._isChecked === value) {\r\n return;\r\n }\r\n\r\n this._isChecked = value;\r\n this._markAsDirty();\r\n\r\n this.onIsCheckedChangedObservable.notifyObservers(value);\r\n\r\n if (this._isChecked && this._host) {\r\n // Update all controls from same group\r\n this._host.executeOnAllControls((control) => {\r\n if (control === this) {\r\n return;\r\n }\r\n\r\n if ((<any>control).group === undefined) {\r\n return;\r\n }\r\n const childRadio = <RadioButton>control;\r\n if (childRadio.group === this.group) {\r\n childRadio.isChecked = false;\r\n }\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Creates a new RadioButton\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 this.isPointerBlocker = true;\r\n }\r\n\r\n protected override _getTypeName(): string {\r\n return \"RadioButton\";\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 const actualWidth = this._currentMeasure.width - this._thickness;\r\n const actualHeight = this._currentMeasure.height - this._thickness;\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 * this._host.idealRatio;\r\n context.shadowOffsetY = this.shadowOffsetY * this._host.idealRatio;\r\n }\r\n\r\n // Outer\r\n Control.drawEllipse(\r\n this._currentMeasure.left + this._currentMeasure.width / 2,\r\n this._currentMeasure.top + this._currentMeasure.height / 2,\r\n this._currentMeasure.width / 2 - this._thickness / 2,\r\n this._currentMeasure.height / 2 - this._thickness / 2,\r\n 1,\r\n context\r\n );\r\n\r\n context.fillStyle = this._isEnabled ? this._background : this._disabledColor;\r\n context.fill();\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 context.strokeStyle = this.color;\r\n context.lineWidth = this._thickness;\r\n\r\n context.stroke();\r\n\r\n // Inner\r\n if (this._isChecked) {\r\n context.fillStyle = this._isEnabled ? this.color : this._disabledColor;\r\n const offsetWidth = actualWidth * this._checkSizeRatio;\r\n const offseHeight = actualHeight * this._checkSizeRatio;\r\n\r\n Control.drawEllipse(\r\n this._currentMeasure.left + this._currentMeasure.width / 2,\r\n this._currentMeasure.top + this._currentMeasure.height / 2,\r\n offsetWidth / 2 - this._thickness / 2,\r\n offseHeight / 2 - this._thickness / 2,\r\n 1,\r\n context\r\n );\r\n\r\n context.fill();\r\n }\r\n context.restore();\r\n }\r\n\r\n // Events\r\n public override _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, pi: PointerInfoBase): boolean {\r\n if (!super._onPointerDown(target, coordinates, pointerId, buttonIndex, pi)) {\r\n return false;\r\n }\r\n\r\n if (this.isReadOnly) {\r\n return true;\r\n }\r\n\r\n if (!this.isChecked) {\r\n this.isChecked = true;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Utility function to easily create a radio button with a header\r\n * @param title defines the label to use for the header\r\n * @param group defines the group to use for the radio button\r\n * @param isChecked defines the initial state of the radio button\r\n * @param onValueChanged defines the callback to call when value changes\r\n * @returns a StackPanel containing the radio button and a textBlock\r\n */\r\n public static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel {\r\n const panel = new StackPanel();\r\n panel.isVertical = false;\r\n panel.height = \"30px\";\r\n\r\n const radio = new RadioButton();\r\n radio.width = \"20px\";\r\n radio.height = \"20px\";\r\n radio.isChecked = isChecked;\r\n radio.color = \"green\";\r\n radio.group = group;\r\n radio.onIsCheckedChangedObservable.add((value) => onValueChanged(radio, value));\r\n panel.addControl(radio);\r\n\r\n const header = new TextBlock();\r\n header.text = title;\r\n header.width = \"180px\";\r\n header.paddingLeft = \"5px\";\r\n header.textHorizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;\r\n header.color = \"white\";\r\n panel.addControl(header);\r\n\r\n return panel;\r\n }\r\n}\r\nRegisterClass(\"BABYLON.GUI.RadioButton\", RadioButton);\r\n"]}
|
package/2D/controls/rectangle.js
CHANGED
|
@@ -115,8 +115,8 @@ export class Rectangle extends Container {
|
|
|
115
115
|
if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
|
|
116
116
|
context.shadowColor = this.shadowColor;
|
|
117
117
|
context.shadowBlur = this.shadowBlur;
|
|
118
|
-
context.shadowOffsetX = this.shadowOffsetX;
|
|
119
|
-
context.shadowOffsetY = this.shadowOffsetY;
|
|
118
|
+
context.shadowOffsetX = this.shadowOffsetX * this._host.idealRatio;
|
|
119
|
+
context.shadowOffsetY = this.shadowOffsetY * this._host.idealRatio;
|
|
120
120
|
}
|
|
121
121
|
if (this._background || this._backgroundGradient) {
|
|
122
122
|
context.fillStyle = this._getRectangleFill(context);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rectangle.js","sourceRoot":"","sources":["../../../../../dev/gui/src/2D/controls/rectangle.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,aAAa,EAAE,0CAA4B;AACpD,OAAO,EAAE,SAAS,EAAE,2CAA6B;AAGjD,+CAA+C;AAC/C,MAAM,OAAO,SAAU,SAAQ,SAAS;IAKpC,oCAAoC;IAEpC,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAED,IAAW,SAAS,CAAC,KAAa;QAC9B,IAAI,IAAI,CAAC,UAAU,KAAK,KAAK,EAAE,CAAC;YAC5B,OAAO;QACX,CAAC;QAED,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB,IAAI,CAAC,YAAY,EAAE,CAAC;IACxB,CAAC;IAED,mDAAmD;IAEnD,IAAW,YAAY;QACnB,OAAO,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IACjC,CAAC;IAED,IAAW,YAAY,CAAC,KAAa;QACjC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;YACZ,KAAK,GAAG,CAAC,CAAC;QACd,CAAC;QAED,IAAI,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,KAAK,IAAI,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,KAAK,IAAI,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,KAAK,IAAI,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,KAAK,EAAE,CAAC;YAC3I,OAAO;QACX,CAAC;QAED,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC,CA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CAAC,uBAAuB,EAAE,SAAS,CAAC,CAAC","sourcesContent":["import { Container } from \"./container\";\r\nimport type { Measure } from \"../measure\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport { serialize } from \"core/Misc/decorators\";\r\nimport type { ICanvasRenderingContext } from \"core/Engines/ICanvas\";\r\n\r\n/** Class used to create rectangle container */\r\nexport class Rectangle extends Container {\r\n private _thickness = 1;\r\n private _cornerRadius = [0, 0, 0, 0];\r\n private _cachedRadius = [0, 0, 0, 0];\r\n\r\n /** Gets or sets border thickness */\r\n @serialize()\r\n public get thickness(): number {\r\n return this._thickness;\r\n }\r\n\r\n public set thickness(value: number) {\r\n if (this._thickness === value) {\r\n return;\r\n }\r\n\r\n this._thickness = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /** Gets or sets the corner radius of all angles */\r\n @serialize()\r\n public get cornerRadius(): number {\r\n return this._cornerRadius[0];\r\n }\r\n\r\n public set cornerRadius(value: number) {\r\n if (value < 0) {\r\n value = 0;\r\n }\r\n\r\n if (this._cornerRadius[0] === value && this._cornerRadius[1] === value && this._cornerRadius[2] === value && this._cornerRadius[3] === value) {\r\n return;\r\n }\r\n\r\n this._cornerRadius[0] = this._cornerRadius[1] = this._cornerRadius[2] = this._cornerRadius[3] = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /** Gets or sets the corner radius top left angle */\r\n @serialize()\r\n public get cornerRadiusX(): number {\r\n return this._cornerRadius[0];\r\n }\r\n\r\n public set cornerRadiusX(value: number) {\r\n if (this._cornerRadius[0] === value) {\r\n return;\r\n }\r\n this._cornerRadius[0] = value;\r\n }\r\n\r\n /** Gets or sets the corner radius top right angle */\r\n @serialize()\r\n public get cornerRadiusY(): number {\r\n return this._cornerRadius[1];\r\n }\r\n\r\n public set cornerRadiusY(value: number) {\r\n if (this._cornerRadius[1] === value) {\r\n return;\r\n }\r\n this._cornerRadius[1] = value;\r\n }\r\n\r\n /** Gets or sets the corner radius bottom left angle */\r\n @serialize()\r\n public get cornerRadiusZ(): number {\r\n return this._cornerRadius[2];\r\n }\r\n\r\n public set cornerRadiusZ(value: number) {\r\n if (this._cornerRadius[2] === value) {\r\n return;\r\n }\r\n this._cornerRadius[2] = value;\r\n }\r\n\r\n /** Gets or sets the corner radius bottom right angle */\r\n @serialize()\r\n public get cornerRadiusW(): number {\r\n return this._cornerRadius[3];\r\n }\r\n\r\n public set cornerRadiusW(value: number) {\r\n if (this._cornerRadius[3] === value) {\r\n return;\r\n }\r\n this._cornerRadius[3] = value;\r\n }\r\n\r\n /**\r\n * Creates a new Rectangle\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 \"Rectangle\";\r\n }\r\n\r\n /** @internal */\r\n protected override _computeAdditionalOffsetX() {\r\n let additionalWidth = 0;\r\n if (this._cornerRadius[0] !== 0 || this._cornerRadius[1] !== 0 || this._cornerRadius[2] !== 0 || this._cornerRadius[3] !== 0) {\r\n // Take in account the aliasing\r\n additionalWidth += 1;\r\n }\r\n if (this.thickness) {\r\n additionalWidth += this.thickness / 2;\r\n }\r\n return additionalWidth;\r\n }\r\n\r\n /** @internal */\r\n protected override _computeAdditionalOffsetY() {\r\n let additionalHeight = 0;\r\n if (this._cornerRadius[0] !== 0 || this._cornerRadius[1] !== 0 || this._cornerRadius[2] !== 0 || this._cornerRadius[3] !== 0) {\r\n // Take in account the aliasing\r\n additionalHeight += 1;\r\n }\r\n if (this.thickness) {\r\n additionalHeight += this.thickness / 2;\r\n }\r\n return additionalHeight;\r\n }\r\n\r\n protected _getRectangleFill(context: ICanvasRenderingContext) {\r\n return this._getBackgroundColor(context);\r\n }\r\n\r\n protected override _localDraw(context: ICanvasRenderingContext): void {\r\n context.save();\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 if (this._background || this._backgroundGradient) {\r\n context.fillStyle = this._getRectangleFill(context);\r\n\r\n if (this._cornerRadius[0] !== 0 || this._cornerRadius[1] !== 0 || this._cornerRadius[2] !== 0 || this._cornerRadius[3] !== 0) {\r\n this._drawRoundedRect(context, this._thickness / 2);\r\n context.fill();\r\n } else {\r\n context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);\r\n }\r\n }\r\n\r\n if (this._thickness) {\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 if (this.color || this.gradient) {\r\n context.strokeStyle = this.gradient ? this.gradient.getCanvasGradient(context) : this.color;\r\n }\r\n context.lineWidth = this._thickness;\r\n\r\n if (this._cornerRadius[0] !== 0 || this._cornerRadius[1] !== 0 || this._cornerRadius[2] !== 0 || this._cornerRadius[3] !== 0) {\r\n this._drawRoundedRect(context, this._thickness / 2);\r\n context.stroke();\r\n } else {\r\n context.strokeRect(\r\n this._currentMeasure.left + this._thickness / 2,\r\n this._currentMeasure.top + this._thickness / 2,\r\n this._currentMeasure.width - this._thickness,\r\n this._currentMeasure.height - this._thickness\r\n );\r\n }\r\n }\r\n\r\n context.restore();\r\n }\r\n\r\n protected override _additionalProcessing(parentMeasure: Measure, context: ICanvasRenderingContext): void {\r\n super._additionalProcessing(parentMeasure, context);\r\n\r\n this._measureForChildren.width -= 2 * this._thickness;\r\n this._measureForChildren.height -= 2 * this._thickness;\r\n this._measureForChildren.left += this._thickness;\r\n this._measureForChildren.top += this._thickness;\r\n }\r\n\r\n private _drawRoundedRect(context: ICanvasRenderingContext, offset: number = 0): void {\r\n const x = this._currentMeasure.left + offset;\r\n const y = this._currentMeasure.top + offset;\r\n const width = this._currentMeasure.width - offset * 2;\r\n const height = this._currentMeasure.height - offset * 2;\r\n\r\n for (let index = 0; index < this._cornerRadius.length; index++) {\r\n this._cachedRadius[index] = Math.abs(Math.min(height / 2, Math.min(width / 2, this._cornerRadius[index])));\r\n }\r\n\r\n context.beginPath();\r\n context.moveTo(x + this._cachedRadius[0], y);\r\n context.lineTo(x + width - this._cachedRadius[1], y);\r\n context.arc(x + width - this._cachedRadius[1], y + this._cachedRadius[1], this._cachedRadius[1], (3 * Math.PI) / 2, Math.PI * 2);\r\n context.lineTo(x + width, y + height - this._cachedRadius[2]);\r\n context.arc(x + width - this._cachedRadius[2], y + height - this._cachedRadius[2], this._cachedRadius[2], 0, Math.PI / 2);\r\n context.lineTo(x + this._cachedRadius[3], y + height);\r\n context.arc(x + this._cachedRadius[3], y + height - this._cachedRadius[3], this._cachedRadius[3], Math.PI / 2, Math.PI);\r\n context.lineTo(x, y + this._cachedRadius[0]);\r\n context.arc(x + this._cachedRadius[0], y + this._cachedRadius[0], this._cachedRadius[0], Math.PI, (3 * Math.PI) / 2);\r\n context.closePath();\r\n }\r\n\r\n protected override _clipForChildren(context: ICanvasRenderingContext) {\r\n if (this._cornerRadius[0] !== 0 || this._cornerRadius[1] !== 0 || this._cornerRadius[2] !== 0 || this._cornerRadius[3] !== 0) {\r\n this._drawRoundedRect(context, this._thickness);\r\n context.clip();\r\n }\r\n }\r\n}\r\nRegisterClass(\"BABYLON.GUI.Rectangle\", Rectangle);\r\n"]}
|
|
1
|
+
{"version":3,"file":"rectangle.js","sourceRoot":"","sources":["../../../../../dev/gui/src/2D/controls/rectangle.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,aAAa,EAAE,0CAA4B;AACpD,OAAO,EAAE,SAAS,EAAE,2CAA6B;AAGjD,+CAA+C;AAC/C,MAAM,OAAO,SAAU,SAAQ,SAAS;IAKpC,oCAAoC;IAEpC,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAED,IAAW,SAA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C,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QACrH,OAAO,CAAC,SAAS,EAAE,CAAC;IACxB,CAAC;IAEkB,gBAAgB,CAAC,OAAgC;QAChE,IAAI,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;YAC3H,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;YAChD,OAAO,CAAC,IAAI,EAAE,CAAC;QACnB,CAAC;IACL,CAAC;CACJ;AArNG;IADC,SAAS,EAAE;0CAGX;AAaD;IADC,SAAS,EAAE;6CAGX;AAiBD;IADC,SAAS,EAAE;8CAGX;AAWD;IADC,SAAS,EAAE;8CAGX;AAWD;IADC,SAAS,EAAE;8CAGX;AAWD;IADC,SAAS,EAAE;8CAGX;AA2IL,aAAa,CAAC,uBAAuB,EAAE,SAAS,CAAC,CAAC","sourcesContent":["import { Container } from \"./container\";\r\nimport type { Measure } from \"../measure\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport { serialize } from \"core/Misc/decorators\";\r\nimport type { ICanvasRenderingContext } from \"core/Engines/ICanvas\";\r\n\r\n/** Class used to create rectangle container */\r\nexport class Rectangle extends Container {\r\n private _thickness = 1;\r\n private _cornerRadius = [0, 0, 0, 0];\r\n private _cachedRadius = [0, 0, 0, 0];\r\n\r\n /** Gets or sets border thickness */\r\n @serialize()\r\n public get thickness(): number {\r\n return this._thickness;\r\n }\r\n\r\n public set thickness(value: number) {\r\n if (this._thickness === value) {\r\n return;\r\n }\r\n\r\n this._thickness = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /** Gets or sets the corner radius of all angles */\r\n @serialize()\r\n public get cornerRadius(): number {\r\n return this._cornerRadius[0];\r\n }\r\n\r\n public set cornerRadius(value: number) {\r\n if (value < 0) {\r\n value = 0;\r\n }\r\n\r\n if (this._cornerRadius[0] === value && this._cornerRadius[1] === value && this._cornerRadius[2] === value && this._cornerRadius[3] === value) {\r\n return;\r\n }\r\n\r\n this._cornerRadius[0] = this._cornerRadius[1] = this._cornerRadius[2] = this._cornerRadius[3] = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /** Gets or sets the corner radius top left angle */\r\n @serialize()\r\n public get cornerRadiusX(): number {\r\n return this._cornerRadius[0];\r\n }\r\n\r\n public set cornerRadiusX(value: number) {\r\n if (this._cornerRadius[0] === value) {\r\n return;\r\n }\r\n this._cornerRadius[0] = value;\r\n }\r\n\r\n /** Gets or sets the corner radius top right angle */\r\n @serialize()\r\n public get cornerRadiusY(): number {\r\n return this._cornerRadius[1];\r\n }\r\n\r\n public set cornerRadiusY(value: number) {\r\n if (this._cornerRadius[1] === value) {\r\n return;\r\n }\r\n this._cornerRadius[1] = value;\r\n }\r\n\r\n /** Gets or sets the corner radius bottom left angle */\r\n @serialize()\r\n public get cornerRadiusZ(): number {\r\n return this._cornerRadius[2];\r\n }\r\n\r\n public set cornerRadiusZ(value: number) {\r\n if (this._cornerRadius[2] === value) {\r\n return;\r\n }\r\n this._cornerRadius[2] = value;\r\n }\r\n\r\n /** Gets or sets the corner radius bottom right angle */\r\n @serialize()\r\n public get cornerRadiusW(): number {\r\n return this._cornerRadius[3];\r\n }\r\n\r\n public set cornerRadiusW(value: number) {\r\n if (this._cornerRadius[3] === value) {\r\n return;\r\n }\r\n this._cornerRadius[3] = value;\r\n }\r\n\r\n /**\r\n * Creates a new Rectangle\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 \"Rectangle\";\r\n }\r\n\r\n /** @internal */\r\n protected override _computeAdditionalOffsetX() {\r\n let additionalWidth = 0;\r\n if (this._cornerRadius[0] !== 0 || this._cornerRadius[1] !== 0 || this._cornerRadius[2] !== 0 || this._cornerRadius[3] !== 0) {\r\n // Take in account the aliasing\r\n additionalWidth += 1;\r\n }\r\n if (this.thickness) {\r\n additionalWidth += this.thickness / 2;\r\n }\r\n return additionalWidth;\r\n }\r\n\r\n /** @internal */\r\n protected override _computeAdditionalOffsetY() {\r\n let additionalHeight = 0;\r\n if (this._cornerRadius[0] !== 0 || this._cornerRadius[1] !== 0 || this._cornerRadius[2] !== 0 || this._cornerRadius[3] !== 0) {\r\n // Take in account the aliasing\r\n additionalHeight += 1;\r\n }\r\n if (this.thickness) {\r\n additionalHeight += this.thickness / 2;\r\n }\r\n return additionalHeight;\r\n }\r\n\r\n protected _getRectangleFill(context: ICanvasRenderingContext) {\r\n return this._getBackgroundColor(context);\r\n }\r\n\r\n protected override _localDraw(context: ICanvasRenderingContext): void {\r\n context.save();\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 * this._host.idealRatio;\r\n context.shadowOffsetY = this.shadowOffsetY * this._host.idealRatio;\r\n }\r\n\r\n if (this._background || this._backgroundGradient) {\r\n context.fillStyle = this._getRectangleFill(context);\r\n\r\n if (this._cornerRadius[0] !== 0 || this._cornerRadius[1] !== 0 || this._cornerRadius[2] !== 0 || this._cornerRadius[3] !== 0) {\r\n this._drawRoundedRect(context, this._thickness / 2);\r\n context.fill();\r\n } else {\r\n context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);\r\n }\r\n }\r\n\r\n if (this._thickness) {\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 if (this.color || this.gradient) {\r\n context.strokeStyle = this.gradient ? this.gradient.getCanvasGradient(context) : this.color;\r\n }\r\n context.lineWidth = this._thickness;\r\n\r\n if (this._cornerRadius[0] !== 0 || this._cornerRadius[1] !== 0 || this._cornerRadius[2] !== 0 || this._cornerRadius[3] !== 0) {\r\n this._drawRoundedRect(context, this._thickness / 2);\r\n context.stroke();\r\n } else {\r\n context.strokeRect(\r\n this._currentMeasure.left + this._thickness / 2,\r\n this._currentMeasure.top + this._thickness / 2,\r\n this._currentMeasure.width - this._thickness,\r\n this._currentMeasure.height - this._thickness\r\n );\r\n }\r\n }\r\n\r\n context.restore();\r\n }\r\n\r\n protected override _additionalProcessing(parentMeasure: Measure, context: ICanvasRenderingContext): void {\r\n super._additionalProcessing(parentMeasure, context);\r\n\r\n this._measureForChildren.width -= 2 * this._thickness;\r\n this._measureForChildren.height -= 2 * this._thickness;\r\n this._measureForChildren.left += this._thickness;\r\n this._measureForChildren.top += this._thickness;\r\n }\r\n\r\n private _drawRoundedRect(context: ICanvasRenderingContext, offset: number = 0): void {\r\n const x = this._currentMeasure.left + offset;\r\n const y = this._currentMeasure.top + offset;\r\n const width = this._currentMeasure.width - offset * 2;\r\n const height = this._currentMeasure.height - offset * 2;\r\n\r\n for (let index = 0; index < this._cornerRadius.length; index++) {\r\n this._cachedRadius[index] = Math.abs(Math.min(height / 2, Math.min(width / 2, this._cornerRadius[index])));\r\n }\r\n\r\n context.beginPath();\r\n context.moveTo(x + this._cachedRadius[0], y);\r\n context.lineTo(x + width - this._cachedRadius[1], y);\r\n context.arc(x + width - this._cachedRadius[1], y + this._cachedRadius[1], this._cachedRadius[1], (3 * Math.PI) / 2, Math.PI * 2);\r\n context.lineTo(x + width, y + height - this._cachedRadius[2]);\r\n context.arc(x + width - this._cachedRadius[2], y + height - this._cachedRadius[2], this._cachedRadius[2], 0, Math.PI / 2);\r\n context.lineTo(x + this._cachedRadius[3], y + height);\r\n context.arc(x + this._cachedRadius[3], y + height - this._cachedRadius[3], this._cachedRadius[3], Math.PI / 2, Math.PI);\r\n context.lineTo(x, y + this._cachedRadius[0]);\r\n context.arc(x + this._cachedRadius[0], y + this._cachedRadius[0], this._cachedRadius[0], Math.PI, (3 * Math.PI) / 2);\r\n context.closePath();\r\n }\r\n\r\n protected override _clipForChildren(context: ICanvasRenderingContext) {\r\n if (this._cornerRadius[0] !== 0 || this._cornerRadius[1] !== 0 || this._cornerRadius[2] !== 0 || this._cornerRadius[3] !== 0) {\r\n this._drawRoundedRect(context, this._thickness);\r\n context.clip();\r\n }\r\n }\r\n}\r\nRegisterClass(\"BABYLON.GUI.Rectangle\", Rectangle);\r\n"]}
|
|
@@ -118,8 +118,8 @@ export class Slider extends BaseSlider {
|
|
|
118
118
|
if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
|
|
119
119
|
context.shadowColor = this.shadowColor;
|
|
120
120
|
context.shadowBlur = this.shadowBlur;
|
|
121
|
-
context.shadowOffsetX = this.shadowOffsetX;
|
|
122
|
-
context.shadowOffsetY = this.shadowOffsetY;
|
|
121
|
+
context.shadowOffsetX = this.shadowOffsetX * this._host.idealRatio;
|
|
122
|
+
context.shadowOffsetY = this.shadowOffsetY * this._host.idealRatio;
|
|
123
123
|
}
|
|
124
124
|
const thumbPosition = this._getThumbPosition();
|
|
125
125
|
context.fillStyle = this._getBackgroundColor(context);
|
|
@@ -202,8 +202,8 @@ export class Slider extends BaseSlider {
|
|
|
202
202
|
if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
|
|
203
203
|
context.shadowColor = this.shadowColor;
|
|
204
204
|
context.shadowBlur = this.shadowBlur;
|
|
205
|
-
context.shadowOffsetX = this.shadowOffsetX;
|
|
206
|
-
context.shadowOffsetY = this.shadowOffsetY;
|
|
205
|
+
context.shadowOffsetX = this.shadowOffsetX * this._host.idealRatio;
|
|
206
|
+
context.shadowOffsetY = this.shadowOffsetY * this._host.idealRatio;
|
|
207
207
|
}
|
|
208
208
|
if (this._isThumbCircle) {
|
|
209
209
|
context.beginPath();
|
|
@@ -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,CAAC;YAClC,OAAO;QACX,CAAC;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,CAAC;YAC9B,OAAO;QACX,CAAC;QAED,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;QAC1B,IAAI,CAAC,YAAY,EAAE,CAAC;IACxB,CAAC;IAED,oCAAoC;IAEpC,IAAW,UAAU;QACjB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IAED,IAAW,UAAU,CAAC,KAAa;QAC/B,IAAI,IAAI,CAAC,WAAW,KAAK,KAAK,EAAE,CAAC;YAC7B,OAAO;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AC,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"]}
|
|
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,CAAC;YAClC,OAAO;QACX,CAAC;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,CAAC;YAC9B,OAAO;QACX,CAAC;QAED,IAAI,CAAC,YAAY,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B,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;QACxE,CAAC;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 * this._host.idealRatio;\r\n context.shadowOffsetY = this.shadowOffsetY * this._host.idealRatio;\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 * this._host.idealRatio;\r\n context.shadowOffsetY = this.shadowOffsetY * this._host.idealRatio;\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"]}
|
|
@@ -118,6 +118,8 @@ export class StackPanel extends Container {
|
|
|
118
118
|
let stackWidth = 0;
|
|
119
119
|
let stackHeight = 0;
|
|
120
120
|
const childrenCount = this._children.length;
|
|
121
|
+
// Calculate scaled spacing using idealRatio (same pattern as shadowOffset)
|
|
122
|
+
const scaledSpacing = this._spacing * this._host.idealRatio;
|
|
121
123
|
for (let index = 0; index < childrenCount; index++) {
|
|
122
124
|
const child = this._children[index];
|
|
123
125
|
if (!child.isVisible || child.notRenderable) {
|
|
@@ -134,7 +136,7 @@ export class StackPanel extends Container {
|
|
|
134
136
|
Logger.Warn(`Control (Name:${child.name}, UniqueId:${child.uniqueId}) is using height in percentage mode inside a vertical StackPanel`, 1);
|
|
135
137
|
}
|
|
136
138
|
else {
|
|
137
|
-
stackHeight += child._currentMeasure.height + child._paddingTopInPixels + child._paddingBottomInPixels + (index < childrenCount - 1 ?
|
|
139
|
+
stackHeight += child._currentMeasure.height + child._paddingTopInPixels + child._paddingBottomInPixels + (index < childrenCount - 1 ? scaledSpacing : 0);
|
|
138
140
|
}
|
|
139
141
|
}
|
|
140
142
|
else {
|
|
@@ -148,7 +150,7 @@ export class StackPanel extends Container {
|
|
|
148
150
|
Logger.Warn(`Control (Name:${child.name}, UniqueId:${child.uniqueId}) is using width in percentage mode inside a horizontal StackPanel`, 1);
|
|
149
151
|
}
|
|
150
152
|
else {
|
|
151
|
-
stackWidth += child._currentMeasure.width + child._paddingLeftInPixels + child._paddingRightInPixels + (index < childrenCount - 1 ?
|
|
153
|
+
stackWidth += child._currentMeasure.width + child._paddingLeftInPixels + child._paddingRightInPixels + (index < childrenCount - 1 ? scaledSpacing : 0);
|
|
152
154
|
}
|
|
153
155
|
}
|
|
154
156
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stackPanel.js","sourceRoot":"","sources":["../../../../../dev/gui/src/2D/controls/stackPanel.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,0CAA4B;AACpD,OAAO,EAAE,SAAS,EAAE,2CAA6B;AAGjD,OAAO,EAAE,MAAM,EAAE,uCAAyB;AAE1C;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,SAAS;IAarC,oFAAoF;IAEpF,IAAW,UAAU;QACjB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IAED,IAAW,UAAU,CAAC,KAAc;QAChC,IAAI,IAAI,CAAC,WAAW,KAAK,KAAK,E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AW,CAAC;QACjD,IAAI,CAAC,aAAa,GAAG,gBAAgB,CAAC,YAAY,CAAC;QAEnD,KAAK,CAAC,iBAAiB,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;IACpD,CAAC;CACJ;AAzPU;IADN,SAAS,EAAE;wDACwB;AAIpC;IADC,SAAS,EAAE;4CAGX;AAeD;IADC,SAAS,EAAE;yCAGX;AAgBD;IADC,SAAS,EAAE;uCAaX;AAWD;IADC,SAAS,EAAE;wCAaX;AAgLL,aAAa,CAAC,wBAAwB,EAAE,UAAU,CAAC,CAAC","sourcesContent":["import { Container } from \"./container\";\r\nimport type { Measure } from \"../measure\";\r\nimport { Control } from \"./control\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport { serialize } from \"core/Misc/decorators\";\r\nimport type { AdvancedDynamicTexture } from \"../advancedDynamicTexture\";\r\nimport type { ICanvasRenderingContext } from \"core/Engines/ICanvas\";\r\nimport { Logger } from \"core/Misc/logger\";\r\n\r\n/**\r\n * Class used to create a 2D stack panel container\r\n */\r\nexport class StackPanel extends Container {\r\n private _isVertical = true;\r\n private _manualWidth = false;\r\n private _manualHeight = false;\r\n private _doNotTrackManualChanges = false;\r\n private _spacing = 0;\r\n\r\n /**\r\n * Gets or sets a boolean indicating that layout warnings should be ignored\r\n */\r\n @serialize()\r\n public ignoreLayoutWarnings = false;\r\n\r\n /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/\r\n @serialize()\r\n public get isVertical(): boolean {\r\n return this._isVertical;\r\n }\r\n\r\n public set isVertical(value: boolean) {\r\n if (this._isVertical === value) {\r\n return;\r\n }\r\n\r\n this._isVertical = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets the spacing (in pixels) between each child.\r\n */\r\n @serialize()\r\n public get spacing(): number {\r\n return this._spacing;\r\n }\r\n\r\n public set spacing(value: number) {\r\n if (this._spacing === value) {\r\n return;\r\n }\r\n\r\n this._spacing = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets panel width.\r\n * This value should not be set when in horizontal mode as it will be computed automatically\r\n */\r\n @serialize()\r\n public override set width(value: string | number) {\r\n if (!this._doNotTrackManualChanges) {\r\n this._manualWidth = true;\r\n }\r\n\r\n if (this._width.toString(this._host) === value) {\r\n return;\r\n }\r\n\r\n if (this._width.fromString(value)) {\r\n this._markAsDirty();\r\n }\r\n }\r\n\r\n public override get width(): string | number {\r\n return this._width.toString(this._host);\r\n }\r\n\r\n /**\r\n * Gets or sets panel height.\r\n * This value should not be set when in vertical mode as it will be computed automatically\r\n */\r\n @serialize()\r\n public override set height(value: string | number) {\r\n if (!this._doNotTrackManualChanges) {\r\n this._manualHeight = true;\r\n }\r\n\r\n if (this._height.toString(this._host) === value) {\r\n return;\r\n }\r\n\r\n if (this._height.fromString(value)) {\r\n this._markAsDirty();\r\n }\r\n }\r\n\r\n public override get height(): string | number {\r\n return this._height.toString(this._host);\r\n }\r\n\r\n /**\r\n * Creates a new StackPanel\r\n * @param name defines 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 \"StackPanel\";\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n protected override _preMeasure(parentMeasure: Measure, context: ICanvasRenderingContext): void {\r\n for (const child of this._children) {\r\n if (this._isVertical) {\r\n child.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;\r\n } else {\r\n child.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;\r\n }\r\n }\r\n\r\n super._preMeasure(parentMeasure, context);\r\n }\r\n\r\n protected override _additionalProcessing(parentMeasure: Measure, context: ICanvasRenderingContext): void {\r\n super._additionalProcessing(parentMeasure, context);\r\n\r\n this._measureForChildren.copyFrom(parentMeasure);\r\n\r\n this._measureForChildren.left = this._currentMeasure.left;\r\n this._measureForChildren.top = this._currentMeasure.top;\r\n\r\n if (!this.isVertical || this._manualWidth) {\r\n this._measureForChildren.width = this._currentMeasure.width;\r\n }\r\n\r\n if (this.isVertical || this._manualHeight) {\r\n this._measureForChildren.height = this._currentMeasure.height;\r\n }\r\n }\r\n\r\n protected override _postMeasure(): void {\r\n let stackWidth = 0;\r\n let stackHeight = 0;\r\n const childrenCount = this._children.length;\r\n for (let index = 0; index < childrenCount; index++) {\r\n const child = this._children[index];\r\n if (!child.isVisible || child.notRenderable) {\r\n continue;\r\n }\r\n\r\n if (this._isVertical) {\r\n const top = stackHeight + \"px\";\r\n if (child.top !== top) {\r\n child.top = top;\r\n this._rebuildLayout = true;\r\n child._top.ignoreAdaptiveScaling = true;\r\n }\r\n\r\n if (!this.ignoreLayoutWarnings && !child.isDimensionFullyDefined(\"height\")) {\r\n Logger.Warn(`Control (Name:${child.name}, UniqueId:${child.uniqueId}) is using height in percentage mode inside a vertical StackPanel`, 1);\r\n } else {\r\n stackHeight += child._currentMeasure.height + child._paddingTopInPixels + child._paddingBottomInPixels + (index < childrenCount - 1 ? this._spacing : 0);\r\n }\r\n } else {\r\n const left = stackWidth + \"px\";\r\n if (child.left !== left) {\r\n child.left = left;\r\n this._rebuildLayout = true;\r\n child._left.ignoreAdaptiveScaling = true;\r\n }\r\n\r\n if (!this.ignoreLayoutWarnings && !child.isDimensionFullyDefined(\"width\")) {\r\n Logger.Warn(`Control (Name:${child.name}, UniqueId:${child.uniqueId}) is using width in percentage mode inside a horizontal StackPanel`, 1);\r\n } else {\r\n stackWidth += child._currentMeasure.width + child._paddingLeftInPixels + child._paddingRightInPixels + (index < childrenCount - 1 ? this._spacing : 0);\r\n }\r\n }\r\n }\r\n\r\n stackWidth += this._paddingLeftInPixels + this._paddingRightInPixels;\r\n stackHeight += this._paddingTopInPixels + this._paddingBottomInPixels;\r\n\r\n this._doNotTrackManualChanges = true;\r\n\r\n // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.\r\n // User can now define their own height and width for stack panel.\r\n\r\n let panelWidthChanged = false;\r\n let panelHeightChanged = false;\r\n\r\n if ((!this._manualHeight || this.adaptHeightToChildren) && this._isVertical) {\r\n // do not specify height if strictly defined by user\r\n const previousHeight = this.height;\r\n this.height = stackHeight + \"px\";\r\n panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;\r\n }\r\n if ((!this._manualWidth || this.adaptWidthToChildren) && !this._isVertical) {\r\n // do not specify width if strictly defined by user\r\n const previousWidth = this.width;\r\n this.width = stackWidth + \"px\";\r\n panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;\r\n }\r\n\r\n if (panelHeightChanged) {\r\n this._height.ignoreAdaptiveScaling = true;\r\n }\r\n\r\n if (panelWidthChanged) {\r\n this._width.ignoreAdaptiveScaling = true;\r\n }\r\n\r\n this._doNotTrackManualChanges = false;\r\n\r\n if (panelWidthChanged || panelHeightChanged) {\r\n this._rebuildLayout = true;\r\n }\r\n\r\n super._postMeasure();\r\n }\r\n\r\n private _getManualDim(dim: \"width\" | \"height\") {\r\n if (dim === \"width\") {\r\n return this._manualWidth;\r\n } else {\r\n return this._manualHeight;\r\n }\r\n }\r\n\r\n public override isDimensionFullyDefined(dim: \"width\" | \"height\"): boolean {\r\n if (dim === \"height\" ? this.isVertical : !this.isVertical && !this._getManualDim(dim)) {\r\n for (const child of this._children) {\r\n if (!child.isDimensionFullyDefined(dim)) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n return this.getDimension(dim).isPixel || this._getAdaptDimTo(dim);\r\n }\r\n\r\n /**\r\n * Serializes the current control\r\n * @param serializationObject defined the JSON serialized object\r\n * @param force force serialization even if isSerializable === false\r\n * @param allowCanvas defines if the control is allowed to use a Canvas2D object to serialize\r\n */\r\n public override serialize(serializationObject: any, force: boolean, allowCanvas: boolean) {\r\n super.serialize(serializationObject, force, allowCanvas);\r\n if (!this.isSerializable && !force) {\r\n return;\r\n }\r\n serializationObject.manualWidth = this._manualWidth;\r\n serializationObject.manualHeight = this._manualHeight;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public override _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture) {\r\n this._manualWidth = serializedObject.manualWidth;\r\n this._manualHeight = serializedObject.manualHeight;\r\n\r\n super._parseFromContent(serializedObject, host);\r\n }\r\n}\r\nRegisterClass(\"BABYLON.GUI.StackPanel\", StackPanel);\r\n"]}
|
|
1
|
+
{"version":3,"file":"stackPanel.js","sourceRoot":"","sources":["../../../../../dev/gui/src/2D/controls/stackPanel.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,0CAA4B;AACpD,OAAO,EAAE,SAAS,EAAE,2CAA6B;AAGjD,OAAO,EAAE,MAAM,EAAE,uCAAyB;AAE1C;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,SAAS;IAarC,oFAAoF;IAEpF,IAAW,UAAU;QACjB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IAED,IAAW,UAAU,CAAC,KAAc;QAChC,IAAI,IAAI,CAAC,WAAW,KAAK,KAAK,EAAE,CAAC;YAC7B,OAAO;QACX,CAAC;QAED,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;QACzB,IAAI,CAAC,YAAY,EAAE,CAAC;IACxB,CAAC;IAED;;OAEG;IAEH,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAED,IAAW,OAAO,CAAC,KAAa;QAC5B,IAAI,IAAI,CAAC,QAAQ,KAAK,KAAK,EAAE,CAAC;YAC1B,OAAO;QACX,CAAC;QAED,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACtB,IAAI,CAAC,YAAY,EAAE,CAAC;IACxB,CAAC;IAED;;;OAGG;IAEH,IAAoB,KAAK,CAAC,KAAsB;QAC5C,IAAI,CAAC,IAAI,CAAC,wBAAwB,EAAE,CAAC;YACjC,IAAI,CAAC,YAAY,GAAG,IA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MAAM,KAAK,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;gBACjC,IAAI,CAAC,KAAK,CAAC,uBAAuB,CAAC,GAAG,CAAC,EAAE,CAAC;oBACtC,OAAO,KAAK,CAAC;gBACjB,CAAC;YACL,CAAC;YACD,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,OAAO,IAAI,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;IACtE,CAAC;IAED;;;;;OAKG;IACa,SAAS,CAAC,mBAAwB,EAAE,KAAc,EAAE,WAAoB;QACpF,KAAK,CAAC,SAAS,CAAC,mBAAmB,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC;QACzD,IAAI,CAAC,IAAI,CAAC,cAAc,IAAI,CAAC,KAAK,EAAE,CAAC;YACjC,OAAO;QACX,CAAC;QACD,mBAAmB,CAAC,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC;QACpD,mBAAmB,CAAC,YAAY,GAAG,IAAI,CAAC,aAAa,CAAC;IAC1D,CAAC;IAED;;OAEG;IACa,iBAAiB,CAAC,gBAAqB,EAAE,IAA4B;QACjF,IAAI,CAAC,YAAY,GAAG,gBAAgB,CAAC,WAAW,CAAC;QACjD,IAAI,CAAC,aAAa,GAAG,gBAAgB,CAAC,YAAY,CAAC;QAEnD,KAAK,CAAC,iBAAiB,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;IACpD,CAAC;CACJ;AA7PU;IADN,SAAS,EAAE;wDACwB;AAIpC;IADC,SAAS,EAAE;4CAGX;AAeD;IADC,SAAS,EAAE;yCAGX;AAgBD;IADC,SAAS,EAAE;uCAaX;AAWD;IADC,SAAS,EAAE;wCAaX;AAoLL,aAAa,CAAC,wBAAwB,EAAE,UAAU,CAAC,CAAC","sourcesContent":["import { Container } from \"./container\";\r\nimport type { Measure } from \"../measure\";\r\nimport { Control } from \"./control\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport { serialize } from \"core/Misc/decorators\";\r\nimport type { AdvancedDynamicTexture } from \"../advancedDynamicTexture\";\r\nimport type { ICanvasRenderingContext } from \"core/Engines/ICanvas\";\r\nimport { Logger } from \"core/Misc/logger\";\r\n\r\n/**\r\n * Class used to create a 2D stack panel container\r\n */\r\nexport class StackPanel extends Container {\r\n private _isVertical = true;\r\n private _manualWidth = false;\r\n private _manualHeight = false;\r\n private _doNotTrackManualChanges = false;\r\n private _spacing = 0;\r\n\r\n /**\r\n * Gets or sets a boolean indicating that layout warnings should be ignored\r\n */\r\n @serialize()\r\n public ignoreLayoutWarnings = false;\r\n\r\n /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/\r\n @serialize()\r\n public get isVertical(): boolean {\r\n return this._isVertical;\r\n }\r\n\r\n public set isVertical(value: boolean) {\r\n if (this._isVertical === value) {\r\n return;\r\n }\r\n\r\n this._isVertical = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets the spacing (in pixels) between each child.\r\n */\r\n @serialize()\r\n public get spacing(): number {\r\n return this._spacing;\r\n }\r\n\r\n public set spacing(value: number) {\r\n if (this._spacing === value) {\r\n return;\r\n }\r\n\r\n this._spacing = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets panel width.\r\n * This value should not be set when in horizontal mode as it will be computed automatically\r\n */\r\n @serialize()\r\n public override set width(value: string | number) {\r\n if (!this._doNotTrackManualChanges) {\r\n this._manualWidth = true;\r\n }\r\n\r\n if (this._width.toString(this._host) === value) {\r\n return;\r\n }\r\n\r\n if (this._width.fromString(value)) {\r\n this._markAsDirty();\r\n }\r\n }\r\n\r\n public override get width(): string | number {\r\n return this._width.toString(this._host);\r\n }\r\n\r\n /**\r\n * Gets or sets panel height.\r\n * This value should not be set when in vertical mode as it will be computed automatically\r\n */\r\n @serialize()\r\n public override set height(value: string | number) {\r\n if (!this._doNotTrackManualChanges) {\r\n this._manualHeight = true;\r\n }\r\n\r\n if (this._height.toString(this._host) === value) {\r\n return;\r\n }\r\n\r\n if (this._height.fromString(value)) {\r\n this._markAsDirty();\r\n }\r\n }\r\n\r\n public override get height(): string | number {\r\n return this._height.toString(this._host);\r\n }\r\n\r\n /**\r\n * Creates a new StackPanel\r\n * @param name defines 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 \"StackPanel\";\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n protected override _preMeasure(parentMeasure: Measure, context: ICanvasRenderingContext): void {\r\n for (const child of this._children) {\r\n if (this._isVertical) {\r\n child.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;\r\n } else {\r\n child.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;\r\n }\r\n }\r\n\r\n super._preMeasure(parentMeasure, context);\r\n }\r\n\r\n protected override _additionalProcessing(parentMeasure: Measure, context: ICanvasRenderingContext): void {\r\n super._additionalProcessing(parentMeasure, context);\r\n\r\n this._measureForChildren.copyFrom(parentMeasure);\r\n\r\n this._measureForChildren.left = this._currentMeasure.left;\r\n this._measureForChildren.top = this._currentMeasure.top;\r\n\r\n if (!this.isVertical || this._manualWidth) {\r\n this._measureForChildren.width = this._currentMeasure.width;\r\n }\r\n\r\n if (this.isVertical || this._manualHeight) {\r\n this._measureForChildren.height = this._currentMeasure.height;\r\n }\r\n }\r\n\r\n protected override _postMeasure(): void {\r\n let stackWidth = 0;\r\n let stackHeight = 0;\r\n const childrenCount = this._children.length;\r\n\r\n // Calculate scaled spacing using idealRatio (same pattern as shadowOffset)\r\n const scaledSpacing = this._spacing * this._host.idealRatio;\r\n\r\n for (let index = 0; index < childrenCount; index++) {\r\n const child = this._children[index];\r\n if (!child.isVisible || child.notRenderable) {\r\n continue;\r\n }\r\n\r\n if (this._isVertical) {\r\n const top = stackHeight + \"px\";\r\n if (child.top !== top) {\r\n child.top = top;\r\n this._rebuildLayout = true;\r\n child._top.ignoreAdaptiveScaling = true;\r\n }\r\n\r\n if (!this.ignoreLayoutWarnings && !child.isDimensionFullyDefined(\"height\")) {\r\n Logger.Warn(`Control (Name:${child.name}, UniqueId:${child.uniqueId}) is using height in percentage mode inside a vertical StackPanel`, 1);\r\n } else {\r\n stackHeight += child._currentMeasure.height + child._paddingTopInPixels + child._paddingBottomInPixels + (index < childrenCount - 1 ? scaledSpacing : 0);\r\n }\r\n } else {\r\n const left = stackWidth + \"px\";\r\n if (child.left !== left) {\r\n child.left = left;\r\n this._rebuildLayout = true;\r\n child._left.ignoreAdaptiveScaling = true;\r\n }\r\n\r\n if (!this.ignoreLayoutWarnings && !child.isDimensionFullyDefined(\"width\")) {\r\n Logger.Warn(`Control (Name:${child.name}, UniqueId:${child.uniqueId}) is using width in percentage mode inside a horizontal StackPanel`, 1);\r\n } else {\r\n stackWidth += child._currentMeasure.width + child._paddingLeftInPixels + child._paddingRightInPixels + (index < childrenCount - 1 ? scaledSpacing : 0);\r\n }\r\n }\r\n }\r\n\r\n stackWidth += this._paddingLeftInPixels + this._paddingRightInPixels;\r\n stackHeight += this._paddingTopInPixels + this._paddingBottomInPixels;\r\n\r\n this._doNotTrackManualChanges = true;\r\n\r\n // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.\r\n // User can now define their own height and width for stack panel.\r\n\r\n let panelWidthChanged = false;\r\n let panelHeightChanged = false;\r\n\r\n if ((!this._manualHeight || this.adaptHeightToChildren) && this._isVertical) {\r\n // do not specify height if strictly defined by user\r\n const previousHeight = this.height;\r\n this.height = stackHeight + \"px\";\r\n panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;\r\n }\r\n if ((!this._manualWidth || this.adaptWidthToChildren) && !this._isVertical) {\r\n // do not specify width if strictly defined by user\r\n const previousWidth = this.width;\r\n this.width = stackWidth + \"px\";\r\n panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;\r\n }\r\n\r\n if (panelHeightChanged) {\r\n this._height.ignoreAdaptiveScaling = true;\r\n }\r\n\r\n if (panelWidthChanged) {\r\n this._width.ignoreAdaptiveScaling = true;\r\n }\r\n\r\n this._doNotTrackManualChanges = false;\r\n\r\n if (panelWidthChanged || panelHeightChanged) {\r\n this._rebuildLayout = true;\r\n }\r\n\r\n super._postMeasure();\r\n }\r\n\r\n private _getManualDim(dim: \"width\" | \"height\") {\r\n if (dim === \"width\") {\r\n return this._manualWidth;\r\n } else {\r\n return this._manualHeight;\r\n }\r\n }\r\n\r\n public override isDimensionFullyDefined(dim: \"width\" | \"height\"): boolean {\r\n if (dim === \"height\" ? this.isVertical : !this.isVertical && !this._getManualDim(dim)) {\r\n for (const child of this._children) {\r\n if (!child.isDimensionFullyDefined(dim)) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n return this.getDimension(dim).isPixel || this._getAdaptDimTo(dim);\r\n }\r\n\r\n /**\r\n * Serializes the current control\r\n * @param serializationObject defined the JSON serialized object\r\n * @param force force serialization even if isSerializable === false\r\n * @param allowCanvas defines if the control is allowed to use a Canvas2D object to serialize\r\n */\r\n public override serialize(serializationObject: any, force: boolean, allowCanvas: boolean) {\r\n super.serialize(serializationObject, force, allowCanvas);\r\n if (!this.isSerializable && !force) {\r\n return;\r\n }\r\n serializationObject.manualWidth = this._manualWidth;\r\n serializationObject.manualHeight = this._manualHeight;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public override _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture) {\r\n this._manualWidth = serializedObject.manualWidth;\r\n this._manualHeight = serializedObject.manualHeight;\r\n\r\n super._parseFromContent(serializedObject, host);\r\n }\r\n}\r\nRegisterClass(\"BABYLON.GUI.StackPanel\", StackPanel);\r\n"]}
|
package/2D/controls/textBlock.js
CHANGED
|
@@ -357,8 +357,9 @@ export class TextBlock extends Control {
|
|
|
357
357
|
if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
|
|
358
358
|
context.shadowColor = this.shadowColor;
|
|
359
359
|
context.shadowBlur = this.shadowBlur;
|
|
360
|
-
|
|
361
|
-
context.
|
|
360
|
+
const idealRatio = this.host.idealRatio;
|
|
361
|
+
context.shadowOffsetX = this.shadowOffsetX * idealRatio;
|
|
362
|
+
context.shadowOffsetY = this.shadowOffsetY * idealRatio;
|
|
362
363
|
}
|
|
363
364
|
if (this.outlineWidth) {
|
|
364
365
|
context.strokeText(text, this._currentMeasure.left + x, y);
|