@babylonjs/gui 8.34.1 → 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.
|
@@ -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.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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;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,C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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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@babylonjs/gui",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.35.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"module": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"postcompile": "build-tools -c add-js-to-es6"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@babylonjs/core": "^8.
|
|
21
|
+
"@babylonjs/core": "^8.35.0",
|
|
22
22
|
"@dev/build-tools": "^1.0.0",
|
|
23
23
|
"@lts/gui": "1.0.0"
|
|
24
24
|
},
|