@onerjs/gui 8.23.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/2D/FrameGraph/guiTask.d.ts +34 -0
- package/2D/FrameGraph/guiTask.js +62 -0
- package/2D/FrameGraph/guiTask.js.map +1 -0
- package/2D/FrameGraph/renderGraphGUIBlock.d.ts +43 -0
- package/2D/FrameGraph/renderGraphGUIBlock.js +66 -0
- package/2D/FrameGraph/renderGraphGUIBlock.js.map +1 -0
- package/2D/adtInstrumentation.d.ts +52 -0
- package/2D/adtInstrumentation.js +107 -0
- package/2D/adtInstrumentation.js.map +1 -0
- package/2D/advancedDynamicTexture.d.ts +548 -0
- package/2D/advancedDynamicTexture.js +1522 -0
- package/2D/advancedDynamicTexture.js.map +1 -0
- package/2D/controls/button.d.ts +109 -0
- package/2D/controls/button.js +246 -0
- package/2D/controls/button.js.map +1 -0
- package/2D/controls/checkbox.d.ts +53 -0
- package/2D/controls/checkbox.js +164 -0
- package/2D/controls/checkbox.js.map +1 -0
- package/2D/controls/colorpicker.d.ts +101 -0
- package/2D/controls/colorpicker.js +1396 -0
- package/2D/controls/colorpicker.js.map +1 -0
- package/2D/controls/container.d.ts +179 -0
- package/2D/controls/container.js +616 -0
- package/2D/controls/container.js.map +1 -0
- package/2D/controls/control.d.ts +943 -0
- package/2D/controls/control.js +2460 -0
- package/2D/controls/control.js.map +1 -0
- package/2D/controls/displayGrid.d.ts +53 -0
- package/2D/controls/displayGrid.js +202 -0
- package/2D/controls/displayGrid.js.map +1 -0
- package/2D/controls/ellipse.d.ts +25 -0
- package/2D/controls/ellipse.js +93 -0
- package/2D/controls/ellipse.js.map +1 -0
- package/2D/controls/focusableButton.d.ts +17 -0
- package/2D/controls/focusableButton.js +25 -0
- package/2D/controls/focusableButton.js.map +1 -0
- package/2D/controls/focusableControl.d.ts +43 -0
- package/2D/controls/focusableControl.js +2 -0
- package/2D/controls/focusableControl.js.map +1 -0
- package/2D/controls/gradient/BaseGradient.d.ts +69 -0
- package/2D/controls/gradient/BaseGradient.js +84 -0
- package/2D/controls/gradient/BaseGradient.js.map +1 -0
- package/2D/controls/gradient/LinearGradient.d.ts +45 -0
- package/2D/controls/gradient/LinearGradient.js +73 -0
- package/2D/controls/gradient/LinearGradient.js.map +1 -0
- package/2D/controls/gradient/RadialGradient.d.ts +53 -0
- package/2D/controls/gradient/RadialGradient.js +89 -0
- package/2D/controls/gradient/RadialGradient.js.map +1 -0
- package/2D/controls/grid.d.ts +151 -0
- package/2D/controls/grid.js +528 -0
- package/2D/controls/grid.js.map +1 -0
- package/2D/controls/image.d.ts +228 -0
- package/2D/controls/image.js +915 -0
- package/2D/controls/image.js.map +1 -0
- package/2D/controls/index.d.ts +34 -0
- package/2D/controls/index.js +35 -0
- package/2D/controls/index.js.map +1 -0
- package/2D/controls/inputPassword.d.ts +9 -0
- package/2D/controls/inputPassword.js +22 -0
- package/2D/controls/inputPassword.js.map +1 -0
- package/2D/controls/inputText.d.ts +197 -0
- package/2D/controls/inputText.js +1035 -0
- package/2D/controls/inputText.js.map +1 -0
- package/2D/controls/inputTextArea.d.ts +142 -0
- package/2D/controls/inputTextArea.js +1025 -0
- package/2D/controls/inputTextArea.js.map +1 -0
- package/2D/controls/line.d.ts +73 -0
- package/2D/controls/line.js +227 -0
- package/2D/controls/line.js.map +1 -0
- package/2D/controls/multiLine.d.ts +75 -0
- package/2D/controls/multiLine.js +237 -0
- package/2D/controls/multiLine.js.map +1 -0
- package/2D/controls/radioButton.d.ts +49 -0
- package/2D/controls/radioButton.js +185 -0
- package/2D/controls/radioButton.js.map +1 -0
- package/2D/controls/rectangle.d.ts +43 -0
- package/2D/controls/rectangle.js +204 -0
- package/2D/controls/rectangle.js.map +1 -0
- package/2D/controls/scrollViewers/scrollViewer.d.ts +178 -0
- package/2D/controls/scrollViewers/scrollViewer.js +587 -0
- package/2D/controls/scrollViewers/scrollViewer.js.map +1 -0
- package/2D/controls/scrollViewers/scrollViewerWindow.d.ts +51 -0
- package/2D/controls/scrollViewers/scrollViewerWindow.js +254 -0
- package/2D/controls/scrollViewers/scrollViewerWindow.js.map +1 -0
- package/2D/controls/selector.d.ts +237 -0
- package/2D/controls/selector.js +579 -0
- package/2D/controls/selector.js.map +1 -0
- package/2D/controls/sliders/baseSlider.d.ts +80 -0
- package/2D/controls/sliders/baseSlider.js +299 -0
- package/2D/controls/sliders/baseSlider.js.map +1 -0
- package/2D/controls/sliders/imageBasedSlider.d.ts +47 -0
- package/2D/controls/sliders/imageBasedSlider.js +168 -0
- package/2D/controls/sliders/imageBasedSlider.js.map +1 -0
- package/2D/controls/sliders/imageScrollBar.d.ts +67 -0
- package/2D/controls/sliders/imageScrollBar.js +248 -0
- package/2D/controls/sliders/imageScrollBar.js.map +1 -0
- package/2D/controls/sliders/scrollBar.d.ts +50 -0
- package/2D/controls/sliders/scrollBar.js +175 -0
- package/2D/controls/sliders/scrollBar.js.map +1 -0
- package/2D/controls/sliders/slider.d.ts +46 -0
- package/2D/controls/sliders/slider.js +281 -0
- package/2D/controls/sliders/slider.js.map +1 -0
- package/2D/controls/stackPanel.d.ts +64 -0
- package/2D/controls/stackPanel.js +244 -0
- package/2D/controls/stackPanel.js.map +1 -0
- package/2D/controls/statics.d.ts +6 -0
- package/2D/controls/statics.js +50 -0
- package/2D/controls/statics.js.map +1 -0
- package/2D/controls/textBlock.d.ts +219 -0
- package/2D/controls/textBlock.js +670 -0
- package/2D/controls/textBlock.js.map +1 -0
- package/2D/controls/textWrapper.d.ts +13 -0
- package/2D/controls/textWrapper.js +88 -0
- package/2D/controls/textWrapper.js.map +1 -0
- package/2D/controls/toggleButton.d.ts +93 -0
- package/2D/controls/toggleButton.js +229 -0
- package/2D/controls/toggleButton.js.map +1 -0
- package/2D/controls/virtualKeyboard.d.ts +102 -0
- package/2D/controls/virtualKeyboard.js +275 -0
- package/2D/controls/virtualKeyboard.js.map +1 -0
- package/2D/index.d.ts +11 -0
- package/2D/index.js +13 -0
- package/2D/index.js.map +1 -0
- package/2D/math2D.d.ts +136 -0
- package/2D/math2D.js +235 -0
- package/2D/math2D.js.map +1 -0
- package/2D/measure.d.ts +77 -0
- package/2D/measure.js +138 -0
- package/2D/measure.js.map +1 -0
- package/2D/multiLinePoint.d.ts +47 -0
- package/2D/multiLinePoint.js +110 -0
- package/2D/multiLinePoint.js.map +1 -0
- package/2D/style.d.ts +46 -0
- package/2D/style.js +80 -0
- package/2D/style.js.map +1 -0
- package/2D/valueAndUnit.d.ts +89 -0
- package/2D/valueAndUnit.js +194 -0
- package/2D/valueAndUnit.js.map +1 -0
- package/2D/xmlLoader.d.ts +60 -0
- package/2D/xmlLoader.js +348 -0
- package/2D/xmlLoader.js.map +1 -0
- package/3D/behaviors/defaultBehavior.d.ts +73 -0
- package/3D/behaviors/defaultBehavior.js +103 -0
- package/3D/behaviors/defaultBehavior.js.map +1 -0
- package/3D/controls/MRTK3/touchHolographicButton.d.ts +220 -0
- package/3D/controls/MRTK3/touchHolographicButton.js +868 -0
- package/3D/controls/MRTK3/touchHolographicButton.js.map +1 -0
- package/3D/controls/abstractButton3D.d.ts +15 -0
- package/3D/controls/abstractButton3D.js +22 -0
- package/3D/controls/abstractButton3D.js.map +1 -0
- package/3D/controls/button3D.d.ts +51 -0
- package/3D/controls/button3D.js +98 -0
- package/3D/controls/button3D.js.map +1 -0
- package/3D/controls/container3D.d.ts +72 -0
- package/3D/controls/container3D.js +126 -0
- package/3D/controls/container3D.js.map +1 -0
- package/3D/controls/contentDisplay3D.d.ts +42 -0
- package/3D/controls/contentDisplay3D.js +81 -0
- package/3D/controls/contentDisplay3D.js.map +1 -0
- package/3D/controls/control3D.d.ts +183 -0
- package/3D/controls/control3D.js +401 -0
- package/3D/controls/control3D.js.map +1 -0
- package/3D/controls/cylinderPanel.d.ts +17 -0
- package/3D/controls/cylinderPanel.js +57 -0
- package/3D/controls/cylinderPanel.js.map +1 -0
- package/3D/controls/handMenu.d.ts +28 -0
- package/3D/controls/handMenu.js +39 -0
- package/3D/controls/handMenu.js.map +1 -0
- package/3D/controls/holographicBackplate.d.ts +49 -0
- package/3D/controls/holographicBackplate.js +104 -0
- package/3D/controls/holographicBackplate.js.map +1 -0
- package/3D/controls/holographicButton.d.ts +84 -0
- package/3D/controls/holographicButton.js +300 -0
- package/3D/controls/holographicButton.js.map +1 -0
- package/3D/controls/holographicSlate.d.ts +134 -0
- package/3D/controls/holographicSlate.js +413 -0
- package/3D/controls/holographicSlate.js.map +1 -0
- package/3D/controls/index.d.ts +22 -0
- package/3D/controls/index.js +24 -0
- package/3D/controls/index.js.map +1 -0
- package/3D/controls/meshButton3D.d.ts +21 -0
- package/3D/controls/meshButton3D.js +58 -0
- package/3D/controls/meshButton3D.js.map +1 -0
- package/3D/controls/nearMenu.d.ts +44 -0
- package/3D/controls/nearMenu.js +103 -0
- package/3D/controls/nearMenu.js.map +1 -0
- package/3D/controls/planePanel.d.ts +9 -0
- package/3D/controls/planePanel.js +30 -0
- package/3D/controls/planePanel.js.map +1 -0
- package/3D/controls/scatterPanel.d.ts +18 -0
- package/3D/controls/scatterPanel.js +98 -0
- package/3D/controls/scatterPanel.js.map +1 -0
- package/3D/controls/slider3D.d.ts +95 -0
- package/3D/controls/slider3D.js +256 -0
- package/3D/controls/slider3D.js.map +1 -0
- package/3D/controls/spherePanel.d.ts +17 -0
- package/3D/controls/spherePanel.js +58 -0
- package/3D/controls/spherePanel.js.map +1 -0
- package/3D/controls/stackPanel3D.d.ts +22 -0
- package/3D/controls/stackPanel3D.js +95 -0
- package/3D/controls/stackPanel3D.js.map +1 -0
- package/3D/controls/touchButton3D.d.ts +77 -0
- package/3D/controls/touchButton3D.js +205 -0
- package/3D/controls/touchButton3D.js.map +1 -0
- package/3D/controls/touchHolographicButton.d.ts +110 -0
- package/3D/controls/touchHolographicButton.js +400 -0
- package/3D/controls/touchHolographicButton.js.map +1 -0
- package/3D/controls/touchHolographicMenu.d.ts +61 -0
- package/3D/controls/touchHolographicMenu.js +139 -0
- package/3D/controls/touchHolographicMenu.js.map +1 -0
- package/3D/controls/touchMeshButton3D.d.ts +21 -0
- package/3D/controls/touchMeshButton3D.js +58 -0
- package/3D/controls/touchMeshButton3D.js.map +1 -0
- package/3D/controls/volumeBasedPanel.d.ts +53 -0
- package/3D/controls/volumeBasedPanel.js +158 -0
- package/3D/controls/volumeBasedPanel.js.map +1 -0
- package/3D/gizmos/gizmoHandle.d.ts +108 -0
- package/3D/gizmos/gizmoHandle.js +175 -0
- package/3D/gizmos/gizmoHandle.js.map +1 -0
- package/3D/gizmos/index.d.ts +2 -0
- package/3D/gizmos/index.js +3 -0
- package/3D/gizmos/index.js.map +1 -0
- package/3D/gizmos/slateGizmo.d.ts +57 -0
- package/3D/gizmos/slateGizmo.js +353 -0
- package/3D/gizmos/slateGizmo.js.map +1 -0
- package/3D/gui3DManager.d.ts +94 -0
- package/3D/gui3DManager.js +233 -0
- package/3D/gui3DManager.js.map +1 -0
- package/3D/index.d.ts +5 -0
- package/3D/index.js +7 -0
- package/3D/index.js.map +1 -0
- package/3D/materials/fluent/fluentMaterial.d.ts +91 -0
- package/3D/materials/fluent/fluentMaterial.js +286 -0
- package/3D/materials/fluent/fluentMaterial.js.map +1 -0
- package/3D/materials/fluent/index.d.ts +1 -0
- package/3D/materials/fluent/index.js +2 -0
- package/3D/materials/fluent/index.js.map +1 -0
- package/3D/materials/fluent/shaders/fluent.fragment.d.ts +5 -0
- package/3D/materials/fluent/shaders/fluent.fragment.js +41 -0
- package/3D/materials/fluent/shaders/fluent.fragment.js.map +1 -0
- package/3D/materials/fluent/shaders/fluent.vertex.d.ts +5 -0
- package/3D/materials/fluent/shaders/fluent.vertex.js +40 -0
- package/3D/materials/fluent/shaders/fluent.vertex.js.map +1 -0
- package/3D/materials/fluentBackplate/fluentBackplateMaterial.d.ts +155 -0
- package/3D/materials/fluentBackplate/fluentBackplateMaterial.js +466 -0
- package/3D/materials/fluentBackplate/fluentBackplateMaterial.js.map +1 -0
- package/3D/materials/fluentBackplate/index.d.ts +1 -0
- package/3D/materials/fluentBackplate/index.js +2 -0
- package/3D/materials/fluentBackplate/index.js.map +1 -0
- package/3D/materials/fluentBackplate/shaders/fluentBackplate.fragment.d.ts +5 -0
- package/3D/materials/fluentBackplate/shaders/fluentBackplate.fragment.js +60 -0
- package/3D/materials/fluentBackplate/shaders/fluentBackplate.fragment.js.map +1 -0
- package/3D/materials/fluentBackplate/shaders/fluentBackplate.vertex.d.ts +5 -0
- package/3D/materials/fluentBackplate/shaders/fluentBackplate.vertex.js +127 -0
- package/3D/materials/fluentBackplate/shaders/fluentBackplate.vertex.js.map +1 -0
- package/3D/materials/fluentButton/fluentButtonMaterial.d.ts +190 -0
- package/3D/materials/fluentButton/fluentButtonMaterial.js +536 -0
- package/3D/materials/fluentButton/fluentButtonMaterial.js.map +1 -0
- package/3D/materials/fluentButton/index.d.ts +1 -0
- package/3D/materials/fluentButton/index.js +2 -0
- package/3D/materials/fluentButton/index.js.map +1 -0
- package/3D/materials/fluentButton/shaders/fluentButton.fragment.d.ts +5 -0
- package/3D/materials/fluentButton/shaders/fluentButton.fragment.js +57 -0
- package/3D/materials/fluentButton/shaders/fluentButton.fragment.js.map +1 -0
- package/3D/materials/fluentButton/shaders/fluentButton.vertex.d.ts +5 -0
- package/3D/materials/fluentButton/shaders/fluentButton.vertex.js +162 -0
- package/3D/materials/fluentButton/shaders/fluentButton.vertex.js.map +1 -0
- package/3D/materials/fluentMaterial.d.ts +4 -0
- package/3D/materials/fluentMaterial.js +5 -0
- package/3D/materials/fluentMaterial.js.map +1 -0
- package/3D/materials/handle/handleMaterial.d.ts +68 -0
- package/3D/materials/handle/handleMaterial.js +114 -0
- package/3D/materials/handle/handleMaterial.js.map +1 -0
- package/3D/materials/handle/index.d.ts +1 -0
- package/3D/materials/handle/index.js +2 -0
- package/3D/materials/handle/index.js.map +1 -0
- package/3D/materials/handle/shaders/handle.fragment.d.ts +5 -0
- package/3D/materials/handle/shaders/handle.fragment.js +11 -0
- package/3D/materials/handle/shaders/handle.fragment.js.map +1 -0
- package/3D/materials/handle/shaders/handle.vertex.d.ts +5 -0
- package/3D/materials/handle/shaders/handle.vertex.js +11 -0
- package/3D/materials/handle/shaders/handle.vertex.js.map +1 -0
- package/3D/materials/index.d.ts +5 -0
- package/3D/materials/index.js +7 -0
- package/3D/materials/index.js.map +1 -0
- package/3D/materials/mrdl/index.d.ts +3 -0
- package/3D/materials/mrdl/index.js +4 -0
- package/3D/materials/mrdl/index.js.map +1 -0
- package/3D/materials/mrdl/mrdlBackglowMaterial.d.ts +87 -0
- package/3D/materials/mrdl/mrdlBackglowMaterial.js +302 -0
- package/3D/materials/mrdl/mrdlBackglowMaterial.js.map +1 -0
- package/3D/materials/mrdl/mrdlBackplateMaterial.d.ts +148 -0
- package/3D/materials/mrdl/mrdlBackplateMaterial.js +433 -0
- package/3D/materials/mrdl/mrdlBackplateMaterial.js.map +1 -0
- package/3D/materials/mrdl/mrdlFrontplateMaterial.d.ts +186 -0
- package/3D/materials/mrdl/mrdlFrontplateMaterial.js +532 -0
- package/3D/materials/mrdl/mrdlFrontplateMaterial.js.map +1 -0
- package/3D/materials/mrdl/mrdlInnerquadMaterial.d.ts +56 -0
- package/3D/materials/mrdl/mrdlInnerquadMaterial.js +230 -0
- package/3D/materials/mrdl/mrdlInnerquadMaterial.js.map +1 -0
- package/3D/materials/mrdl/mrdlSliderBarMaterial.d.ts +337 -0
- package/3D/materials/mrdl/mrdlSliderBarMaterial.js +855 -0
- package/3D/materials/mrdl/mrdlSliderBarMaterial.js.map +1 -0
- package/3D/materials/mrdl/mrdlSliderThumbMaterial.d.ts +337 -0
- package/3D/materials/mrdl/mrdlSliderThumbMaterial.js +855 -0
- package/3D/materials/mrdl/mrdlSliderThumbMaterial.js.map +1 -0
- package/3D/materials/mrdl/shaders/mrdlBackglow.fragment.d.ts +5 -0
- package/3D/materials/mrdl/shaders/mrdlBackglow.fragment.js +25 -0
- package/3D/materials/mrdl/shaders/mrdlBackglow.fragment.js.map +1 -0
- package/3D/materials/mrdl/shaders/mrdlBackglow.vertex.d.ts +5 -0
- package/3D/materials/mrdl/shaders/mrdlBackglow.vertex.js +12 -0
- package/3D/materials/mrdl/shaders/mrdlBackglow.vertex.js.map +1 -0
- package/3D/materials/mrdl/shaders/mrdlBackplate.fragment.d.ts +5 -0
- package/3D/materials/mrdl/shaders/mrdlBackplate.fragment.js +88 -0
- package/3D/materials/mrdl/shaders/mrdlBackplate.fragment.js.map +1 -0
- package/3D/materials/mrdl/shaders/mrdlBackplate.vertex.d.ts +5 -0
- package/3D/materials/mrdl/shaders/mrdlBackplate.vertex.js +96 -0
- package/3D/materials/mrdl/shaders/mrdlBackplate.vertex.js.map +1 -0
- package/3D/materials/mrdl/shaders/mrdlFrontplate.fragment.d.ts +5 -0
- package/3D/materials/mrdl/shaders/mrdlFrontplate.fragment.js +48 -0
- package/3D/materials/mrdl/shaders/mrdlFrontplate.fragment.js.map +1 -0
- package/3D/materials/mrdl/shaders/mrdlFrontplate.vertex.d.ts +5 -0
- package/3D/materials/mrdl/shaders/mrdlFrontplate.vertex.js +158 -0
- package/3D/materials/mrdl/shaders/mrdlFrontplate.vertex.js.map +1 -0
- package/3D/materials/mrdl/shaders/mrdlInnerquad.fragment.d.ts +5 -0
- package/3D/materials/mrdl/shaders/mrdlInnerquad.fragment.js +27 -0
- package/3D/materials/mrdl/shaders/mrdlInnerquad.fragment.js.map +1 -0
- package/3D/materials/mrdl/shaders/mrdlInnerquad.vertex.d.ts +5 -0
- package/3D/materials/mrdl/shaders/mrdlInnerquad.vertex.js +13 -0
- package/3D/materials/mrdl/shaders/mrdlInnerquad.vertex.js.map +1 -0
- package/3D/materials/mrdl/shaders/mrdlSliderBar.fragment.d.ts +5 -0
- package/3D/materials/mrdl/shaders/mrdlSliderBar.fragment.js +236 -0
- package/3D/materials/mrdl/shaders/mrdlSliderBar.fragment.js.map +1 -0
- package/3D/materials/mrdl/shaders/mrdlSliderBar.vertex.d.ts +5 -0
- package/3D/materials/mrdl/shaders/mrdlSliderBar.vertex.js +137 -0
- package/3D/materials/mrdl/shaders/mrdlSliderBar.vertex.js.map +1 -0
- package/3D/materials/mrdl/shaders/mrdlSliderThumb.fragment.d.ts +5 -0
- package/3D/materials/mrdl/shaders/mrdlSliderThumb.fragment.js +236 -0
- package/3D/materials/mrdl/shaders/mrdlSliderThumb.fragment.js.map +1 -0
- package/3D/materials/mrdl/shaders/mrdlSliderThumb.vertex.d.ts +5 -0
- package/3D/materials/mrdl/shaders/mrdlSliderThumb.vertex.js +137 -0
- package/3D/materials/mrdl/shaders/mrdlSliderThumb.vertex.js.map +1 -0
- package/3D/vector3WithInfo.d.ts +16 -0
- package/3D/vector3WithInfo.js +18 -0
- package/3D/vector3WithInfo.js.map +1 -0
- package/index.d.ts +2 -0
- package/index.js +4 -0
- package/index.js.map +1 -0
- package/legacy/legacy.d.ts +1 -0
- package/legacy/legacy.js +17 -0
- package/legacy/legacy.js.map +1 -0
- package/license.md +71 -0
- package/package.json +47 -0
- package/readme.md +31 -0
|
@@ -0,0 +1,670 @@
|
|
|
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.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
|
+
if (!this._fontOffset || this.isDirty) {
|
|
299
|
+
this._fontOffset = Control._GetFontOffset(context.font, this._host.getScene()?.getEngine());
|
|
300
|
+
}
|
|
301
|
+
super._processMeasures(parentMeasure, context);
|
|
302
|
+
// Prepare lines
|
|
303
|
+
this._lines = this._breakLines(this._currentMeasure.width, this._currentMeasure.height, context);
|
|
304
|
+
this.onLinesReadyObservable.notifyObservers(this);
|
|
305
|
+
let maxLineWidth = 0;
|
|
306
|
+
for (let i = 0; i < this._lines.length; i++) {
|
|
307
|
+
const line = this._lines[i];
|
|
308
|
+
if (line.width > maxLineWidth) {
|
|
309
|
+
maxLineWidth = line.width;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
if (this._resizeToFit) {
|
|
313
|
+
if (this._textWrapping === 0 /* TextWrapping.Clip */ || this._forceResizeWidth) {
|
|
314
|
+
const newWidth = Math.ceil(this._paddingLeftInPixels) + Math.ceil(this._paddingRightInPixels) + Math.ceil(maxLineWidth);
|
|
315
|
+
if (newWidth !== this._width.getValueInPixel(this._host, this._tempParentMeasure.width)) {
|
|
316
|
+
this._width.updateInPlace(newWidth, ValueAndUnit.UNITMODE_PIXEL);
|
|
317
|
+
this._rebuildLayout = true;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
let newHeight = (this._paddingTopInPixels + this._paddingBottomInPixels + this._fontOffset.height * this._lines.length) | 0;
|
|
321
|
+
if (this._lines.length > 0 && this._lineSpacing.internalValue !== 0) {
|
|
322
|
+
let lineSpacing = 0;
|
|
323
|
+
if (this._lineSpacing.isPixel) {
|
|
324
|
+
lineSpacing = this._lineSpacing.getValue(this._host);
|
|
325
|
+
}
|
|
326
|
+
else {
|
|
327
|
+
lineSpacing = this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
|
|
328
|
+
}
|
|
329
|
+
newHeight += (this._lines.length - 1) * lineSpacing;
|
|
330
|
+
}
|
|
331
|
+
if (newHeight !== this._height.internalValue) {
|
|
332
|
+
this._height.updateInPlace(newHeight, ValueAndUnit.UNITMODE_PIXEL);
|
|
333
|
+
this._rebuildLayout = true;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
_drawText(text, textWidth, y, context) {
|
|
338
|
+
const width = this._currentMeasure.width;
|
|
339
|
+
let x = 0;
|
|
340
|
+
switch (this._textHorizontalAlignment) {
|
|
341
|
+
case Control.HORIZONTAL_ALIGNMENT_LEFT:
|
|
342
|
+
x = 0;
|
|
343
|
+
break;
|
|
344
|
+
case Control.HORIZONTAL_ALIGNMENT_RIGHT:
|
|
345
|
+
x = width - textWidth;
|
|
346
|
+
break;
|
|
347
|
+
case Control.HORIZONTAL_ALIGNMENT_CENTER:
|
|
348
|
+
x = (width - textWidth) / 2;
|
|
349
|
+
break;
|
|
350
|
+
}
|
|
351
|
+
if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
|
|
352
|
+
context.shadowColor = this.shadowColor;
|
|
353
|
+
context.shadowBlur = this.shadowBlur;
|
|
354
|
+
context.shadowOffsetX = this.shadowOffsetX;
|
|
355
|
+
context.shadowOffsetY = this.shadowOffsetY;
|
|
356
|
+
}
|
|
357
|
+
if (this.outlineWidth) {
|
|
358
|
+
context.strokeText(text, this._currentMeasure.left + x, y);
|
|
359
|
+
}
|
|
360
|
+
context.fillText(text, this._currentMeasure.left + x, y);
|
|
361
|
+
if (this._underline) {
|
|
362
|
+
this._drawLine(this._currentMeasure.left + x, y + 3, this._currentMeasure.left + x + textWidth, y + 3, context);
|
|
363
|
+
}
|
|
364
|
+
if (this._lineThrough) {
|
|
365
|
+
this._drawLine(this._currentMeasure.left + x, y - this.fontSizeInPixels / 3, this._currentMeasure.left + x + textWidth, y - this.fontSizeInPixels / 3, context);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
_drawLine(xFrom, yFrom, xTo, yTo, context) {
|
|
369
|
+
context.beginPath();
|
|
370
|
+
context.lineWidth = Math.round(this.fontSizeInPixels * 0.05);
|
|
371
|
+
context.moveTo(xFrom, yFrom);
|
|
372
|
+
context.lineTo(xTo, yTo);
|
|
373
|
+
if (this.outlineWidth && this.applyOutlineToUnderline) {
|
|
374
|
+
context.stroke();
|
|
375
|
+
context.fill();
|
|
376
|
+
}
|
|
377
|
+
else {
|
|
378
|
+
const currentStroke = context.strokeStyle;
|
|
379
|
+
context.strokeStyle = context.fillStyle;
|
|
380
|
+
context.stroke();
|
|
381
|
+
context.strokeStyle = currentStroke;
|
|
382
|
+
}
|
|
383
|
+
context.closePath();
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* @internal
|
|
387
|
+
*/
|
|
388
|
+
_draw(context) {
|
|
389
|
+
context.save();
|
|
390
|
+
this._applyStates(context);
|
|
391
|
+
// Render lines
|
|
392
|
+
this._renderLines(context);
|
|
393
|
+
context.restore();
|
|
394
|
+
}
|
|
395
|
+
_applyStates(context) {
|
|
396
|
+
super._applyStates(context);
|
|
397
|
+
if (this.outlineWidth) {
|
|
398
|
+
context.lineWidth = this.outlineWidth;
|
|
399
|
+
context.strokeStyle = this.outlineColor;
|
|
400
|
+
context.lineJoin = "miter";
|
|
401
|
+
context.miterLimit = 2;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
_breakLines(refWidth, refHeight, context) {
|
|
405
|
+
this._linesTemp.length = 0;
|
|
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;
|
|
429
|
+
}
|
|
430
|
+
return this._linesTemp;
|
|
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
|
+
}
|
|
470
|
+
_parseLine(line = "", context) {
|
|
471
|
+
return { text: line, width: this._getTextMetricsWidth(context.measureText(line)) };
|
|
472
|
+
}
|
|
473
|
+
//Calculate how many characters approximately we need to remove
|
|
474
|
+
_getCharsToRemove(lineWidth, width, lineLength) {
|
|
475
|
+
const diff = lineWidth > width ? lineWidth - width : 0;
|
|
476
|
+
// This isn't exact unless the font is monospaced
|
|
477
|
+
const charWidth = lineWidth / lineLength;
|
|
478
|
+
const removeChars = Math.max(Math.floor(diff / charWidth), 1);
|
|
479
|
+
return removeChars;
|
|
480
|
+
}
|
|
481
|
+
_parseLineEllipsis(line = "", width, context) {
|
|
482
|
+
let lineWidth = this._getTextMetricsWidth(context.measureText(line));
|
|
483
|
+
let removeChars = this._getCharsToRemove(lineWidth, width, line.length);
|
|
484
|
+
// unicode support. split('') does not work with unicode!
|
|
485
|
+
// make sure Array.from is available
|
|
486
|
+
const characters = Array.from && Array.from(line);
|
|
487
|
+
if (!characters) {
|
|
488
|
+
// no array.from, use the old method
|
|
489
|
+
while (line.length > 2 && lineWidth > width) {
|
|
490
|
+
line = line.slice(0, -removeChars);
|
|
491
|
+
lineWidth = this._getTextMetricsWidth(context.measureText(line + "…"));
|
|
492
|
+
removeChars = this._getCharsToRemove(lineWidth, width, line.length);
|
|
493
|
+
}
|
|
494
|
+
// Add on the end
|
|
495
|
+
line += "…";
|
|
496
|
+
}
|
|
497
|
+
else {
|
|
498
|
+
while (characters.length && lineWidth > width) {
|
|
499
|
+
characters.splice(characters.length - removeChars, removeChars);
|
|
500
|
+
line = `${characters.join("")}…`;
|
|
501
|
+
lineWidth = this._getTextMetricsWidth(context.measureText(line));
|
|
502
|
+
removeChars = this._getCharsToRemove(lineWidth, width, line.length);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
return { text: line, width: lineWidth };
|
|
506
|
+
}
|
|
507
|
+
_getTextMetricsWidth(textMetrics) {
|
|
508
|
+
if (textMetrics.actualBoundingBoxLeft !== undefined) {
|
|
509
|
+
return Math.abs(textMetrics.actualBoundingBoxLeft) + Math.abs(textMetrics.actualBoundingBoxRight);
|
|
510
|
+
}
|
|
511
|
+
return textMetrics.width;
|
|
512
|
+
}
|
|
513
|
+
_parseLineWordWrap(line = "", width, context) {
|
|
514
|
+
const lines = [];
|
|
515
|
+
const words = this.wordSplittingFunction ? this.wordSplittingFunction(line) : line.split(this._wordDivider);
|
|
516
|
+
let lineWidth = this._getTextMetricsWidth(context.measureText(line));
|
|
517
|
+
for (let n = 0; n < words.length; n++) {
|
|
518
|
+
const testLine = n > 0 ? line + this._wordDivider + words[n] : words[0];
|
|
519
|
+
const testWidth = this._getTextMetricsWidth(context.measureText(testLine));
|
|
520
|
+
if (testWidth > width && n > 0) {
|
|
521
|
+
lines.push({ text: line, width: lineWidth });
|
|
522
|
+
line = words[n];
|
|
523
|
+
lineWidth = this._getTextMetricsWidth(context.measureText(line));
|
|
524
|
+
}
|
|
525
|
+
else {
|
|
526
|
+
lineWidth = testWidth;
|
|
527
|
+
line = testLine;
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
lines.push({ text: line, width: lineWidth });
|
|
531
|
+
return lines;
|
|
532
|
+
}
|
|
533
|
+
_parseLineWordWrapEllipsis(line = "", width, height, context) {
|
|
534
|
+
const lines = this._parseLineWordWrap(line, width, context);
|
|
535
|
+
for (let n = 1; n <= lines.length; n++) {
|
|
536
|
+
const currentHeight = this._computeHeightForLinesOf(n);
|
|
537
|
+
if (currentHeight > height && n > 1) {
|
|
538
|
+
const lastLine = lines[n - 2];
|
|
539
|
+
const currentLine = lines[n - 1];
|
|
540
|
+
lines[n - 2] = this._parseLineEllipsis(lastLine.text + this._wordDivider + currentLine.text, width, context);
|
|
541
|
+
const linesToRemove = lines.length - n + 1;
|
|
542
|
+
for (let i = 0; i < linesToRemove; i++) {
|
|
543
|
+
lines.pop();
|
|
544
|
+
}
|
|
545
|
+
return lines;
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
return lines;
|
|
549
|
+
}
|
|
550
|
+
_renderLines(context) {
|
|
551
|
+
if (!this._fontOffset || !this._lines) {
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
554
|
+
const height = this._currentMeasure.height;
|
|
555
|
+
let rootY = 0;
|
|
556
|
+
switch (this._textVerticalAlignment) {
|
|
557
|
+
case Control.VERTICAL_ALIGNMENT_TOP:
|
|
558
|
+
rootY = this._fontOffset.ascent;
|
|
559
|
+
break;
|
|
560
|
+
case Control.VERTICAL_ALIGNMENT_BOTTOM:
|
|
561
|
+
rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
|
|
562
|
+
break;
|
|
563
|
+
case Control.VERTICAL_ALIGNMENT_CENTER:
|
|
564
|
+
rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
|
|
565
|
+
break;
|
|
566
|
+
}
|
|
567
|
+
rootY += this._currentMeasure.top;
|
|
568
|
+
for (let i = 0; i < this._lines.length; i++) {
|
|
569
|
+
const line = this._lines[i];
|
|
570
|
+
if (i !== 0 && this._lineSpacing.internalValue !== 0) {
|
|
571
|
+
if (this._lineSpacing.isPixel) {
|
|
572
|
+
rootY += this._lineSpacing.getValue(this._host);
|
|
573
|
+
}
|
|
574
|
+
else {
|
|
575
|
+
rootY = rootY + this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
this._drawText(line.text, line.width, rootY, context);
|
|
579
|
+
rootY += this._fontOffset.height;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
_computeHeightForLinesOf(lineCount) {
|
|
583
|
+
let newHeight = this._paddingTopInPixels + this._paddingBottomInPixels + this._fontOffset.height * lineCount;
|
|
584
|
+
if (lineCount > 0 && this._lineSpacing.internalValue !== 0) {
|
|
585
|
+
let lineSpacing = 0;
|
|
586
|
+
if (this._lineSpacing.isPixel) {
|
|
587
|
+
lineSpacing = this._lineSpacing.getValue(this._host);
|
|
588
|
+
}
|
|
589
|
+
else {
|
|
590
|
+
lineSpacing = this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
|
|
591
|
+
}
|
|
592
|
+
newHeight += (lineCount - 1) * lineSpacing;
|
|
593
|
+
}
|
|
594
|
+
return newHeight;
|
|
595
|
+
}
|
|
596
|
+
isDimensionFullyDefined(dim) {
|
|
597
|
+
if (this.resizeToFit) {
|
|
598
|
+
return true;
|
|
599
|
+
}
|
|
600
|
+
return super.isDimensionFullyDefined(dim);
|
|
601
|
+
}
|
|
602
|
+
/**
|
|
603
|
+
* Given a width constraint applied on the text block, find the expected height
|
|
604
|
+
* @returns expected height
|
|
605
|
+
*/
|
|
606
|
+
computeExpectedHeight() {
|
|
607
|
+
if (this.text && this.widthInPixels) {
|
|
608
|
+
// Should abstract platform instead of using LastCreatedEngine
|
|
609
|
+
const context = EngineStore.LastCreatedEngine?.createCanvas(0, 0).getContext("2d");
|
|
610
|
+
if (context) {
|
|
611
|
+
this._applyStates(context);
|
|
612
|
+
if (!this._fontOffset) {
|
|
613
|
+
this._fontOffset = Control._GetFontOffset(context.font, this._host.getScene()?.getEngine());
|
|
614
|
+
}
|
|
615
|
+
const lines = this._lines
|
|
616
|
+
? this._lines
|
|
617
|
+
: this._breakLines(this.widthInPixels - this._paddingLeftInPixels - this._paddingRightInPixels, this.heightInPixels - this._paddingTopInPixels - this._paddingBottomInPixels, context);
|
|
618
|
+
return this._computeHeightForLinesOf(lines.length);
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
return 0;
|
|
622
|
+
}
|
|
623
|
+
dispose() {
|
|
624
|
+
super.dispose();
|
|
625
|
+
this.onTextChangedObservable.clear();
|
|
626
|
+
this._htmlElement?.remove();
|
|
627
|
+
this._htmlElement = null;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
__decorate([
|
|
631
|
+
serialize()
|
|
632
|
+
], TextBlock.prototype, "resizeToFit", null);
|
|
633
|
+
__decorate([
|
|
634
|
+
serialize()
|
|
635
|
+
], TextBlock.prototype, "textWrapping", null);
|
|
636
|
+
__decorate([
|
|
637
|
+
serialize()
|
|
638
|
+
], TextBlock.prototype, "text", null);
|
|
639
|
+
__decorate([
|
|
640
|
+
serialize()
|
|
641
|
+
], TextBlock.prototype, "textHorizontalAlignment", null);
|
|
642
|
+
__decorate([
|
|
643
|
+
serialize()
|
|
644
|
+
], TextBlock.prototype, "textVerticalAlignment", null);
|
|
645
|
+
__decorate([
|
|
646
|
+
serialize()
|
|
647
|
+
], TextBlock.prototype, "lineSpacing", null);
|
|
648
|
+
__decorate([
|
|
649
|
+
serialize()
|
|
650
|
+
], TextBlock.prototype, "outlineWidth", null);
|
|
651
|
+
__decorate([
|
|
652
|
+
serialize()
|
|
653
|
+
], TextBlock.prototype, "underline", null);
|
|
654
|
+
__decorate([
|
|
655
|
+
serialize()
|
|
656
|
+
], TextBlock.prototype, "lineThrough", null);
|
|
657
|
+
__decorate([
|
|
658
|
+
serialize()
|
|
659
|
+
], TextBlock.prototype, "applyOutlineToUnderline", null);
|
|
660
|
+
__decorate([
|
|
661
|
+
serialize()
|
|
662
|
+
], TextBlock.prototype, "outlineColor", null);
|
|
663
|
+
__decorate([
|
|
664
|
+
serialize()
|
|
665
|
+
], TextBlock.prototype, "wordDivider", null);
|
|
666
|
+
__decorate([
|
|
667
|
+
serialize()
|
|
668
|
+
], TextBlock.prototype, "forceResizeWidth", null);
|
|
669
|
+
RegisterClass("BABYLON.GUI.TextBlock", TextBlock);
|
|
670
|
+
//# sourceMappingURL=textBlock.js.map
|