@babylonjs/gui 9.12.1 → 9.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (283) hide show
  1. package/2D/FrameGraph/pure.d.ts +2 -0
  2. package/2D/FrameGraph/pure.js +3 -0
  3. package/2D/FrameGraph/pure.js.map +1 -0
  4. package/2D/FrameGraph/renderGraphGUIBlock.d.ts +3 -41
  5. package/2D/FrameGraph/renderGraphGUIBlock.js +5 -64
  6. package/2D/FrameGraph/renderGraphGUIBlock.js.map +1 -1
  7. package/2D/FrameGraph/renderGraphGUIBlock.pure.d.ts +48 -0
  8. package/2D/FrameGraph/renderGraphGUIBlock.pure.js +78 -0
  9. package/2D/FrameGraph/renderGraphGUIBlock.pure.js.map +1 -0
  10. package/2D/controls/button.d.ts +3 -107
  11. package/2D/controls/button.js +5 -243
  12. package/2D/controls/button.js.map +1 -1
  13. package/2D/controls/button.pure.d.ts +114 -0
  14. package/2D/controls/button.pure.js +257 -0
  15. package/2D/controls/button.pure.js.map +1 -0
  16. package/2D/controls/checkbox.d.ts +3 -51
  17. package/2D/controls/checkbox.js +5 -161
  18. package/2D/controls/checkbox.js.map +1 -1
  19. package/2D/controls/checkbox.pure.d.ts +58 -0
  20. package/2D/controls/checkbox.pure.js +175 -0
  21. package/2D/controls/checkbox.pure.js.map +1 -0
  22. package/2D/controls/colorpicker.d.ts +5 -101
  23. package/2D/controls/colorpicker.js +7 -1394
  24. package/2D/controls/colorpicker.js.map +1 -1
  25. package/2D/controls/colorpicker.pure.d.ts +106 -0
  26. package/2D/controls/colorpicker.pure.js +1406 -0
  27. package/2D/controls/colorpicker.pure.js.map +1 -0
  28. package/2D/controls/container.d.ts +3 -177
  29. package/2D/controls/container.js +5 -615
  30. package/2D/controls/container.js.map +1 -1
  31. package/2D/controls/container.pure.d.ts +184 -0
  32. package/2D/controls/container.pure.js +629 -0
  33. package/2D/controls/container.pure.js.map +1 -0
  34. package/2D/controls/control.d.ts +3 -944
  35. package/2D/controls/control.js +5 -2457
  36. package/2D/controls/control.js.map +1 -1
  37. package/2D/controls/control.pure.d.ts +951 -0
  38. package/2D/controls/control.pure.js +2471 -0
  39. package/2D/controls/control.pure.js.map +1 -0
  40. package/2D/controls/displayGrid.d.ts +5 -53
  41. package/2D/controls/displayGrid.js +7 -201
  42. package/2D/controls/displayGrid.js.map +1 -1
  43. package/2D/controls/displayGrid.pure.d.ts +58 -0
  44. package/2D/controls/displayGrid.pure.js +213 -0
  45. package/2D/controls/displayGrid.pure.js.map +1 -0
  46. package/2D/controls/ellipse.d.ts +5 -25
  47. package/2D/controls/ellipse.js +7 -92
  48. package/2D/controls/ellipse.js.map +1 -1
  49. package/2D/controls/ellipse.pure.d.ts +30 -0
  50. package/2D/controls/ellipse.pure.js +104 -0
  51. package/2D/controls/ellipse.pure.js.map +1 -0
  52. package/2D/controls/focusableButton.d.ts +3 -15
  53. package/2D/controls/focusableButton.js +5 -22
  54. package/2D/controls/focusableButton.js.map +1 -1
  55. package/2D/controls/focusableButton.pure.d.ts +22 -0
  56. package/2D/controls/focusableButton.pure.js +36 -0
  57. package/2D/controls/focusableButton.pure.js.map +1 -0
  58. package/2D/controls/gradient/LinearGradient.d.ts +3 -43
  59. package/2D/controls/gradient/LinearGradient.js +5 -70
  60. package/2D/controls/gradient/LinearGradient.js.map +1 -1
  61. package/2D/controls/gradient/LinearGradient.pure.d.ts +50 -0
  62. package/2D/controls/gradient/LinearGradient.pure.js +84 -0
  63. package/2D/controls/gradient/LinearGradient.pure.js.map +1 -0
  64. package/2D/controls/gradient/RadialGradient.d.ts +3 -51
  65. package/2D/controls/gradient/RadialGradient.js +5 -86
  66. package/2D/controls/gradient/RadialGradient.js.map +1 -1
  67. package/2D/controls/gradient/RadialGradient.pure.d.ts +58 -0
  68. package/2D/controls/gradient/RadialGradient.pure.js +100 -0
  69. package/2D/controls/gradient/RadialGradient.pure.js.map +1 -0
  70. package/2D/controls/gradient/pure.d.ts +3 -0
  71. package/2D/controls/gradient/pure.js +4 -0
  72. package/2D/controls/gradient/pure.js.map +1 -0
  73. package/2D/controls/grid.d.ts +3 -149
  74. package/2D/controls/grid.js +5 -525
  75. package/2D/controls/grid.js.map +1 -1
  76. package/2D/controls/grid.pure.d.ts +156 -0
  77. package/2D/controls/grid.pure.js +539 -0
  78. package/2D/controls/grid.pure.js.map +1 -0
  79. package/2D/controls/image.d.ts +3 -226
  80. package/2D/controls/image.js +5 -913
  81. package/2D/controls/image.js.map +1 -1
  82. package/2D/controls/image.pure.d.ts +233 -0
  83. package/2D/controls/image.pure.js +927 -0
  84. package/2D/controls/image.pure.js.map +1 -0
  85. package/2D/controls/inputPassword.d.ts +3 -7
  86. package/2D/controls/inputPassword.js +5 -19
  87. package/2D/controls/inputPassword.js.map +1 -1
  88. package/2D/controls/inputPassword.pure.d.ts +14 -0
  89. package/2D/controls/inputPassword.pure.js +33 -0
  90. package/2D/controls/inputPassword.pure.js.map +1 -0
  91. package/2D/controls/inputText.d.ts +3 -202
  92. package/2D/controls/inputText.js +5 -1050
  93. package/2D/controls/inputText.js.map +1 -1
  94. package/2D/controls/inputText.pure.d.ts +209 -0
  95. package/2D/controls/inputText.pure.js +1064 -0
  96. package/2D/controls/inputText.pure.js.map +1 -0
  97. package/2D/controls/inputTextArea.d.ts +3 -140
  98. package/2D/controls/inputTextArea.js +5 -1023
  99. package/2D/controls/inputTextArea.js.map +1 -1
  100. package/2D/controls/inputTextArea.pure.d.ts +147 -0
  101. package/2D/controls/inputTextArea.pure.js +1037 -0
  102. package/2D/controls/inputTextArea.pure.js.map +1 -0
  103. package/2D/controls/line.d.ts +5 -74
  104. package/2D/controls/line.js +7 -234
  105. package/2D/controls/line.js.map +1 -1
  106. package/2D/controls/line.pure.d.ts +79 -0
  107. package/2D/controls/line.pure.js +246 -0
  108. package/2D/controls/line.pure.js.map +1 -0
  109. package/2D/controls/multiLine.d.ts +3 -73
  110. package/2D/controls/multiLine.js +5 -234
  111. package/2D/controls/multiLine.js.map +1 -1
  112. package/2D/controls/multiLine.pure.d.ts +80 -0
  113. package/2D/controls/multiLine.pure.js +248 -0
  114. package/2D/controls/multiLine.pure.js.map +1 -0
  115. package/2D/controls/pure.d.ts +38 -0
  116. package/2D/controls/pure.js +39 -0
  117. package/2D/controls/pure.js.map +1 -0
  118. package/2D/controls/radioButton.d.ts +3 -47
  119. package/2D/controls/radioButton.js +5 -182
  120. package/2D/controls/radioButton.js.map +1 -1
  121. package/2D/controls/radioButton.pure.d.ts +54 -0
  122. package/2D/controls/radioButton.pure.js +196 -0
  123. package/2D/controls/radioButton.pure.js.map +1 -0
  124. package/2D/controls/rectangle.d.ts +5 -43
  125. package/2D/controls/rectangle.js +7 -205
  126. package/2D/controls/rectangle.js.map +1 -1
  127. package/2D/controls/rectangle.pure.d.ts +48 -0
  128. package/2D/controls/rectangle.pure.js +217 -0
  129. package/2D/controls/rectangle.pure.js.map +1 -0
  130. package/2D/controls/scrollViewers/pure.d.ts +2 -0
  131. package/2D/controls/scrollViewers/pure.js +3 -0
  132. package/2D/controls/scrollViewers/pure.js.map +1 -0
  133. package/2D/controls/scrollViewers/scrollViewer.d.ts +3 -176
  134. package/2D/controls/scrollViewers/scrollViewer.js +5 -584
  135. package/2D/controls/scrollViewers/scrollViewer.js.map +1 -1
  136. package/2D/controls/scrollViewers/scrollViewer.pure.d.ts +183 -0
  137. package/2D/controls/scrollViewers/scrollViewer.pure.js +598 -0
  138. package/2D/controls/scrollViewers/scrollViewer.pure.js.map +1 -0
  139. package/2D/controls/sliders/imageBasedSlider.d.ts +3 -45
  140. package/2D/controls/sliders/imageBasedSlider.js +5 -165
  141. package/2D/controls/sliders/imageBasedSlider.js.map +1 -1
  142. package/2D/controls/sliders/imageBasedSlider.pure.d.ts +52 -0
  143. package/2D/controls/sliders/imageBasedSlider.pure.js +179 -0
  144. package/2D/controls/sliders/imageBasedSlider.pure.js.map +1 -0
  145. package/2D/controls/sliders/pure.d.ts +4 -0
  146. package/2D/controls/sliders/pure.js +5 -0
  147. package/2D/controls/sliders/pure.js.map +1 -0
  148. package/2D/controls/sliders/scrollBar.d.ts +3 -48
  149. package/2D/controls/sliders/scrollBar.js +5 -170
  150. package/2D/controls/sliders/scrollBar.js.map +1 -1
  151. package/2D/controls/sliders/scrollBar.pure.d.ts +55 -0
  152. package/2D/controls/sliders/scrollBar.pure.js +184 -0
  153. package/2D/controls/sliders/scrollBar.pure.js.map +1 -0
  154. package/2D/controls/sliders/slider.d.ts +3 -44
  155. package/2D/controls/sliders/slider.js +5 -278
  156. package/2D/controls/sliders/slider.js.map +1 -1
  157. package/2D/controls/sliders/slider.pure.d.ts +51 -0
  158. package/2D/controls/sliders/slider.pure.js +292 -0
  159. package/2D/controls/sliders/slider.pure.js.map +1 -0
  160. package/2D/controls/stackPanel.d.ts +3 -62
  161. package/2D/controls/stackPanel.js +5 -243
  162. package/2D/controls/stackPanel.js.map +1 -1
  163. package/2D/controls/stackPanel.pure.d.ts +69 -0
  164. package/2D/controls/stackPanel.pure.js +257 -0
  165. package/2D/controls/stackPanel.pure.js.map +1 -0
  166. package/2D/controls/statics.d.ts +3 -4
  167. package/2D/controls/statics.js +5 -47
  168. package/2D/controls/statics.js.map +1 -1
  169. package/2D/controls/statics.pure.d.ts +11 -0
  170. package/2D/controls/statics.pure.js +61 -0
  171. package/2D/controls/statics.pure.js.map +1 -0
  172. package/2D/controls/textBlock.d.ts +3 -217
  173. package/2D/controls/textBlock.js +5 -676
  174. package/2D/controls/textBlock.js.map +1 -1
  175. package/2D/controls/textBlock.pure.d.ts +224 -0
  176. package/2D/controls/textBlock.pure.js +690 -0
  177. package/2D/controls/textBlock.pure.js.map +1 -0
  178. package/2D/controls/toggleButton.d.ts +3 -91
  179. package/2D/controls/toggleButton.js +5 -226
  180. package/2D/controls/toggleButton.js.map +1 -1
  181. package/2D/controls/toggleButton.pure.d.ts +98 -0
  182. package/2D/controls/toggleButton.pure.js +240 -0
  183. package/2D/controls/toggleButton.pure.js.map +1 -0
  184. package/2D/controls/virtualKeyboard.d.ts +3 -100
  185. package/2D/controls/virtualKeyboard.js +5 -272
  186. package/2D/controls/virtualKeyboard.js.map +1 -1
  187. package/2D/controls/virtualKeyboard.pure.d.ts +107 -0
  188. package/2D/controls/virtualKeyboard.pure.js +286 -0
  189. package/2D/controls/virtualKeyboard.pure.js.map +1 -0
  190. package/2D/pure.d.ts +13 -0
  191. package/2D/pure.js +15 -0
  192. package/2D/pure.js.map +1 -0
  193. package/3D/controls/pure.d.ts +23 -0
  194. package/3D/controls/pure.js +24 -0
  195. package/3D/controls/pure.js.map +1 -0
  196. package/3D/gizmos/pure.d.ts +3 -0
  197. package/3D/gizmos/pure.js +4 -0
  198. package/3D/gizmos/pure.js.map +1 -0
  199. package/3D/materials/fluent/fluentMaterial.d.ts +5 -100
  200. package/3D/materials/fluent/fluentMaterial.js +7 -305
  201. package/3D/materials/fluent/fluentMaterial.js.map +1 -1
  202. package/3D/materials/fluent/fluentMaterial.pure.d.ts +105 -0
  203. package/3D/materials/fluent/fluentMaterial.pure.js +317 -0
  204. package/3D/materials/fluent/fluentMaterial.pure.js.map +1 -0
  205. package/3D/materials/fluent/pure.d.ts +2 -0
  206. package/3D/materials/fluent/pure.js +3 -0
  207. package/3D/materials/fluent/pure.js.map +1 -0
  208. package/3D/materials/fluentBackplate/fluentBackplateMaterial.d.ts +5 -164
  209. package/3D/materials/fluentBackplate/fluentBackplateMaterial.js +7 -488
  210. package/3D/materials/fluentBackplate/fluentBackplateMaterial.js.map +1 -1
  211. package/3D/materials/fluentBackplate/fluentBackplateMaterial.pure.d.ts +169 -0
  212. package/3D/materials/fluentBackplate/fluentBackplateMaterial.pure.js +500 -0
  213. package/3D/materials/fluentBackplate/fluentBackplateMaterial.pure.js.map +1 -0
  214. package/3D/materials/fluentBackplate/pure.d.ts +2 -0
  215. package/3D/materials/fluentBackplate/pure.js +3 -0
  216. package/3D/materials/fluentBackplate/pure.js.map +1 -0
  217. package/3D/materials/fluentButton/fluentButtonMaterial.d.ts +5 -200
  218. package/3D/materials/fluentButton/fluentButtonMaterial.js +7 -563
  219. package/3D/materials/fluentButton/fluentButtonMaterial.js.map +1 -1
  220. package/3D/materials/fluentButton/fluentButtonMaterial.pure.d.ts +205 -0
  221. package/3D/materials/fluentButton/fluentButtonMaterial.pure.js +575 -0
  222. package/3D/materials/fluentButton/fluentButtonMaterial.pure.js.map +1 -0
  223. package/3D/materials/fluentButton/pure.d.ts +2 -0
  224. package/3D/materials/fluentButton/pure.js +3 -0
  225. package/3D/materials/fluentButton/pure.js.map +1 -0
  226. package/3D/materials/handle/handleMaterial.d.ts +5 -66
  227. package/3D/materials/handle/handleMaterial.js +5 -118
  228. package/3D/materials/handle/handleMaterial.js.map +1 -1
  229. package/3D/materials/handle/handleMaterial.pure.d.ts +66 -0
  230. package/3D/materials/handle/handleMaterial.pure.js +119 -0
  231. package/3D/materials/handle/handleMaterial.pure.js.map +1 -0
  232. package/3D/materials/handle/pure.d.ts +2 -0
  233. package/3D/materials/handle/pure.js +3 -0
  234. package/3D/materials/handle/pure.js.map +1 -0
  235. package/3D/materials/mrdl/mrdlBackglowMaterial.d.ts +5 -85
  236. package/3D/materials/mrdl/mrdlBackglowMaterial.js +7 -299
  237. package/3D/materials/mrdl/mrdlBackglowMaterial.js.map +1 -1
  238. package/3D/materials/mrdl/mrdlBackglowMaterial.pure.d.ts +90 -0
  239. package/3D/materials/mrdl/mrdlBackglowMaterial.pure.js +311 -0
  240. package/3D/materials/mrdl/mrdlBackglowMaterial.pure.js.map +1 -0
  241. package/3D/materials/mrdl/mrdlBackplateMaterial.d.ts +5 -145
  242. package/3D/materials/mrdl/mrdlBackplateMaterial.js +7 -433
  243. package/3D/materials/mrdl/mrdlBackplateMaterial.js.map +1 -1
  244. package/3D/materials/mrdl/mrdlBackplateMaterial.pure.d.ts +157 -0
  245. package/3D/materials/mrdl/mrdlBackplateMaterial.pure.js +452 -0
  246. package/3D/materials/mrdl/mrdlBackplateMaterial.pure.js.map +1 -0
  247. package/3D/materials/mrdl/mrdlFrontplateMaterial.d.ts +5 -183
  248. package/3D/materials/mrdl/mrdlFrontplateMaterial.js +7 -532
  249. package/3D/materials/mrdl/mrdlFrontplateMaterial.js.map +1 -1
  250. package/3D/materials/mrdl/mrdlFrontplateMaterial.pure.d.ts +188 -0
  251. package/3D/materials/mrdl/mrdlFrontplateMaterial.pure.js +544 -0
  252. package/3D/materials/mrdl/mrdlFrontplateMaterial.pure.js.map +1 -0
  253. package/3D/materials/mrdl/mrdlInnerquadMaterial.d.ts +5 -54
  254. package/3D/materials/mrdl/mrdlInnerquadMaterial.js +7 -227
  255. package/3D/materials/mrdl/mrdlInnerquadMaterial.js.map +1 -1
  256. package/3D/materials/mrdl/mrdlInnerquadMaterial.pure.d.ts +59 -0
  257. package/3D/materials/mrdl/mrdlInnerquadMaterial.pure.js +239 -0
  258. package/3D/materials/mrdl/mrdlInnerquadMaterial.pure.js.map +1 -0
  259. package/3D/materials/mrdl/mrdlSliderBarMaterial.d.ts +5 -334
  260. package/3D/materials/mrdl/mrdlSliderBarMaterial.js +7 -855
  261. package/3D/materials/mrdl/mrdlSliderBarMaterial.js.map +1 -1
  262. package/3D/materials/mrdl/mrdlSliderBarMaterial.pure.d.ts +346 -0
  263. package/3D/materials/mrdl/mrdlSliderBarMaterial.pure.js +874 -0
  264. package/3D/materials/mrdl/mrdlSliderBarMaterial.pure.js.map +1 -0
  265. package/3D/materials/mrdl/mrdlSliderThumbMaterial.d.ts +5 -334
  266. package/3D/materials/mrdl/mrdlSliderThumbMaterial.js +7 -855
  267. package/3D/materials/mrdl/mrdlSliderThumbMaterial.js.map +1 -1
  268. package/3D/materials/mrdl/mrdlSliderThumbMaterial.pure.d.ts +346 -0
  269. package/3D/materials/mrdl/mrdlSliderThumbMaterial.pure.js +874 -0
  270. package/3D/materials/mrdl/mrdlSliderThumbMaterial.pure.js.map +1 -0
  271. package/3D/materials/mrdl/pure.d.ts +7 -0
  272. package/3D/materials/mrdl/pure.js +8 -0
  273. package/3D/materials/mrdl/pure.js.map +1 -0
  274. package/3D/materials/pure.d.ts +6 -0
  275. package/3D/materials/pure.js +8 -0
  276. package/3D/materials/pure.js.map +1 -0
  277. package/3D/pure.d.ts +6 -0
  278. package/3D/pure.js +8 -0
  279. package/3D/pure.js.map +1 -0
  280. package/package.json +50 -3
  281. package/pure.d.ts +3 -0
  282. package/pure.js +5 -0
  283. package/pure.js.map +1 -0
