From e3db9b573a00c5f5f20968db1234e20009c1eab3 Mon Sep 17 00:00:00 2001 From: Carolina Date: Wed, 4 Jan 2023 13:20:44 -0300 Subject: [PATCH] Fix calculation of text height in InputTextArea --- .../dev/gui/src/2D/controls/inputTextArea.ts | 23 +++++++++--------- ...UI Input Text Area Inside ScrollViewer.png | Bin 0 -> 5465 bytes .../tests/test/visualization/config.json | 4 +++ 3 files changed, 16 insertions(+), 11 deletions(-) create mode 100644 packages/tools/tests/test/visualization/ReferenceImages/GUI Input Text Area Inside ScrollViewer.png diff --git a/packages/dev/gui/src/2D/controls/inputTextArea.ts b/packages/dev/gui/src/2D/controls/inputTextArea.ts index 1362c0448e6..d77c764a8e3 100644 --- a/packages/dev/gui/src/2D/controls/inputTextArea.ts +++ b/packages/dev/gui/src/2D/controls/inputTextArea.ts @@ -663,17 +663,9 @@ export class InputTextArea extends InputText { } } - /** - * Processing of child after the parent measurement update - * - * @param parentMeasure The parent measure - * @param context The rendering canvas - * @internal - */ - // eslint-disable-next-line @typescript-eslint/no-unused-vars - protected _additionalProcessing(parentMeasure: Measure, context: ICanvasRenderingContext): void { - this._clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, parentMeasure.width); - this._clipTextTop = this._currentMeasure.top + this._margin.getValueInPixel(this._host, parentMeasure.height); + private _computeScroll() { + this._clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width); + this._clipTextTop = this._currentMeasure.top + this._margin.getValueInPixel(this._host, this._cachedParentMeasure.height); if (this._isFocused && this._lines[this._cursorInfo.currentLineIndex].width > this._availableWidth) { const textLeft = this._clipTextLeft - this._lines[this._cursorInfo.currentLineIndex].width + this._availableWidth; @@ -695,7 +687,14 @@ export class InputTextArea extends InputText { } else { this._scrollTop = this._clipTextTop; } + } + /** + * Processing of child after the parent measurement update + * + * @internal + */ + protected _additionalProcessing(): void { // Flush the highlighted text each frame this.highlightedText = ""; @@ -795,6 +794,8 @@ export class InputTextArea extends InputText { } public _draw(context: ICanvasRenderingContext): void { + this._computeScroll(); + this._scrollLeft = this._scrollLeft ?? 0; this._scrollTop = this._scrollTop ?? 0; diff --git a/packages/tools/tests/test/visualization/ReferenceImages/GUI Input Text Area Inside ScrollViewer.png b/packages/tools/tests/test/visualization/ReferenceImages/GUI Input Text Area Inside ScrollViewer.png new file mode 100644 index 0000000000000000000000000000000000000000..2247acbc954c856a709c7790bf65dab7ac956534 GIT binary patch literal 5465 zcmdT|X;f3!zE4$ZtD?8ht5iTxQKJP#2m)b>Ga^H5xh?Zh83LCfN`OEDMC?y zLLg~H^jQIAHVg?k0D%lb+CUh>9Ht};0Yc`t&!_wSeYoqnRzBpMb;s&JLGoh{6A7kC8MgGprkh4$^gY3 z<8Y8*O6a(@GcNPO#~ZPxa zG;NDMw4@!LHs@AyHs9>GDXdAs2w0INj+9e8&ENx zVKY5OU0Y%2iVN?Xz+mHvW^Z7y2VYyjZr|9l6ZYGa_ARgz$3LH2eA~XQ%S-bW4LRtw zuV61e^mN6S&V93KH@#y&?3`7m9_+eD=ohfR?*--mxb5@0RnrI>8Qr%)-pV;BltRtBq@MOm8ge?D_nTE_CQE{{W}3Tgoh@?5DASz0Nz-U5ZJ+ z5LRtr1aec@k>7~t%y~o}MPClRrTj17(hcDP(VV;yUovMkj^fa~IqW?CvH9U)eE-IQ z;@l0IWUtM>QbYddTD;G@_5X?JE90JShmEhUS ztK?DB1#%zN6@&_QT|=^fu9KH9rh%8t({oTJ?n26O&z5?x@g236I17I zjn^M}Gj29V`LoPVQ`axgqTe^sbEz$CEMx^+IhG+Dd8V0q1>5$gUFym{*h^e$vjgmO zUdmD6J*h6vG7-DCyZfpzO~$UBO2*?coKocc!a`4D+_1H+?N7Ro=0rcxHGTTX{)7JLv%3xC$vs});Tz>CR}p#q|m1}EELwI9Ch)H4Wt91u@CW@Hs7`sY4+?$#G@-_r%s)MU#JwsJ{QDBrlmQ#d5KlMBsg<$&=;hJ zCP=`a61K=qR^Ql28AQ3bWK1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7Vt_eF(wK0JUVtVNj+#Whare|kfsz<$f%QY20^ z{d<;4&xT|ej951(IUOgxpF>j_oFAK%m>3=&e)Kh6`N!+ssKZXrC#X|a`e}cERA7#+ z-%&skxW|}M=f2UN)HSR!Y87p4K|S7k{ub9^sa=CIBX8`hG}_TIaA35| zv^~?ewSAsx__>~c{rjj6B8M?`?l27I1+V`6k8M<@R}K9fB9<4#;K&r_cG>Gv^@Y$o F{|hASb9Mj# literal 0 HcmV?d00001 diff --git a/packages/tools/tests/test/visualization/config.json b/packages/tools/tests/test/visualization/config.json index 1168ccab485..32ae452f1e2 100644 --- a/packages/tools/tests/test/visualization/config.json +++ b/packages/tools/tests/test/visualization/config.json @@ -1514,6 +1514,10 @@ "playgroundId": "#20OAV9#9228", "referenceImage": "exportGltfKHRTextureTransform.png", "renderCount": 5 + }, + { + "title": "GUI Input Text Area Inside ScrollViewer", + "playgroundId": "#NVAEWD#69" } ] }