@babylonjs/gui 7.15.1 → 7.16.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -585,6 +585,7 @@ export class Image extends Control {
585
585
  this._workingCanvas = null;
586
586
  this._loaded = false;
587
587
  this._stretch = Image.STRETCH_FILL;
588
+ this._source = null;
588
589
  this._autoScale = false;
589
590
  this._sourceLeft = 0;
590
591
  this._sourceTop = 0;
@@ -1 +1 @@
1
- {"version":3,"file":"image.js","sourceRoot":"","sources":["../../../../../dev/gui/src/2D/controls/image.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,2CAA6B;AAClD,OAAO,EAAE,KAAK,EAAE,sCAAwB;AAExC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,aAAa,EAAE,0CAA4B;AACpD,OAAO,EAAE,SAAS,EAAE,2CAA6B;AAEjD,OAAO,EAAE,WAAW,EAAE,+CAAiC;AAEvD;;GAEG;AACH,MAAM,OAAO,KAAM,SAAQ,OAAO;IA8D9B;;OAEG;IACH,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAEe,OAAO;QACnB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAED;;;OAGG;IAEH,IAAW,yBAAyB;QAChC,OAAO,IAAI,CAAC,0BAA0B,CAAC;IAC3C,CAAC;IAED,IAAW,yBAAyB,CAAC,KAAc;QAC/C,IAAI,IAAI,CAAC,0BAA0B,KAAK,KAAK,EAAE;YAC3C,OAAO;SACV;QAED,IAAI,CAAC,0BAA0B,GAAG,KAAK,CAAC;IAC5C,CAAC;IAED;;OAEG;IAEH,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAED,IAAW,SAAS,CAAC,KAAa;QAC9B,IAAI,IAAI,CAAC,UAAU,KAAK,KAAK,EAAE;YAC3B,OAAO;SACV;QAED,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QAExB,IAAI,CAA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AAAJ,CAAK;AAC3C,qBAAqB;AACE,oBAAc,GAAG,CAAC,AAAJ,CAAK;AAC1C,iBAAiB;AACM,wBAAkB,GAAG,CAAC,AAAJ,CAAK;AA/7B9C;IADC,SAAS,EAAE;sDAGX;AAcD;IADC,SAAS,EAAE;sCAGX;AAgBD;IADC,SAAS,EAAE;uCAGX;AAgBD;IADC,SAAS,EAAE;qCAGX;AAgBD;IADC,SAAS,EAAE;wCAGX;AAgBD;IADC,SAAS,EAAE;uCAGX;AAgBD;IADC,SAAS,EAAE;sCAGX;AAgBD;IADC,SAAS,EAAE;wCAGX;AAgBD;IADC,SAAS,EAAE;yCAGX;AA8BD;IADC,SAAS,EAAE;6DAGX;AA6BD;IADC,SAAS,EAAE;sCAGX;AAgBD;IADC,SAAS,EAAE;oCAGX;AAsMD;IADC,SAAS,EAAE;mCAGX;AA2MD;IADC,SAAS,EAAE;sCAGX;AAeD;IADC,SAAS,EAAE;uCAGX;AAeD;IADC,SAAS,EAAE;mCAGX;AAySL,aAAa,CAAC,mBAAmB,EAAE,KAAK,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { Observable } from \"core/Misc/observable\";\r\nimport { Tools } from \"core/Misc/tools\";\r\n\r\nimport { Control } from \"./control\";\r\nimport type { Measure } from \"../measure\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport { serialize } from \"core/Misc/decorators\";\r\nimport type { ICanvas, ICanvasRenderingContext, IImage } from \"core/Engines/ICanvas\";\r\nimport { EngineStore } from \"core/Engines/engineStore\";\r\n\r\n/**\r\n * Class used to create 2D images\r\n */\r\nexport class Image extends Control {\r\n /**\r\n * Specifies an alternate text for the image, if the image for some reason cannot be displayed.\r\n */\r\n public alt?: string;\r\n\r\n private _workingCanvas: Nullable<ICanvas> = null;\r\n\r\n private _domImage: IImage;\r\n private _imageWidth: number;\r\n private _imageHeight: number;\r\n private _loaded = false;\r\n private _stretch = Image.STRETCH_FILL;\r\n private _source: Nullable<string>;\r\n private _autoScale = false;\r\n\r\n private _sourceLeft = 0;\r\n private _sourceTop = 0;\r\n private _sourceWidth = 0;\r\n private _sourceHeight = 0;\r\n private _svgAttributesComputationCompleted: boolean = false;\r\n private _isSVG: boolean = false;\r\n\r\n private _cellWidth: number = 0;\r\n private _cellHeight: number = 0;\r\n private _cellId: number = -1;\r\n\r\n private _sliceLeft: number;\r\n private _sliceRight: number;\r\n private _sliceTop: number;\r\n private _sliceBottom: number;\r\n\r\n private _populateNinePatchSlicesFromImage = false;\r\n\r\n private _detectPointerOnOpaqueOnly: boolean;\r\n\r\n private _imageDataCache: {\r\n data: Uint8ClampedArray | null;\r\n key: string;\r\n } = { data: null, key: \"\" };\r\n\r\n /**\r\n * Cache of images to avoid loading the same image multiple times\r\n */\r\n public static SourceImgCache = new Map<string, { img: IImage; timesUsed: number; loaded: boolean; waitingForLoadCallback: Array<() => void> }>();\r\n\r\n /**\r\n * Observable notified when the content is loaded\r\n */\r\n public onImageLoadedObservable = new Observable<Image>();\r\n\r\n /**\r\n * Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed\r\n */\r\n public onSVGAttributesComputedObservable = new Observable<Image>();\r\n\r\n /**\r\n * Gets or sets the referrer policy to apply on the img element load request.\r\n * You should set referrerPolicy before set the source of the image if you want to ensure the header will be present on the xhr loading request\r\n */\r\n public referrerPolicy: Nullable<ReferrerPolicy>;\r\n\r\n /**\r\n * Gets a boolean indicating that the content is loaded\r\n */\r\n public get isLoaded(): boolean {\r\n return this._loaded;\r\n }\r\n\r\n public override isReady(): boolean {\r\n return this.isLoaded;\r\n }\r\n\r\n /**\r\n * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.\r\n * Beware using this as this will consume more memory as the image has to be stored twice\r\n */\r\n @serialize()\r\n public get detectPointerOnOpaqueOnly(): boolean {\r\n return this._detectPointerOnOpaqueOnly;\r\n }\r\n\r\n public set detectPointerOnOpaqueOnly(value: boolean) {\r\n if (this._detectPointerOnOpaqueOnly === value) {\r\n return;\r\n }\r\n\r\n this._detectPointerOnOpaqueOnly = value;\r\n }\r\n\r\n /**\r\n * Gets or sets the left value for slicing (9-patch)\r\n */\r\n @serialize()\r\n public get sliceLeft(): number {\r\n return this._sliceLeft;\r\n }\r\n\r\n public set sliceLeft(value: number) {\r\n if (this._sliceLeft === value) {\r\n return;\r\n }\r\n\r\n this._sliceLeft = value;\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets the right value for slicing (9-patch)\r\n */\r\n @serialize()\r\n public get sliceRight(): number {\r\n return this._sliceRight;\r\n }\r\n\r\n public set sliceRight(value: number) {\r\n if (this._sliceRight === value) {\r\n return;\r\n }\r\n\r\n this._sliceRight = value;\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets the top value for slicing (9-patch)\r\n */\r\n @serialize()\r\n public get sliceTop(): number {\r\n return this._sliceTop;\r\n }\r\n\r\n public set sliceTop(value: number) {\r\n if (this._sliceTop === value) {\r\n return;\r\n }\r\n\r\n this._sliceTop = value;\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets the bottom value for slicing (9-patch)\r\n */\r\n @serialize()\r\n public get sliceBottom(): number {\r\n return this._sliceBottom;\r\n }\r\n\r\n public set sliceBottom(value: number) {\r\n if (this._sliceBottom === value) {\r\n return;\r\n }\r\n\r\n this._sliceBottom = value;\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets the left coordinate in the source image\r\n */\r\n @serialize()\r\n public get sourceLeft(): number {\r\n return this._sourceLeft;\r\n }\r\n\r\n public set sourceLeft(value: number) {\r\n if (this._sourceLeft === value) {\r\n return;\r\n }\r\n\r\n this._sourceLeft = value;\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets the top coordinate in the source image\r\n */\r\n @serialize()\r\n public get sourceTop(): number {\r\n return this._sourceTop;\r\n }\r\n\r\n public set sourceTop(value: number) {\r\n if (this._sourceTop === value) {\r\n return;\r\n }\r\n\r\n this._sourceTop = value;\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets the width to capture in the source image\r\n */\r\n @serialize()\r\n public get sourceWidth(): number {\r\n return this._sourceWidth;\r\n }\r\n\r\n public set sourceWidth(value: number) {\r\n if (this._sourceWidth === value) {\r\n return;\r\n }\r\n\r\n this._sourceWidth = value;\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets the height to capture in the source image\r\n */\r\n @serialize()\r\n public get sourceHeight(): number {\r\n return this._sourceHeight;\r\n }\r\n\r\n public set sourceHeight(value: number) {\r\n if (this._sourceHeight === value) {\r\n return;\r\n }\r\n\r\n this._sourceHeight = value;\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets the image width\r\n */\r\n public get imageWidth(): number {\r\n return this._imageWidth;\r\n }\r\n\r\n /**\r\n * Gets the image height\r\n */\r\n public get imageHeight(): number {\r\n return this._imageHeight;\r\n }\r\n\r\n /**\r\n * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data\r\n */\r\n @serialize()\r\n public get populateNinePatchSlicesFromImage(): boolean {\r\n return this._populateNinePatchSlicesFromImage;\r\n }\r\n\r\n public set populateNinePatchSlicesFromImage(value: boolean) {\r\n if (this._populateNinePatchSlicesFromImage === value) {\r\n return;\r\n }\r\n\r\n this._populateNinePatchSlicesFromImage = value;\r\n\r\n if (this._populateNinePatchSlicesFromImage && this._loaded) {\r\n this._extractNinePatchSliceDataFromImage();\r\n }\r\n }\r\n\r\n /** Indicates if the format of the image is SVG */\r\n public get isSVG(): boolean {\r\n return this._isSVG;\r\n }\r\n\r\n /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */\r\n public get svgAttributesComputationCompleted(): boolean {\r\n return this._svgAttributesComputationCompleted;\r\n }\r\n\r\n /**\r\n * Gets or sets a boolean indicating if the image can force its container to adapt its size\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/gui/gui#image\r\n */\r\n @serialize()\r\n public get autoScale(): boolean {\r\n return this._autoScale;\r\n }\r\n\r\n public set autoScale(value: boolean) {\r\n if (this._autoScale === value) {\r\n return;\r\n }\r\n\r\n this._autoScale = value;\r\n\r\n if (value && this._loaded) {\r\n this.synchronizeSizeWithContent();\r\n }\r\n }\r\n\r\n /** Gets or sets the stretching mode used by the image */\r\n @serialize()\r\n public get stretch(): number {\r\n return this._stretch;\r\n }\r\n\r\n public set stretch(value: number) {\r\n if (this._stretch === value) {\r\n return;\r\n }\r\n\r\n this._stretch = value;\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _rotate90(n: number, preserveProperties: boolean = false): Image {\r\n const width = this._domImage.width;\r\n const height = this._domImage.height;\r\n\r\n // Should abstract platform instead of using LastCreatedEngine\r\n const engine = this._host?.getScene()?.getEngine() || EngineStore.LastCreatedEngine;\r\n if (!engine) {\r\n throw new Error(\"Invalid engine. Unable to create a canvas.\");\r\n }\r\n const canvas = engine.createCanvas(height, width);\r\n\r\n const context = canvas.getContext(\"2d\")!;\r\n\r\n context.translate(canvas.width / 2, canvas.height / 2);\r\n context.rotate((n * Math.PI) / 2);\r\n\r\n context.drawImage(this._domImage, 0, 0, width, height, -width / 2, -height / 2, width, height);\r\n\r\n const dataUrl: string = canvas.toDataURL(\"image/jpg\");\r\n const rotatedImage = new Image(this.name + \"rotated\", dataUrl);\r\n\r\n if (preserveProperties) {\r\n rotatedImage._stretch = this._stretch;\r\n rotatedImage._autoScale = this._autoScale;\r\n rotatedImage._cellId = this._cellId;\r\n rotatedImage._cellWidth = n % 1 ? this._cellHeight : this._cellWidth;\r\n rotatedImage._cellHeight = n % 1 ? this._cellWidth : this._cellHeight;\r\n }\r\n\r\n this._handleRotationForSVGImage(this, rotatedImage, n);\r\n\r\n this._imageDataCache.data = null;\r\n\r\n return rotatedImage;\r\n }\r\n\r\n private _handleRotationForSVGImage(srcImage: Image, dstImage: Image, n: number): void {\r\n if (!srcImage._isSVG) {\r\n return;\r\n }\r\n\r\n if (srcImage._svgAttributesComputationCompleted) {\r\n this._rotate90SourceProperties(srcImage, dstImage, n);\r\n this._markAsDirty();\r\n } else {\r\n srcImage.onSVGAttributesComputedObservable.addOnce(() => {\r\n this._rotate90SourceProperties(srcImage, dstImage, n);\r\n this._markAsDirty();\r\n });\r\n }\r\n }\r\n\r\n private _rotate90SourceProperties(srcImage: Image, dstImage: Image, n: number): void {\r\n let srcLeft = srcImage.sourceLeft,\r\n srcTop = srcImage.sourceTop,\r\n srcWidth = srcImage.domImage.width,\r\n srcHeight = srcImage.domImage.height;\r\n\r\n let dstLeft = srcLeft,\r\n dstTop = srcTop,\r\n dstWidth = srcImage.sourceWidth,\r\n dstHeight = srcImage.sourceHeight;\r\n\r\n if (n != 0) {\r\n const mult = n < 0 ? -1 : 1;\r\n n = n % 4;\r\n for (let i = 0; i < Math.abs(n); ++i) {\r\n dstLeft = -(srcTop - srcHeight / 2) * mult + srcHeight / 2;\r\n dstTop = (srcLeft - srcWidth / 2) * mult + srcWidth / 2;\r\n [dstWidth, dstHeight] = [dstHeight, dstWidth];\r\n if (n < 0) {\r\n dstTop -= dstHeight;\r\n } else {\r\n dstLeft -= dstWidth;\r\n }\r\n srcLeft = dstLeft;\r\n srcTop = dstTop;\r\n [srcWidth, srcHeight] = [srcHeight, srcWidth];\r\n }\r\n }\r\n\r\n dstImage.sourceLeft = dstLeft;\r\n dstImage.sourceTop = dstTop;\r\n dstImage.sourceWidth = dstWidth;\r\n dstImage.sourceHeight = dstHeight;\r\n }\r\n\r\n private _extractNinePatchSliceDataFromImage() {\r\n const width = this._domImage.width;\r\n const height = this._domImage.height;\r\n\r\n if (!this._workingCanvas) {\r\n const engine = this._host?.getScene()?.getEngine() || EngineStore.LastCreatedEngine;\r\n if (!engine) {\r\n throw new Error(\"Invalid engine. Unable to create a canvas.\");\r\n }\r\n this._workingCanvas = engine.createCanvas(width, height);\r\n }\r\n const canvas = this._workingCanvas;\r\n const context = canvas.getContext(\"2d\")!;\r\n\r\n context.drawImage(this._domImage, 0, 0, width, height);\r\n const imageData = context.getImageData(0, 0, width, height);\r\n\r\n // Left and right\r\n this._sliceLeft = -1;\r\n this._sliceRight = -1;\r\n for (let x = 0; x < width; x++) {\r\n const alpha = imageData.data[x * 4 + 3];\r\n\r\n if (alpha > 127 && this._sliceLeft === -1) {\r\n this._sliceLeft = x;\r\n continue;\r\n }\r\n\r\n if (alpha < 127 && this._sliceLeft > -1) {\r\n this._sliceRight = x;\r\n break;\r\n }\r\n }\r\n\r\n // top and bottom\r\n this._sliceTop = -1;\r\n this._sliceBottom = -1;\r\n for (let y = 0; y < height; y++) {\r\n const alpha = imageData.data[y * width * 4 + 3];\r\n\r\n if (alpha > 127 && this._sliceTop === -1) {\r\n this._sliceTop = y;\r\n continue;\r\n }\r\n\r\n if (alpha < 127 && this._sliceTop > -1) {\r\n this._sliceBottom = y;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets or sets the internal DOM image used to render the control\r\n */\r\n public set domImage(value: IImage) {\r\n this._domImage = value;\r\n this._loaded = false;\r\n this._imageDataCache.data = null;\r\n\r\n if (this._domImage.width) {\r\n this._onImageLoaded();\r\n } else {\r\n this._domImage.onload = () => {\r\n this._onImageLoaded();\r\n };\r\n }\r\n }\r\n\r\n public get domImage(): IImage {\r\n return this._domImage;\r\n }\r\n\r\n private _onImageLoaded(): void {\r\n this._imageDataCache.data = null;\r\n this._imageWidth = this._domImage.width;\r\n this._imageHeight = this._domImage.height;\r\n this._loaded = true;\r\n\r\n if (this._populateNinePatchSlicesFromImage) {\r\n this._extractNinePatchSliceDataFromImage();\r\n }\r\n\r\n if (this._autoScale) {\r\n this.synchronizeSizeWithContent();\r\n }\r\n\r\n this.onImageLoadedObservable.notifyObservers(this);\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets the image source url\r\n */\r\n @serialize()\r\n public get source() {\r\n return this._source;\r\n }\r\n\r\n /**\r\n * Resets the internal Image Element cache. Can reduce memory usage.\r\n */\r\n public static ResetImageCache() {\r\n Image.SourceImgCache.clear();\r\n }\r\n\r\n private _removeCacheUsage(source: Nullable<string>) {\r\n const value = source && Image.SourceImgCache.get(source);\r\n if (value) {\r\n value.timesUsed -= 1;\r\n\r\n // Remove from DOM\r\n const htmlElement = value.img as HTMLImageElement;\r\n if (htmlElement.parentNode) {\r\n htmlElement.parentNode.removeChild(htmlElement);\r\n }\r\n\r\n // Since the image isn't being used anymore, we can clean it from the cache\r\n if (value.timesUsed === 0) {\r\n Image.SourceImgCache.delete(source);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets or sets image source url\r\n */\r\n public set source(value: Nullable<string>) {\r\n if (this._urlRewriter && value) {\r\n value = this._urlRewriter(value);\r\n }\r\n\r\n if (this._source === value) {\r\n return;\r\n }\r\n\r\n this._removeCacheUsage(this._source);\r\n\r\n this._loaded = false;\r\n this._source = value;\r\n this._imageDataCache.data = null;\r\n\r\n if (value) {\r\n value = this._svgCheck(value);\r\n }\r\n\r\n // Should abstract platform instead of using LastCreatedEngine\r\n const engine = this._host?.getScene()?.getEngine() || EngineStore.LastCreatedEngine;\r\n if (!engine) {\r\n throw new Error(\"Invalid engine. Unable to create a canvas.\");\r\n }\r\n if (value && Image.SourceImgCache.has(value)) {\r\n const cachedData = Image.SourceImgCache.get(value)!;\r\n this._domImage = cachedData.img;\r\n cachedData.timesUsed += 1;\r\n if (cachedData.loaded) {\r\n this._onImageLoaded();\r\n } else {\r\n cachedData.waitingForLoadCallback.push(this._onImageLoaded.bind(this));\r\n }\r\n return;\r\n }\r\n this._domImage = engine.createCanvasImage();\r\n // need to add to enforce rendering\r\n const imgElement = this._domImage as HTMLImageElement;\r\n let addedToDom = false;\r\n if (imgElement.style && this._source?.endsWith(\".svg\")) {\r\n imgElement.style.visibility = \"hidden\";\r\n imgElement.style.position = \"absolute\";\r\n imgElement.style.top = \"0\";\r\n engine.getRenderingCanvas()?.parentNode?.appendChild(imgElement);\r\n addedToDom = true;\r\n }\r\n\r\n if (value) {\r\n Image.SourceImgCache.set(value, { img: this._domImage, timesUsed: 1, loaded: false, waitingForLoadCallback: [this._onImageLoaded.bind(this)] });\r\n }\r\n\r\n this._domImage.onload = () => {\r\n if (value) {\r\n const cachedData = Image.SourceImgCache.get(value);\r\n if (cachedData) {\r\n cachedData.loaded = true;\r\n for (const waitingCallback of cachedData.waitingForLoadCallback) {\r\n waitingCallback();\r\n }\r\n cachedData.waitingForLoadCallback.length = 0;\r\n addedToDom && imgElement.remove();\r\n return;\r\n }\r\n }\r\n this._onImageLoaded();\r\n addedToDom && imgElement.remove();\r\n };\r\n if (value) {\r\n Tools.SetCorsBehavior(value, this._domImage);\r\n Tools.SetReferrerPolicyBehavior(this.referrerPolicy, this._domImage);\r\n this._domImage.src = value;\r\n }\r\n }\r\n\r\n /**\r\n * Checks for svg document with icon id present\r\n * @param value the source svg\r\n * @returns the svg\r\n */\r\n private _svgCheck(value: string): string {\r\n if (window.SVGSVGElement && value.search(/(\\.svg|\\.svg?[?|#].*)$/gi) !== -1 && value.indexOf(\"#\") === value.lastIndexOf(\"#\")) {\r\n this._isSVG = true;\r\n const svgsrc = value.split(\"#\")[0];\r\n const elemid = value.split(\"#\")[1];\r\n // check if object alr exist in document\r\n const svgExist = <HTMLObjectElement>document.body.querySelector('object[data=\"' + svgsrc + '\"]');\r\n if (svgExist) {\r\n const svgDoc = svgExist.contentDocument;\r\n // get viewbox width and height, get svg document width and height in px\r\n if (svgDoc && svgDoc.documentElement) {\r\n const vb = svgDoc.documentElement.getAttribute(\"viewBox\");\r\n const docwidth = Number(svgDoc.documentElement.getAttribute(\"width\"));\r\n const docheight = Number(svgDoc.documentElement.getAttribute(\"height\"));\r\n const elem = <SVGGraphicsElement>(<unknown>svgDoc.getElementById(elemid));\r\n if (elem && vb && docwidth && docheight) {\r\n this._getSVGAttribs(svgExist, elemid);\r\n return value;\r\n }\r\n }\r\n\r\n // wait for object to load\r\n svgExist.addEventListener(\"load\", () => {\r\n this._getSVGAttribs(svgExist, elemid);\r\n });\r\n } else {\r\n // create document object\r\n const svgImage = document.createElement(\"object\");\r\n svgImage.data = svgsrc;\r\n svgImage.type = \"image/svg+xml\";\r\n svgImage.width = \"0%\";\r\n svgImage.height = \"0%\";\r\n document.body.appendChild(svgImage);\r\n // when the object has loaded, get the element attribs\r\n svgImage.onload = () => {\r\n const svgobj = <HTMLObjectElement>document.body.querySelector('object[data=\"' + svgsrc + '\"]');\r\n if (svgobj) {\r\n this._getSVGAttribs(svgobj, elemid);\r\n }\r\n };\r\n }\r\n return svgsrc;\r\n } else {\r\n return value;\r\n }\r\n }\r\n\r\n /**\r\n * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically\r\n * given external svg file and icon id\r\n * @param svgsrc\r\n * @param elemid\r\n */\r\n private _getSVGAttribs(svgsrc: HTMLObjectElement, elemid: string) {\r\n const svgDoc = svgsrc.contentDocument;\r\n // get viewbox width and height, get svg document width and height in px\r\n if (svgDoc && svgDoc.documentElement) {\r\n const vb = svgDoc.documentElement.getAttribute(\"viewBox\");\r\n const docwidth = Number(svgDoc.documentElement.getAttribute(\"width\"));\r\n const docheight = Number(svgDoc.documentElement.getAttribute(\"height\"));\r\n // get element bbox and matrix transform\r\n const elem = svgDoc.getElementById(elemid) as Nullable<SVGGraphicsElement>;\r\n if (vb && docwidth && docheight && elem) {\r\n const vb_width = Number(vb.split(\" \")[2]);\r\n const vb_height = Number(vb.split(\" \")[3]);\r\n const elem_bbox = elem.getBBox();\r\n let elem_matrix_a = 1;\r\n let elem_matrix_d = 1;\r\n let elem_matrix_e = 0;\r\n let elem_matrix_f = 0;\r\n const mainMatrix = elem.transform.baseVal.consolidate()!.matrix;\r\n if (elem.transform && elem.transform.baseVal.consolidate()) {\r\n elem_matrix_a = mainMatrix.a;\r\n elem_matrix_d = mainMatrix.d;\r\n elem_matrix_e = mainMatrix.e;\r\n elem_matrix_f = mainMatrix.f;\r\n }\r\n\r\n // compute source coordinates and dimensions\r\n this.sourceLeft = ((elem_matrix_a * elem_bbox.x + elem_matrix_e) * docwidth) / vb_width;\r\n this.sourceTop = ((elem_matrix_d * elem_bbox.y + elem_matrix_f) * docheight) / vb_height;\r\n this.sourceWidth = elem_bbox.width * elem_matrix_a * (docwidth / vb_width);\r\n this.sourceHeight = elem_bbox.height * elem_matrix_d * (docheight / vb_height);\r\n this._svgAttributesComputationCompleted = true;\r\n this.onSVGAttributesComputedObservable.notifyObservers(this);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets or sets the cell width to use when animation sheet is enabled\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/gui/gui#image\r\n */\r\n @serialize()\r\n get cellWidth(): number {\r\n return this._cellWidth;\r\n }\r\n set cellWidth(value: number) {\r\n if (this._cellWidth === value) {\r\n return;\r\n }\r\n\r\n this._cellWidth = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets the cell height to use when animation sheet is enabled\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/gui/gui#image\r\n */\r\n @serialize()\r\n get cellHeight(): number {\r\n return this._cellHeight;\r\n }\r\n set cellHeight(value: number) {\r\n if (this._cellHeight === value) {\r\n return;\r\n }\r\n\r\n this._cellHeight = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets the cell id to use (this will turn on the animation sheet mode)\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/gui/gui#image\r\n */\r\n @serialize()\r\n get cellId(): number {\r\n return this._cellId;\r\n }\r\n set cellId(value: number) {\r\n if (this._cellId === value) {\r\n return;\r\n }\r\n\r\n this._cellId = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Creates a new Image\r\n * @param name defines the control name\r\n * @param url defines the image url\r\n */\r\n constructor(\r\n public override name?: string,\r\n url: Nullable<string> = null\r\n ) {\r\n super(name);\r\n this.source = url;\r\n }\r\n\r\n /**\r\n * Tests if a given coordinates belong to the current control\r\n * @param x defines x coordinate to test\r\n * @param y defines y coordinate to test\r\n * @returns true if the coordinates are inside the control\r\n */\r\n public override contains(x: number, y: number): boolean {\r\n if (!super.contains(x, y)) {\r\n return false;\r\n }\r\n\r\n if (!this._detectPointerOnOpaqueOnly || !this._workingCanvas) {\r\n return true;\r\n }\r\n\r\n const width = this._currentMeasure.width | 0;\r\n const height = this._currentMeasure.height | 0;\r\n const key = width + \"_\" + height;\r\n\r\n let imageData = this._imageDataCache.data;\r\n\r\n if (!imageData || this._imageDataCache.key !== key) {\r\n const canvas = this._workingCanvas;\r\n const context = canvas.getContext(\"2d\")!;\r\n\r\n this._imageDataCache.data = imageData = context.getImageData(0, 0, width, height).data;\r\n this._imageDataCache.key = key;\r\n }\r\n\r\n x = (x - this._currentMeasure.left) | 0;\r\n y = (y - this._currentMeasure.top) | 0;\r\n\r\n const pickedPixel = imageData[(x + y * width) * 4 + 3];\r\n\r\n return pickedPixel > 0;\r\n }\r\n\r\n protected override _getTypeName(): string {\r\n return \"Image\";\r\n }\r\n\r\n /** Force the control to synchronize with its content */\r\n public synchronizeSizeWithContent() {\r\n if (!this._loaded) {\r\n return;\r\n }\r\n\r\n this.width = this._domImage.width + \"px\";\r\n this.height = this._domImage.height + \"px\";\r\n }\r\n\r\n protected override _processMeasures(parentMeasure: Measure, context: ICanvasRenderingContext): void {\r\n if (this._loaded) {\r\n switch (this._stretch) {\r\n case Image.STRETCH_NONE:\r\n break;\r\n case Image.STRETCH_FILL:\r\n break;\r\n case Image.STRETCH_UNIFORM:\r\n break;\r\n case Image.STRETCH_NINE_PATCH:\r\n break;\r\n case Image.STRETCH_EXTEND:\r\n if (this._autoScale) {\r\n this.synchronizeSizeWithContent();\r\n }\r\n if (this.parent && this.parent.parent) {\r\n // Will update root size if root is not the top root\r\n this.parent.adaptWidthToChildren = true;\r\n this.parent.adaptHeightToChildren = true;\r\n }\r\n break;\r\n }\r\n }\r\n\r\n super._processMeasures(parentMeasure, context);\r\n }\r\n\r\n private _prepareWorkingCanvasForOpaqueDetection() {\r\n if (!this._detectPointerOnOpaqueOnly) {\r\n return;\r\n }\r\n\r\n const width = this._currentMeasure.width;\r\n const height = this._currentMeasure.height;\r\n\r\n if (!this._workingCanvas) {\r\n const engine = this._host?.getScene()?.getEngine() || EngineStore.LastCreatedEngine;\r\n if (!engine) {\r\n throw new Error(\"Invalid engine. Unable to create a canvas.\");\r\n }\r\n this._workingCanvas = engine.createCanvas(width, height);\r\n }\r\n const canvas = this._workingCanvas;\r\n\r\n const context = canvas.getContext(\"2d\")!;\r\n\r\n context.clearRect(0, 0, width, height);\r\n }\r\n\r\n private _drawImage(context: ICanvasRenderingContext, sx: number, sy: number, sw: number, sh: number, tx: number, ty: number, tw: number, th: number) {\r\n context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);\r\n\r\n if (!this._detectPointerOnOpaqueOnly) {\r\n return;\r\n }\r\n\r\n const transform = context.getTransform();\r\n\r\n const canvas = this._workingCanvas!;\r\n const workingCanvasContext = canvas.getContext(\"2d\")!;\r\n workingCanvasContext.save();\r\n const ttx = tx - this._currentMeasure.left;\r\n const tty = ty - this._currentMeasure.top;\r\n workingCanvasContext.setTransform(transform.a, transform.b, transform.c, transform.d, (ttx + tw) / 2, (tty + th) / 2);\r\n workingCanvasContext.translate(-(ttx + tw) / 2, -(tty + th) / 2);\r\n\r\n workingCanvasContext.drawImage(this._domImage, sx, sy, sw, sh, ttx, tty, tw, th);\r\n workingCanvasContext.restore();\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 let x, y, width, height;\r\n if (this.cellId == -1) {\r\n x = this._sourceLeft;\r\n y = this._sourceTop;\r\n\r\n width = this._sourceWidth ? this._sourceWidth : this._imageWidth;\r\n height = this._sourceHeight ? this._sourceHeight : this._imageHeight;\r\n } else {\r\n const rowCount = this._domImage.naturalWidth / this.cellWidth;\r\n const column = (this.cellId / rowCount) >> 0;\r\n const row = this.cellId % rowCount;\r\n\r\n x = this.cellWidth * row;\r\n y = this.cellHeight * column;\r\n width = this.cellWidth;\r\n height = this.cellHeight;\r\n }\r\n\r\n this._prepareWorkingCanvasForOpaqueDetection();\r\n\r\n this._applyStates(context);\r\n if (this._loaded) {\r\n switch (this._stretch) {\r\n case Image.STRETCH_NONE:\r\n this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);\r\n break;\r\n case Image.STRETCH_FILL:\r\n this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);\r\n break;\r\n case Image.STRETCH_UNIFORM: {\r\n const hRatio = this._currentMeasure.width / width;\r\n const vRatio = this._currentMeasure.height / height;\r\n const ratio = Math.min(hRatio, vRatio);\r\n const centerX = (this._currentMeasure.width - width * ratio) / 2;\r\n const centerY = (this._currentMeasure.height - height * ratio) / 2;\r\n\r\n this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);\r\n break;\r\n }\r\n case Image.STRETCH_EXTEND:\r\n this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);\r\n break;\r\n case Image.STRETCH_NINE_PATCH:\r\n this._renderNinePatch(context, x, y, width, height);\r\n break;\r\n }\r\n }\r\n\r\n context.restore();\r\n }\r\n\r\n private _renderNinePatch(context: ICanvasRenderingContext, sx: number, sy: number, sw: number, sh: number): void {\r\n const idealRatio = this.host.idealWidth\r\n ? this._width.getValue(this.host) / this.host.idealWidth\r\n : this.host.idealHeight\r\n ? this._height.getValue(this.host) / this.host.idealHeight\r\n : 1;\r\n const leftWidth = this._sliceLeft;\r\n const topHeight = this._sliceTop;\r\n const bottomHeight = sh - this._sliceBottom;\r\n const rightWidth = sw - this._sliceRight;\r\n const centerWidth = this._sliceRight - this._sliceLeft;\r\n const centerHeight = this._sliceBottom - this._sliceTop;\r\n const leftWidthAdjusted = Math.round(leftWidth * idealRatio);\r\n const topHeightAdjusted = Math.round(topHeight * idealRatio);\r\n const bottomHeightAdjusted = Math.round(bottomHeight * idealRatio);\r\n const rightWidthAdjusted = Math.round(rightWidth * idealRatio);\r\n const targetCenterWidth = Math.round(this._currentMeasure.width) - rightWidthAdjusted - leftWidthAdjusted + 2;\r\n const targetCenterHeight = Math.round(this._currentMeasure.height) - bottomHeightAdjusted - topHeightAdjusted + 2;\r\n const centerLeftOffset = Math.round(this._currentMeasure.left) + leftWidthAdjusted - 1;\r\n const centerTopOffset = Math.round(this._currentMeasure.top) + topHeightAdjusted - 1;\r\n const rightOffset = Math.round(this._currentMeasure.left + this._currentMeasure.width) - rightWidthAdjusted;\r\n const bottomOffset = Math.round(this._currentMeasure.top + this._currentMeasure.height) - bottomHeightAdjusted;\r\n\r\n //Top Left\r\n this._drawImage(context, sx, sy, leftWidth, topHeight, this._currentMeasure.left, this._currentMeasure.top, leftWidthAdjusted, topHeightAdjusted);\r\n //Top\r\n this._drawImage(context, sx + this._sliceLeft, sy, centerWidth, topHeight, centerLeftOffset + 1, this._currentMeasure.top, targetCenterWidth - 2, topHeightAdjusted);\r\n //Top Right\r\n this._drawImage(context, sx + this._sliceRight, sy, rightWidth, topHeight, rightOffset, this._currentMeasure.top, rightWidthAdjusted, topHeightAdjusted);\r\n //Left\r\n this._drawImage(context, sx, sy + this._sliceTop, leftWidth, centerHeight, this._currentMeasure.left, centerTopOffset + 1, leftWidthAdjusted, targetCenterHeight - 2);\r\n // Center\r\n this._drawImage(\r\n context,\r\n sx + this._sliceLeft,\r\n sy + this._sliceTop,\r\n centerWidth,\r\n centerHeight,\r\n centerLeftOffset + 1,\r\n centerTopOffset + 1,\r\n targetCenterWidth - 2,\r\n targetCenterHeight - 2\r\n );\r\n //Right\r\n this._drawImage(\r\n context,\r\n sx + this._sliceRight,\r\n sy + this._sliceTop,\r\n rightWidth,\r\n centerHeight,\r\n rightOffset,\r\n centerTopOffset + 1,\r\n rightWidthAdjusted,\r\n targetCenterHeight - 2\r\n );\r\n //Bottom Left\r\n this._drawImage(context, sx, sy + this._sliceBottom, leftWidth, bottomHeight, this._currentMeasure.left, bottomOffset, leftWidthAdjusted, bottomHeightAdjusted);\r\n //Bottom\r\n this._drawImage(\r\n context,\r\n sx + this.sliceLeft,\r\n sy + this._sliceBottom,\r\n centerWidth,\r\n bottomHeight,\r\n centerLeftOffset + 1,\r\n bottomOffset,\r\n targetCenterWidth - 2,\r\n bottomHeightAdjusted\r\n );\r\n //Bottom Right\r\n this._drawImage(context, sx + this._sliceRight, sy + this._sliceBottom, rightWidth, bottomHeight, rightOffset, bottomOffset, rightWidthAdjusted, bottomHeightAdjusted);\r\n }\r\n\r\n public override dispose() {\r\n super.dispose();\r\n this.onImageLoadedObservable.clear();\r\n this.onSVGAttributesComputedObservable.clear();\r\n this._removeCacheUsage(this._source);\r\n }\r\n\r\n // Static\r\n /** STRETCH_NONE */\r\n public static readonly STRETCH_NONE = 0;\r\n /** STRETCH_FILL */\r\n public static readonly STRETCH_FILL = 1;\r\n /** STRETCH_UNIFORM */\r\n public static readonly STRETCH_UNIFORM = 2;\r\n /** STRETCH_EXTEND */\r\n public static readonly STRETCH_EXTEND = 3;\r\n /** NINE_PATCH */\r\n public static readonly STRETCH_NINE_PATCH = 4;\r\n}\r\nRegisterClass(\"BABYLON.GUI.Image\", Image);\r\n"]}
1
+ {"version":3,"file":"image.js","sourceRoot":"","sources":["../../../../../dev/gui/src/2D/controls/image.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,2CAA6B;AAClD,OAAO,EAAE,KAAK,EAAE,sCAAwB;AAExC,OAAO,EAAE,OAAO,EAAE,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CAGX;AA8BD;IADC,SAAS,EAAE;6DAGX;AA6BD;IADC,SAAS,EAAE;sCAGX;AAgBD;IADC,SAAS,EAAE;oCAGX;AAsMD;IADC,SAAS,EAAE;mCAGX;AA2MD;IADC,SAAS,EAAE;sCAGX;AAeD;IADC,SAAS,EAAE;uCAGX;AAeD;IADC,SAAS,EAAE;mCAGX;AAySL,aAAa,CAAC,mBAAmB,EAAE,KAAK,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { Observable } from \"core/Misc/observable\";\r\nimport { Tools } from \"core/Misc/tools\";\r\n\r\nimport { Control } from \"./control\";\r\nimport type { Measure } from \"../measure\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport { serialize } from \"core/Misc/decorators\";\r\nimport type { ICanvas, ICanvasRenderingContext, IImage } from \"core/Engines/ICanvas\";\r\nimport { EngineStore } from \"core/Engines/engineStore\";\r\n\r\n/**\r\n * Class used to create 2D images\r\n */\r\nexport class Image extends Control {\r\n /**\r\n * Specifies an alternate text for the image, if the image for some reason cannot be displayed.\r\n */\r\n public alt?: string;\r\n\r\n private _workingCanvas: Nullable<ICanvas> = null;\r\n\r\n private _domImage: IImage;\r\n private _imageWidth: number;\r\n private _imageHeight: number;\r\n private _loaded = false;\r\n private _stretch = Image.STRETCH_FILL;\r\n private _source: Nullable<string> = null;\r\n private _autoScale = false;\r\n\r\n private _sourceLeft = 0;\r\n private _sourceTop = 0;\r\n private _sourceWidth = 0;\r\n private _sourceHeight = 0;\r\n private _svgAttributesComputationCompleted: boolean = false;\r\n private _isSVG: boolean = false;\r\n\r\n private _cellWidth: number = 0;\r\n private _cellHeight: number = 0;\r\n private _cellId: number = -1;\r\n\r\n private _sliceLeft: number;\r\n private _sliceRight: number;\r\n private _sliceTop: number;\r\n private _sliceBottom: number;\r\n\r\n private _populateNinePatchSlicesFromImage = false;\r\n\r\n private _detectPointerOnOpaqueOnly: boolean;\r\n\r\n private _imageDataCache: {\r\n data: Uint8ClampedArray | null;\r\n key: string;\r\n } = { data: null, key: \"\" };\r\n\r\n /**\r\n * Cache of images to avoid loading the same image multiple times\r\n */\r\n public static SourceImgCache = new Map<string, { img: IImage; timesUsed: number; loaded: boolean; waitingForLoadCallback: Array<() => void> }>();\r\n\r\n /**\r\n * Observable notified when the content is loaded\r\n */\r\n public onImageLoadedObservable = new Observable<Image>();\r\n\r\n /**\r\n * Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed\r\n */\r\n public onSVGAttributesComputedObservable = new Observable<Image>();\r\n\r\n /**\r\n * Gets or sets the referrer policy to apply on the img element load request.\r\n * You should set referrerPolicy before set the source of the image if you want to ensure the header will be present on the xhr loading request\r\n */\r\n public referrerPolicy: Nullable<ReferrerPolicy>;\r\n\r\n /**\r\n * Gets a boolean indicating that the content is loaded\r\n */\r\n public get isLoaded(): boolean {\r\n return this._loaded;\r\n }\r\n\r\n public override isReady(): boolean {\r\n return this.isLoaded;\r\n }\r\n\r\n /**\r\n * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.\r\n * Beware using this as this will consume more memory as the image has to be stored twice\r\n */\r\n @serialize()\r\n public get detectPointerOnOpaqueOnly(): boolean {\r\n return this._detectPointerOnOpaqueOnly;\r\n }\r\n\r\n public set detectPointerOnOpaqueOnly(value: boolean) {\r\n if (this._detectPointerOnOpaqueOnly === value) {\r\n return;\r\n }\r\n\r\n this._detectPointerOnOpaqueOnly = value;\r\n }\r\n\r\n /**\r\n * Gets or sets the left value for slicing (9-patch)\r\n */\r\n @serialize()\r\n public get sliceLeft(): number {\r\n return this._sliceLeft;\r\n }\r\n\r\n public set sliceLeft(value: number) {\r\n if (this._sliceLeft === value) {\r\n return;\r\n }\r\n\r\n this._sliceLeft = value;\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets the right value for slicing (9-patch)\r\n */\r\n @serialize()\r\n public get sliceRight(): number {\r\n return this._sliceRight;\r\n }\r\n\r\n public set sliceRight(value: number) {\r\n if (this._sliceRight === value) {\r\n return;\r\n }\r\n\r\n this._sliceRight = value;\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets the top value for slicing (9-patch)\r\n */\r\n @serialize()\r\n public get sliceTop(): number {\r\n return this._sliceTop;\r\n }\r\n\r\n public set sliceTop(value: number) {\r\n if (this._sliceTop === value) {\r\n return;\r\n }\r\n\r\n this._sliceTop = value;\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets the bottom value for slicing (9-patch)\r\n */\r\n @serialize()\r\n public get sliceBottom(): number {\r\n return this._sliceBottom;\r\n }\r\n\r\n public set sliceBottom(value: number) {\r\n if (this._sliceBottom === value) {\r\n return;\r\n }\r\n\r\n this._sliceBottom = value;\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets the left coordinate in the source image\r\n */\r\n @serialize()\r\n public get sourceLeft(): number {\r\n return this._sourceLeft;\r\n }\r\n\r\n public set sourceLeft(value: number) {\r\n if (this._sourceLeft === value) {\r\n return;\r\n }\r\n\r\n this._sourceLeft = value;\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets the top coordinate in the source image\r\n */\r\n @serialize()\r\n public get sourceTop(): number {\r\n return this._sourceTop;\r\n }\r\n\r\n public set sourceTop(value: number) {\r\n if (this._sourceTop === value) {\r\n return;\r\n }\r\n\r\n this._sourceTop = value;\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets the width to capture in the source image\r\n */\r\n @serialize()\r\n public get sourceWidth(): number {\r\n return this._sourceWidth;\r\n }\r\n\r\n public set sourceWidth(value: number) {\r\n if (this._sourceWidth === value) {\r\n return;\r\n }\r\n\r\n this._sourceWidth = value;\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets the height to capture in the source image\r\n */\r\n @serialize()\r\n public get sourceHeight(): number {\r\n return this._sourceHeight;\r\n }\r\n\r\n public set sourceHeight(value: number) {\r\n if (this._sourceHeight === value) {\r\n return;\r\n }\r\n\r\n this._sourceHeight = value;\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets the image width\r\n */\r\n public get imageWidth(): number {\r\n return this._imageWidth;\r\n }\r\n\r\n /**\r\n * Gets the image height\r\n */\r\n public get imageHeight(): number {\r\n return this._imageHeight;\r\n }\r\n\r\n /**\r\n * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data\r\n */\r\n @serialize()\r\n public get populateNinePatchSlicesFromImage(): boolean {\r\n return this._populateNinePatchSlicesFromImage;\r\n }\r\n\r\n public set populateNinePatchSlicesFromImage(value: boolean) {\r\n if (this._populateNinePatchSlicesFromImage === value) {\r\n return;\r\n }\r\n\r\n this._populateNinePatchSlicesFromImage = value;\r\n\r\n if (this._populateNinePatchSlicesFromImage && this._loaded) {\r\n this._extractNinePatchSliceDataFromImage();\r\n }\r\n }\r\n\r\n /** Indicates if the format of the image is SVG */\r\n public get isSVG(): boolean {\r\n return this._isSVG;\r\n }\r\n\r\n /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */\r\n public get svgAttributesComputationCompleted(): boolean {\r\n return this._svgAttributesComputationCompleted;\r\n }\r\n\r\n /**\r\n * Gets or sets a boolean indicating if the image can force its container to adapt its size\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/gui/gui#image\r\n */\r\n @serialize()\r\n public get autoScale(): boolean {\r\n return this._autoScale;\r\n }\r\n\r\n public set autoScale(value: boolean) {\r\n if (this._autoScale === value) {\r\n return;\r\n }\r\n\r\n this._autoScale = value;\r\n\r\n if (value && this._loaded) {\r\n this.synchronizeSizeWithContent();\r\n }\r\n }\r\n\r\n /** Gets or sets the stretching mode used by the image */\r\n @serialize()\r\n public get stretch(): number {\r\n return this._stretch;\r\n }\r\n\r\n public set stretch(value: number) {\r\n if (this._stretch === value) {\r\n return;\r\n }\r\n\r\n this._stretch = value;\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _rotate90(n: number, preserveProperties: boolean = false): Image {\r\n const width = this._domImage.width;\r\n const height = this._domImage.height;\r\n\r\n // Should abstract platform instead of using LastCreatedEngine\r\n const engine = this._host?.getScene()?.getEngine() || EngineStore.LastCreatedEngine;\r\n if (!engine) {\r\n throw new Error(\"Invalid engine. Unable to create a canvas.\");\r\n }\r\n const canvas = engine.createCanvas(height, width);\r\n\r\n const context = canvas.getContext(\"2d\")!;\r\n\r\n context.translate(canvas.width / 2, canvas.height / 2);\r\n context.rotate((n * Math.PI) / 2);\r\n\r\n context.drawImage(this._domImage, 0, 0, width, height, -width / 2, -height / 2, width, height);\r\n\r\n const dataUrl: string = canvas.toDataURL(\"image/jpg\");\r\n const rotatedImage = new Image(this.name + \"rotated\", dataUrl);\r\n\r\n if (preserveProperties) {\r\n rotatedImage._stretch = this._stretch;\r\n rotatedImage._autoScale = this._autoScale;\r\n rotatedImage._cellId = this._cellId;\r\n rotatedImage._cellWidth = n % 1 ? this._cellHeight : this._cellWidth;\r\n rotatedImage._cellHeight = n % 1 ? this._cellWidth : this._cellHeight;\r\n }\r\n\r\n this._handleRotationForSVGImage(this, rotatedImage, n);\r\n\r\n this._imageDataCache.data = null;\r\n\r\n return rotatedImage;\r\n }\r\n\r\n private _handleRotationForSVGImage(srcImage: Image, dstImage: Image, n: number): void {\r\n if (!srcImage._isSVG) {\r\n return;\r\n }\r\n\r\n if (srcImage._svgAttributesComputationCompleted) {\r\n this._rotate90SourceProperties(srcImage, dstImage, n);\r\n this._markAsDirty();\r\n } else {\r\n srcImage.onSVGAttributesComputedObservable.addOnce(() => {\r\n this._rotate90SourceProperties(srcImage, dstImage, n);\r\n this._markAsDirty();\r\n });\r\n }\r\n }\r\n\r\n private _rotate90SourceProperties(srcImage: Image, dstImage: Image, n: number): void {\r\n let srcLeft = srcImage.sourceLeft,\r\n srcTop = srcImage.sourceTop,\r\n srcWidth = srcImage.domImage.width,\r\n srcHeight = srcImage.domImage.height;\r\n\r\n let dstLeft = srcLeft,\r\n dstTop = srcTop,\r\n dstWidth = srcImage.sourceWidth,\r\n dstHeight = srcImage.sourceHeight;\r\n\r\n if (n != 0) {\r\n const mult = n < 0 ? -1 : 1;\r\n n = n % 4;\r\n for (let i = 0; i < Math.abs(n); ++i) {\r\n dstLeft = -(srcTop - srcHeight / 2) * mult + srcHeight / 2;\r\n dstTop = (srcLeft - srcWidth / 2) * mult + srcWidth / 2;\r\n [dstWidth, dstHeight] = [dstHeight, dstWidth];\r\n if (n < 0) {\r\n dstTop -= dstHeight;\r\n } else {\r\n dstLeft -= dstWidth;\r\n }\r\n srcLeft = dstLeft;\r\n srcTop = dstTop;\r\n [srcWidth, srcHeight] = [srcHeight, srcWidth];\r\n }\r\n }\r\n\r\n dstImage.sourceLeft = dstLeft;\r\n dstImage.sourceTop = dstTop;\r\n dstImage.sourceWidth = dstWidth;\r\n dstImage.sourceHeight = dstHeight;\r\n }\r\n\r\n private _extractNinePatchSliceDataFromImage() {\r\n const width = this._domImage.width;\r\n const height = this._domImage.height;\r\n\r\n if (!this._workingCanvas) {\r\n const engine = this._host?.getScene()?.getEngine() || EngineStore.LastCreatedEngine;\r\n if (!engine) {\r\n throw new Error(\"Invalid engine. Unable to create a canvas.\");\r\n }\r\n this._workingCanvas = engine.createCanvas(width, height);\r\n }\r\n const canvas = this._workingCanvas;\r\n const context = canvas.getContext(\"2d\")!;\r\n\r\n context.drawImage(this._domImage, 0, 0, width, height);\r\n const imageData = context.getImageData(0, 0, width, height);\r\n\r\n // Left and right\r\n this._sliceLeft = -1;\r\n this._sliceRight = -1;\r\n for (let x = 0; x < width; x++) {\r\n const alpha = imageData.data[x * 4 + 3];\r\n\r\n if (alpha > 127 && this._sliceLeft === -1) {\r\n this._sliceLeft = x;\r\n continue;\r\n }\r\n\r\n if (alpha < 127 && this._sliceLeft > -1) {\r\n this._sliceRight = x;\r\n break;\r\n }\r\n }\r\n\r\n // top and bottom\r\n this._sliceTop = -1;\r\n this._sliceBottom = -1;\r\n for (let y = 0; y < height; y++) {\r\n const alpha = imageData.data[y * width * 4 + 3];\r\n\r\n if (alpha > 127 && this._sliceTop === -1) {\r\n this._sliceTop = y;\r\n continue;\r\n }\r\n\r\n if (alpha < 127 && this._sliceTop > -1) {\r\n this._sliceBottom = y;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets or sets the internal DOM image used to render the control\r\n */\r\n public set domImage(value: IImage) {\r\n this._domImage = value;\r\n this._loaded = false;\r\n this._imageDataCache.data = null;\r\n\r\n if (this._domImage.width) {\r\n this._onImageLoaded();\r\n } else {\r\n this._domImage.onload = () => {\r\n this._onImageLoaded();\r\n };\r\n }\r\n }\r\n\r\n public get domImage(): IImage {\r\n return this._domImage;\r\n }\r\n\r\n private _onImageLoaded(): void {\r\n this._imageDataCache.data = null;\r\n this._imageWidth = this._domImage.width;\r\n this._imageHeight = this._domImage.height;\r\n this._loaded = true;\r\n\r\n if (this._populateNinePatchSlicesFromImage) {\r\n this._extractNinePatchSliceDataFromImage();\r\n }\r\n\r\n if (this._autoScale) {\r\n this.synchronizeSizeWithContent();\r\n }\r\n\r\n this.onImageLoadedObservable.notifyObservers(this);\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets the image source url\r\n */\r\n @serialize()\r\n public get source() {\r\n return this._source;\r\n }\r\n\r\n /**\r\n * Resets the internal Image Element cache. Can reduce memory usage.\r\n */\r\n public static ResetImageCache() {\r\n Image.SourceImgCache.clear();\r\n }\r\n\r\n private _removeCacheUsage(source: Nullable<string>) {\r\n const value = source && Image.SourceImgCache.get(source);\r\n if (value) {\r\n value.timesUsed -= 1;\r\n\r\n // Remove from DOM\r\n const htmlElement = value.img as HTMLImageElement;\r\n if (htmlElement.parentNode) {\r\n htmlElement.parentNode.removeChild(htmlElement);\r\n }\r\n\r\n // Since the image isn't being used anymore, we can clean it from the cache\r\n if (value.timesUsed === 0) {\r\n Image.SourceImgCache.delete(source);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets or sets image source url\r\n */\r\n public set source(value: Nullable<string>) {\r\n if (this._urlRewriter && value) {\r\n value = this._urlRewriter(value);\r\n }\r\n\r\n if (this._source === value) {\r\n return;\r\n }\r\n\r\n this._removeCacheUsage(this._source);\r\n\r\n this._loaded = false;\r\n this._source = value;\r\n this._imageDataCache.data = null;\r\n\r\n if (value) {\r\n value = this._svgCheck(value);\r\n }\r\n\r\n // Should abstract platform instead of using LastCreatedEngine\r\n const engine = this._host?.getScene()?.getEngine() || EngineStore.LastCreatedEngine;\r\n if (!engine) {\r\n throw new Error(\"Invalid engine. Unable to create a canvas.\");\r\n }\r\n if (value && Image.SourceImgCache.has(value)) {\r\n const cachedData = Image.SourceImgCache.get(value)!;\r\n this._domImage = cachedData.img;\r\n cachedData.timesUsed += 1;\r\n if (cachedData.loaded) {\r\n this._onImageLoaded();\r\n } else {\r\n cachedData.waitingForLoadCallback.push(this._onImageLoaded.bind(this));\r\n }\r\n return;\r\n }\r\n this._domImage = engine.createCanvasImage();\r\n // need to add to enforce rendering\r\n const imgElement = this._domImage as HTMLImageElement;\r\n let addedToDom = false;\r\n if (imgElement.style && this._source?.endsWith(\".svg\")) {\r\n imgElement.style.visibility = \"hidden\";\r\n imgElement.style.position = \"absolute\";\r\n imgElement.style.top = \"0\";\r\n engine.getRenderingCanvas()?.parentNode?.appendChild(imgElement);\r\n addedToDom = true;\r\n }\r\n\r\n if (value) {\r\n Image.SourceImgCache.set(value, { img: this._domImage, timesUsed: 1, loaded: false, waitingForLoadCallback: [this._onImageLoaded.bind(this)] });\r\n }\r\n\r\n this._domImage.onload = () => {\r\n if (value) {\r\n const cachedData = Image.SourceImgCache.get(value);\r\n if (cachedData) {\r\n cachedData.loaded = true;\r\n for (const waitingCallback of cachedData.waitingForLoadCallback) {\r\n waitingCallback();\r\n }\r\n cachedData.waitingForLoadCallback.length = 0;\r\n addedToDom && imgElement.remove();\r\n return;\r\n }\r\n }\r\n this._onImageLoaded();\r\n addedToDom && imgElement.remove();\r\n };\r\n if (value) {\r\n Tools.SetCorsBehavior(value, this._domImage);\r\n Tools.SetReferrerPolicyBehavior(this.referrerPolicy, this._domImage);\r\n this._domImage.src = value;\r\n }\r\n }\r\n\r\n /**\r\n * Checks for svg document with icon id present\r\n * @param value the source svg\r\n * @returns the svg\r\n */\r\n private _svgCheck(value: string): string {\r\n if (window.SVGSVGElement && value.search(/(\\.svg|\\.svg?[?|#].*)$/gi) !== -1 && value.indexOf(\"#\") === value.lastIndexOf(\"#\")) {\r\n this._isSVG = true;\r\n const svgsrc = value.split(\"#\")[0];\r\n const elemid = value.split(\"#\")[1];\r\n // check if object alr exist in document\r\n const svgExist = <HTMLObjectElement>document.body.querySelector('object[data=\"' + svgsrc + '\"]');\r\n if (svgExist) {\r\n const svgDoc = svgExist.contentDocument;\r\n // get viewbox width and height, get svg document width and height in px\r\n if (svgDoc && svgDoc.documentElement) {\r\n const vb = svgDoc.documentElement.getAttribute(\"viewBox\");\r\n const docwidth = Number(svgDoc.documentElement.getAttribute(\"width\"));\r\n const docheight = Number(svgDoc.documentElement.getAttribute(\"height\"));\r\n const elem = <SVGGraphicsElement>(<unknown>svgDoc.getElementById(elemid));\r\n if (elem && vb && docwidth && docheight) {\r\n this._getSVGAttribs(svgExist, elemid);\r\n return value;\r\n }\r\n }\r\n\r\n // wait for object to load\r\n svgExist.addEventListener(\"load\", () => {\r\n this._getSVGAttribs(svgExist, elemid);\r\n });\r\n } else {\r\n // create document object\r\n const svgImage = document.createElement(\"object\");\r\n svgImage.data = svgsrc;\r\n svgImage.type = \"image/svg+xml\";\r\n svgImage.width = \"0%\";\r\n svgImage.height = \"0%\";\r\n document.body.appendChild(svgImage);\r\n // when the object has loaded, get the element attribs\r\n svgImage.onload = () => {\r\n const svgobj = <HTMLObjectElement>document.body.querySelector('object[data=\"' + svgsrc + '\"]');\r\n if (svgobj) {\r\n this._getSVGAttribs(svgobj, elemid);\r\n }\r\n };\r\n }\r\n return svgsrc;\r\n } else {\r\n return value;\r\n }\r\n }\r\n\r\n /**\r\n * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically\r\n * given external svg file and icon id\r\n * @param svgsrc\r\n * @param elemid\r\n */\r\n private _getSVGAttribs(svgsrc: HTMLObjectElement, elemid: string) {\r\n const svgDoc = svgsrc.contentDocument;\r\n // get viewbox width and height, get svg document width and height in px\r\n if (svgDoc && svgDoc.documentElement) {\r\n const vb = svgDoc.documentElement.getAttribute(\"viewBox\");\r\n const docwidth = Number(svgDoc.documentElement.getAttribute(\"width\"));\r\n const docheight = Number(svgDoc.documentElement.getAttribute(\"height\"));\r\n // get element bbox and matrix transform\r\n const elem = svgDoc.getElementById(elemid) as Nullable<SVGGraphicsElement>;\r\n if (vb && docwidth && docheight && elem) {\r\n const vb_width = Number(vb.split(\" \")[2]);\r\n const vb_height = Number(vb.split(\" \")[3]);\r\n const elem_bbox = elem.getBBox();\r\n let elem_matrix_a = 1;\r\n let elem_matrix_d = 1;\r\n let elem_matrix_e = 0;\r\n let elem_matrix_f = 0;\r\n const mainMatrix = elem.transform.baseVal.consolidate()!.matrix;\r\n if (elem.transform && elem.transform.baseVal.consolidate()) {\r\n elem_matrix_a = mainMatrix.a;\r\n elem_matrix_d = mainMatrix.d;\r\n elem_matrix_e = mainMatrix.e;\r\n elem_matrix_f = mainMatrix.f;\r\n }\r\n\r\n // compute source coordinates and dimensions\r\n this.sourceLeft = ((elem_matrix_a * elem_bbox.x + elem_matrix_e) * docwidth) / vb_width;\r\n this.sourceTop = ((elem_matrix_d * elem_bbox.y + elem_matrix_f) * docheight) / vb_height;\r\n this.sourceWidth = elem_bbox.width * elem_matrix_a * (docwidth / vb_width);\r\n this.sourceHeight = elem_bbox.height * elem_matrix_d * (docheight / vb_height);\r\n this._svgAttributesComputationCompleted = true;\r\n this.onSVGAttributesComputedObservable.notifyObservers(this);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets or sets the cell width to use when animation sheet is enabled\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/gui/gui#image\r\n */\r\n @serialize()\r\n get cellWidth(): number {\r\n return this._cellWidth;\r\n }\r\n set cellWidth(value: number) {\r\n if (this._cellWidth === value) {\r\n return;\r\n }\r\n\r\n this._cellWidth = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets the cell height to use when animation sheet is enabled\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/gui/gui#image\r\n */\r\n @serialize()\r\n get cellHeight(): number {\r\n return this._cellHeight;\r\n }\r\n set cellHeight(value: number) {\r\n if (this._cellHeight === value) {\r\n return;\r\n }\r\n\r\n this._cellHeight = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets the cell id to use (this will turn on the animation sheet mode)\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/gui/gui#image\r\n */\r\n @serialize()\r\n get cellId(): number {\r\n return this._cellId;\r\n }\r\n set cellId(value: number) {\r\n if (this._cellId === value) {\r\n return;\r\n }\r\n\r\n this._cellId = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Creates a new Image\r\n * @param name defines the control name\r\n * @param url defines the image url\r\n */\r\n constructor(\r\n public override name?: string,\r\n url: Nullable<string> = null\r\n ) {\r\n super(name);\r\n this.source = url;\r\n }\r\n\r\n /**\r\n * Tests if a given coordinates belong to the current control\r\n * @param x defines x coordinate to test\r\n * @param y defines y coordinate to test\r\n * @returns true if the coordinates are inside the control\r\n */\r\n public override contains(x: number, y: number): boolean {\r\n if (!super.contains(x, y)) {\r\n return false;\r\n }\r\n\r\n if (!this._detectPointerOnOpaqueOnly || !this._workingCanvas) {\r\n return true;\r\n }\r\n\r\n const width = this._currentMeasure.width | 0;\r\n const height = this._currentMeasure.height | 0;\r\n const key = width + \"_\" + height;\r\n\r\n let imageData = this._imageDataCache.data;\r\n\r\n if (!imageData || this._imageDataCache.key !== key) {\r\n const canvas = this._workingCanvas;\r\n const context = canvas.getContext(\"2d\")!;\r\n\r\n this._imageDataCache.data = imageData = context.getImageData(0, 0, width, height).data;\r\n this._imageDataCache.key = key;\r\n }\r\n\r\n x = (x - this._currentMeasure.left) | 0;\r\n y = (y - this._currentMeasure.top) | 0;\r\n\r\n const pickedPixel = imageData[(x + y * width) * 4 + 3];\r\n\r\n return pickedPixel > 0;\r\n }\r\n\r\n protected override _getTypeName(): string {\r\n return \"Image\";\r\n }\r\n\r\n /** Force the control to synchronize with its content */\r\n public synchronizeSizeWithContent() {\r\n if (!this._loaded) {\r\n return;\r\n }\r\n\r\n this.width = this._domImage.width + \"px\";\r\n this.height = this._domImage.height + \"px\";\r\n }\r\n\r\n protected override _processMeasures(parentMeasure: Measure, context: ICanvasRenderingContext): void {\r\n if (this._loaded) {\r\n switch (this._stretch) {\r\n case Image.STRETCH_NONE:\r\n break;\r\n case Image.STRETCH_FILL:\r\n break;\r\n case Image.STRETCH_UNIFORM:\r\n break;\r\n case Image.STRETCH_NINE_PATCH:\r\n break;\r\n case Image.STRETCH_EXTEND:\r\n if (this._autoScale) {\r\n this.synchronizeSizeWithContent();\r\n }\r\n if (this.parent && this.parent.parent) {\r\n // Will update root size if root is not the top root\r\n this.parent.adaptWidthToChildren = true;\r\n this.parent.adaptHeightToChildren = true;\r\n }\r\n break;\r\n }\r\n }\r\n\r\n super._processMeasures(parentMeasure, context);\r\n }\r\n\r\n private _prepareWorkingCanvasForOpaqueDetection() {\r\n if (!this._detectPointerOnOpaqueOnly) {\r\n return;\r\n }\r\n\r\n const width = this._currentMeasure.width;\r\n const height = this._currentMeasure.height;\r\n\r\n if (!this._workingCanvas) {\r\n const engine = this._host?.getScene()?.getEngine() || EngineStore.LastCreatedEngine;\r\n if (!engine) {\r\n throw new Error(\"Invalid engine. Unable to create a canvas.\");\r\n }\r\n this._workingCanvas = engine.createCanvas(width, height);\r\n }\r\n const canvas = this._workingCanvas;\r\n\r\n const context = canvas.getContext(\"2d\")!;\r\n\r\n context.clearRect(0, 0, width, height);\r\n }\r\n\r\n private _drawImage(context: ICanvasRenderingContext, sx: number, sy: number, sw: number, sh: number, tx: number, ty: number, tw: number, th: number) {\r\n context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);\r\n\r\n if (!this._detectPointerOnOpaqueOnly) {\r\n return;\r\n }\r\n\r\n const transform = context.getTransform();\r\n\r\n const canvas = this._workingCanvas!;\r\n const workingCanvasContext = canvas.getContext(\"2d\")!;\r\n workingCanvasContext.save();\r\n const ttx = tx - this._currentMeasure.left;\r\n const tty = ty - this._currentMeasure.top;\r\n workingCanvasContext.setTransform(transform.a, transform.b, transform.c, transform.d, (ttx + tw) / 2, (tty + th) / 2);\r\n workingCanvasContext.translate(-(ttx + tw) / 2, -(tty + th) / 2);\r\n\r\n workingCanvasContext.drawImage(this._domImage, sx, sy, sw, sh, ttx, tty, tw, th);\r\n workingCanvasContext.restore();\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 let x, y, width, height;\r\n if (this.cellId == -1) {\r\n x = this._sourceLeft;\r\n y = this._sourceTop;\r\n\r\n width = this._sourceWidth ? this._sourceWidth : this._imageWidth;\r\n height = this._sourceHeight ? this._sourceHeight : this._imageHeight;\r\n } else {\r\n const rowCount = this._domImage.naturalWidth / this.cellWidth;\r\n const column = (this.cellId / rowCount) >> 0;\r\n const row = this.cellId % rowCount;\r\n\r\n x = this.cellWidth * row;\r\n y = this.cellHeight * column;\r\n width = this.cellWidth;\r\n height = this.cellHeight;\r\n }\r\n\r\n this._prepareWorkingCanvasForOpaqueDetection();\r\n\r\n this._applyStates(context);\r\n if (this._loaded) {\r\n switch (this._stretch) {\r\n case Image.STRETCH_NONE:\r\n this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);\r\n break;\r\n case Image.STRETCH_FILL:\r\n this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);\r\n break;\r\n case Image.STRETCH_UNIFORM: {\r\n const hRatio = this._currentMeasure.width / width;\r\n const vRatio = this._currentMeasure.height / height;\r\n const ratio = Math.min(hRatio, vRatio);\r\n const centerX = (this._currentMeasure.width - width * ratio) / 2;\r\n const centerY = (this._currentMeasure.height - height * ratio) / 2;\r\n\r\n this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);\r\n break;\r\n }\r\n case Image.STRETCH_EXTEND:\r\n this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);\r\n break;\r\n case Image.STRETCH_NINE_PATCH:\r\n this._renderNinePatch(context, x, y, width, height);\r\n break;\r\n }\r\n }\r\n\r\n context.restore();\r\n }\r\n\r\n private _renderNinePatch(context: ICanvasRenderingContext, sx: number, sy: number, sw: number, sh: number): void {\r\n const idealRatio = this.host.idealWidth\r\n ? this._width.getValue(this.host) / this.host.idealWidth\r\n : this.host.idealHeight\r\n ? this._height.getValue(this.host) / this.host.idealHeight\r\n : 1;\r\n const leftWidth = this._sliceLeft;\r\n const topHeight = this._sliceTop;\r\n const bottomHeight = sh - this._sliceBottom;\r\n const rightWidth = sw - this._sliceRight;\r\n const centerWidth = this._sliceRight - this._sliceLeft;\r\n const centerHeight = this._sliceBottom - this._sliceTop;\r\n const leftWidthAdjusted = Math.round(leftWidth * idealRatio);\r\n const topHeightAdjusted = Math.round(topHeight * idealRatio);\r\n const bottomHeightAdjusted = Math.round(bottomHeight * idealRatio);\r\n const rightWidthAdjusted = Math.round(rightWidth * idealRatio);\r\n const targetCenterWidth = Math.round(this._currentMeasure.width) - rightWidthAdjusted - leftWidthAdjusted + 2;\r\n const targetCenterHeight = Math.round(this._currentMeasure.height) - bottomHeightAdjusted - topHeightAdjusted + 2;\r\n const centerLeftOffset = Math.round(this._currentMeasure.left) + leftWidthAdjusted - 1;\r\n const centerTopOffset = Math.round(this._currentMeasure.top) + topHeightAdjusted - 1;\r\n const rightOffset = Math.round(this._currentMeasure.left + this._currentMeasure.width) - rightWidthAdjusted;\r\n const bottomOffset = Math.round(this._currentMeasure.top + this._currentMeasure.height) - bottomHeightAdjusted;\r\n\r\n //Top Left\r\n this._drawImage(context, sx, sy, leftWidth, topHeight, this._currentMeasure.left, this._currentMeasure.top, leftWidthAdjusted, topHeightAdjusted);\r\n //Top\r\n this._drawImage(context, sx + this._sliceLeft, sy, centerWidth, topHeight, centerLeftOffset + 1, this._currentMeasure.top, targetCenterWidth - 2, topHeightAdjusted);\r\n //Top Right\r\n this._drawImage(context, sx + this._sliceRight, sy, rightWidth, topHeight, rightOffset, this._currentMeasure.top, rightWidthAdjusted, topHeightAdjusted);\r\n //Left\r\n this._drawImage(context, sx, sy + this._sliceTop, leftWidth, centerHeight, this._currentMeasure.left, centerTopOffset + 1, leftWidthAdjusted, targetCenterHeight - 2);\r\n // Center\r\n this._drawImage(\r\n context,\r\n sx + this._sliceLeft,\r\n sy + this._sliceTop,\r\n centerWidth,\r\n centerHeight,\r\n centerLeftOffset + 1,\r\n centerTopOffset + 1,\r\n targetCenterWidth - 2,\r\n targetCenterHeight - 2\r\n );\r\n //Right\r\n this._drawImage(\r\n context,\r\n sx + this._sliceRight,\r\n sy + this._sliceTop,\r\n rightWidth,\r\n centerHeight,\r\n rightOffset,\r\n centerTopOffset + 1,\r\n rightWidthAdjusted,\r\n targetCenterHeight - 2\r\n );\r\n //Bottom Left\r\n this._drawImage(context, sx, sy + this._sliceBottom, leftWidth, bottomHeight, this._currentMeasure.left, bottomOffset, leftWidthAdjusted, bottomHeightAdjusted);\r\n //Bottom\r\n this._drawImage(\r\n context,\r\n sx + this.sliceLeft,\r\n sy + this._sliceBottom,\r\n centerWidth,\r\n bottomHeight,\r\n centerLeftOffset + 1,\r\n bottomOffset,\r\n targetCenterWidth - 2,\r\n bottomHeightAdjusted\r\n );\r\n //Bottom Right\r\n this._drawImage(context, sx + this._sliceRight, sy + this._sliceBottom, rightWidth, bottomHeight, rightOffset, bottomOffset, rightWidthAdjusted, bottomHeightAdjusted);\r\n }\r\n\r\n public override dispose() {\r\n super.dispose();\r\n this.onImageLoadedObservable.clear();\r\n this.onSVGAttributesComputedObservable.clear();\r\n this._removeCacheUsage(this._source);\r\n }\r\n\r\n // Static\r\n /** STRETCH_NONE */\r\n public static readonly STRETCH_NONE = 0;\r\n /** STRETCH_FILL */\r\n public static readonly STRETCH_FILL = 1;\r\n /** STRETCH_UNIFORM */\r\n public static readonly STRETCH_UNIFORM = 2;\r\n /** STRETCH_EXTEND */\r\n public static readonly STRETCH_EXTEND = 3;\r\n /** NINE_PATCH */\r\n public static readonly STRETCH_NINE_PATCH = 4;\r\n}\r\nRegisterClass(\"BABYLON.GUI.Image\", Image);\r\n"]}
@@ -22,7 +22,11 @@ export declare const enum TextWrapping {
22
22
  /**
23
23
  * Wrap the text word-wise and clip the text when the text's height is larger than the Control.height, and shrink the last line with trailing … .
24
24
  */
25
- WordWrapEllipsis = 3
25
+ WordWrapEllipsis = 3,
26
+ /**
27
+ * Use HTML to wrap the text. This is the only mode that supports east-asian languages.
28
+ */
29
+ HTML = 4
26
30
  }
27
31
  /**
28
32
  * Class used to create text block control
@@ -58,6 +62,16 @@ export declare class TextBlock extends Control {
58
62
  * Function used to split a string into words. By default, a string is split at each space character found
59
63
  */
60
64
  wordSplittingFunction: Nullable<(line: string) => string[]>;
65
+ /**
66
+ * This function will be called when a new HTML element is generated to be used for word wrapping.
67
+ * This is only used when wrapping mode HTML is selected.
68
+ * Using this function you can adjust word-break, overflow-wrap, hyphens, or any other CSS properties of the HTML element, language-dependent.
69
+ */
70
+ adjustWordWrappingHTMLElement: Nullable<(element: HTMLElement) => void>;
71
+ /**
72
+ * Gets or sets a boolean indicating if the HTML element generated for word wrapping should be reused or removed after each wrapping.
73
+ */
74
+ reuseHTMLForWordWrapping: boolean;
61
75
  /**
62
76
  * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
63
77
  */
@@ -185,6 +199,8 @@ export declare class TextBlock extends Control {
185
199
  protected _applyStates(context: ICanvasRenderingContext): void;
186
200
  private _linesTemp;
187
201
  protected _breakLines(refWidth: number, refHeight: number, context: ICanvasRenderingContext): object[];
202
+ private _htmlElement;
203
+ protected _parseHTMLText(refWidth: number, refHeight: number, context: ICanvasRenderingContext): string[];
188
204
  protected _parseLine(line: string | undefined, context: ICanvasRenderingContext): object;
189
205
  private _getCharsToRemove;
190
206
  protected _parseLineEllipsis(line: string | undefined, width: number, context: ICanvasRenderingContext): object;
@@ -26,6 +26,10 @@ export var TextWrapping;
26
26
  * Wrap the text word-wise and clip the text when the text's height is larger than the Control.height, and shrink the last line with trailing … .
27
27
  */
28
28
  TextWrapping[TextWrapping["WordWrapEllipsis"] = 3] = "WordWrapEllipsis";
29
+ /**
30
+ * Use HTML to wrap the text. This is the only mode that supports east-asian languages.
31
+ */
32
+ TextWrapping[TextWrapping["HTML"] = 4] = "HTML";
29
33
  })(TextWrapping || (TextWrapping = {}));
