@babylonjs/gui 9.31.3 → 9.32.1
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.
|
@@ -879,6 +879,7 @@ export declare class Control implements IAnimatable, IFocusableControl {
|
|
|
879
879
|
*/
|
|
880
880
|
_processObservables(type: number, x: number, y: number, pi: Nullable<PointerInfoBase>, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
|
|
881
881
|
private _getStyleProperty;
|
|
882
|
+
private _getFont;
|
|
882
883
|
private _prepareFont;
|
|
883
884
|
/**
|
|
884
885
|
* A control has a dimension fully defined if that dimension doesn't depend on the parent's dimension.
|
|
@@ -909,6 +910,7 @@ export declare class Control implements IAnimatable, IFocusableControl {
|
|
|
909
910
|
parse(serializedObject: any, host?: AdvancedDynamicTexture, urlRewriter?: (url: string) => string): Control;
|
|
910
911
|
/**
|
|
911
912
|
* Serializes the current control
|
|
913
|
+
* Preserves the live layout and cached font metrics when adaptive scaling is enabled.
|
|
912
914
|
* @param serializationObject defined the JSON serialized object
|
|
913
915
|
* @param force if the control should be serialized even if the isSerializable flag is set to false (default false)
|
|
914
916
|
* @param allowCanvas defines if the control is allowed to use a Canvas2D object to serialize (true by default)
|
|
@@ -2138,18 +2138,20 @@ let Control = (() => {
|
|
|
2138
2138
|
return prop;
|
|
2139
2139
|
}
|
|
2140
2140
|
}
|
|
2141
|
+
_getFont() {
|
|
2142
|
+
return (this._getStyleProperty("fontStyle", "") +
|
|
2143
|
+
" " +
|
|
2144
|
+
this._getStyleProperty("fontWeight", "") +
|
|
2145
|
+
" " +
|
|
2146
|
+
this.fontSizeInPixels +
|
|
2147
|
+
"px " +
|
|
2148
|
+
this._getStyleProperty("fontFamily", "Arial"));
|
|
2149
|
+
}
|
|
2141
2150
|
_prepareFont() {
|
|
2142
2151
|
if (!this._font && !this._fontSet) {
|
|
2143
2152
|
return;
|
|
2144
2153
|
}
|
|
2145
|
-
this._font =
|
|
2146
|
-
this._getStyleProperty("fontStyle", "") +
|
|
2147
|
-
" " +
|
|
2148
|
-
this._getStyleProperty("fontWeight", "") +
|
|
2149
|
-
" " +
|
|
2150
|
-
this.fontSizeInPixels +
|
|
2151
|
-
"px " +
|
|
2152
|
-
this._getStyleProperty("fontFamily", "Arial");
|
|
2154
|
+
this._font = this._getFont();
|
|
2153
2155
|
this._fontOffset = _a._GetFontOffset(this._font, this._host?.getScene()?.getEngine());
|
|
2154
2156
|
//children need to be refreshed
|
|
2155
2157
|
const descendants = this.getDescendants();
|
|
@@ -2208,6 +2210,7 @@ let Control = (() => {
|
|
|
2208
2210
|
}
|
|
2209
2211
|
/**
|
|
2210
2212
|
* Serializes the current control
|
|
2213
|
+
* Preserves the live layout and cached font metrics when adaptive scaling is enabled.
|
|
2211
2214
|
* @param serializationObject defined the JSON serialized object
|
|
2212
2215
|
* @param force if the control should be serialized even if the isSerializable flag is set to false (default false)
|
|
2213
2216
|
* @param allowCanvas defines if the control is allowed to use a Canvas2D object to serialize (true by default)
|
|
@@ -2216,45 +2219,46 @@ let Control = (() => {
|
|
|
2216
2219
|
if (!this.isSerializable && !force) {
|
|
2217
2220
|
return;
|
|
2218
2221
|
}
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
//
|
|
2223
|
-
if (
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2222
|
+
const host = this._host;
|
|
2223
|
+
const idealWidth = host?.idealWidth ?? 0;
|
|
2224
|
+
const idealHeight = host?.idealHeight ?? 0;
|
|
2225
|
+
// Serialize declared values without the setters invalidating the entire GUI for each control.
|
|
2226
|
+
if (host) {
|
|
2227
|
+
host._idealWidth = 0;
|
|
2228
|
+
host._idealHeight = 0;
|
|
2229
|
+
}
|
|
2230
|
+
try {
|
|
2231
|
+
SerializationHelper.Serialize(this, serializationObject);
|
|
2232
|
+
serializationObject.name = this.name;
|
|
2233
|
+
serializationObject.className = this.getClassName();
|
|
2234
|
+
if (allowCanvas && (this._font || this._fontSet)) {
|
|
2235
|
+
// Compute unscaled metrics without changing the live font cache or dirtying descendants.
|
|
2236
|
+
serializationObject.fontOffset = _a._GetFontOffset(this._getFont(), host?.getScene()?.getEngine());
|
|
2237
|
+
}
|
|
2238
|
+
if (this._fontFamily) {
|
|
2239
|
+
serializationObject.fontFamily = this._fontFamily;
|
|
2240
|
+
}
|
|
2241
|
+
if (this.fontSize) {
|
|
2242
|
+
serializationObject.fontSize = this.fontSize;
|
|
2243
|
+
}
|
|
2244
|
+
if (this.fontWeight) {
|
|
2245
|
+
serializationObject.fontWeight = this.fontWeight;
|
|
2246
|
+
}
|
|
2247
|
+
if (this.fontStyle) {
|
|
2248
|
+
serializationObject.fontStyle = this.fontStyle;
|
|
2249
|
+
}
|
|
2250
|
+
if (this._gradient) {
|
|
2251
|
+
serializationObject.gradient = {};
|
|
2252
|
+
this._gradient.serialize(serializationObject.gradient);
|
|
2253
|
+
}
|
|
2254
|
+
// Animations
|
|
2255
|
+
SerializationHelper.AppendSerializedAnimations(this, serializationObject);
|
|
2251
2256
|
}
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
this.host.idealHeight = idealHeight;
|
|
2257
|
+
finally {
|
|
2258
|
+
if (host) {
|
|
2259
|
+
host._idealWidth = idealWidth;
|
|
2260
|
+
host._idealHeight = idealHeight;
|
|
2261
|
+
}
|
|
2258
2262
|
}
|
|
2259
2263
|
}
|
|
2260
2264
|
/**
|