@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
@@ -1,618 +1,8 @@
1
- import { __decorate } from "@babylonjs/core/tslib.es6.js";
2
- import { Logger } from "@babylonjs/core/Misc/logger.js";
3
- import { Control } from "./control.js";
4
- import { Measure } from "../measure.js";
5
- import { RegisterClass } from "@babylonjs/core/Misc/typeStore.js";
6
- import { serialize } from "@babylonjs/core/Misc/decorators.js";
7
- import { DynamicTexture } from "@babylonjs/core/Materials/Textures/dynamicTexture.js";
8
- import { Texture } from "@babylonjs/core/Materials/Textures/texture.js";
9
- import { Constants } from "@babylonjs/core/Engines/constants.js";
10
- import { Observable } from "@babylonjs/core/Misc/observable.js";
11
- import { Tools } from "@babylonjs/core/Misc/tools.js";
12
- import { Matrix2D } from "../math2D.js";
13
1
  /**
14
- * Root class for 2D containers
15
- * @see https://doc.babylonjs.com/features/featuresDeepDive/gui/gui#containers
2
+ * Re-exports the pure implementation and applies the runtime registration side effect.
3
+ * Import "./container.pure" for tree-shakeable, side-effect-free usage.
16
4
  */
17
- export class Container extends Control {
18
- /** Gets or sets boolean indicating if children should be rendered to an intermediate texture rather than directly to host, useful for alpha blending */
19
- get renderToIntermediateTexture() {
20
- return this._renderToIntermediateTexture;
21
- }
22
- set renderToIntermediateTexture(value) {
23
- if (this._renderToIntermediateTexture === value) {
24
- return;
25
- }
26
- this._renderToIntermediateTexture = value;
27
- this._markAsDirty();
28
- }
29
- /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
30
- get adaptHeightToChildren() {
31
- return this._adaptHeightToChildren;
32
- }
33
- set adaptHeightToChildren(value) {
34
- if (this._adaptHeightToChildren === value) {
35
- return;
36
- }
37
- this._adaptHeightToChildren = value;
38
- if (value) {
39
- this.height = "100%";
40
- }
41
- this._rebuildLayout = true;
42
- this._markAsDirty();
43
- }
44
- /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
45
- get adaptWidthToChildren() {
46
- return this._adaptWidthToChildren;
47
- }
48
- set adaptWidthToChildren(value) {
49
- if (this._adaptWidthToChildren === value) {
50
- return;
51
- }
52
- this._adaptWidthToChildren = value;
53
- if (value) {
54
- this.width = "100%";
55
- }
56
- this._rebuildLayout = true;
57
- this._markAsDirty();
58
- }
59
- /** Gets or sets background color */
60
- get background() {
61
- return this._background;
62
- }
63
- set background(value) {
64
- if (this._background === value) {
65
- return;
66
- }
67
- this._background = value;
68
- this._markAsDirty();
69
- }
70
- /** Gets or sets background gradient color. Takes precedence over background */
71
- get backgroundGradient() {
72
- return this._backgroundGradient;
73
- }
74
- set backgroundGradient(value) {
75
- if (this._backgroundGradient === value) {
76
- return;
77
- }
78
- this._backgroundGradient = value;
79
- this._markAsDirty();
80
- }
81
- /** Gets the list of children */
82
- get children() {
83
- return this._children;
84
- }
85
- get isReadOnly() {
86
- return this._isReadOnly;
87
- }
88
- set isReadOnly(value) {
89
- this._isReadOnly = value;
90
- for (const child of this._children) {
91
- child.isReadOnly = value;
92
- }
93
- }
94
- /**
95
- * Creates a new Container
96
- * @param name defines the name of the container
97
- */
98
- constructor(name) {
99
- super(name);
100
- this.name = name;
101
- /** @internal */
102
- this._children = new Array();
103
- /** @internal */
104
- this._measureForChildren = Measure.Empty();
105
- /** @internal */
106
- this._background = "";
107
- /** @internal */
108
- this._backgroundGradient = null;
109
- /** @internal */
110
- this._adaptWidthToChildren = false;
111
- /** @internal */
112
- this._adaptHeightToChildren = false;
113
- /** @internal */
114
- this._renderToIntermediateTexture = false;
115
- /** @internal */
116
- this._intermediateTexture = null;
117
- /**
118
- * Gets or sets a boolean indicating that the container will let internal controls handle picking instead of doing it directly using its bounding info
119
- */
120
- this.delegatePickingToChildren = false;
121
- /**
122
- * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
123
- */
124
- this.logLayoutCycleErrors = false;
125
- /**
126
- * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
127
- */
128
- this.maxLayoutCycle = 3;
129
- /**
130
- * An event triggered when any control is added to this container.
131
- */
132
- this.onControlAddedObservable = new Observable();
133
- /**
134
- * An event triggered when any control is removed from this container.
135
- */
136
- this.onControlRemovedObservable = new Observable();
137
- this._inverseTransformMatrix = Matrix2D.Identity();
138
- this._inverseMeasure = new Measure(0, 0, 0, 0);
139
- }
140
- _getTypeName() {
141
- return "Container";
142
- }
143
- _flagDescendantsAsMatrixDirty() {
144
- for (const child of this.children) {
145
- child._isClipped = false;
146
- child._markMatrixAsDirty();
147
- }
148
- }
149
- /**
150
- * Gets a child using its name
151
- * @param name defines the child name to look for
152
- * @returns the child control if found
153
- */
154
- getChildByName(name) {
155
- for (const child of this.children) {
156
- if (child.name === name) {
157
- return child;
158
- }
159
- }
160
- return null;
161
- }
162
- /**
163
- * Gets a child using its type and its name
164
- * @param name defines the child name to look for
165
- * @param type defines the child type to look for
166
- * @returns the child control if found
167
- */
168
- getChildByType(name, type) {
169
- for (const child of this.children) {
170
- if (child.name === name && child.typeName === type) {
171
- return child;
172
- }
173
- }
174
- return null;
175
- }
176
- /**
177
- * Search for a specific control in children
178
- * @param control defines the control to look for
179
- * @returns true if the control is in child list
180
- */
181
- containsControl(control) {
182
- return this.children.indexOf(control) !== -1;
183
- }
184
- /**
185
- * Adds a new control to the current container
186
- * @param control defines the control to add
187
- * @returns the current container
188
- */
189
- addControl(control) {
190
- if (!control) {
191
- return this;
192
- }
193
- const index = this._children.indexOf(control);
194
- if (index !== -1) {
195
- return this;
196
- }
197
- control._link(this._host);
198
- control._markAllAsDirty();
199
- this._reOrderControl(control);
200
- this._markAsDirty();
201
- this.onControlAddedObservable.notifyObservers(control);
202
- return this;
203
- }
204
- /**
205
- * Removes all controls from the current container
206
- * @returns the current container
207
- */
208
- clearControls() {
209
- const children = this.children.slice();
210
- for (const child of children) {
211
- this.removeControl(child);
212
- }
213
- return this;
214
- }
215
- /**
216
- * Removes a control from the current container
217
- * @param control defines the control to remove
218
- * @returns the current container
219
- */
220
- removeControl(control) {
221
- const index = this._children.indexOf(control);
222
- if (index !== -1) {
223
- this._children.splice(index, 1);
224
- control.parent = null;
225
- }
226
- control.linkWithMesh(null);
227
- if (this._host) {
228
- this._host._cleanControlAfterRemoval(control);
229
- }
230
- this._markAsDirty();
231
- this.onControlRemovedObservable.notifyObservers(control);
232
- return this;
233
- }
234
- /**
235
- * @internal
236
- */
237
- _reOrderControl(control) {
238
- const linkedMesh = control.linkedMesh;
239
- this.removeControl(control);
240
- let wasAdded = false;
241
- for (let index = 0; index < this._children.length; index++) {
242
- if (this._children[index].zIndex > control.zIndex) {
243
- this._children.splice(index, 0, control);
244
- wasAdded = true;
245
- break;
246
- }
247
- }
248
- if (!wasAdded) {
249
- this._children.push(control);
250
- }
251
- control.parent = this;
252
- if (linkedMesh) {
253
- control.linkWithMesh(linkedMesh);
254
- }
255
- this._markAsDirty();
256
- }
257
- /**
258
- * @internal
259
- */
260
- _offsetLeft(offset) {
261
- super._offsetLeft(offset);
262
- for (const child of this._children) {
263
- child._offsetLeft(offset);
264
- }
265
- }
266
- /**
267
- * @internal
268
- */
269
- _offsetTop(offset) {
270
- super._offsetTop(offset);
271
- for (const child of this._children) {
272
- child._offsetTop(offset);
273
- }
274
- }
275
- /** @internal */
276
- _markAllAsDirty() {
277
- super._markAllAsDirty();
278
- for (let index = 0; index < this._children.length; index++) {
279
- this._children[index]._markAllAsDirty();
280
- }
281
- }
282
- _getBackgroundColor(context) {
283
- return this._backgroundGradient ? this._backgroundGradient.getCanvasGradient(context) : this._background;
284
- }
285
- /**
286
- * @internal
287
- */
288
- _localDraw(context) {
289
- if (this._background || this._backgroundGradient) {
290
- context.save();
291
- if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
292
- context.shadowColor = this.shadowColor;
293
- context.shadowBlur = this.shadowBlur;
294
- context.shadowOffsetX = this.shadowOffsetX * this._host.idealRatio;
295
- context.shadowOffsetY = this.shadowOffsetY * this._host.idealRatio;
296
- }
297
- context.fillStyle = this._getBackgroundColor(context);
298
- context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
299
- context.restore();
300
- }
301
- }
302
- /**
303
- * @internal
304
- */
305
- _link(host) {
306
- super._link(host);
307
- for (const child of this._children) {
308
- child._link(host);
309
- }
310
- }
311
- /** @internal */
312
- _beforeLayout() {
313
- // Do nothing
314
- }
315
- /**
316
- * @internal
317
- */
318
- _processMeasures(parentMeasure, context) {
319
- if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
320
- super._processMeasures(parentMeasure, context);
321
- this._evaluateClippingState(parentMeasure);
322
- if (this._renderToIntermediateTexture) {
323
- if (this._intermediateTexture && this._host.getScene() != this._intermediateTexture.getScene()) {
324
- this._intermediateTexture.dispose();
325
- this._intermediateTexture = null;
326
- }
327
- if (!this._intermediateTexture) {
328
- this._intermediateTexture = new DynamicTexture("", { width: this._currentMeasure.width, height: this._currentMeasure.height }, this._host.getScene(), false, Texture.NEAREST_SAMPLINGMODE, Constants.TEXTUREFORMAT_RGBA, false);
329
- this._intermediateTexture.hasAlpha = true;
330
- }
331
- else {
332
- this._intermediateTexture.scaleTo(this._currentMeasure.width, this._currentMeasure.height);
333
- }
334
- }
335
- }
336
- }
337
- /**
338
- * @internal
339
- */
340
- _layout(parentMeasure, context) {
341
- if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
342
- return false;
343
- }
344
- this.host._numLayoutCalls++;
345
- if (this._isDirty) {
346
- this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
347
- }
348
- let rebuildCount = 0;
349
- context.save();
350
- this._applyStates(context);
351
- this._beforeLayout();
352
- do {
353
- let computedWidth = -1;
354
- let computedHeight = -1;
355
- this._rebuildLayout = false;
356
- this._processMeasures(parentMeasure, context);
357
- if (!this._isClipped) {
358
- for (const child of this._children) {
359
- child._tempParentMeasure.copyFrom(this._measureForChildren);
360
- if (child._layout(this._measureForChildren, context)) {
361
- if (child.isVisible && !child.notRenderable) {
362
- if (this.adaptWidthToChildren && child._width.isPixel) {
363
- computedWidth = Math.max(computedWidth, child._currentMeasure.width + child._paddingLeftInPixels + child._paddingRightInPixels);
364
- }
365
- if (this.adaptHeightToChildren && child._height.isPixel) {
366
- computedHeight = Math.max(computedHeight, child._currentMeasure.height + child._paddingTopInPixels + child._paddingBottomInPixels);
367
- }
368
- }
369
- }
370
- }
371
- if (this.adaptWidthToChildren && computedWidth >= 0) {
372
- computedWidth += this.paddingLeftInPixels + this.paddingRightInPixels;
373
- const width = computedWidth + "px";
374
- if (this.width !== width) {
375
- this.parent?._markAsDirty();
376
- this.width = width;
377
- this._width.ignoreAdaptiveScaling = true;
378
- this._rebuildLayout = true;
379
- }
380
- }
381
- if (this.adaptHeightToChildren && computedHeight >= 0) {
382
- computedHeight += this.paddingTopInPixels + this.paddingBottomInPixels;
383
- const height = computedHeight + "px";
384
- if (this.height !== height) {
385
- this.parent?._markAsDirty();
386
- this.height = height;
387
- this._height.ignoreAdaptiveScaling = true;
388
- this._rebuildLayout = true;
389
- }
390
- }
391
- this._postMeasure();
392
- }
393
- rebuildCount++;
394
- } while (this._rebuildLayout && rebuildCount < this.maxLayoutCycle);
395
- if (this._rebuildLayout && rebuildCount >= this.maxLayoutCycle && this.logLayoutCycleErrors) {
396
- Logger.Error(`Layout cycle detected in GUI (Container name=${this.name}, uniqueId=${this.uniqueId})`);
397
- }
398
- context.restore();
399
- if (this._isDirty) {
400
- this.invalidateRect();
401
- this._isDirty = false;
402
- }
403
- return true;
404
- }
405
- _postMeasure() {
406
- // Do nothing by default
407
- }
408
- /**
409
- * @internal
410
- */
411
- _draw(context, invalidatedRectangle) {
412
- const renderToIntermediateTextureThisDraw = this._renderToIntermediateTexture && this._intermediateTexture;
413
- const contextToDrawTo = renderToIntermediateTextureThisDraw ? this._intermediateTexture.getContext() : context;
414
- if (renderToIntermediateTextureThisDraw) {
415
- contextToDrawTo.save();
416
- contextToDrawTo.translate(-this._currentMeasure.left, -this._currentMeasure.top);
417
- if (invalidatedRectangle) {
418
- this._transformMatrix.invertToRef(this._inverseTransformMatrix);
419
- invalidatedRectangle.transformToRef(this._inverseTransformMatrix, this._inverseMeasure);
420
- contextToDrawTo.clearRect(this._inverseMeasure.left, this._inverseMeasure.top, this._inverseMeasure.width, this._inverseMeasure.height);
421
- }
422
- else {
423
- contextToDrawTo.clearRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
424
- }
425
- }
426
- this._localDraw(contextToDrawTo);
427
- context.save();
428
- if (this.clipChildren) {
429
- this._clipForChildren(contextToDrawTo);
430
- }
431
- for (const child of this._children) {
432
- // Only redraw parts of the screen that are invalidated
433
- if (invalidatedRectangle) {
434
- if (!child._intersectsRect(invalidatedRectangle)) {
435
- continue;
436
- }
437
- }
438
- child._render(contextToDrawTo, invalidatedRectangle);
439
- }
440
- if (renderToIntermediateTextureThisDraw) {
441
- contextToDrawTo.restore();
442
- context.save();
443
- context.globalAlpha = this.alpha;
444
- context.drawImage(contextToDrawTo.canvas, this._currentMeasure.left, this._currentMeasure.top);
445
- context.restore();
446
- }
447
- context.restore();
448
- }
449
- getDescendantsToRef(results, directDescendantsOnly = false, predicate) {
450
- if (!this.children) {
451
- return;
452
- }
453
- for (let index = 0; index < this.children.length; index++) {
454
- const item = this.children[index];
455
- if (!predicate || predicate(item)) {
456
- results.push(item);
457
- }
458
- if (!directDescendantsOnly) {
459
- item.getDescendantsToRef(results, false, predicate);
460
- }
461
- }
462
- }
463
- /**
464
- * @internal
465
- */
466
- _processPicking(x, y, pi, type, pointerId, buttonIndex, deltaX, deltaY) {
467
- if (!this._isEnabled || !this.isVisible || this.notRenderable) {
468
- return false;
469
- }
470
- // checks if the picking position is within the container
471
- const contains = super.contains(x, y);
472
- // if clipChildren is off, we should still pass picking events to children even if we don't contain the pointer
473
- if (!contains && this.clipChildren) {
474
- return false;
475
- }
476
- if (this.delegatePickingToChildren) {
477
- let contains = false;
478
- for (let index = this._children.length - 1; index >= 0; index--) {
479
- const child = this._children[index];
480
- if (child.isEnabled && child.isHitTestVisible && child.isVisible && !child.notRenderable && child.contains(x, y)) {
481
- contains = true;
482
- break;
483
- }
484
- }
485
- if (!contains) {
486
- return false;
487
- }
488
- }
489
- // Checking backwards to pick closest first
490
- for (let index = this._children.length - 1; index >= 0; index--) {
491
- const child = this._children[index];
492
- if (child._processPicking(x, y, pi, type, pointerId, buttonIndex, deltaX, deltaY)) {
493
- if (child.hoverCursor) {
494
- this._host._changeCursor(child.hoverCursor);
495
- }
496
- return true;
497
- }
498
- }
499
- if (!contains) {
500
- return false;
501
- }
502
- if (!this.isHitTestVisible) {
503
- return false;
504
- }
505
- return this._processObservables(type, x, y, pi, pointerId, buttonIndex, deltaX, deltaY);
506
- }
507
- /**
508
- * @internal
509
- */
510
- _additionalProcessing(parentMeasure, context) {
511
- super._additionalProcessing(parentMeasure, context);
512
- this._measureForChildren.copyFrom(this._currentMeasure);
513
- }
514
- _getAdaptDimTo(dim) {
515
- if (dim === "width") {
516
- return this.adaptWidthToChildren;
517
- }
518
- else {
519
- return this.adaptHeightToChildren;
520
- }
521
- }
522
- isDimensionFullyDefined(dim) {
523
- if (this._getAdaptDimTo(dim)) {
524
- for (const child of this.children) {
525
- if (!child.isDimensionFullyDefined(dim)) {
526
- return false;
527
- }
528
- }
529
- return true;
530
- }
531
- return super.isDimensionFullyDefined(dim);
532
- }
533
- /**
534
- * Serializes the current control
535
- * @param serializationObject defined the JSON serialized object
536
- * @param force force serialization even if isSerializable === false
537
- * @param allowCanvas defines if the control is allowed to use a Canvas2D object to serialize (true by default)
538
- */
539
- serialize(serializationObject, force = false, allowCanvas = true) {
540
- super.serialize(serializationObject, force, allowCanvas);
541
- if (!this.isSerializable && !force) {
542
- return;
543
- }
544
- if (this.backgroundGradient) {
545
- serializationObject.backgroundGradient = {};
546
- this.backgroundGradient.serialize(serializationObject.backgroundGradient);
547
- }
548
- if (!this.children.length) {
549
- return;
550
- }
551
- serializationObject.children = [];
552
- for (const child of this.children) {
553
- if (child.isSerializable || force) {
554
- const childSerializationObject = {};
555
- child.serialize(childSerializationObject, force, allowCanvas);
556
- serializationObject.children.push(childSerializationObject);
557
- }
558
- }
559
- }
560
- /** Releases associated resources */
561
- dispose() {
562
- super.dispose();
563
- for (let index = this.children.length - 1; index >= 0; index--) {
564
- this.children[index].dispose();
565
- }
566
- this._intermediateTexture?.dispose();
567
- }
568
- /**
569
- * @internal
570
- */
571
- _parseFromContent(serializedObject, host, urlRewriter) {
572
- super._parseFromContent(serializedObject, host, urlRewriter);
573
- this._link(host);
574
- // Gradient
575
- if (serializedObject.backgroundGradient) {
576
- const className = Tools.Instantiate("BABYLON.GUI." + serializedObject.backgroundGradient.className);
577
- this._backgroundGradient = new className();
578
- this._backgroundGradient?.parse(serializedObject.backgroundGradient);
579
- }
580
- if (!serializedObject.children) {
581
- return;
582
- }
583
- for (const childData of serializedObject.children) {
584
- this.addControl(Control.Parse(childData, host, urlRewriter));
585
- }
586
- }
587
- isReady() {
588
- for (const child of this.children) {
589
- if (!child.isReady()) {
590
- return false;
591
- }
592
- }
593
- return true;
594
- }
595
- }
596
- __decorate([
597
- serialize()
598
- ], Container.prototype, "delegatePickingToChildren", void 0);
599
- __decorate([
600
- serialize()
601
- ], Container.prototype, "renderToIntermediateTexture", null);
602
- __decorate([
603
- serialize()
604
- ], Container.prototype, "maxLayoutCycle", void 0);
605
- __decorate([
606
- serialize()
607
- ], Container.prototype, "adaptHeightToChildren", null);
608
- __decorate([
609
- serialize()
610
- ], Container.prototype, "adaptWidthToChildren", null);
611
- __decorate([
612
- serialize()
613
- ], Container.prototype, "background", null);
614
- __decorate([
615
- serialize()
616
- ], Container.prototype, "backgroundGradient", null);
617
- RegisterClass("BABYLON.GUI.Container", Container);
5
+ export * from "./container.pure.js";
6
+ import { RegisterContainer } from "./container.pure.js";
7
+ RegisterContainer();
618
8
  //# sourceMappingURL=container.js.map