30
34
  /**
31
35
  * Class used to create text block control
@@ -279,7 +283,12 @@ export class TextBlock extends Control {
279
283
  * An event triggered after the text was broken up into lines
280
284
  */
281
285
  this.onLinesReadyObservable = new Observable();
286
+ /**
287
+ * Gets or sets a boolean indicating if the HTML element generated for word wrapping should be reused or removed after each wrapping.
288
+ */
289
+ this.reuseHTMLForWordWrapping = false;
282
290
  this._linesTemp = [];
291
+ this._htmlElement = null;
283
292
  this.text = text;
284
293
  }
285
294
  _getTypeName() {
@@ -394,29 +403,70 @@ export class TextBlock extends Control {
394
403
  }
395
404
  _breakLines(refWidth, refHeight, context) {
396
405
  this._linesTemp.length = 0;
397
- const _lines = this.text.split("\n");
398
- if (this._textWrapping === 2 /* TextWrapping.Ellipsis */) {
399
- for (const _line of _lines) {
400
- this._linesTemp.push(this._parseLineEllipsis(_line, refWidth, context));
401
- }
402
- }
403
- else if (this._textWrapping === 1 /* TextWrapping.WordWrap */) {
404
- for (const _line of _lines) {
405
- this._linesTemp.push(...this._parseLineWordWrap(_line, refWidth, context));
406
- }
407
- }
408
- else if (this._textWrapping === 3 /* TextWrapping.WordWrapEllipsis */) {
409
- for (const _line of _lines) {
410
- this._linesTemp.push(...this._parseLineWordWrapEllipsis(_line, refWidth, refHeight, context));
411
- }
412
- }
413
- else {
414
- for (const _line of _lines) {
415
- this._linesTemp.push(this._parseLine(_line, context));
416
- }
406
+ const _lines = this._textWrapping === 4 /* TextWrapping.HTML */ ? this._parseHTMLText(refWidth, refHeight, context) : this.text.split("\n");
407
+ switch (this._textWrapping) {
408
+ case 1 /* TextWrapping.WordWrap */:
409
+ for (const _line of _lines) {
410
+ this._linesTemp.push(...this._parseLineWordWrap(_line, refWidth, context));
411
+ }
412
+ break;
413
+ case 2 /* TextWrapping.Ellipsis */:
414
+ for (const _line of _lines) {
415
+ this._linesTemp.push(this._parseLineEllipsis(_line, refWidth, context));
416
+ }
417
+ break;
418
+ case 3 /* TextWrapping.WordWrapEllipsis */:
419
+ for (const _line of _lines) {
420
+ this._linesTemp.push(...this._parseLineWordWrapEllipsis(_line, refWidth, refHeight, context));
421
+ }
422
+ break;
423
+ case 4 /* TextWrapping.HTML */:
424
+ default:
425
+ for (const _line of _lines) {
426
+ this._linesTemp.push(this._parseLine(_line, context));
427
+ }
428
+ break;
417
429
  }
418
430
  return this._linesTemp;
419
431
  }
432
+ _parseHTMLText(refWidth, refHeight, context) {
433
+ const lines = [];
434
+ if (!this._htmlElement) {
435
+ this._htmlElement = document.createElement("div");
436
+ document.body.appendChild(this._htmlElement);
437
+ }
438
+ const htmlElement = this._htmlElement;
439
+ htmlElement.textContent = this.text;
440
+ htmlElement.style.font = context.font;
441
+ htmlElement.style.position = "absolute";
442
+ htmlElement.style.visibility = "hidden";
443
+ htmlElement.style.top = "-1000px";
444
+ htmlElement.style.left = "-1000px";
445
+ this.adjustWordWrappingHTMLElement?.(htmlElement);
446
+ htmlElement.style.width = refWidth + "px";
447
+ htmlElement.style.height = refHeight + "px";
448
+ const textContent = htmlElement.textContent;
449
+ if (!textContent) {
450
+ return lines;
451
+ }
452
+ // get the text node
453
+ const textNode = htmlElement.childNodes[0];
454
+ const range = document.createRange();
455
+ let idx = 0;
456
+ for (const c of textContent) {
457
+ range.setStart(textNode, 0);
458
+ range.setEnd(textNode, idx + 1);
459
+ // "select" text from beginning to this position to determine the line
460
+ const lineIndex = range.getClientRects().length - 1;
461
+ lines[lineIndex] = (lines[lineIndex] || "") + c;
462
+ idx++;
463
+ }
464
+ if (!this.reuseHTMLForWordWrapping) {
465
+ htmlElement.remove();
466
+ this._htmlElement = null;
467
+ }
468
+ return lines;
469
+ }
420
470
  _parseLine(line = "", context) {
421
471
  return { text: line, width: this._getTextMetricsWidth(context.measureText(line)) };
422
472
  }
@@ -573,6 +623,8 @@ export class TextBlock extends Control {
573
623
  dispose() {
574
624
  super.dispose();
575
625
  this.onTextChangedObservable.clear();
626
+ this._htmlElement?.remove();
627
+ this._htmlElement = null;
576
628
  }
577
629
  }
578
630
  __decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"textBlock.js","sourceRoot":"","sources":["../../../../../dev/gui/src/2D/controls/textBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,2CAA6B;AAElD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,0CAA4B;AAEpD,OAAO,EAAE,SAAS,EAAE,2CAA6B;AAEjD,OAAO,EAAE,WAAW,EAAE,+CAAiC;AAEvD;;GAEG;AACH,MAAM,CAAN,IAAkB,YAoBjB;AApBD,WAAkB,YAAY;IAC1B;;OAEG;IACH,+C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AmBD;IADC,SAAS,EAAE;iDAGX;AA+WL,aAAa,CAAC,uBAAuB,EAAE,SAAS,CAAC,CAAC","sourcesContent":["import { Observable } from \"core/Misc/observable\";\r\nimport type { Measure } from \"../measure\";\r\nimport { ValueAndUnit } from \"../valueAndUnit\";\r\nimport { Control } from \"./control\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport type { Nullable } from \"core/types\";\r\nimport { serialize } from \"core/Misc/decorators\";\r\nimport type { ICanvasRenderingContext, ITextMetrics } from \"core/Engines/ICanvas\";\r\nimport { EngineStore } from \"core/Engines/engineStore\";\r\n\r\n/**\r\n * Enum that determines the text-wrapping mode to use.\r\n */\r\nexport const enum TextWrapping {\r\n /**\r\n * Clip the text when it's larger than Control.width; this is the default mode.\r\n */\r\n Clip = 0,\r\n\r\n /**\r\n * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.\r\n */\r\n WordWrap = 1,\r\n\r\n /**\r\n * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.\r\n */\r\n Ellipsis = 2,\r\n\r\n /**\r\n * Wrap the text word-wise and clip the text when the text's height is larger than the Control.height, and shrink the last line with trailing … .\r\n */\r\n WordWrapEllipsis,\r\n}\r\n\r\n/**\r\n * Class used to create text block control\r\n */\r\nexport class TextBlock extends Control {\r\n private _text = \"\";\r\n private _textWrapping = TextWrapping.Clip;\r\n private _textHorizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;\r\n private _textVerticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;\r\n\r\n private _lines: any[];\r\n private _resizeToFit: boolean = false;\r\n private _lineSpacing: ValueAndUnit = new ValueAndUnit(0);\r\n private _outlineWidth: number = 0;\r\n private _outlineColor: string = \"white\";\r\n private _underline: boolean = false;\r\n private _lineThrough: boolean = false;\r\n private _wordDivider: string = \" \";\r\n private _forceResizeWidth: boolean = false;\r\n private _applyOutlineToUnderline: boolean = false;\r\n\r\n /**\r\n * An event triggered after the text is changed\r\n */\r\n public onTextChangedObservable = new Observable<TextBlock>();\r\n\r\n /**\r\n * An event triggered after the text was broken up into lines\r\n */\r\n public onLinesReadyObservable = new Observable<TextBlock>();\r\n\r\n /**\r\n * Function used to split a string into words. By default, a string is split at each space character found\r\n */\r\n public wordSplittingFunction: Nullable<(line: string) => string[]>;\r\n\r\n /**\r\n * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)\r\n */\r\n public get lines(): any[] {\r\n return this._lines;\r\n }\r\n\r\n /**\r\n * Gets or sets a boolean indicating that the TextBlock will be resized to fit its content\r\n\r\n */\r\n @serialize()\r\n public get resizeToFit(): boolean {\r\n return this._resizeToFit;\r\n }\r\n\r\n /**\r\n * Gets or sets a boolean indicating that the TextBlock will be resized to fit its content\r\n\r\n */\r\n public set resizeToFit(value: boolean) {\r\n if (this._resizeToFit === value) {\r\n return;\r\n }\r\n this._resizeToFit = value;\r\n\r\n if (this._resizeToFit) {\r\n this._width.ignoreAdaptiveScaling = true;\r\n this._height.ignoreAdaptiveScaling = true;\r\n }\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets a boolean indicating if text must be wrapped\r\n */\r\n @serialize()\r\n public get textWrapping(): TextWrapping | boolean {\r\n return this._textWrapping;\r\n }\r\n\r\n /**\r\n * Gets or sets a boolean indicating if text must be wrapped\r\n */\r\n public set textWrapping(value: TextWrapping | boolean) {\r\n if (this._textWrapping === value) {\r\n return;\r\n }\r\n this._textWrapping = +value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets text to display\r\n */\r\n @serialize()\r\n public get text(): string {\r\n return this._text;\r\n }\r\n\r\n /**\r\n * Gets or sets text to display\r\n */\r\n public set text(value: string) {\r\n if (this._text === value) {\r\n return;\r\n }\r\n this._text = value + \"\"; // Making sure it is a text\r\n this._markAsDirty();\r\n\r\n this.onTextChangedObservable.notifyObservers(this);\r\n }\r\n\r\n /**\r\n * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)\r\n */\r\n @serialize()\r\n public get textHorizontalAlignment(): number {\r\n return this._textHorizontalAlignment;\r\n }\r\n\r\n /**\r\n * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)\r\n */\r\n public set textHorizontalAlignment(value: number) {\r\n if (this._textHorizontalAlignment === value) {\r\n return;\r\n }\r\n\r\n this._textHorizontalAlignment = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)\r\n */\r\n @serialize()\r\n public get textVerticalAlignment(): number {\r\n return this._textVerticalAlignment;\r\n }\r\n\r\n /**\r\n * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)\r\n */\r\n public set textVerticalAlignment(value: number) {\r\n if (this._textVerticalAlignment === value) {\r\n return;\r\n }\r\n\r\n this._textVerticalAlignment = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets line spacing value\r\n */\r\n @serialize()\r\n public set lineSpacing(value: string | number) {\r\n if (this._lineSpacing.fromString(value)) {\r\n this._markAsDirty();\r\n }\r\n }\r\n\r\n /**\r\n * Gets or sets line spacing value\r\n */\r\n public get lineSpacing(): string | number {\r\n return this._lineSpacing.toString(this._host);\r\n }\r\n\r\n /**\r\n * Gets or sets outlineWidth of the text to display\r\n */\r\n @serialize()\r\n public get outlineWidth(): number {\r\n return this._outlineWidth;\r\n }\r\n\r\n /**\r\n * Gets or sets outlineWidth of the text to display\r\n */\r\n public set outlineWidth(value: number) {\r\n if (this._outlineWidth === value) {\r\n return;\r\n }\r\n this._outlineWidth = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets a boolean indicating that text must have underline\r\n */\r\n @serialize()\r\n public get underline(): boolean {\r\n return this._underline;\r\n }\r\n\r\n /**\r\n * Gets or sets a boolean indicating that text must have underline\r\n */\r\n public set underline(value: boolean) {\r\n if (this._underline === value) {\r\n return;\r\n }\r\n this._underline = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets an boolean indicating that text must be crossed out\r\n */\r\n @serialize()\r\n public get lineThrough(): boolean {\r\n return this._lineThrough;\r\n }\r\n\r\n /**\r\n * Gets or sets an boolean indicating that text must be crossed out\r\n */\r\n public set lineThrough(value: boolean) {\r\n if (this._lineThrough === value) {\r\n return;\r\n }\r\n this._lineThrough = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * If the outline should be applied to the underline/strike-through too. Has different behavior in Edge/Chrome vs Firefox.\r\n */\r\n @serialize()\r\n public get applyOutlineToUnderline(): boolean {\r\n return this._applyOutlineToUnderline;\r\n }\r\n\r\n public set applyOutlineToUnderline(value: boolean) {\r\n if (this._applyOutlineToUnderline === value) {\r\n return;\r\n }\r\n this._applyOutlineToUnderline = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets outlineColor of the text to display\r\n */\r\n @serialize()\r\n public get outlineColor(): string {\r\n return this._outlineColor;\r\n }\r\n\r\n /**\r\n * Gets or sets outlineColor of the text to display\r\n */\r\n public set outlineColor(value: string) {\r\n if (this._outlineColor === value) {\r\n return;\r\n }\r\n this._outlineColor = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets word divider\r\n */\r\n @serialize()\r\n public get wordDivider(): string {\r\n return this._wordDivider;\r\n }\r\n\r\n /**\r\n * Gets or sets word divider\r\n */\r\n public set wordDivider(value: string) {\r\n if (this._wordDivider === value) {\r\n return;\r\n }\r\n this._wordDivider = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * By default, if a text block has text wrapping other than Clip, its width\r\n * is not resized even if resizeToFit = true. This parameter forces the width\r\n * to be resized.\r\n */\r\n @serialize()\r\n public get forceResizeWidth(): boolean {\r\n return this._forceResizeWidth;\r\n }\r\n\r\n public set forceResizeWidth(value: boolean) {\r\n if (this._forceResizeWidth === value) {\r\n return;\r\n }\r\n this._forceResizeWidth = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Creates a new TextBlock object\r\n * @param name defines the name of the control\r\n * @param text defines the text to display (empty string by default)\r\n */\r\n constructor(\r\n /**\r\n * Defines the name of the control\r\n */\r\n public override name?: string,\r\n text: string = \"\"\r\n ) {\r\n super(name);\r\n\r\n this.text = text;\r\n }\r\n\r\n protected override _getTypeName(): string {\r\n return \"TextBlock\";\r\n }\r\n\r\n protected override _processMeasures(parentMeasure: Measure, context: ICanvasRenderingContext): void {\r\n if (!this._fontOffset || this.isDirty) {\r\n this._fontOffset = Control._GetFontOffset(context.font, this._host.getScene()?.getEngine());\r\n }\r\n super._processMeasures(parentMeasure, context);\r\n\r\n // Prepare lines\r\n this._lines = this._breakLines(this._currentMeasure.width, this._currentMeasure.height, context);\r\n this.onLinesReadyObservable.notifyObservers(this);\r\n\r\n let maxLineWidth: number = 0;\r\n\r\n for (let i = 0; i < this._lines.length; i++) {\r\n const line = this._lines[i];\r\n\r\n if (line.width > maxLineWidth) {\r\n maxLineWidth = line.width;\r\n }\r\n }\r\n\r\n if (this._resizeToFit) {\r\n if (this._textWrapping === TextWrapping.Clip || this._forceResizeWidth) {\r\n const newWidth = Math.ceil(this._paddingLeftInPixels) + Math.ceil(this._paddingRightInPixels) + Math.ceil(maxLineWidth);\r\n if (newWidth !== this._width.getValueInPixel(this._host, this._tempParentMeasure.width)) {\r\n this._width.updateInPlace(newWidth, ValueAndUnit.UNITMODE_PIXEL);\r\n this._rebuildLayout = true;\r\n }\r\n }\r\n let newHeight = (this._paddingTopInPixels + this._paddingBottomInPixels + this._fontOffset.height * this._lines.length) | 0;\r\n\r\n if (this._lines.length > 0 && this._lineSpacing.internalValue !== 0) {\r\n let lineSpacing = 0;\r\n if (this._lineSpacing.isPixel) {\r\n lineSpacing = this._lineSpacing.getValue(this._host);\r\n } else {\r\n lineSpacing = this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);\r\n }\r\n\r\n newHeight += (this._lines.length - 1) * lineSpacing;\r\n }\r\n\r\n if (newHeight !== this._height.internalValue) {\r\n this._height.updateInPlace(newHeight, ValueAndUnit.UNITMODE_PIXEL);\r\n this._rebuildLayout = true;\r\n }\r\n }\r\n }\r\n\r\n private _drawText(text: string, textWidth: number, y: number, context: ICanvasRenderingContext): void {\r\n const width = this._currentMeasure.width;\r\n let x = 0;\r\n switch (this._textHorizontalAlignment) {\r\n case Control.HORIZONTAL_ALIGNMENT_LEFT:\r\n x = 0;\r\n break;\r\n case Control.HORIZONTAL_ALIGNMENT_RIGHT:\r\n x = width - textWidth;\r\n break;\r\n case Control.HORIZONTAL_ALIGNMENT_CENTER:\r\n x = (width - textWidth) / 2;\r\n break;\r\n }\r\n\r\n if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {\r\n context.shadowColor = this.shadowColor;\r\n context.shadowBlur = this.shadowBlur;\r\n context.shadowOffsetX = this.shadowOffsetX;\r\n context.shadowOffsetY = this.shadowOffsetY;\r\n }\r\n\r\n if (this.outlineWidth) {\r\n context.strokeText(text, this._currentMeasure.left + x, y);\r\n }\r\n context.fillText(text, this._currentMeasure.left + x, y);\r\n\r\n if (this._underline) {\r\n this._drawLine(this._currentMeasure.left + x, y + 3, this._currentMeasure.left + x + textWidth, y + 3, context);\r\n }\r\n\r\n if (this._lineThrough) {\r\n this._drawLine(this._currentMeasure.left + x, y - this.fontSizeInPixels / 3, this._currentMeasure.left + x + textWidth, y - this.fontSizeInPixels / 3, context);\r\n }\r\n }\r\n\r\n private _drawLine(xFrom: number, yFrom: number, xTo: number, yTo: number, context: ICanvasRenderingContext): void {\r\n context.beginPath();\r\n context.lineWidth = Math.round(this.fontSizeInPixels * 0.05);\r\n context.moveTo(xFrom, yFrom);\r\n context.lineTo(xTo, yTo);\r\n if (this.outlineWidth && this.applyOutlineToUnderline) {\r\n context.stroke();\r\n context.fill();\r\n } else {\r\n const currentStroke = context.strokeStyle;\r\n context.strokeStyle = context.fillStyle;\r\n context.stroke();\r\n context.strokeStyle = currentStroke;\r\n }\r\n context.closePath();\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public override _draw(context: ICanvasRenderingContext): void {\r\n context.save();\r\n\r\n this._applyStates(context);\r\n\r\n // Render lines\r\n this._renderLines(context);\r\n\r\n context.restore();\r\n }\r\n\r\n protected override _applyStates(context: ICanvasRenderingContext): void {\r\n super._applyStates(context);\r\n if (this.outlineWidth) {\r\n context.lineWidth = this.outlineWidth;\r\n context.strokeStyle = this.outlineColor;\r\n context.lineJoin = \"miter\";\r\n context.miterLimit = 2;\r\n }\r\n }\r\n\r\n private _linesTemp: object[] = [];\r\n\r\n protected _breakLines(refWidth: number, refHeight: number, context: ICanvasRenderingContext): object[] {\r\n this._linesTemp.length = 0;\r\n const _lines = this.text.split(\"\\n\");\r\n\r\n if (this._textWrapping === TextWrapping.Ellipsis) {\r\n for (const _line of _lines) {\r\n this._linesTemp.push(this._parseLineEllipsis(_line, refWidth, context));\r\n }\r\n } else if (this._textWrapping === TextWrapping.WordWrap) {\r\n for (const _line of _lines) {\r\n this._linesTemp.push(...this._parseLineWordWrap(_line, refWidth, context));\r\n }\r\n } else if (this._textWrapping === TextWrapping.WordWrapEllipsis) {\r\n for (const _line of _lines) {\r\n this._linesTemp.push(...this._parseLineWordWrapEllipsis(_line, refWidth, refHeight!, context));\r\n }\r\n } else {\r\n for (const _line of _lines) {\r\n this._linesTemp.push(this._parseLine(_line, context));\r\n }\r\n }\r\n\r\n return this._linesTemp;\r\n }\r\n\r\n protected _parseLine(line: string = \"\", context: ICanvasRenderingContext): object {\r\n return { text: line, width: this._getTextMetricsWidth(context.measureText(line)) };\r\n }\r\n\r\n //Calculate how many characters approximately we need to remove\r\n private _getCharsToRemove(lineWidth: number, width: number, lineLength: number) {\r\n const diff = lineWidth > width ? lineWidth - width : 0;\r\n // This isn't exact unless the font is monospaced\r\n const charWidth = lineWidth / lineLength;\r\n const removeChars = Math.max(Math.floor(diff / charWidth), 1);\r\n return removeChars;\r\n }\r\n\r\n protected _parseLineEllipsis(line: string = \"\", width: number, context: ICanvasRenderingContext): object {\r\n let lineWidth = this._getTextMetricsWidth(context.measureText(line));\r\n\r\n let removeChars = this._getCharsToRemove(lineWidth, width, line.length);\r\n\r\n // unicode support. split('') does not work with unicode!\r\n // make sure Array.from is available\r\n const characters = Array.from && Array.from(line);\r\n if (!characters) {\r\n // no array.from, use the old method\r\n while (line.length > 2 && lineWidth > width) {\r\n line = line.slice(0, -removeChars);\r\n lineWidth = this._getTextMetricsWidth(context.measureText(line + \"…\"));\r\n\r\n removeChars = this._getCharsToRemove(lineWidth, width, line.length);\r\n }\r\n // Add on the end\r\n line += \"…\";\r\n } else {\r\n while (characters.length && lineWidth > width) {\r\n characters.splice(characters.length - removeChars, removeChars);\r\n line = `${characters.join(\"\")}…`;\r\n lineWidth = this._getTextMetricsWidth(context.measureText(line));\r\n\r\n removeChars = this._getCharsToRemove(lineWidth, width, line.length);\r\n }\r\n }\r\n\r\n return { text: line, width: lineWidth };\r\n }\r\n\r\n private _getTextMetricsWidth(textMetrics: ITextMetrics) {\r\n if (textMetrics.actualBoundingBoxLeft !== undefined) {\r\n return Math.abs(textMetrics.actualBoundingBoxLeft) + Math.abs(textMetrics.actualBoundingBoxRight);\r\n }\r\n return textMetrics.width;\r\n }\r\n\r\n protected _parseLineWordWrap(line: string = \"\", width: number, context: ICanvasRenderingContext): object[] {\r\n const lines = [];\r\n const words = this.wordSplittingFunction ? this.wordSplittingFunction(line) : line.split(this._wordDivider);\r\n let lineWidth = this._getTextMetricsWidth(context.measureText(line));\r\n\r\n for (let n = 0; n < words.length; n++) {\r\n const testLine = n > 0 ? line + this._wordDivider + words[n] : words[0];\r\n const testWidth = this._getTextMetricsWidth(context.measureText(testLine));\r\n if (testWidth > width && n > 0) {\r\n lines.push({ text: line, width: lineWidth });\r\n line = words[n];\r\n lineWidth = this._getTextMetricsWidth(context.measureText(line));\r\n } else {\r\n lineWidth = testWidth;\r\n line = testLine;\r\n }\r\n }\r\n lines.push({ text: line, width: lineWidth });\r\n\r\n return lines;\r\n }\r\n\r\n protected _parseLineWordWrapEllipsis(line: string = \"\", width: number, height: number, context: ICanvasRenderingContext): object[] {\r\n const lines = this._parseLineWordWrap(line, width, context);\r\n for (let n = 1; n <= lines.length; n++) {\r\n const currentHeight = this._computeHeightForLinesOf(n);\r\n if (currentHeight > height && n > 1) {\r\n const lastLine = lines[n - 2] as { text: string; width: number };\r\n const currentLine = lines[n - 1] as { text: string; width: number };\r\n lines[n - 2] = this._parseLineEllipsis(lastLine.text + this._wordDivider + currentLine.text, width, context);\r\n const linesToRemove = lines.length - n + 1;\r\n for (let i = 0; i < linesToRemove; i++) {\r\n lines.pop();\r\n }\r\n return lines;\r\n }\r\n }\r\n\r\n return lines;\r\n }\r\n\r\n protected _renderLines(context: ICanvasRenderingContext): void {\r\n if (!this._fontOffset || !this._lines) {\r\n return;\r\n }\r\n const height = this._currentMeasure.height;\r\n let rootY = 0;\r\n switch (this._textVerticalAlignment) {\r\n case Control.VERTICAL_ALIGNMENT_TOP:\r\n rootY = this._fontOffset.ascent;\r\n break;\r\n case Control.VERTICAL_ALIGNMENT_BOTTOM:\r\n rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;\r\n break;\r\n case Control.VERTICAL_ALIGNMENT_CENTER:\r\n rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;\r\n break;\r\n }\r\n\r\n rootY += this._currentMeasure.top;\r\n\r\n for (let i = 0; i < this._lines.length; i++) {\r\n const line = this._lines[i];\r\n\r\n if (i !== 0 && this._lineSpacing.internalValue !== 0) {\r\n if (this._lineSpacing.isPixel) {\r\n rootY += this._lineSpacing.getValue(this._host);\r\n } else {\r\n rootY = rootY + this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);\r\n }\r\n }\r\n\r\n this._drawText(line.text, line.width, rootY, context);\r\n rootY += this._fontOffset.height;\r\n }\r\n }\r\n\r\n private _computeHeightForLinesOf(lineCount: number): number {\r\n let newHeight = this._paddingTopInPixels + this._paddingBottomInPixels + this._fontOffset.height * lineCount;\r\n\r\n if (lineCount > 0 && this._lineSpacing.internalValue !== 0) {\r\n let lineSpacing = 0;\r\n if (this._lineSpacing.isPixel) {\r\n lineSpacing = this._lineSpacing.getValue(this._host);\r\n } else {\r\n lineSpacing = this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);\r\n }\r\n\r\n newHeight += (lineCount - 1) * lineSpacing;\r\n }\r\n\r\n return newHeight;\r\n }\r\n\r\n public override isDimensionFullyDefined(dim: \"width\" | \"height\"): boolean {\r\n if (this.resizeToFit) {\r\n return true;\r\n }\r\n return super.isDimensionFullyDefined(dim);\r\n }\r\n\r\n /**\r\n * Given a width constraint applied on the text block, find the expected height\r\n * @returns expected height\r\n */\r\n public computeExpectedHeight(): number {\r\n if (this.text && this.widthInPixels) {\r\n // Should abstract platform instead of using LastCreatedEngine\r\n const context = EngineStore.LastCreatedEngine?.createCanvas(0, 0).getContext(\"2d\");\r\n if (context) {\r\n this._applyStates(context);\r\n if (!this._fontOffset) {\r\n this._fontOffset = Control._GetFontOffset(context.font, this._host.getScene()?.getEngine());\r\n }\r\n const lines = this._lines\r\n ? this._lines\r\n : this._breakLines(\r\n this.widthInPixels - this._paddingLeftInPixels - this._paddingRightInPixels,\r\n this.heightInPixels - this._paddingTopInPixels - this._paddingBottomInPixels,\r\n context\r\n );\r\n return this._computeHeightForLinesOf(lines.length);\r\n }\r\n }\r\n return 0;\r\n }\r\n\r\n override dispose(): void {\r\n super.dispose();\r\n\r\n this.onTextChangedObservable.clear();\r\n }\r\n}\r\nRegisterClass(\"BABYLON.GUI.TextBlock\", TextBlock);\r\n"]}
1
+ {"version":3,"file":"textBlock.js","sourceRoot":"","sources":["../../../../../dev/gui/src/2D/controls/textBlock.ts"],"names":[],"mapp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Misc/observable\";\r\nimport type { Measure } from \"../measure\";\r\nimport { ValueAndUnit } from \"../valueAndUnit\";\r\nimport { Control } from \"./control\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport type { Nullable } from \"core/types\";\r\nimport { serialize } from \"core/Misc/decorators\";\r\nimport type { ICanvasRenderingContext, ITextMetrics } from \"core/Engines/ICanvas\";\r\nimport { EngineStore } from \"core/Engines/engineStore\";\r\n\r\n/**\r\n * Enum that determines the text-wrapping mode to use.\r\n */\r\nexport const enum TextWrapping {\r\n /**\r\n * Clip the text when it's larger than Control.width; this is the default mode.\r\n */\r\n Clip = 0,\r\n\r\n /**\r\n * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.\r\n */\r\n WordWrap = 1,\r\n\r\n /**\r\n * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.\r\n */\r\n Ellipsis = 2,\r\n\r\n /**\r\n * Wrap the text word-wise and clip the text when the text's height is larger than the Control.height, and shrink the last line with trailing … .\r\n */\r\n WordWrapEllipsis = 3,\r\n\r\n /**\r\n * Use HTML to wrap the text. This is the only mode that supports east-asian languages.\r\n */\r\n HTML = 4,\r\n}\r\n\r\n/**\r\n * Class used to create text block control\r\n */\r\nexport class TextBlock extends Control {\r\n private _text = \"\";\r\n private _textWrapping = TextWrapping.Clip;\r\n private _textHorizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;\r\n private _textVerticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;\r\n\r\n private _lines: any[];\r\n private _resizeToFit: boolean = false;\r\n private _lineSpacing: ValueAndUnit = new ValueAndUnit(0);\r\n private _outlineWidth: number = 0;\r\n private _outlineColor: string = \"white\";\r\n private _underline: boolean = false;\r\n private _lineThrough: boolean = false;\r\n private _wordDivider: string = \" \";\r\n private _forceResizeWidth: boolean = false;\r\n private _applyOutlineToUnderline: boolean = false;\r\n\r\n /**\r\n * An event triggered after the text is changed\r\n */\r\n public onTextChangedObservable = new Observable<TextBlock>();\r\n\r\n /**\r\n * An event triggered after the text was broken up into lines\r\n */\r\n public onLinesReadyObservable = new Observable<TextBlock>();\r\n\r\n /**\r\n * Function used to split a string into words. By default, a string is split at each space character found\r\n */\r\n public wordSplittingFunction: Nullable<(line: string) => string[]>;\r\n\r\n /**\r\n * This function will be called when a new HTML element is generated to be used for word wrapping.\r\n * This is only used when wrapping mode HTML is selected.\r\n * Using this function you can adjust word-break, overflow-wrap, hyphens, or any other CSS properties of the HTML element, language-dependent.\r\n */\r\n public adjustWordWrappingHTMLElement: Nullable<(element: HTMLElement) => void>;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if the HTML element generated for word wrapping should be reused or removed after each wrapping.\r\n */\r\n public reuseHTMLForWordWrapping: boolean = false;\r\n\r\n /**\r\n * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)\r\n */\r\n public get lines(): any[] {\r\n return this._lines;\r\n }\r\n\r\n /**\r\n * Gets or sets a boolean indicating that the TextBlock will be resized to fit its content\r\n\r\n */\r\n @serialize()\r\n public get resizeToFit(): boolean {\r\n return this._resizeToFit;\r\n }\r\n\r\n /**\r\n * Gets or sets a boolean indicating that the TextBlock will be resized to fit its content\r\n\r\n */\r\n public set resizeToFit(value: boolean) {\r\n if (this._resizeToFit === value) {\r\n return;\r\n }\r\n this._resizeToFit = value;\r\n\r\n if (this._resizeToFit) {\r\n this._width.ignoreAdaptiveScaling = true;\r\n this._height.ignoreAdaptiveScaling = true;\r\n }\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets a boolean indicating if text must be wrapped\r\n */\r\n @serialize()\r\n public get textWrapping(): TextWrapping | boolean {\r\n return this._textWrapping;\r\n }\r\n\r\n /**\r\n * Gets or sets a boolean indicating if text must be wrapped\r\n */\r\n public set textWrapping(value: TextWrapping | boolean) {\r\n if (this._textWrapping === value) {\r\n return;\r\n }\r\n this._textWrapping = +value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets text to display\r\n */\r\n @serialize()\r\n public get text(): string {\r\n return this._text;\r\n }\r\n\r\n /**\r\n * Gets or sets text to display\r\n */\r\n public set text(value: string) {\r\n if (this._text === value) {\r\n return;\r\n }\r\n this._text = value + \"\"; // Making sure it is a text\r\n this._markAsDirty();\r\n\r\n this.onTextChangedObservable.notifyObservers(this);\r\n }\r\n\r\n /**\r\n * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)\r\n */\r\n @serialize()\r\n public get textHorizontalAlignment(): number {\r\n return this._textHorizontalAlignment;\r\n }\r\n\r\n /**\r\n * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)\r\n */\r\n public set textHorizontalAlignment(value: number) {\r\n if (this._textHorizontalAlignment === value) {\r\n return;\r\n }\r\n\r\n this._textHorizontalAlignment = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)\r\n */\r\n @serialize()\r\n public get textVerticalAlignment(): number {\r\n return this._textVerticalAlignment;\r\n }\r\n\r\n /**\r\n * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)\r\n */\r\n public set textVerticalAlignment(value: number) {\r\n if (this._textVerticalAlignment === value) {\r\n return;\r\n }\r\n\r\n this._textVerticalAlignment = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets line spacing value\r\n */\r\n @serialize()\r\n public set lineSpacing(value: string | number) {\r\n if (this._lineSpacing.fromString(value)) {\r\n this._markAsDirty();\r\n }\r\n }\r\n\r\n /**\r\n * Gets or sets line spacing value\r\n */\r\n public get lineSpacing(): string | number {\r\n return this._lineSpacing.toString(this._host);\r\n }\r\n\r\n /**\r\n * Gets or sets outlineWidth of the text to display\r\n */\r\n @serialize()\r\n public get outlineWidth(): number {\r\n return this._outlineWidth;\r\n }\r\n\r\n /**\r\n * Gets or sets outlineWidth of the text to display\r\n */\r\n public set outlineWidth(value: number) {\r\n if (this._outlineWidth === value) {\r\n return;\r\n }\r\n this._outlineWidth = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets a boolean indicating that text must have underline\r\n */\r\n @serialize()\r\n public get underline(): boolean {\r\n return this._underline;\r\n }\r\n\r\n /**\r\n * Gets or sets a boolean indicating that text must have underline\r\n */\r\n public set underline(value: boolean) {\r\n if (this._underline === value) {\r\n return;\r\n }\r\n this._underline = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets an boolean indicating that text must be crossed out\r\n */\r\n @serialize()\r\n public get lineThrough(): boolean {\r\n return this._lineThrough;\r\n }\r\n\r\n /**\r\n * Gets or sets an boolean indicating that text must be crossed out\r\n */\r\n public set lineThrough(value: boolean) {\r\n if (this._lineThrough === value) {\r\n return;\r\n }\r\n this._lineThrough = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * If the outline should be applied to the underline/strike-through too. Has different behavior in Edge/Chrome vs Firefox.\r\n */\r\n @serialize()\r\n public get applyOutlineToUnderline(): boolean {\r\n return this._applyOutlineToUnderline;\r\n }\r\n\r\n public set applyOutlineToUnderline(value: boolean) {\r\n if (this._applyOutlineToUnderline === value) {\r\n return;\r\n }\r\n this._applyOutlineToUnderline = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets outlineColor of the text to display\r\n */\r\n @serialize()\r\n public get outlineColor(): string {\r\n return this._outlineColor;\r\n }\r\n\r\n /**\r\n * Gets or sets outlineColor of the text to display\r\n */\r\n public set outlineColor(value: string) {\r\n if (this._outlineColor === value) {\r\n return;\r\n }\r\n this._outlineColor = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets word divider\r\n */\r\n @serialize()\r\n public get wordDivider(): string {\r\n return this._wordDivider;\r\n }\r\n\r\n /**\r\n * Gets or sets word divider\r\n */\r\n public set wordDivider(value: string) {\r\n if (this._wordDivider === value) {\r\n return;\r\n }\r\n this._wordDivider = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * By default, if a text block has text wrapping other than Clip, its width\r\n * is not resized even if resizeToFit = true. This parameter forces the width\r\n * to be resized.\r\n */\r\n @serialize()\r\n public get forceResizeWidth(): boolean {\r\n return this._forceResizeWidth;\r\n }\r\n\r\n public set forceResizeWidth(value: boolean) {\r\n if (this._forceResizeWidth === value) {\r\n return;\r\n }\r\n this._forceResizeWidth = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Creates a new TextBlock object\r\n * @param name defines the name of the control\r\n * @param text defines the text to display (empty string by default)\r\n */\r\n constructor(\r\n /**\r\n * Defines the name of the control\r\n */\r\n public override name?: string,\r\n text: string = \"\"\r\n ) {\r\n super(name);\r\n\r\n this.text = text;\r\n }\r\n\r\n protected override _getTypeName(): string {\r\n return \"TextBlock\";\r\n }\r\n\r\n protected override _processMeasures(parentMeasure: Measure, context: ICanvasRenderingContext): void {\r\n if (!this._fontOffset || this.isDirty) {\r\n this._fontOffset = Control._GetFontOffset(context.font, this._host.getScene()?.getEngine());\r\n }\r\n super._processMeasures(parentMeasure, context);\r\n\r\n // Prepare lines\r\n this._lines = this._breakLines(this._currentMeasure.width, this._currentMeasure.height, context);\r\n this.onLinesReadyObservable.notifyObservers(this);\r\n\r\n let maxLineWidth: number = 0;\r\n\r\n for (let i = 0; i < this._lines.length; i++) {\r\n const line = this._lines[i];\r\n\r\n if (line.width > maxLineWidth) {\r\n maxLineWidth = line.width;\r\n }\r\n }\r\n\r\n if (this._resizeToFit) {\r\n if (this._textWrapping === TextWrapping.Clip || this._forceResizeWidth) {\r\n const newWidth = Math.ceil(this._paddingLeftInPixels) + Math.ceil(this._paddingRightInPixels) + Math.ceil(maxLineWidth);\r\n if (newWidth !== this._width.getValueInPixel(this._host, this._tempParentMeasure.width)) {\r\n this._width.updateInPlace(newWidth, ValueAndUnit.UNITMODE_PIXEL);\r\n this._rebuildLayout = true;\r\n }\r\n }\r\n let newHeight = (this._paddingTopInPixels + this._paddingBottomInPixels + this._fontOffset.height * this._lines.length) | 0;\r\n\r\n if (this._lines.length > 0 && this._lineSpacing.internalValue !== 0) {\r\n let lineSpacing = 0;\r\n if (this._lineSpacing.isPixel) {\r\n lineSpacing = this._lineSpacing.getValue(this._host);\r\n } else {\r\n lineSpacing = this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);\r\n }\r\n\r\n newHeight += (this._lines.length - 1) * lineSpacing;\r\n }\r\n\r\n if (newHeight !== this._height.internalValue) {\r\n this._height.updateInPlace(newHeight, ValueAndUnit.UNITMODE_PIXEL);\r\n this._rebuildLayout = true;\r\n }\r\n }\r\n }\r\n\r\n private _drawText(text: string, textWidth: number, y: number, context: ICanvasRenderingContext): void {\r\n const width = this._currentMeasure.width;\r\n let x = 0;\r\n switch (this._textHorizontalAlignment) {\r\n case Control.HORIZONTAL_ALIGNMENT_LEFT:\r\n x = 0;\r\n break;\r\n case Control.HORIZONTAL_ALIGNMENT_RIGHT:\r\n x = width - textWidth;\r\n break;\r\n case Control.HORIZONTAL_ALIGNMENT_CENTER:\r\n x = (width - textWidth) / 2;\r\n break;\r\n }\r\n\r\n if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {\r\n context.shadowColor = this.shadowColor;\r\n context.shadowBlur = this.shadowBlur;\r\n context.shadowOffsetX = this.shadowOffsetX;\r\n context.shadowOffsetY = this.shadowOffsetY;\r\n }\r\n\r\n if (this.outlineWidth) {\r\n context.strokeText(text, this._currentMeasure.left + x, y);\r\n }\r\n context.fillText(text, this._currentMeasure.left + x, y);\r\n\r\n if (this._underline) {\r\n this._drawLine(this._currentMeasure.left + x, y + 3, this._currentMeasure.left + x + textWidth, y + 3, context);\r\n }\r\n\r\n if (this._lineThrough) {\r\n this._drawLine(this._currentMeasure.left + x, y - this.fontSizeInPixels / 3, this._currentMeasure.left + x + textWidth, y - this.fontSizeInPixels / 3, context);\r\n }\r\n }\r\n\r\n private _drawLine(xFrom: number, yFrom: number, xTo: number, yTo: number, context: ICanvasRenderingContext): void {\r\n context.beginPath();\r\n context.lineWidth = Math.round(this.fontSizeInPixels * 0.05);\r\n context.moveTo(xFrom, yFrom);\r\n context.lineTo(xTo, yTo);\r\n if (this.outlineWidth && this.applyOutlineToUnderline) {\r\n context.stroke();\r\n context.fill();\r\n } else {\r\n const currentStroke = context.strokeStyle;\r\n context.strokeStyle = context.fillStyle;\r\n context.stroke();\r\n context.strokeStyle = currentStroke;\r\n }\r\n context.closePath();\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public override _draw(context: ICanvasRenderingContext): void {\r\n context.save();\r\n\r\n this._applyStates(context);\r\n\r\n // Render lines\r\n this._renderLines(context);\r\n\r\n context.restore();\r\n }\r\n\r\n protected override _applyStates(context: ICanvasRenderingContext): void {\r\n super._applyStates(context);\r\n if (this.outlineWidth) {\r\n context.lineWidth = this.outlineWidth;\r\n context.strokeStyle = this.outlineColor;\r\n context.lineJoin = \"miter\";\r\n context.miterLimit = 2;\r\n }\r\n }\r\n\r\n private _linesTemp: object[] = [];\r\n\r\n protected _breakLines(refWidth: number, refHeight: number, context: ICanvasRenderingContext): object[] {\r\n this._linesTemp.length = 0;\r\n const _lines = this._textWrapping === TextWrapping.HTML ? this._parseHTMLText(refWidth, refHeight, context) : this.text.split(\"\\n\");\r\n\r\n switch (this._textWrapping) {\r\n case TextWrapping.WordWrap:\r\n for (const _line of _lines) {\r\n this._linesTemp.push(...this._parseLineWordWrap(_line, refWidth, context));\r\n }\r\n break;\r\n case TextWrapping.Ellipsis:\r\n for (const _line of _lines) {\r\n this._linesTemp.push(this._parseLineEllipsis(_line, refWidth, context));\r\n }\r\n break;\r\n case TextWrapping.WordWrapEllipsis:\r\n for (const _line of _lines) {\r\n this._linesTemp.push(...this._parseLineWordWrapEllipsis(_line, refWidth, refHeight, context));\r\n }\r\n break;\r\n case TextWrapping.HTML:\r\n default:\r\n for (const _line of _lines) {\r\n this._linesTemp.push(this._parseLine(_line, context));\r\n }\r\n break;\r\n }\r\n\r\n return this._linesTemp;\r\n }\r\n\r\n private _htmlElement: Nullable<HTMLElement> = null;\r\n\r\n protected _parseHTMLText(refWidth: number, refHeight: number, context: ICanvasRenderingContext): string[] {\r\n const lines = [] as string[];\r\n if (!this._htmlElement) {\r\n this._htmlElement = document.createElement(\"div\");\r\n document.body.appendChild(this._htmlElement);\r\n }\r\n const htmlElement = this._htmlElement;\r\n htmlElement.textContent = this.text;\r\n htmlElement.style.font = context.font;\r\n htmlElement.style.position = \"absolute\";\r\n htmlElement.style.visibility = \"hidden\";\r\n htmlElement.style.top = \"-1000px\";\r\n htmlElement.style.left = \"-1000px\";\r\n this.adjustWordWrappingHTMLElement?.(htmlElement);\r\n htmlElement.style.width = refWidth + \"px\";\r\n htmlElement.style.height = refHeight + \"px\";\r\n const textContent = htmlElement.textContent;\r\n if (!textContent) {\r\n return lines;\r\n }\r\n // get the text node\r\n const textNode = htmlElement.childNodes[0];\r\n const range = document.createRange();\r\n let idx = 0;\r\n for (const c of textContent) {\r\n range.setStart(textNode, 0);\r\n range.setEnd(textNode, idx + 1);\r\n // \"select\" text from beginning to this position to determine the line\r\n const lineIndex = range.getClientRects().length - 1;\r\n lines[lineIndex] = (lines[lineIndex] || \"\") + c;\r\n idx++;\r\n }\r\n\r\n if (!this.reuseHTMLForWordWrapping) {\r\n htmlElement.remove();\r\n this._htmlElement = null;\r\n }\r\n\r\n return lines;\r\n }\r\n\r\n protected _parseLine(line: string = \"\", context: ICanvasRenderingContext): object {\r\n return { text: line, width: this._getTextMetricsWidth(context.measureText(line)) };\r\n }\r\n\r\n //Calculate how many characters approximately we need to remove\r\n private _getCharsToRemove(lineWidth: number, width: number, lineLength: number) {\r\n const diff = lineWidth > width ? lineWidth - width : 0;\r\n // This isn't exact unless the font is monospaced\r\n const charWidth = lineWidth / lineLength;\r\n const removeChars = Math.max(Math.floor(diff / charWidth), 1);\r\n return removeChars;\r\n }\r\n\r\n protected _parseLineEllipsis(line: string = \"\", width: number, context: ICanvasRenderingContext): object {\r\n let lineWidth = this._getTextMetricsWidth(context.measureText(line));\r\n\r\n let removeChars = this._getCharsToRemove(lineWidth, width, line.length);\r\n\r\n // unicode support. split('') does not work with unicode!\r\n // make sure Array.from is available\r\n const characters = Array.from && Array.from(line);\r\n if (!characters) {\r\n // no array.from, use the old method\r\n while (line.length > 2 && lineWidth > width) {\r\n line = line.slice(0, -removeChars);\r\n lineWidth = this._getTextMetricsWidth(context.measureText(line + \"…\"));\r\n\r\n removeChars = this._getCharsToRemove(lineWidth, width, line.length);\r\n }\r\n // Add on the end\r\n line += \"…\";\r\n } else {\r\n while (characters.length && lineWidth > width) {\r\n characters.splice(characters.length - removeChars, removeChars);\r\n line = `${characters.join(\"\")}…`;\r\n lineWidth = this._getTextMetricsWidth(context.measureText(line));\r\n\r\n removeChars = this._getCharsToRemove(lineWidth, width, line.length);\r\n }\r\n }\r\n\r\n return { text: line, width: lineWidth };\r\n }\r\n\r\n private _getTextMetricsWidth(textMetrics: ITextMetrics) {\r\n if (textMetrics.actualBoundingBoxLeft !== undefined) {\r\n return Math.abs(textMetrics.actualBoundingBoxLeft) + Math.abs(textMetrics.actualBoundingBoxRight);\r\n }\r\n return textMetrics.width;\r\n }\r\n\r\n protected _parseLineWordWrap(line: string = \"\", width: number, context: ICanvasRenderingContext): object[] {\r\n const lines = [];\r\n const words = this.wordSplittingFunction ? this.wordSplittingFunction(line) : line.split(this._wordDivider);\r\n let lineWidth = this._getTextMetricsWidth(context.measureText(line));\r\n\r\n for (let n = 0; n < words.length; n++) {\r\n const testLine = n > 0 ? line + this._wordDivider + words[n] : words[0];\r\n const testWidth = this._getTextMetricsWidth(context.measureText(testLine));\r\n if (testWidth > width && n > 0) {\r\n lines.push({ text: line, width: lineWidth });\r\n line = words[n];\r\n lineWidth = this._getTextMetricsWidth(context.measureText(line));\r\n } else {\r\n lineWidth = testWidth;\r\n line = testLine;\r\n }\r\n }\r\n lines.push({ text: line, width: lineWidth });\r\n\r\n return lines;\r\n }\r\n\r\n protected _parseLineWordWrapEllipsis(line: string = \"\", width: number, height: number, context: ICanvasRenderingContext): object[] {\r\n const lines = this._parseLineWordWrap(line, width, context);\r\n for (let n = 1; n <= lines.length; n++) {\r\n const currentHeight = this._computeHeightForLinesOf(n);\r\n if (currentHeight > height && n > 1) {\r\n const lastLine = lines[n - 2] as { text: string; width: number };\r\n const currentLine = lines[n - 1] as { text: string; width: number };\r\n lines[n - 2] = this._parseLineEllipsis(lastLine.text + this._wordDivider + currentLine.text, width, context);\r\n const linesToRemove = lines.length - n + 1;\r\n for (let i = 0; i < linesToRemove; i++) {\r\n lines.pop();\r\n }\r\n return lines;\r\n }\r\n }\r\n\r\n return lines;\r\n }\r\n\r\n protected _renderLines(context: ICanvasRenderingContext): void {\r\n if (!this._fontOffset || !this._lines) {\r\n return;\r\n }\r\n const height = this._currentMeasure.height;\r\n let rootY = 0;\r\n switch (this._textVerticalAlignment) {\r\n case Control.VERTICAL_ALIGNMENT_TOP:\r\n rootY = this._fontOffset.ascent;\r\n break;\r\n case Control.VERTICAL_ALIGNMENT_BOTTOM:\r\n rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;\r\n break;\r\n case Control.VERTICAL_ALIGNMENT_CENTER:\r\n rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;\r\n break;\r\n }\r\n\r\n rootY += this._currentMeasure.top;\r\n\r\n for (let i = 0; i < this._lines.length; i++) {\r\n const line = this._lines[i];\r\n\r\n if (i !== 0 && this._lineSpacing.internalValue !== 0) {\r\n if (this._lineSpacing.isPixel) {\r\n rootY += this._lineSpacing.getValue(this._host);\r\n } else {\r\n rootY = rootY + this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);\r\n }\r\n }\r\n\r\n this._drawText(line.text, line.width, rootY, context);\r\n rootY += this._fontOffset.height;\r\n }\r\n }\r\n\r\n private _computeHeightForLinesOf(lineCount: number): number {\r\n let newHeight = this._paddingTopInPixels + this._paddingBottomInPixels + this._fontOffset.height * lineCount;\r\n\r\n if (lineCount > 0 && this._lineSpacing.internalValue !== 0) {\r\n let lineSpacing = 0;\r\n if (this._lineSpacing.isPixel) {\r\n lineSpacing = this._lineSpacing.getValue(this._host);\r\n } else {\r\n lineSpacing = this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);\r\n }\r\n\r\n newHeight += (lineCount - 1) * lineSpacing;\r\n }\r\n\r\n return newHeight;\r\n }\r\n\r\n public override isDimensionFullyDefined(dim: \"width\" | \"height\"): boolean {\r\n if (this.resizeToFit) {\r\n return true;\r\n }\r\n return super.isDimensionFullyDefined(dim);\r\n }\r\n\r\n /**\r\n * Given a width constraint applied on the text block, find the expected height\r\n * @returns expected height\r\n */\r\n public computeExpectedHeight(): number {\r\n if (this.text && this.widthInPixels) {\r\n // Should abstract platform instead of using LastCreatedEngine\r\n const context = EngineStore.LastCreatedEngine?.createCanvas(0, 0).getContext(\"2d\");\r\n if (context) {\r\n this._applyStates(context);\r\n if (!this._fontOffset) {\r\n this._fontOffset = Control._GetFontOffset(context.font, this._host.getScene()?.getEngine());\r\n }\r\n const lines = this._lines\r\n ? this._lines\r\n : this._breakLines(\r\n this.widthInPixels - this._paddingLeftInPixels - this._paddingRightInPixels,\r\n this.heightInPixels - this._paddingTopInPixels - this._paddingBottomInPixels,\r\n context\r\n );\r\n return this._computeHeightForLinesOf(lines.length);\r\n }\r\n }\r\n return 0;\r\n }\r\n\r\n override dispose(): void {\r\n super.dispose();\r\n\r\n this.onTextChangedObservable.clear();\r\n this._htmlElement?.remove();\r\n this._htmlElement = null;\r\n }\r\n}\r\nRegisterClass(\"BABYLON.GUI.TextBlock\", TextBlock);\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babylonjs/gui",
3
- "version": "7.15.1",
3
+ "version": "7.16.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": "^7.15.1",
21
+ "@babylonjs/core": "^7.16.0",
22
22
  "@dev/build-tools": "^1.0.0",
23
23
  "@lts/gui": "1.0.0"
24
24
  },