@@ -0,0 +1,690 @@
1
+ import { __decorate } from "@babylonjs/core/tslib.es6.js";
2
+ import { Observable } from "@babylonjs/core/Misc/observable.js";
3
+ import { ValueAndUnit } from "../valueAndUnit.js";
4
+ import { Control } from "./control.pure.js";
5
+ import { RegisterClass } from "@babylonjs/core/Misc/typeStore.js";
6
+ import { serialize } from "@babylonjs/core/Misc/decorators.js";
7
+ import { EngineStore } from "@babylonjs/core/Engines/engineStore.js";
8
+ /**
9
+ * Enum that determines the text-wrapping mode to use.
10
+ */
11
+ export var TextWrapping;
12
+ (function (TextWrapping) {
13
+ /**
14
+ * Clip the text when it's larger than Control.width; this is the default mode.
15
+ */
16
+ TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
17
+ /**
18
+ * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
19
+ */
20
+ TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
21
+ /**
22
+ * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
23
+ */
24
+ TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
25
+ /**
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
+ */
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";
33
+ })(TextWrapping || (TextWrapping = {}));
34
+ /**
35
+ * Class used to create text block control
36
+ */
37
+ export class TextBlock extends Control {
38
+ /**
39
+ * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
40
+ */
41
+ get lines() {
42
+ return this._lines;
43
+ }
44
+ /**
45
+ * Gets or sets a boolean indicating that the TextBlock will be resized to fit its content
46
+
47
+ */
48
+ get resizeToFit() {
49
+ return this._resizeToFit;
50
+ }
51
+ /**
52
+ * Gets or sets a boolean indicating that the TextBlock will be resized to fit its content
53
+
54
+ */
55
+ set resizeToFit(value) {
56
+ if (this._resizeToFit === value) {
57
+ return;
58
+ }
59
+ this._resizeToFit = value;
60
+ if (this._resizeToFit) {
61
+ this._width.ignoreAdaptiveScaling = true;
62
+ this._height.ignoreAdaptiveScaling = true;
63
+ }
64
+ this._markAsDirty();
65
+ }
66
+ /**
67
+ * Gets or sets a boolean indicating if text must be wrapped
68
+ */
69
+ get textWrapping() {
70
+ return this._textWrapping;
71
+ }
72
+ /**
73
+ * Gets or sets a boolean indicating if text must be wrapped
74
+ */
75
+ set textWrapping(value) {
76
+ if (this._textWrapping === value) {
77
+ return;
78
+ }
79
+ this._textWrapping = +value;
80
+ this._markAsDirty();
81
+ }
82
+ /**
83
+ * Gets or sets text to display
84
+ */
85
+ get text() {
86
+ return this._text;
87
+ }
88
+ /**
89
+ * Gets or sets text to display
90
+ */
91
+ set text(value) {
92
+ if (this._text === value) {
93
+ return;
94
+ }
95
+ this._text = value + ""; // Making sure it is a text
96
+ this._markAsDirty();
97
+ this.onTextChangedObservable.notifyObservers(this);
98
+ }
99
+ /**
100
+ * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
101
+ */
102
+ get textHorizontalAlignment() {
103
+ return this._textHorizontalAlignment;
104
+ }
105
+ /**
106
+ * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
107
+ */
108
+ set textHorizontalAlignment(value) {
109
+ if (this._textHorizontalAlignment === value) {
110
+ return;
111
+ }
112
+ this._textHorizontalAlignment = value;
113
+ this._markAsDirty();
114
+ }
115
+ /**
116
+ * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
117
+ */
118
+ get textVerticalAlignment() {
119
+ return this._textVerticalAlignment;
120
+ }
121
+ /**
122
+ * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
123
+ */
124
+ set textVerticalAlignment(value) {
125
+ if (this._textVerticalAlignment === value) {
126
+ return;
127
+ }
128
+ this._textVerticalAlignment = value;
129
+ this._markAsDirty();
130
+ }
131
+ /**
132
+ * Gets or sets line spacing value
133
+ */
134
+ set lineSpacing(value) {
135
+ if (this._lineSpacing.fromString(value)) {
136
+ this._markAsDirty();
137
+ }
138
+ }
139
+ /**
140
+ * Gets or sets line spacing value
141
+ */
142
+ get lineSpacing() {
143
+ return this._lineSpacing.toString(this._host);
144
+ }
145
+ /**
146
+ * Gets or sets outlineWidth of the text to display
147
+ */
148
+ get outlineWidth() {
149
+ return this._outlineWidth;
150
+ }
151
+ /**
152
+ * Gets or sets outlineWidth of the text to display
153
+ */
154
+ set outlineWidth(value) {
155
+ if (this._outlineWidth === value) {
156
+ return;
157
+ }
158
+ this._outlineWidth = value;
159
+ this._markAsDirty();
160
+ }
161
+ /**
162
+ * Gets or sets a boolean indicating that text must have underline
163
+ */
164
+ get underline() {
165
+ return this._underline;
166
+ }
167
+ /**
168
+ * Gets or sets a boolean indicating that text must have underline
169
+ */
170
+ set underline(value) {
171
+ if (this._underline === value) {
172
+ return;
173
+ }
174
+ this._underline = value;
175
+ this._markAsDirty();
176
+ }
177
+ /**
178
+ * Gets or sets an boolean indicating that text must be crossed out
179
+ */
180
+ get lineThrough() {
181
+ return this._lineThrough;
182
+ }
183
+ /**
184
+ * Gets or sets an boolean indicating that text must be crossed out
185
+ */
186
+ set lineThrough(value) {
187
+ if (this._lineThrough === value) {
188
+ return;
189
+ }
190
+ this._lineThrough = value;
191
+ this._markAsDirty();
192
+ }
193
+ /**
194
+ * If the outline should be applied to the underline/strike-through too. Has different behavior in Edge/Chrome vs Firefox.
195
+ */
196
+ get applyOutlineToUnderline() {
197
+ return this._applyOutlineToUnderline;
198
+ }
199
+ set applyOutlineToUnderline(value) {
200
+ if (this._applyOutlineToUnderline === value) {
201
+ return;
202
+ }
203
+ this._applyOutlineToUnderline = value;
204
+ this._markAsDirty();
205
+ }
206
+ /**
207
+ * Gets or sets outlineColor of the text to display
208
+ */
209
+ get outlineColor() {
210
+ return this._outlineColor;
211
+ }
212
+ /**
213
+ * Gets or sets outlineColor of the text to display
214
+ */
215
+ set outlineColor(value) {
216
+ if (this._outlineColor === value) {
217
+ return;
218
+ }
219
+ this._outlineColor = value;
220
+ this._markAsDirty();
221
+ }
222
+ /**
223
+ * Gets or sets word divider
224
+ */
225
+ get wordDivider() {
226
+ return this._wordDivider;
227
+ }
228
+ /**
229
+ * Gets or sets word divider
230
+ */
231
+ set wordDivider(value) {
232
+ if (this._wordDivider === value) {
233
+ return;
234
+ }
235
+ this._wordDivider = value;
236
+ this._markAsDirty();
237
+ }
238
+ /**
239
+ * By default, if a text block has text wrapping other than Clip, its width
240
+ * is not resized even if resizeToFit = true. This parameter forces the width
241
+ * to be resized.
242
+ */
243
+ get forceResizeWidth() {
244
+ return this._forceResizeWidth;
245
+ }
246
+ set forceResizeWidth(value) {
247
+ if (this._forceResizeWidth === value) {
248
+ return;
249
+ }
250
+ this._forceResizeWidth = value;
251
+ this._markAsDirty();
252
+ }
253
+ /**
254
+ * Creates a new TextBlock object
255
+ * @param name defines the name of the control
256
+ * @param text defines the text to display (empty string by default)
257
+ */
258
+ constructor(
259
+ /**
260
+ * Defines the name of the control
261
+ */
262
+ name, text = "") {
263
+ super(name);
264
+ this.name = name;
265
+ this._text = "";
266
+ this._textWrapping = 0 /* TextWrapping.Clip */;
267
+ this._textHorizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;
268
+ this._textVerticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
269
+ this._resizeToFit = false;
270
+ this._lineSpacing = new ValueAndUnit(0);
271
+ this._outlineWidth = 0;
272
+ this._outlineColor = "white";
273
+ this._underline = false;
274
+ this._lineThrough = false;
275
+ this._wordDivider = " ";
276
+ this._forceResizeWidth = false;
277
+ this._applyOutlineToUnderline = false;
278
+ /**
279
+ * An event triggered after the text is changed
280
+ */
281
+ this.onTextChangedObservable = new Observable();
282
+ /**
283
+ * An event triggered after the text was broken up into lines
284
+ */
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;
290
+ this._linesTemp = [];
291
+ this._htmlElement = null;
292
+ this.text = text;
293
+ }
294
+ _getTypeName() {
295
+ return "TextBlock";
296
+ }
297
+ _processMeasures(parentMeasure, context) {
298
+ super._processMeasures(parentMeasure, context);
299
+ // Apply states so we can use the right font to measure
300
+ context.save();
301
+ this._applyStates(context);
302
+ // Measure the font
303
+ if (!this._fontOffset || this.isDirty) {
304
+ this._fontOffset = Control._GetFontOffset(context.font, this._host.getScene()?.getEngine());
305
+ }
306
+ // Prepare lines
307
+ this._lines = this._breakLines(this._currentMeasure.width, this._currentMeasure.height, context);
308
+ this.onLinesReadyObservable.notifyObservers(this);
309
+ // Restore context now that we're done measuring the font
310
+ context.restore();
311
+ let maxLineWidth = 0;
312
+ for (let i = 0; i < this._lines.length; i++) {
313
+ const line = this._lines[i];
314
+ if (line.width > maxLineWidth) {
315
+ maxLineWidth = line.width;
316
+ }
317
+ }
318
+ if (this._resizeToFit) {
319
+ if (this._textWrapping === 0 /* TextWrapping.Clip */ || this._forceResizeWidth) {
320
+ const newWidth = Math.ceil(this._paddingLeftInPixels) + Math.ceil(this._paddingRightInPixels) + Math.ceil(maxLineWidth);
321
+ if (newWidth !== this._width.getValueInPixel(this._host, this._tempParentMeasure.width)) {
322
+ this._width.updateInPlace(newWidth, ValueAndUnit.UNITMODE_PIXEL);
323
+ this._rebuildLayout = true;
324
+ }
325
+ }
326
+ let newHeight = (this._paddingTopInPixels + this._paddingBottomInPixels + this._fontOffset.height * this._lines.length) | 0;
327
+ if (this._lines.length > 0 && this._lineSpacing.internalValue !== 0) {
328
+ let lineSpacing;
329
+ if (this._lineSpacing.isPixel) {
330
+ lineSpacing = this._lineSpacing.getValue(this._host);
331
+ }
332
+ else {
333
+ lineSpacing = this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
334
+ }
335
+ newHeight += (this._lines.length - 1) * lineSpacing;
336
+ }
337
+ if (newHeight !== this._height.internalValue) {
338
+ this._height.updateInPlace(newHeight, ValueAndUnit.UNITMODE_PIXEL);
339
+ this._rebuildLayout = true;
340
+ }
341
+ }
342
+ }
343
+ _drawText(text, textWidth, y, context) {
344
+ const width = this._currentMeasure.width;
345
+ let x = 0;
346
+ switch (this._textHorizontalAlignment) {
347
+ case Control.HORIZONTAL_ALIGNMENT_LEFT:
348
+ x = 0;
349
+ break;
350
+ case Control.HORIZONTAL_ALIGNMENT_RIGHT:
351
+ x = width - textWidth;
352
+ break;
353
+ case Control.HORIZONTAL_ALIGNMENT_CENTER:
354
+ x = (width - textWidth) / 2;
355
+ break;
356
+ }
357
+ if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
358
+ context.shadowColor = this.shadowColor;
359
+ context.shadowBlur = this.shadowBlur;
360
+ const idealRatio = this.host.idealRatio;
361
+ context.shadowOffsetX = this.shadowOffsetX * idealRatio;
362
+ context.shadowOffsetY = this.shadowOffsetY * idealRatio;
363
+ }
364
+ if (this.outlineWidth) {
365
+ context.strokeText(text, this._currentMeasure.left + x, y);
366
+ }
367
+ context.fillText(text, this._currentMeasure.left + x, y);
368
+ if (this._underline) {
369
+ this._drawLine(this._currentMeasure.left + x, y + 3, this._currentMeasure.left + x + textWidth, y + 3, context);
370
+ }
371
+ if (this._lineThrough) {
372
+ this._drawLine(this._currentMeasure.left + x, y - this.fontSizeInPixels / 3, this._currentMeasure.left + x + textWidth, y - this.fontSizeInPixels / 3, context);
373
+ }
374
+ }
375
+ _drawLine(xFrom, yFrom, xTo, yTo, context) {
376
+ context.beginPath();
377
+ context.lineWidth = Math.round(this.fontSizeInPixels * 0.05);
378
+ context.moveTo(xFrom, yFrom);
379
+ context.lineTo(xTo, yTo);
380
+ if (this.outlineWidth && this.applyOutlineToUnderline) {
381
+ context.stroke();
382
+ context.fill();
383
+ }
384
+ else {
385
+ const currentStroke = context.strokeStyle;
386
+ context.strokeStyle = context.fillStyle;
387
+ context.stroke();
388
+ context.strokeStyle = currentStroke;
389
+ }
390
+ context.closePath();
391
+ }
392
+ /**
393
+ * @internal
394
+ */
395
+ _draw(context) {
396
+ context.save();
397
+ this._applyStates(context);
398
+ // Render lines
399
+ this._renderLines(context);
400
+ context.restore();
401
+ }
402
+ _applyStates(context) {
403
+ super._applyStates(context);
404
+ if (this.outlineWidth) {
405
+ context.lineWidth = this.outlineWidth;
406
+ context.strokeStyle = this.outlineColor;
407
+ context.lineJoin = "miter";
408
+ context.miterLimit = 2;
409
+ }
410
+ }
411
+ _breakLines(refWidth, refHeight, context) {
412
+ this._linesTemp.length = 0;
413
+ const _lines = this._textWrapping === 4 /* TextWrapping.HTML */ ? this._parseHTMLText(refWidth, refHeight, context) : this.text.split("\n");
414
+ switch (this._textWrapping) {
415
+ case 1 /* TextWrapping.WordWrap */:
416
+ for (const _line of _lines) {
417
+ this._linesTemp.push(...this._parseLineWordWrap(_line, refWidth, context));
418
+ }
419
+ break;
420
+ case 2 /* TextWrapping.Ellipsis */:
421
+ for (const _line of _lines) {
422
+ this._linesTemp.push(this._parseLineEllipsis(_line, refWidth, context));
423
+ }
424
+ break;
425
+ case 3 /* TextWrapping.WordWrapEllipsis */:
426
+ for (const _line of _lines) {
427
+ this._linesTemp.push(...this._parseLineWordWrapEllipsis(_line, refWidth, refHeight, context));
428
+ }
429
+ break;
430
+ case 4 /* TextWrapping.HTML */:
431
+ default:
432
+ for (const _line of _lines) {
433
+ this._linesTemp.push(this._parseLine(_line, context));
434
+ }
435
+ break;
436
+ }
437
+ return this._linesTemp;
438
+ }
439
+ _parseHTMLText(refWidth, refHeight, context) {
440
+ const lines = [];
441
+ if (!this._htmlElement) {
442
+ this._htmlElement = document.createElement("div");
443
+ document.body.appendChild(this._htmlElement);
444
+ }
445
+ const htmlElement = this._htmlElement;
446
+ htmlElement.textContent = this.text;
447
+ htmlElement.style.font = context.font;
448
+ htmlElement.style.position = "absolute";
449
+ htmlElement.style.visibility = "hidden";
450
+ htmlElement.style.top = "-1000px";
451
+ htmlElement.style.left = "-1000px";
452
+ this.adjustWordWrappingHTMLElement?.(htmlElement);
453
+ htmlElement.style.width = refWidth + "px";
454
+ htmlElement.style.height = refHeight + "px";
455
+ const textContent = htmlElement.textContent;
456
+ if (!textContent) {
457
+ return lines;
458
+ }
459
+ // get the text node
460
+ const textNode = htmlElement.childNodes[0];
461
+ const range = document.createRange();
462
+ let idx = 0;
463
+ for (const c of textContent) {
464
+ range.setStart(textNode, 0);
465
+ range.setEnd(textNode, idx + 1);
466
+ // "select" text from beginning to this position to determine the line
467
+ const lineIndex = range.getClientRects().length - 1;
468
+ lines[lineIndex] = (lines[lineIndex] || "") + c;
469
+ idx++;
470
+ }
471
+ if (!this.reuseHTMLForWordWrapping) {
472
+ htmlElement.remove();
473
+ this._htmlElement = null;
474
+ }
475
+ return lines;
476
+ }
477
+ _parseLine(line = "", context) {
478
+ return { text: line, width: this._getTextMetricsWidth(context.measureText(line)) };
479
+ }
480
+ //Calculate how many characters approximately we need to remove
481
+ _getCharsToRemove(lineWidth, width, lineLength) {
482
+ const diff = lineWidth > width ? lineWidth - width : 0;
483
+ // This isn't exact unless the font is monospaced
484
+ const charWidth = lineWidth / lineLength;
485
+ const removeChars = Math.max(Math.floor(diff / charWidth), 1);
486
+ return removeChars;
487
+ }
488
+ _parseLineEllipsis(line = "", width, context) {
489
+ let lineWidth = this._getTextMetricsWidth(context.measureText(line));
490
+ let removeChars = this._getCharsToRemove(lineWidth, width, line.length);
491
+ // unicode support. split('') does not work with unicode!
492
+ // make sure Array.from is available
493
+ const characters = Array.from && Array.from(line);
494
+ if (!characters) {
495
+ // no array.from, use the old method
496
+ while (line.length > 2 && lineWidth > width) {
497
+ line = line.slice(0, -removeChars);
498
+ lineWidth = this._getTextMetricsWidth(context.measureText(line + "…"));
499
+ removeChars = this._getCharsToRemove(lineWidth, width, line.length);
500
+ }
501
+ // Add on the end
502
+ line += "…";
503
+ }
504
+ else {
505
+ while (characters.length && lineWidth > width) {
506
+ characters.splice(characters.length - removeChars, removeChars);
507
+ line = `${characters.join("")}…`;
508
+ lineWidth = this._getTextMetricsWidth(context.measureText(line));
509
+ removeChars = this._getCharsToRemove(lineWidth, width, line.length);
510
+ }
511
+ }
512
+ return { text: line, width: lineWidth };
513
+ }
514
+ _getTextMetricsWidth(textMetrics) {
515
+ if (textMetrics.actualBoundingBoxLeft !== undefined) {
516
+ return Math.abs(textMetrics.actualBoundingBoxLeft) + Math.abs(textMetrics.actualBoundingBoxRight);
517
+ }
518
+ return textMetrics.width;
519
+ }
520
+ _parseLineWordWrap(line = "", width, context) {
521
+ const lines = [];
522
+ const words = this.wordSplittingFunction ? this.wordSplittingFunction(line) : line.split(this._wordDivider);
523
+ let lineWidth = this._getTextMetricsWidth(context.measureText(line));
524
+ for (let n = 0; n < words.length; n++) {
525
+ const testLine = n > 0 ? line + this._wordDivider + words[n] : words[0];
526
+ const testWidth = this._getTextMetricsWidth(context.measureText(testLine));
527
+ if (testWidth > width && n > 0) {
528
+ lines.push({ text: line, width: lineWidth });
529
+ line = words[n];
530
+ lineWidth = this._getTextMetricsWidth(context.measureText(line));
531
+ }
532
+ else {
533
+ lineWidth = testWidth;
534
+ line = testLine;
535
+ }
536
+ }
537
+ lines.push({ text: line, width: lineWidth });
538
+ return lines;
539
+ }
540
+ _parseLineWordWrapEllipsis(line = "", width, height, context) {
541
+ const lines = this._parseLineWordWrap(line, width, context);
542
+ for (let n = 1; n <= lines.length; n++) {
543
+ const currentHeight = this._computeHeightForLinesOf(n);
544
+ if (currentHeight > height && n > 1) {
545
+ const lastLine = lines[n - 2];
546
+ const currentLine = lines[n - 1];
547
+ lines[n - 2] = this._parseLineEllipsis(lastLine.text + this._wordDivider + currentLine.text, width, context);
548
+ const linesToRemove = lines.length - n + 1;
549
+ for (let i = 0; i < linesToRemove; i++) {
550
+ lines.pop();
551
+ }
552
+ return lines;
553
+ }
554
+ }
555
+ return lines;
556
+ }
557
+ _renderLines(context) {
558
+ if (!this._fontOffset || !this._lines) {
559
+ return;
560
+ }
561
+ const height = this._currentMeasure.height;
562
+ let rootY = 0;
563
+ switch (this._textVerticalAlignment) {
564
+ case Control.VERTICAL_ALIGNMENT_TOP:
565
+ rootY = this._fontOffset.ascent;
566
+ break;
567
+ case Control.VERTICAL_ALIGNMENT_BOTTOM:
568
+ rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
569
+ break;
570
+ case Control.VERTICAL_ALIGNMENT_CENTER:
571
+ rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
572
+ break;
573
+ }
574
+ rootY += this._currentMeasure.top;
575
+ for (let i = 0; i < this._lines.length; i++) {
576
+ const line = this._lines[i];
577
+ if (i !== 0 && this._lineSpacing.internalValue !== 0) {
578
+ if (this._lineSpacing.isPixel) {
579
+ rootY += this._lineSpacing.getValue(this._host);
580
+ }
581
+ else {
582
+ rootY = rootY + this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
583
+ }
584
+ }
585
+ this._drawText(line.text, line.width, rootY, context);
586
+ rootY += this._fontOffset.height;
587
+ }
588
+ }
589
+ _computeHeightForLinesOf(lineCount) {
590
+ let newHeight = this._paddingTopInPixels + this._paddingBottomInPixels + this._fontOffset.height * lineCount;
591
+ if (lineCount > 0 && this._lineSpacing.internalValue !== 0) {
592
+ let lineSpacing;
593
+ if (this._lineSpacing.isPixel) {
594
+ lineSpacing = this._lineSpacing.getValue(this._host);
595
+ }
596
+ else {
597
+ lineSpacing = this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
598
+ }
599
+ newHeight += (lineCount - 1) * lineSpacing;
600
+ }
601
+ return newHeight;
602
+ }
603
+ isDimensionFullyDefined(dim) {
604
+ if (this.resizeToFit) {
605
+ return true;
606
+ }
607
+ return super.isDimensionFullyDefined(dim);
608
+ }
609
+ /**
610
+ * Given a width constraint applied on the text block, find the expected height
611
+ * @returns expected height
612
+ */
613
+ computeExpectedHeight() {
614
+ if (this.text && this.widthInPixels) {
615
+ // Should abstract platform instead of using LastCreatedEngine
616
+ const context = EngineStore.LastCreatedEngine?.createCanvas(0, 0).getContext("2d");
617
+ if (context) {
618
+ // This is a temporary context, no need to save/restore
619
+ // eslint-disable-next-line babylonjs/require-context-save-before-apply-states
620
+ this._applyStates(context);
621
+ if (!this._fontOffset) {
622
+ this._fontOffset = Control._GetFontOffset(context.font, this._host.getScene()?.getEngine());
623
+ }
624
+ const lines = this._lines
625
+ ? this._lines
626
+ : this._breakLines(this.widthInPixels - this._paddingLeftInPixels - this._paddingRightInPixels, this.heightInPixels - this._paddingTopInPixels - this._paddingBottomInPixels, context);
627
+ return this._computeHeightForLinesOf(lines.length);
628
+ }
629
+ }
630
+ return 0;
631
+ }
632
+ dispose() {
633
+ super.dispose();
634
+ this.onTextChangedObservable.clear();
635
+ this._htmlElement?.remove();
636
+ this._htmlElement = null;
637
+ }
638
+ }
639
+ __decorate([
640
+ serialize()
641
+ ], TextBlock.prototype, "resizeToFit", null);
642
+ __decorate([
643
+ serialize()
644
+ ], TextBlock.prototype, "textWrapping", null);
645
+ __decorate([
646
+ serialize()
647
+ ], TextBlock.prototype, "text", null);
648
+ __decorate([
649
+ serialize()
650
+ ], TextBlock.prototype, "textHorizontalAlignment", null);
651
+ __decorate([
652
+ serialize()
653
+ ], TextBlock.prototype, "textVerticalAlignment", null);
654
+ __decorate([
655
+ serialize()
656
+ ], TextBlock.prototype, "lineSpacing", null);
657
+ __decorate([
658
+ serialize()
659
+ ], TextBlock.prototype, "outlineWidth", null);
660
+ __decorate([
661
+ serialize()
662
+ ], TextBlock.prototype, "underline", null);
663
+ __decorate([
664
+ serialize()
665
+ ], TextBlock.prototype, "lineThrough", null);
666
+ __decorate([
667
+ serialize()
668
+ ], TextBlock.prototype, "applyOutlineToUnderline", null);
669
+ __decorate([
670
+ serialize()
671
+ ], TextBlock.prototype, "outlineColor", null);
672
+ __decorate([
673
+ serialize()
674
+ ], TextBlock.prototype, "wordDivider", null);
675
+ __decorate([
676
+ serialize()
677
+ ], TextBlock.prototype, "forceResizeWidth", null);
678
+ let _Registered = false;
679
+ /**
680
+ * Registers the TextBlock class with the type store for serialization support.
681
+ * Safe to call multiple times; only the first call has an effect.
682
+ */
683
+ export function RegisterTextBlock() {
684
+ if (_Registered) {
685
+ return;
686
+ }
687
+ _Registered = true;
688
+ RegisterClass("BABYLON.GUI.TextBlock", TextBlock);
689
+ }
690
+ //# sourceMappingURL=textBlock.pure.js.map