@next2d/player 1.14.19 → 1.14.21
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/index.js +3 -3
- package/package.json +31 -6
- package/interface/AjaxEventImpl.d.ts +0 -5
- package/interface/AjaxEventImpl.js +0 -1
- package/interface/AjaxOptionImpl.d.ts +0 -13
- package/interface/AjaxOptionImpl.js +0 -1
- package/interface/AttachmentImpl.d.ts +0 -11
- package/interface/AttachmentImpl.js +0 -1
- package/interface/BitmapDataChannelImpl.d.ts +0 -1
- package/interface/BitmapDataChannelImpl.js +0 -1
- package/interface/BitmapDrawObjectImpl.d.ts +0 -6
- package/interface/BitmapDrawObjectImpl.js +0 -1
- package/interface/BitmapFilterTypeImpl.d.ts +0 -1
- package/interface/BitmapFilterTypeImpl.js +0 -1
- package/interface/BlendModeImpl.d.ts +0 -1
- package/interface/BlendModeImpl.js +0 -1
- package/interface/BoundsImpl.d.ts +0 -6
- package/interface/BoundsImpl.js +0 -1
- package/interface/Character.d.ts +0 -2
- package/interface/Character.js +0 -1
- package/interface/CharacterImpl.d.ts +0 -2
- package/interface/CharacterImpl.js +0 -1
- package/interface/ClipObjectImpl.d.ts +0 -14
- package/interface/ClipObjectImpl.js +0 -1
- package/interface/ColorStopImpl.d.ts +0 -7
- package/interface/ColorStopImpl.js +0 -1
- package/interface/DictionaryTagImpl.d.ts +0 -7
- package/interface/DictionaryTagImpl.js +0 -1
- package/interface/DisplacementMapFilterModeImpl.d.ts +0 -1
- package/interface/DisplacementMapFilterModeImpl.js +0 -1
- package/interface/DisplayImpl.d.ts +0 -28
- package/interface/DisplayImpl.js +0 -1
- package/interface/DisplayObjectImpl.d.ts +0 -2
- package/interface/DisplayObjectImpl.js +0 -1
- package/interface/DragRulesImpl.d.ts +0 -7
- package/interface/DragRulesImpl.js +0 -1
- package/interface/DropTargetImpl.d.ts +0 -2
- package/interface/DropTargetImpl.js +0 -1
- package/interface/EventDispatcherImpl.d.ts +0 -2
- package/interface/EventDispatcherImpl.js +0 -1
- package/interface/EventListenerImpl.d.ts +0 -6
- package/interface/EventListenerImpl.js +0 -1
- package/interface/EventsImpl.d.ts +0 -20
- package/interface/EventsImpl.js +0 -1
- package/interface/FillMeshImpl.d.ts +0 -5
- package/interface/FillMeshImpl.js +0 -1
- package/interface/FilterArrayImpl.d.ts +0 -10
- package/interface/FilterArrayImpl.js +0 -1
- package/interface/FilterQualityImpl.d.ts +0 -1
- package/interface/FilterQualityImpl.js +0 -1
- package/interface/FiltersImpl.d.ts +0 -20
- package/interface/FiltersImpl.js +0 -1
- package/interface/GeomImpl.d.ts +0 -12
- package/interface/GeomImpl.js +0 -1
- package/interface/GradientTypeImpl.d.ts +0 -3
- package/interface/GradientTypeImpl.js +0 -1
- package/interface/GraphicsParentImpl.d.ts +0 -2
- package/interface/GraphicsParentImpl.js +0 -1
- package/interface/GridImpl.d.ts +0 -6
- package/interface/GridImpl.js +0 -1
- package/interface/ImageTypeImpl.d.ts +0 -1
- package/interface/ImageTypeImpl.js +0 -1
- package/interface/IndexRangeImpl.d.ts +0 -4
- package/interface/IndexRangeImpl.js +0 -1
- package/interface/LoaderInfoDataImpl.d.ts +0 -7
- package/interface/LoaderInfoDataImpl.js +0 -1
- package/interface/LoopConfigImpl.d.ts +0 -8
- package/interface/LoopConfigImpl.js +0 -1
- package/interface/LoopTypeImpl.d.ts +0 -1
- package/interface/LoopTypeImpl.js +0 -1
- package/interface/MediaImpl.d.ts +0 -10
- package/interface/MediaImpl.js +0 -1
- package/interface/MovieClipActionObjectImpl.d.ts +0 -5
- package/interface/MovieClipActionObjectImpl.js +0 -1
- package/interface/MovieClipCharacterImpl.d.ts +0 -18
- package/interface/MovieClipCharacterImpl.js +0 -1
- package/interface/MovieClipLabelObjectImpl.d.ts +0 -4
- package/interface/MovieClipLabelObjectImpl.js +0 -1
- package/interface/MovieClipSoundObjectImpl.d.ts +0 -5
- package/interface/MovieClipSoundObjectImpl.js +0 -1
- package/interface/NetImpl.d.ts +0 -6
- package/interface/NetImpl.js +0 -1
- package/interface/NoCodeDataImpl.d.ts +0 -7
- package/interface/NoCodeDataImpl.js +0 -1
- package/interface/NoCodeDataZlibImpl.d.ts +0 -4
- package/interface/NoCodeDataZlibImpl.js +0 -1
- package/interface/ParentImpl.d.ts +0 -2
- package/interface/ParentImpl.js +0 -1
- package/interface/PlaceObjectImpl.d.ts +0 -12
- package/interface/PlaceObjectImpl.js +0 -1
- package/interface/PlayerHitObjectImpl.d.ts +0 -7
- package/interface/PlayerHitObjectImpl.js +0 -1
- package/interface/PlayerModeImpl.d.ts +0 -1
- package/interface/PlayerModeImpl.js +0 -1
- package/interface/PlayerOptionsImpl.d.ts +0 -8
- package/interface/PlayerOptionsImpl.js +0 -1
- package/interface/PointImpl.d.ts +0 -4
- package/interface/PointImpl.js +0 -1
- package/interface/PreObjectImpl.d.ts +0 -23
- package/interface/PreObjectImpl.js +0 -1
- package/interface/PropertyBitmapDataMessageImpl.d.ts +0 -8
- package/interface/PropertyBitmapDataMessageImpl.js +0 -1
- package/interface/PropertyContainerMessageImpl.d.ts +0 -6
- package/interface/PropertyContainerMessageImpl.js +0 -1
- package/interface/PropertyMessageImpl.d.ts +0 -41
- package/interface/PropertyMessageImpl.js +0 -1
- package/interface/PropertyMessageMapImpl.d.ts +0 -2
- package/interface/PropertyMessageMapImpl.js +0 -1
- package/interface/PropertyShapeMessageImpl.d.ts +0 -6
- package/interface/PropertyShapeMessageImpl.js +0 -1
- package/interface/PropertyTextMessageImpl.d.ts +0 -25
- package/interface/PropertyTextMessageImpl.js +0 -1
- package/interface/PropertyVideoMessageImpl.d.ts +0 -5
- package/interface/PropertyVideoMessageImpl.js +0 -1
- package/interface/RGBAImpl.d.ts +0 -6
- package/interface/RGBAImpl.js +0 -1
- package/interface/ShapeCharacterImpl.d.ts +0 -14
- package/interface/ShapeCharacterImpl.js +0 -1
- package/interface/SoundCharacterImpl.d.ts +0 -5
- package/interface/SoundCharacterImpl.js +0 -1
- package/interface/SoundTagImpl.d.ts +0 -6
- package/interface/SoundTagImpl.js +0 -1
- package/interface/SpriteImpl.d.ts +0 -2
- package/interface/SpriteImpl.js +0 -1
- package/interface/StageDataImpl.d.ts +0 -6
- package/interface/StageDataImpl.js +0 -1
- package/interface/StageQualityImpl.d.ts +0 -1
- package/interface/StageQualityImpl.js +0 -1
- package/interface/StrokeMethImpl.d.ts +0 -4
- package/interface/StrokeMethImpl.js +0 -1
- package/interface/StrokeTypeImpl.d.ts +0 -2
- package/interface/StrokeTypeImpl.js +0 -1
- package/interface/SurfaceFilterImpl.d.ts +0 -6
- package/interface/SurfaceFilterImpl.js +0 -1
- package/interface/TextBreakObjectImpl.d.ts +0 -9
- package/interface/TextBreakObjectImpl.js +0 -1
- package/interface/TextCharacterImpl.d.ts +0 -27
- package/interface/TextCharacterImpl.js +0 -1
- package/interface/TextDataImpl.d.ts +0 -2
- package/interface/TextDataImpl.js +0 -1
- package/interface/TextFieldAutoSizeImpl.d.ts +0 -1
- package/interface/TextFieldAutoSizeImpl.js +0 -1
- package/interface/TextFieldTypeImpl.d.ts +0 -1
- package/interface/TextFieldTypeImpl.js +0 -1
- package/interface/TextFormatAlignImpl.d.ts +0 -1
- package/interface/TextFormatAlignImpl.js +0 -1
- package/interface/TextFormatVerticalAlignImpl.d.ts +0 -1
- package/interface/TextFormatVerticalAlignImpl.js +0 -1
- package/interface/TextImageObjectImpl.d.ts +0 -11
- package/interface/TextImageObjectImpl.js +0 -1
- package/interface/TextImpl.d.ts +0 -6
- package/interface/TextImpl.js +0 -1
- package/interface/TextObjectImpl.d.ts +0 -7
- package/interface/TextObjectImpl.js +0 -1
- package/interface/TextObjectModeImpl.d.ts +0 -1
- package/interface/TextObjectModeImpl.js +0 -1
- package/interface/TextStringObjectImpl.d.ts +0 -7
- package/interface/TextStringObjectImpl.js +0 -1
- package/interface/UIImpl.d.ts +0 -8
- package/interface/UIImpl.js +0 -1
- package/interface/URLLoaderDataFormatImpl.d.ts +0 -1
- package/interface/URLLoaderDataFormatImpl.js +0 -1
- package/interface/URLRequestMethodImpl.d.ts +0 -1
- package/interface/URLRequestMethodImpl.js +0 -1
- package/interface/UniformDataImpl.d.ts +0 -5
- package/interface/UniformDataImpl.js +0 -1
- package/interface/UnzipQueueImpl.d.ts +0 -6
- package/interface/UnzipQueueImpl.js +0 -1
- package/interface/VerticesImpl.d.ts +0 -1
- package/interface/VerticesImpl.js +0 -1
- package/interface/VideoCharacterImpl.d.ts +0 -12
- package/interface/VideoCharacterImpl.js +0 -1
- package/next2d/display/BitmapData.d.ts +0 -143
- package/next2d/display/BitmapData.js +0 -387
- package/next2d/display/BlendMode.d.ts +0 -204
- package/next2d/display/BlendMode.js +0 -240
- package/next2d/display/DisplayObject.d.ts +0 -565
- package/next2d/display/DisplayObject.js +0 -1670
- package/next2d/display/DisplayObjectContainer.d.ts +0 -351
- package/next2d/display/DisplayObjectContainer.js +0 -1776
- package/next2d/display/FrameLabel.d.ts +0 -98
- package/next2d/display/FrameLabel.js +0 -120
- package/next2d/display/Graphics.d.ts +0 -577
- package/next2d/display/Graphics.js +0 -2161
- package/next2d/display/GraphicsBitmapFill.d.ts +0 -49
- package/next2d/display/GraphicsBitmapFill.js +0 -86
- package/next2d/display/GraphicsGradientFill.d.ts +0 -66
- package/next2d/display/GraphicsGradientFill.js +0 -157
- package/next2d/display/InteractiveObject.d.ts +0 -32
- package/next2d/display/InteractiveObject.js +0 -43
- package/next2d/display/Loader.d.ts +0 -131
- package/next2d/display/Loader.js +0 -321
- package/next2d/display/LoaderInfo.d.ts +0 -122
- package/next2d/display/LoaderInfo.js +0 -184
- package/next2d/display/LoopConfig.d.ts +0 -108
- package/next2d/display/LoopConfig.js +0 -156
- package/next2d/display/LoopType.d.ts +0 -104
- package/next2d/display/LoopType.js +0 -122
- package/next2d/display/MovieClip.d.ts +0 -314
- package/next2d/display/MovieClip.js +0 -941
- package/next2d/display/Shape.d.ts +0 -169
- package/next2d/display/Shape.js +0 -509
- package/next2d/display/Sprite.d.ts +0 -175
- package/next2d/display/Sprite.js +0 -280
- package/next2d/display/Stage.d.ts +0 -164
- package/next2d/display/Stage.js +0 -251
- package/next2d/events/Event.d.ts +0 -424
- package/next2d/events/Event.js +0 -560
- package/next2d/events/EventDispatcher.d.ts +0 -138
- package/next2d/events/EventDispatcher.js +0 -623
- package/next2d/events/EventPhase.d.ts +0 -80
- package/next2d/events/EventPhase.js +0 -94
- package/next2d/events/FocusEvent.d.ts +0 -89
- package/next2d/events/FocusEvent.js +0 -103
- package/next2d/events/HTTPStatusEvent.d.ts +0 -107
- package/next2d/events/HTTPStatusEvent.js +0 -139
- package/next2d/events/IOErrorEvent.d.ts +0 -82
- package/next2d/events/IOErrorEvent.js +0 -101
- package/next2d/events/MouseEvent.d.ts +0 -163
- package/next2d/events/MouseEvent.js +0 -207
- package/next2d/events/ProgressEvent.d.ts +0 -97
- package/next2d/events/ProgressEvent.js +0 -123
- package/next2d/events/VideoEvent.d.ts +0 -145
- package/next2d/events/VideoEvent.js +0 -181
- package/next2d/filters/BevelFilter.d.ts +0 -254
- package/next2d/filters/BevelFilter.js +0 -491
- package/next2d/filters/BitmapFilter.d.ts +0 -75
- package/next2d/filters/BitmapFilter.js +0 -95
- package/next2d/filters/BlurFilter.d.ts +0 -150
- package/next2d/filters/BlurFilter.js +0 -370
- package/next2d/filters/ColorMatrixFilter.d.ts +0 -116
- package/next2d/filters/ColorMatrixFilter.js +0 -179
- package/next2d/filters/ConvolutionFilter.d.ts +0 -210
- package/next2d/filters/ConvolutionFilter.js +0 -366
- package/next2d/filters/DisplacementMapFilter.d.ts +0 -212
- package/next2d/filters/DisplacementMapFilter.js +0 -372
- package/next2d/filters/DropShadowFilter.d.ts +0 -240
- package/next2d/filters/DropShadowFilter.js +0 -461
- package/next2d/filters/GlowFilter.d.ts +0 -204
- package/next2d/filters/GlowFilter.js +0 -356
- package/next2d/filters/GradientBevelFilter.d.ts +0 -243
- package/next2d/filters/GradientBevelFilter.js +0 -474
- package/next2d/filters/GradientGlowFilter.d.ts +0 -243
- package/next2d/filters/GradientGlowFilter.js +0 -464
- package/next2d/geom/ColorTransform.d.ts +0 -201
- package/next2d/geom/ColorTransform.js +0 -278
- package/next2d/geom/Matrix.d.ts +0 -299
- package/next2d/geom/Matrix.js +0 -454
- package/next2d/geom/Point.d.ts +0 -213
- package/next2d/geom/Point.js +0 -274
- package/next2d/geom/Rectangle.d.ts +0 -364
- package/next2d/geom/Rectangle.js +0 -513
- package/next2d/geom/Transform.d.ts +0 -213
- package/next2d/geom/Transform.js +0 -492
- package/next2d/media/Sound.d.ts +0 -208
- package/next2d/media/Sound.js +0 -504
- package/next2d/media/SoundMixer.d.ts +0 -68
- package/next2d/media/SoundMixer.js +0 -115
- package/next2d/media/SoundTransform.d.ts +0 -80
- package/next2d/media/SoundTransform.js +0 -111
- package/next2d/media/Video.d.ts +0 -331
- package/next2d/media/Video.js +0 -856
- package/next2d/net/URLRequest.d.ts +0 -143
- package/next2d/net/URLRequest.js +0 -232
- package/next2d/net/URLRequestHeader.d.ts +0 -82
- package/next2d/net/URLRequestHeader.js +0 -105
- package/next2d/text/TextField.d.ts +0 -644
- package/next2d/text/TextField.js +0 -2662
- package/next2d/text/TextFormat.d.ts +0 -250
- package/next2d/text/TextFormat.js +0 -460
- package/next2d/ui/Easing.d.ts +0 -359
- package/next2d/ui/Easing.js +0 -481
- package/next2d/ui/Job.d.ts +0 -155
- package/next2d/ui/Job.js +0 -333
- package/next2d/ui/Tween.d.ts +0 -62
- package/next2d/ui/Tween.js +0 -72
- package/packages/Display.d.ts +0 -3
- package/packages/Display.js +0 -36
- package/packages/Events.d.ts +0 -3
- package/packages/Events.js +0 -28
- package/packages/Filters.d.ts +0 -3
- package/packages/Filters.js +0 -28
- package/packages/Geom.d.ts +0 -3
- package/packages/Geom.js +0 -20
- package/packages/Media.d.ts +0 -3
- package/packages/Media.js +0 -18
- package/packages/Net.d.ts +0 -3
- package/packages/Net.js +0 -14
- package/packages/Text.d.ts +0 -3
- package/packages/Text.js +0 -14
- package/packages/UI.d.ts +0 -3
- package/packages/UI.js +0 -16
- package/player/Next2D.d.ts +0 -70
- package/player/Next2D.js +0 -192
- package/player/Player.d.ts +0 -334
- package/player/Player.js +0 -1863
- package/util/CacheStore.d.ts +0 -115
- package/util/CacheStore.js +0 -276
- package/util/Global.d.ts +0 -23
- package/util/Global.js +0 -67
- package/util/RenderUtil.d.ts +0 -472
- package/util/RenderUtil.js +0 -686
- package/util/Shortcut.d.ts +0 -28
- package/util/Shortcut.js +0 -28
- package/util/Util.d.ts +0 -334
- package/util/Util.js +0 -844
- package/webgl/BezierConverter.d.ts +0 -59
- package/webgl/BezierConverter.js +0 -106
- package/webgl/CanvasGradientToWebGL.d.ts +0 -94
- package/webgl/CanvasGradientToWebGL.js +0 -181
- package/webgl/CanvasPatternToWebGL.d.ts +0 -39
- package/webgl/CanvasPatternToWebGL.js +0 -66
- package/webgl/CanvasToWebGLContext.d.ts +0 -596
- package/webgl/CanvasToWebGLContext.js +0 -1421
- package/webgl/CanvasToWebGLContextBlend.d.ts +0 -97
- package/webgl/CanvasToWebGLContextBlend.js +0 -299
- package/webgl/CanvasToWebGLContextGrid.d.ts +0 -74
- package/webgl/CanvasToWebGLContextGrid.js +0 -283
- package/webgl/CanvasToWebGLContextMask.d.ts +0 -113
- package/webgl/CanvasToWebGLContextMask.js +0 -436
- package/webgl/CanvasToWebGLContextPath.d.ts +0 -111
- package/webgl/CanvasToWebGLContextPath.js +0 -210
- package/webgl/CanvasToWebGLContextStyle.d.ts +0 -77
- package/webgl/CanvasToWebGLContextStyle.js +0 -139
- package/webgl/ColorBufferPool.d.ts +0 -58
- package/webgl/ColorBufferPool.js +0 -134
- package/webgl/FrameBufferManager.d.ts +0 -135
- package/webgl/FrameBufferManager.js +0 -358
- package/webgl/StencilBufferPool.d.ts +0 -56
- package/webgl/StencilBufferPool.js +0 -142
- package/webgl/TextureManager.d.ts +0 -130
- package/webgl/TextureManager.js +0 -296
- package/webgl/VertexArrayObjectManager.d.ts +0 -95
- package/webgl/VertexArrayObjectManager.js +0 -277
- package/webgl/WebGLFillMeshGenerator.d.ts +0 -31
- package/webgl/WebGLFillMeshGenerator.js +0 -101
- package/webgl/WebGLStrokeMeshGenerator.d.ts +0 -182
- package/webgl/WebGLStrokeMeshGenerator.js +0 -504
- package/webgl/shader/CanvasToWebGLShader.d.ts +0 -85
- package/webgl/shader/CanvasToWebGLShader.js +0 -192
- package/webgl/shader/CanvasToWebGLShaderList.d.ts +0 -70
- package/webgl/shader/CanvasToWebGLShaderList.js +0 -109
- package/webgl/shader/GradientLUTGenerator.d.ts +0 -36
- package/webgl/shader/GradientLUTGenerator.js +0 -123
- package/webgl/shader/WebGLShaderUniform.d.ts +0 -52
- package/webgl/shader/WebGLShaderUniform.js +0 -165
- package/webgl/shader/fragment/FragmentShaderLibrary.d.ts +0 -18
- package/webgl/shader/fragment/FragmentShaderLibrary.js +0 -35
- package/webgl/shader/fragment/FragmentShaderSource.d.ts +0 -29
- package/webgl/shader/fragment/FragmentShaderSource.js +0 -99
- package/webgl/shader/fragment/FragmentShaderSourceBlend.d.ts +0 -67
- package/webgl/shader/fragment/FragmentShaderSourceBlend.js +0 -319
- package/webgl/shader/fragment/FragmentShaderSourceGradient.d.ts +0 -44
- package/webgl/shader/fragment/FragmentShaderSourceGradient.js +0 -114
- package/webgl/shader/fragment/FragmentShaderSourceGradientLUT.d.ts +0 -14
- package/webgl/shader/fragment/FragmentShaderSourceGradientLUT.js +0 -58
- package/webgl/shader/fragment/FragmentShaderSourceTexture.d.ts +0 -12
- package/webgl/shader/fragment/FragmentShaderSourceTexture.js +0 -36
- package/webgl/shader/fragment/filter/FragmentShaderSourceBlurFilter.d.ts +0 -12
- package/webgl/shader/fragment/filter/FragmentShaderSourceBlurFilter.js +0 -42
- package/webgl/shader/fragment/filter/FragmentShaderSourceColorMatrixFilter.d.ts +0 -11
- package/webgl/shader/fragment/filter/FragmentShaderSourceColorMatrixFilter.js +0 -35
- package/webgl/shader/fragment/filter/FragmentShaderSourceConvolutionFilter.d.ts +0 -16
- package/webgl/shader/fragment/filter/FragmentShaderSourceConvolutionFilter.js +0 -80
- package/webgl/shader/fragment/filter/FragmentShaderSourceDisplacementMapFilter.d.ts +0 -15
- package/webgl/shader/fragment/filter/FragmentShaderSourceDisplacementMapFilter.js +0 -106
- package/webgl/shader/fragment/filter/FragmentShaderSourceFilter.d.ts +0 -112
- package/webgl/shader/fragment/filter/FragmentShaderSourceFilter.js +0 -275
- package/webgl/shader/variants/BlendShaderVariantCollection.d.ts +0 -99
- package/webgl/shader/variants/BlendShaderVariantCollection.js +0 -239
- package/webgl/shader/variants/FilterShaderVariantCollection.d.ts +0 -150
- package/webgl/shader/variants/FilterShaderVariantCollection.js +0 -395
- package/webgl/shader/variants/GradientLUTShaderVariantCollection.d.ts +0 -49
- package/webgl/shader/variants/GradientLUTShaderVariantCollection.js +0 -107
- package/webgl/shader/variants/GradientShapeShaderVariantCollection.d.ts +0 -61
- package/webgl/shader/variants/GradientShapeShaderVariantCollection.js +0 -196
- package/webgl/shader/variants/ShapeShaderVariantCollection.d.ts +0 -117
- package/webgl/shader/variants/ShapeShaderVariantCollection.js +0 -427
- package/webgl/shader/vertex/VertexShaderLibrary.d.ts +0 -18
- package/webgl/shader/vertex/VertexShaderLibrary.js +0 -75
- package/webgl/shader/vertex/VertexShaderSource.d.ts +0 -23
- package/webgl/shader/vertex/VertexShaderSource.js +0 -92
- package/webgl/shader/vertex/VertexShaderSourceFill.d.ts +0 -45
- package/webgl/shader/vertex/VertexShaderSourceFill.js +0 -112
- package/webgl/shader/vertex/VertexShaderSourceStroke.d.ts +0 -27
- package/webgl/shader/vertex/VertexShaderSourceStroke.js +0 -149
package/next2d/text/TextField.js
DELETED
|
@@ -1,2662 +0,0 @@
|
|
|
1
|
-
import { InteractiveObject } from "../display/InteractiveObject";
|
|
2
|
-
import { TextFormat } from "./TextFormat";
|
|
3
|
-
import { FocusEvent } from "../events/FocusEvent";
|
|
4
|
-
import { Event as Next2DEvent } from "../events/Event";
|
|
5
|
-
import { MouseEvent as Next2DMouseEvent } from "../events/MouseEvent";
|
|
6
|
-
import { Sprite } from "../display/Sprite";
|
|
7
|
-
import { Tween } from "../ui/Tween";
|
|
8
|
-
import { Rectangle } from "../geom/Rectangle";
|
|
9
|
-
import { $doUpdated } from "../../util/Global";
|
|
10
|
-
import { $currentPlayer, $DIV, $isSafari, $MOUSE_DOWN, $MOUSE_UP, $MOUSE_WHEEL, $P_TAG, $PREFIX, $rendererWorker, $SCROLL, $textContext, $TOUCH_END, $TOUCH_START } from "../../util/Util";
|
|
11
|
-
import { $devicePixelRatio, $document, $RegExp } from "../../util/Shortcut";
|
|
12
|
-
import { $clamp, $getArray, $intToRGBA, $isNaN, $Math, $requestAnimationFrame, $toColorInt, $getMap, $poolFloat32Array6, $boundsMatrix, $multiplicationMatrix, $poolBoundsObject, $multiplicationColor, $Infinity, $Number, $poolArray, $poolFloat32Array8, $generateFontStyle, $getBoundsObject } from "../../util/RenderUtil";
|
|
13
|
-
/**
|
|
14
|
-
* TextField クラスは、テキストの表示と入力用の表示オブジェクトを作成するために使用されます。
|
|
15
|
-
* プロパティインスペクターを使用して、テキストフィールドにインスタンス名を付けることができます。
|
|
16
|
-
* また、TextField クラスのメソッドとプロパティを使用して、JavaScript でテキストフィールドを操作できます。
|
|
17
|
-
*
|
|
18
|
-
* The TextField class is used to create display objects for text display and input.
|
|
19
|
-
* You can give a text field an instance name in the Property inspector
|
|
20
|
-
* and use the methods and properties of the TextField class to manipulate it with JavaScript.
|
|
21
|
-
*
|
|
22
|
-
* @class
|
|
23
|
-
* @memberOf next2d.text
|
|
24
|
-
* @extends InteractiveObject
|
|
25
|
-
*/
|
|
26
|
-
export class TextField extends InteractiveObject {
|
|
27
|
-
/**
|
|
28
|
-
* @constructor
|
|
29
|
-
* @public
|
|
30
|
-
*/
|
|
31
|
-
constructor() {
|
|
32
|
-
super();
|
|
33
|
-
/**
|
|
34
|
-
* @type {boolean}
|
|
35
|
-
* @default false
|
|
36
|
-
* @private
|
|
37
|
-
*/
|
|
38
|
-
this._$background = false;
|
|
39
|
-
/**
|
|
40
|
-
* @type {number}
|
|
41
|
-
* @default 0xffffff
|
|
42
|
-
* @private
|
|
43
|
-
*/
|
|
44
|
-
this._$backgroundColor = 0xffffff;
|
|
45
|
-
/**
|
|
46
|
-
* @type {boolean}
|
|
47
|
-
* @default false
|
|
48
|
-
* @private
|
|
49
|
-
*/
|
|
50
|
-
this._$border = false;
|
|
51
|
-
/**
|
|
52
|
-
* @type {number}
|
|
53
|
-
* @default 0x000000
|
|
54
|
-
* @private
|
|
55
|
-
*/
|
|
56
|
-
this._$borderColor = 0x000000;
|
|
57
|
-
/**
|
|
58
|
-
* @type {string}
|
|
59
|
-
* @default ""
|
|
60
|
-
* @private
|
|
61
|
-
*/
|
|
62
|
-
this._$htmlText = "";
|
|
63
|
-
/**
|
|
64
|
-
* @type {boolean}
|
|
65
|
-
* @default false
|
|
66
|
-
* @private
|
|
67
|
-
*/
|
|
68
|
-
this._$multiline = false;
|
|
69
|
-
/**
|
|
70
|
-
* @type {string}
|
|
71
|
-
* @default ""
|
|
72
|
-
* @private
|
|
73
|
-
*/
|
|
74
|
-
this._$text = "";
|
|
75
|
-
/**
|
|
76
|
-
* @type {boolean}
|
|
77
|
-
* @default false
|
|
78
|
-
* @private
|
|
79
|
-
*/
|
|
80
|
-
this._$wordWrap = false;
|
|
81
|
-
/**
|
|
82
|
-
* @type {number}
|
|
83
|
-
* @default 0
|
|
84
|
-
* @private
|
|
85
|
-
*/
|
|
86
|
-
this._$scrollH = 0;
|
|
87
|
-
/**
|
|
88
|
-
* @type {number}
|
|
89
|
-
* @default 1
|
|
90
|
-
* @private
|
|
91
|
-
*/
|
|
92
|
-
this._$scrollV = 1;
|
|
93
|
-
/**
|
|
94
|
-
* @type {number}
|
|
95
|
-
* @default null
|
|
96
|
-
* @private
|
|
97
|
-
*/
|
|
98
|
-
this._$maxScrollV = null;
|
|
99
|
-
/**
|
|
100
|
-
* @type {number}
|
|
101
|
-
* @default null
|
|
102
|
-
* @private
|
|
103
|
-
*/
|
|
104
|
-
this._$maxScrollH = null;
|
|
105
|
-
/**
|
|
106
|
-
* @type {number}
|
|
107
|
-
* @default 0
|
|
108
|
-
* @private
|
|
109
|
-
*/
|
|
110
|
-
this._$maxChars = 0;
|
|
111
|
-
// TextFormat
|
|
112
|
-
const textFormat = new TextFormat();
|
|
113
|
-
textFormat._$setDefault();
|
|
114
|
-
/**
|
|
115
|
-
* @type {TextFormat}
|
|
116
|
-
* @private
|
|
117
|
-
*/
|
|
118
|
-
this._$defaultTextFormat = textFormat;
|
|
119
|
-
/**
|
|
120
|
-
* @type {string}
|
|
121
|
-
* @default ""
|
|
122
|
-
* @private
|
|
123
|
-
*/
|
|
124
|
-
this._$rawHtmlText = "";
|
|
125
|
-
/**
|
|
126
|
-
* @type {object}
|
|
127
|
-
* @private
|
|
128
|
-
*/
|
|
129
|
-
this._$bounds = {
|
|
130
|
-
"xMin": 0,
|
|
131
|
-
"xMax": 100,
|
|
132
|
-
"yMin": 0,
|
|
133
|
-
"yMax": 100
|
|
134
|
-
};
|
|
135
|
-
/**
|
|
136
|
-
* @type {object}
|
|
137
|
-
* @private
|
|
138
|
-
*/
|
|
139
|
-
this._$originBounds = {
|
|
140
|
-
"xMin": 0,
|
|
141
|
-
"xMax": 100,
|
|
142
|
-
"yMin": 0,
|
|
143
|
-
"yMax": 100
|
|
144
|
-
};
|
|
145
|
-
/**
|
|
146
|
-
* @type {string}
|
|
147
|
-
* @default null
|
|
148
|
-
* @private
|
|
149
|
-
*/
|
|
150
|
-
this._$restrict = "";
|
|
151
|
-
/**
|
|
152
|
-
* @type {boolean}
|
|
153
|
-
* @default false
|
|
154
|
-
* @private
|
|
155
|
-
*/
|
|
156
|
-
this._$isHTML = false;
|
|
157
|
-
/**
|
|
158
|
-
* @type {boolean}
|
|
159
|
-
* @default false
|
|
160
|
-
* @private
|
|
161
|
-
*/
|
|
162
|
-
this._$createdTextData = false;
|
|
163
|
-
/**
|
|
164
|
-
* @type {array}
|
|
165
|
-
* @private
|
|
166
|
-
*/
|
|
167
|
-
this._$textData = $getArray();
|
|
168
|
-
/**
|
|
169
|
-
* @type {number}
|
|
170
|
-
* @default null
|
|
171
|
-
* @private
|
|
172
|
-
*/
|
|
173
|
-
this._$textHeight = null;
|
|
174
|
-
/**
|
|
175
|
-
* @type {number}
|
|
176
|
-
* @default null
|
|
177
|
-
* @private
|
|
178
|
-
*/
|
|
179
|
-
this._$textWidth = null;
|
|
180
|
-
/**
|
|
181
|
-
* @type {array}
|
|
182
|
-
* @private
|
|
183
|
-
*/
|
|
184
|
-
this._$widthTable = $getArray();
|
|
185
|
-
/**
|
|
186
|
-
* @type {HTMLTextAreaElement}
|
|
187
|
-
* @default null
|
|
188
|
-
* @private
|
|
189
|
-
*/
|
|
190
|
-
this._$textarea = null;
|
|
191
|
-
/**
|
|
192
|
-
* @type {string}
|
|
193
|
-
* @default TextFieldAutoSize.NONE
|
|
194
|
-
* @private
|
|
195
|
-
*/
|
|
196
|
-
this._$autoSize = "none";
|
|
197
|
-
/**
|
|
198
|
-
* @type {boolean}
|
|
199
|
-
* @default false
|
|
200
|
-
* @private
|
|
201
|
-
*/
|
|
202
|
-
this._$autoFontSize = false;
|
|
203
|
-
/**
|
|
204
|
-
* @type {array}
|
|
205
|
-
* @default null
|
|
206
|
-
* @private
|
|
207
|
-
*/
|
|
208
|
-
this._$heightTable = $getArray();
|
|
209
|
-
/**
|
|
210
|
-
* @type {array}
|
|
211
|
-
* @private
|
|
212
|
-
*/
|
|
213
|
-
this._$textFormatTable = $getArray();
|
|
214
|
-
/**
|
|
215
|
-
* @type {boolean}
|
|
216
|
-
* @default false
|
|
217
|
-
* @private
|
|
218
|
-
*/
|
|
219
|
-
this._$textAreaActive = false;
|
|
220
|
-
/**
|
|
221
|
-
* @type {number}
|
|
222
|
-
* @default 0
|
|
223
|
-
* @private
|
|
224
|
-
*/
|
|
225
|
-
this._$totalWidth = 0;
|
|
226
|
-
/**
|
|
227
|
-
* @type {array}
|
|
228
|
-
* @private
|
|
229
|
-
*/
|
|
230
|
-
this._$objectTable = $getArray();
|
|
231
|
-
/**
|
|
232
|
-
* @type {array}
|
|
233
|
-
* @private
|
|
234
|
-
*/
|
|
235
|
-
this._$imageData = $getArray();
|
|
236
|
-
/**
|
|
237
|
-
* @type {boolean}
|
|
238
|
-
* @default true
|
|
239
|
-
* @private
|
|
240
|
-
*/
|
|
241
|
-
this._$scrollEnabled = true;
|
|
242
|
-
/**
|
|
243
|
-
* @type {Sprite}
|
|
244
|
-
* @default null
|
|
245
|
-
* @private
|
|
246
|
-
*/
|
|
247
|
-
this._$scrollSprite = null;
|
|
248
|
-
/**
|
|
249
|
-
* @type {string}
|
|
250
|
-
* @default null
|
|
251
|
-
* @private
|
|
252
|
-
*/
|
|
253
|
-
this._$type = "static";
|
|
254
|
-
/**
|
|
255
|
-
* @type {array}
|
|
256
|
-
* @default null
|
|
257
|
-
* @private
|
|
258
|
-
*/
|
|
259
|
-
this._$textHeightTable = $getArray();
|
|
260
|
-
/**
|
|
261
|
-
* @type {boolean}
|
|
262
|
-
* @default false
|
|
263
|
-
* @private
|
|
264
|
-
*/
|
|
265
|
-
this._$focus = false;
|
|
266
|
-
/**
|
|
267
|
-
* @type {boolean}
|
|
268
|
-
* @default false
|
|
269
|
-
* @private
|
|
270
|
-
*/
|
|
271
|
-
this._$isComposing = false;
|
|
272
|
-
/**
|
|
273
|
-
* @type {number}
|
|
274
|
-
* @default 0
|
|
275
|
-
* @private
|
|
276
|
-
*/
|
|
277
|
-
this._$thickness = 0;
|
|
278
|
-
/**
|
|
279
|
-
* @type {number}
|
|
280
|
-
* @default 0
|
|
281
|
-
* @private
|
|
282
|
-
*/
|
|
283
|
-
this._$thicknessColor = 0;
|
|
284
|
-
/**
|
|
285
|
-
* @type {string}
|
|
286
|
-
* @default TextFormatVerticalAlign.TOP
|
|
287
|
-
* @private
|
|
288
|
-
*/
|
|
289
|
-
this._$verticalAlign = "top";
|
|
290
|
-
/**
|
|
291
|
-
* @type {Map}
|
|
292
|
-
* @private
|
|
293
|
-
*/
|
|
294
|
-
this._$heightCache = $getMap();
|
|
295
|
-
}
|
|
296
|
-
/**
|
|
297
|
-
* @description 指定されたクラスのストリングを返します。
|
|
298
|
-
* Returns the string representation of the specified class.
|
|
299
|
-
*
|
|
300
|
-
* @return {string}
|
|
301
|
-
* @default [class TextField]
|
|
302
|
-
* @method
|
|
303
|
-
* @static
|
|
304
|
-
*/
|
|
305
|
-
static toString() {
|
|
306
|
-
return "[class TextField]";
|
|
307
|
-
}
|
|
308
|
-
/**
|
|
309
|
-
* @description 指定されたクラスの空間名を返します。
|
|
310
|
-
* Returns the space name of the specified class.
|
|
311
|
-
*
|
|
312
|
-
* @return {string}
|
|
313
|
-
* @default next2d.text.TextField
|
|
314
|
-
* @const
|
|
315
|
-
* @static
|
|
316
|
-
*/
|
|
317
|
-
static get namespace() {
|
|
318
|
-
return "next2d.text.TextField";
|
|
319
|
-
}
|
|
320
|
-
/**
|
|
321
|
-
* @description 指定されたオブジェクトのストリングを返します。
|
|
322
|
-
* Returns the string representation of the specified object.
|
|
323
|
-
*
|
|
324
|
-
* @return {string}
|
|
325
|
-
* @default [object TextField]
|
|
326
|
-
* @method
|
|
327
|
-
* @public
|
|
328
|
-
*/
|
|
329
|
-
toString() {
|
|
330
|
-
return "[object TextField]";
|
|
331
|
-
}
|
|
332
|
-
/**
|
|
333
|
-
* @description 指定されたオブジェクトの空間名を返します。
|
|
334
|
-
* Returns the space name of the specified object.
|
|
335
|
-
*
|
|
336
|
-
* @return {string}
|
|
337
|
-
* @default next2d.text.TextField
|
|
338
|
-
* @const
|
|
339
|
-
* @public
|
|
340
|
-
*/
|
|
341
|
-
get namespace() {
|
|
342
|
-
return "next2d.text.TextField";
|
|
343
|
-
}
|
|
344
|
-
/**
|
|
345
|
-
* @description テキストサイズの自動的な拡大 / 縮小および整列を制御します。
|
|
346
|
-
* Controls automatic sizing and alignment of text size.
|
|
347
|
-
*
|
|
348
|
-
* @member {boolean}
|
|
349
|
-
* @default false
|
|
350
|
-
* @public
|
|
351
|
-
*/
|
|
352
|
-
get autoFontSize() {
|
|
353
|
-
return this._$autoFontSize;
|
|
354
|
-
}
|
|
355
|
-
set autoFontSize(auto_font_size) {
|
|
356
|
-
if (auto_font_size !== this._$autoFontSize) {
|
|
357
|
-
this._$autoFontSize = auto_font_size;
|
|
358
|
-
this._$reload();
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
/**
|
|
362
|
-
* @description テキストフィールドの自動的な拡大 / 縮小および整列を制御します。
|
|
363
|
-
* Controls automatic sizing and alignment of text fields.
|
|
364
|
-
*
|
|
365
|
-
* @member {string}
|
|
366
|
-
* @default TextFieldAutoSize.NONE
|
|
367
|
-
* @public
|
|
368
|
-
*/
|
|
369
|
-
get autoSize() {
|
|
370
|
-
return this._$autoSize;
|
|
371
|
-
}
|
|
372
|
-
set autoSize(auto_size) {
|
|
373
|
-
if (auto_size !== this._$autoSize) {
|
|
374
|
-
this._$autoSize = auto_size;
|
|
375
|
-
this._$reload();
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
/**
|
|
379
|
-
* @description テキストフィールドに背景の塗りつぶしがあるかどうかを指定します。
|
|
380
|
-
* Specifies whether the text field has a background fill.
|
|
381
|
-
*
|
|
382
|
-
* @member {boolean}
|
|
383
|
-
* @default false
|
|
384
|
-
* @public
|
|
385
|
-
*/
|
|
386
|
-
get background() {
|
|
387
|
-
return this._$background;
|
|
388
|
-
}
|
|
389
|
-
set background(background) {
|
|
390
|
-
if (background !== this._$background) {
|
|
391
|
-
this._$background = !!background;
|
|
392
|
-
this._$reset();
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
/**
|
|
396
|
-
* @description テキストフィールドの背景の色です。
|
|
397
|
-
* The color of the text field background.
|
|
398
|
-
*
|
|
399
|
-
* @member {number}
|
|
400
|
-
* @default 0xffffff
|
|
401
|
-
* @public
|
|
402
|
-
*/
|
|
403
|
-
get backgroundColor() {
|
|
404
|
-
return this._$backgroundColor;
|
|
405
|
-
}
|
|
406
|
-
set backgroundColor(background_color) {
|
|
407
|
-
background_color = $clamp($toColorInt(background_color), 0, 0xffffff, 0xffffff);
|
|
408
|
-
if (background_color !== this._$backgroundColor) {
|
|
409
|
-
this._$backgroundColor = background_color;
|
|
410
|
-
this._$reset();
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
/**
|
|
414
|
-
* @description テキストフィールドに境界線があるかどうかを指定します。
|
|
415
|
-
* Specifies whether the text field has a border.
|
|
416
|
-
*
|
|
417
|
-
* @member {boolean}
|
|
418
|
-
* @default false
|
|
419
|
-
* @public
|
|
420
|
-
*/
|
|
421
|
-
get border() {
|
|
422
|
-
return this._$border;
|
|
423
|
-
}
|
|
424
|
-
set border(border) {
|
|
425
|
-
if (border !== this._$border) {
|
|
426
|
-
this._$border = !!border;
|
|
427
|
-
this._$reset();
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
/**
|
|
431
|
-
* @description テキストフィールドの境界線の色です。
|
|
432
|
-
* The color of the text field border.
|
|
433
|
-
*
|
|
434
|
-
* @member {number}
|
|
435
|
-
* @default 0x000000
|
|
436
|
-
* @public
|
|
437
|
-
*/
|
|
438
|
-
get borderColor() {
|
|
439
|
-
return this._$borderColor;
|
|
440
|
-
}
|
|
441
|
-
set borderColor(border_color) {
|
|
442
|
-
border_color = $clamp($toColorInt(border_color), 0, 0xffffff, 0);
|
|
443
|
-
if (border_color !== this._$borderColor) {
|
|
444
|
-
this._$borderColor = border_color;
|
|
445
|
-
this._$reset();
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
/**
|
|
449
|
-
* @description テキストに適用するフォーマットを指定します。
|
|
450
|
-
* Specifies the formatting to be applied to the text.
|
|
451
|
-
*
|
|
452
|
-
* @member {TextFormat}
|
|
453
|
-
* @public
|
|
454
|
-
*/
|
|
455
|
-
get defaultTextFormat() {
|
|
456
|
-
return this._$defaultTextFormat._$clone();
|
|
457
|
-
}
|
|
458
|
-
set defaultTextFormat(text_format) {
|
|
459
|
-
text_format._$merge(this._$defaultTextFormat);
|
|
460
|
-
this._$defaultTextFormat = text_format;
|
|
461
|
-
this._$reset();
|
|
462
|
-
}
|
|
463
|
-
/**
|
|
464
|
-
* @description このオブジェクトでマウスまたはその他のユーザー入力メッセージを
|
|
465
|
-
*
|
|
466
|
-
* @member {boolean}
|
|
467
|
-
* @default false
|
|
468
|
-
* @public
|
|
469
|
-
*/
|
|
470
|
-
get focus() {
|
|
471
|
-
return this._$focus;
|
|
472
|
-
}
|
|
473
|
-
set focus(focus) {
|
|
474
|
-
if (this._$focus === focus) {
|
|
475
|
-
return;
|
|
476
|
-
}
|
|
477
|
-
this._$focus = focus;
|
|
478
|
-
if (this._$focus) {
|
|
479
|
-
if (this._$type === "input") {
|
|
480
|
-
const player = $currentPlayer();
|
|
481
|
-
const div = $document
|
|
482
|
-
.getElementById(player.contentElementId);
|
|
483
|
-
if (!div) {
|
|
484
|
-
return;
|
|
485
|
-
}
|
|
486
|
-
this._$createTextAreaElement(player._$scale);
|
|
487
|
-
// setup
|
|
488
|
-
const element = this._$textarea;
|
|
489
|
-
if (!element) {
|
|
490
|
-
return;
|
|
491
|
-
}
|
|
492
|
-
const matrix = this._$transform.concatenatedMatrix;
|
|
493
|
-
const bounds = this._$getBounds(null);
|
|
494
|
-
const color = $intToRGBA($toColorInt(this._$defaultTextFormat.color), 100);
|
|
495
|
-
element.style.color = `rgb(${color.R},${color.G},${color.B})`;
|
|
496
|
-
element.style.left = `${(matrix.tx + bounds.xMin + player.x / player._$scale / $devicePixelRatio) * player._$scale}px`;
|
|
497
|
-
element.style.top = `${(matrix.ty + bounds.yMin + player.y / player._$scale / $devicePixelRatio) * player._$scale}px`;
|
|
498
|
-
element.style.width = `${$Math.ceil((this.width - 1) * player._$scale)}px`;
|
|
499
|
-
element.style.height = `${$Math.ceil((this.height - 1) * player._$scale)}px`;
|
|
500
|
-
// set text
|
|
501
|
-
element.value = this.text;
|
|
502
|
-
div.appendChild(element);
|
|
503
|
-
$requestAnimationFrame(() => {
|
|
504
|
-
element.focus();
|
|
505
|
-
});
|
|
506
|
-
this._$doChanged();
|
|
507
|
-
$doUpdated();
|
|
508
|
-
this._$textAreaActive = true;
|
|
509
|
-
// focus in event
|
|
510
|
-
if (this.willTrigger(FocusEvent.FOCUS_IN)) {
|
|
511
|
-
this.dispatchEvent(new FocusEvent(FocusEvent.FOCUS_IN));
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
else {
|
|
516
|
-
// execute
|
|
517
|
-
if (this._$textarea) {
|
|
518
|
-
this._$textarea.dispatchEvent(new Event(`${$PREFIX}_blur`));
|
|
519
|
-
if (this.willTrigger(FocusEvent.FOCUS_OUT)) {
|
|
520
|
-
this.dispatchEvent(new FocusEvent(FocusEvent.FOCUS_OUT));
|
|
521
|
-
}
|
|
522
|
-
this._$textarea.remove();
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
/**
|
|
527
|
-
* @description テキストフィールドの内容を HTML で表します。
|
|
528
|
-
* Contains the HTML representation of the text field contents.
|
|
529
|
-
*
|
|
530
|
-
* @member {string}
|
|
531
|
-
* @default ""
|
|
532
|
-
* @public
|
|
533
|
-
*/
|
|
534
|
-
get htmlText() {
|
|
535
|
-
return this._$htmlText;
|
|
536
|
-
}
|
|
537
|
-
set htmlText(html_text) {
|
|
538
|
-
if (this._$htmlText !== html_text) {
|
|
539
|
-
this._$htmlText = `${html_text}`;
|
|
540
|
-
this._$rawHtmlText = "";
|
|
541
|
-
this._$text = "";
|
|
542
|
-
this._$isHTML = true;
|
|
543
|
-
this._$textFormatTable.length = 0;
|
|
544
|
-
this._$reload();
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
/**
|
|
548
|
-
* @description テキストフィールド内の文字数です。
|
|
549
|
-
* The int of characters in a text field.
|
|
550
|
-
*
|
|
551
|
-
* @member {number}
|
|
552
|
-
* @readonly
|
|
553
|
-
* @public
|
|
554
|
-
*/
|
|
555
|
-
get length() {
|
|
556
|
-
return this.text.length;
|
|
557
|
-
}
|
|
558
|
-
/**
|
|
559
|
-
* @description ユーザーが入力するときに、テキストフィールドに入力できる最大の文字数です。
|
|
560
|
-
* The maximum number of characters that the text field can contain,
|
|
561
|
-
* as entered by a user.
|
|
562
|
-
*
|
|
563
|
-
* @member {number}
|
|
564
|
-
* @default 0
|
|
565
|
-
* @public
|
|
566
|
-
*/
|
|
567
|
-
get maxChars() {
|
|
568
|
-
return this._$maxChars;
|
|
569
|
-
}
|
|
570
|
-
set maxChars(max_chars) {
|
|
571
|
-
this._$maxChars = max_chars | 0;
|
|
572
|
-
}
|
|
573
|
-
/**
|
|
574
|
-
* TODO
|
|
575
|
-
* @description scrollH の最大値です。
|
|
576
|
-
* The maximum value of scrollH.
|
|
577
|
-
*
|
|
578
|
-
* @member {number}
|
|
579
|
-
* @readonly
|
|
580
|
-
* @public
|
|
581
|
-
*/
|
|
582
|
-
get maxScrollH() {
|
|
583
|
-
if (this._$maxScrollH === null) {
|
|
584
|
-
this._$maxScrollH = 0;
|
|
585
|
-
}
|
|
586
|
-
return this._$maxScrollH;
|
|
587
|
-
}
|
|
588
|
-
/**
|
|
589
|
-
* @description scrollV の最大値です。
|
|
590
|
-
* The maximum value of scrollV.
|
|
591
|
-
*
|
|
592
|
-
* @member {number}
|
|
593
|
-
* @readonly
|
|
594
|
-
* @public
|
|
595
|
-
*/
|
|
596
|
-
get maxScrollV() {
|
|
597
|
-
if (this._$maxScrollV === null) {
|
|
598
|
-
this._$maxScrollV = 1;
|
|
599
|
-
this._$getTextData();
|
|
600
|
-
if (!this._$textHeightTable.length) {
|
|
601
|
-
return this._$maxScrollV;
|
|
602
|
-
}
|
|
603
|
-
const length = this._$textHeightTable.length;
|
|
604
|
-
const maxHeight = this.height;
|
|
605
|
-
if (maxHeight > this.textHeight) {
|
|
606
|
-
return this._$maxScrollV;
|
|
607
|
-
}
|
|
608
|
-
let textHeight = 0;
|
|
609
|
-
let idx = 0;
|
|
610
|
-
while (length > idx) {
|
|
611
|
-
textHeight += this._$textHeightTable[idx++];
|
|
612
|
-
if (textHeight > maxHeight) {
|
|
613
|
-
break;
|
|
614
|
-
}
|
|
615
|
-
this._$maxScrollV++;
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
return this._$maxScrollV;
|
|
619
|
-
}
|
|
620
|
-
/**
|
|
621
|
-
* @description フィールドが複数行テキストフィールドであるかどうかを示します。
|
|
622
|
-
* Indicates whether field is a multiline text field.
|
|
623
|
-
*
|
|
624
|
-
* @member {boolean}
|
|
625
|
-
* @default false
|
|
626
|
-
* @public
|
|
627
|
-
*/
|
|
628
|
-
get multiline() {
|
|
629
|
-
return this._$multiline;
|
|
630
|
-
}
|
|
631
|
-
set multiline(multiline) {
|
|
632
|
-
if (multiline !== this._$multiline) {
|
|
633
|
-
this._$multiline = !!multiline;
|
|
634
|
-
this._$reset();
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
/**
|
|
638
|
-
* @description フィールドが複数行テキストフィールドであるかどうかを示します。
|
|
639
|
-
* Indicates whether field is a multiline text field.
|
|
640
|
-
*
|
|
641
|
-
* @member {number}
|
|
642
|
-
* @readonly
|
|
643
|
-
* @public
|
|
644
|
-
*/
|
|
645
|
-
get numLines() {
|
|
646
|
-
if (!this._$createdTextData) {
|
|
647
|
-
this._$getTextData();
|
|
648
|
-
}
|
|
649
|
-
return this._$objectTable.length;
|
|
650
|
-
}
|
|
651
|
-
/**
|
|
652
|
-
* @description ユーザーがテキストフィールドに入力できる文字のセットを指定します。
|
|
653
|
-
* Indicates the set of characters that a user can enter into the text field.
|
|
654
|
-
*
|
|
655
|
-
* @member {string}
|
|
656
|
-
* @default null
|
|
657
|
-
* @public
|
|
658
|
-
*/
|
|
659
|
-
get restrict() {
|
|
660
|
-
return this._$restrict;
|
|
661
|
-
}
|
|
662
|
-
set restrict(restrict) {
|
|
663
|
-
this._$restrict = `${restrict}`;
|
|
664
|
-
}
|
|
665
|
-
/**
|
|
666
|
-
* @description スクロール機能のON/OFFの制御。
|
|
667
|
-
* Control ON/OFF of the scroll function.
|
|
668
|
-
*
|
|
669
|
-
* @member {boolean}
|
|
670
|
-
* @default true
|
|
671
|
-
* @public
|
|
672
|
-
*/
|
|
673
|
-
get scrollEnabled() {
|
|
674
|
-
return this._$scrollEnabled;
|
|
675
|
-
}
|
|
676
|
-
set scrollEnabled(scroll_enabled) {
|
|
677
|
-
this._$scrollEnabled = scroll_enabled;
|
|
678
|
-
}
|
|
679
|
-
/**
|
|
680
|
-
* TODO
|
|
681
|
-
* @description 現在の水平スクロール位置です。
|
|
682
|
-
* The current horizontal scrolling position.
|
|
683
|
-
*
|
|
684
|
-
* @member {number}
|
|
685
|
-
* @public
|
|
686
|
-
*/
|
|
687
|
-
get scrollH() {
|
|
688
|
-
return this._$scrollH;
|
|
689
|
-
}
|
|
690
|
-
set scrollH(scroll_h) {
|
|
691
|
-
scroll_h = $clamp(scroll_h | 0, 0, this.maxScrollH);
|
|
692
|
-
if (this._$scrollH !== scroll_h) {
|
|
693
|
-
this._$scrollH = scroll_h;
|
|
694
|
-
this._$reset();
|
|
695
|
-
if (this.willTrigger(Next2DEvent.SCROLL)) {
|
|
696
|
-
this.dispatchEvent(new Next2DEvent(Next2DEvent.SCROLL, true));
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
/**
|
|
701
|
-
* @description テキストフィールドのテキストの垂直位置です。
|
|
702
|
-
* The vertical position of text in a text field.
|
|
703
|
-
*
|
|
704
|
-
* @member {number}
|
|
705
|
-
* @public
|
|
706
|
-
*/
|
|
707
|
-
get scrollV() {
|
|
708
|
-
return this._$scrollV;
|
|
709
|
-
}
|
|
710
|
-
set scrollV(scroll_v) {
|
|
711
|
-
scroll_v = $clamp(scroll_v | 0, 1, this.maxScrollV);
|
|
712
|
-
if (this._$scrollV !== scroll_v) {
|
|
713
|
-
this._$scrollV = $Math.max(1, scroll_v);
|
|
714
|
-
this._$reset();
|
|
715
|
-
if (this._$scrollSprite && this.textHeight > this.height) {
|
|
716
|
-
this._$scrollSprite.height = this.height * this.height / this.textHeight - 1;
|
|
717
|
-
const parent = this._$parent;
|
|
718
|
-
if (parent) {
|
|
719
|
-
// view start
|
|
720
|
-
this._$scrollSprite.alpha = 1;
|
|
721
|
-
// set position
|
|
722
|
-
this._$scrollSprite.x = this.x + this.width - this._$scrollSprite.width - 0.5;
|
|
723
|
-
this._$scrollSprite.y = this.y + 0.5
|
|
724
|
-
+ (this.height - 1 - this._$scrollSprite.height)
|
|
725
|
-
/ (this.maxScrollV - 1)
|
|
726
|
-
* (this._$scrollV - 1);
|
|
727
|
-
// added sprite
|
|
728
|
-
parent.addChildAt(this._$scrollSprite, parent.getChildIndex(this) + 1);
|
|
729
|
-
// start animation
|
|
730
|
-
if (this._$scrollSprite.hasLocalVariable("job")) {
|
|
731
|
-
this._$scrollSprite.getLocalVariable("job").stop();
|
|
732
|
-
}
|
|
733
|
-
const job = Tween.add(this._$scrollSprite, { "alpha": 1 }, { "alpha": 0 }, 1);
|
|
734
|
-
job.addEventListener(Next2DEvent.COMPLETE, (event) => {
|
|
735
|
-
const sprite = event.target.target;
|
|
736
|
-
sprite.deleteLocalVariable("job");
|
|
737
|
-
if (sprite.parent) {
|
|
738
|
-
sprite.parent.removeChild(sprite);
|
|
739
|
-
}
|
|
740
|
-
});
|
|
741
|
-
job.start();
|
|
742
|
-
this._$scrollSprite.setLocalVariable("job", job);
|
|
743
|
-
}
|
|
744
|
-
}
|
|
745
|
-
if (this.willTrigger(Next2DEvent.SCROLL)) {
|
|
746
|
-
this.dispatchEvent(new Next2DEvent(Next2DEvent.SCROLL, true));
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
|
-
}
|
|
750
|
-
/**
|
|
751
|
-
* @description テキストフィールド内の現在のテキストであるストリングです。
|
|
752
|
-
* A string that is the current text in the text field.
|
|
753
|
-
*
|
|
754
|
-
* @member {string}
|
|
755
|
-
* @default ""
|
|
756
|
-
* @public
|
|
757
|
-
*/
|
|
758
|
-
get text() {
|
|
759
|
-
if (!this._$isHTML) {
|
|
760
|
-
return this._$text;
|
|
761
|
-
}
|
|
762
|
-
if (this._$rawHtmlText) {
|
|
763
|
-
return this._$rawHtmlText;
|
|
764
|
-
}
|
|
765
|
-
let text = "";
|
|
766
|
-
const textData = this._$getTextData();
|
|
767
|
-
for (let idx = 1; idx < textData.length; ++idx) {
|
|
768
|
-
const object = textData[idx];
|
|
769
|
-
switch (object.mode) {
|
|
770
|
-
case "text":
|
|
771
|
-
text += object.text;
|
|
772
|
-
break;
|
|
773
|
-
case "break":
|
|
774
|
-
text += "\r";
|
|
775
|
-
break;
|
|
776
|
-
}
|
|
777
|
-
}
|
|
778
|
-
this._$rawHtmlText = text;
|
|
779
|
-
return text;
|
|
780
|
-
}
|
|
781
|
-
set text(text) {
|
|
782
|
-
if (text === null) {
|
|
783
|
-
text = "";
|
|
784
|
-
}
|
|
785
|
-
text = `${text}`;
|
|
786
|
-
if (text !== this._$text) {
|
|
787
|
-
this._$text = text;
|
|
788
|
-
this._$htmlText = "";
|
|
789
|
-
this._$isHTML = false;
|
|
790
|
-
this._$textFormatTable.length = 0;
|
|
791
|
-
this._$reload();
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
/**
|
|
795
|
-
* @description テキストフィールドのテキストの色です(16 進数形式)。
|
|
796
|
-
* The color of the text in a text field, in hexadecimal format.
|
|
797
|
-
*
|
|
798
|
-
* @member {number}
|
|
799
|
-
* @public
|
|
800
|
-
*/
|
|
801
|
-
get textColor() {
|
|
802
|
-
return this._$defaultTextFormat.color || 0;
|
|
803
|
-
}
|
|
804
|
-
set textColor(text_color) {
|
|
805
|
-
this._$defaultTextFormat.color = text_color;
|
|
806
|
-
this._$reload();
|
|
807
|
-
}
|
|
808
|
-
/**
|
|
809
|
-
* @description テキストの高さです(ピクセル単位)。
|
|
810
|
-
* The height of the text in pixels.
|
|
811
|
-
*
|
|
812
|
-
* @member {number}
|
|
813
|
-
* @readonly
|
|
814
|
-
* @public
|
|
815
|
-
*/
|
|
816
|
-
get textHeight() {
|
|
817
|
-
if (this.text === "") {
|
|
818
|
-
return 0;
|
|
819
|
-
}
|
|
820
|
-
if (this._$textHeight === null) {
|
|
821
|
-
// setup
|
|
822
|
-
this._$textHeight = 2;
|
|
823
|
-
this._$getTextData();
|
|
824
|
-
const length = this._$textHeightTable.length;
|
|
825
|
-
if (length === 1) {
|
|
826
|
-
this._$textHeight += this._$defaultTextFormat.leading || 0;
|
|
827
|
-
}
|
|
828
|
-
for (let idx = 0; idx < length; ++idx) {
|
|
829
|
-
this._$textHeight += this._$textHeightTable[idx];
|
|
830
|
-
}
|
|
831
|
-
}
|
|
832
|
-
return this._$textHeight;
|
|
833
|
-
}
|
|
834
|
-
/**
|
|
835
|
-
* @description テキストの幅です(ピクセル単位)。
|
|
836
|
-
* The width of the text in pixels.
|
|
837
|
-
*
|
|
838
|
-
* @member {number}
|
|
839
|
-
* @readonly
|
|
840
|
-
* @public
|
|
841
|
-
*/
|
|
842
|
-
get textWidth() {
|
|
843
|
-
if (this._$textWidth === null) {
|
|
844
|
-
// setup
|
|
845
|
-
this._$textWidth = 0;
|
|
846
|
-
this._$getTextData();
|
|
847
|
-
for (let idx = 0; idx < this._$widthTable.length; ++idx) {
|
|
848
|
-
this._$textWidth = $Math.max(this._$textWidth, this._$widthTable[idx]);
|
|
849
|
-
}
|
|
850
|
-
}
|
|
851
|
-
return this._$textWidth;
|
|
852
|
-
}
|
|
853
|
-
/**
|
|
854
|
-
* @description 輪郭のテキスト幅です。0(デフォルト値)で無効にできます。
|
|
855
|
-
* The text width of the outline, which can be disabled with 0 (the default value).
|
|
856
|
-
*
|
|
857
|
-
* @member {number}
|
|
858
|
-
* @default 0
|
|
859
|
-
* @public
|
|
860
|
-
*/
|
|
861
|
-
get thickness() {
|
|
862
|
-
return this._$thickness;
|
|
863
|
-
}
|
|
864
|
-
set thickness(thickness) {
|
|
865
|
-
thickness |= 0;
|
|
866
|
-
if (thickness !== this._$thickness) {
|
|
867
|
-
this._$thickness = thickness;
|
|
868
|
-
this._$reset();
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
|
-
/**
|
|
872
|
-
* @description 輪郭のテキストの色です(16 進数形式)。
|
|
873
|
-
* The color of the outline text. (Hexadecimal format)
|
|
874
|
-
*
|
|
875
|
-
* @member {number}
|
|
876
|
-
* @default 0
|
|
877
|
-
* @public
|
|
878
|
-
*/
|
|
879
|
-
get thicknessColor() {
|
|
880
|
-
return this._$thicknessColor;
|
|
881
|
-
}
|
|
882
|
-
set thicknessColor(thickness_color) {
|
|
883
|
-
thickness_color = $clamp($toColorInt(thickness_color), 0, 0xffffff, 0);
|
|
884
|
-
if (thickness_color !== this._$thicknessColor) {
|
|
885
|
-
this._$thicknessColor = thickness_color;
|
|
886
|
-
this._$reset();
|
|
887
|
-
}
|
|
888
|
-
}
|
|
889
|
-
/**
|
|
890
|
-
* @description テキストフィールドのタイプです。
|
|
891
|
-
* The type of the text field.
|
|
892
|
-
*
|
|
893
|
-
* @member {string}
|
|
894
|
-
* @default TextFieldType.STATIC
|
|
895
|
-
* @public
|
|
896
|
-
*/
|
|
897
|
-
get type() {
|
|
898
|
-
return this._$type;
|
|
899
|
-
}
|
|
900
|
-
set type(type) {
|
|
901
|
-
this._$type = type;
|
|
902
|
-
if (type === "static") {
|
|
903
|
-
this._$textarea = null;
|
|
904
|
-
}
|
|
905
|
-
}
|
|
906
|
-
/**
|
|
907
|
-
* @description 縦方向の揃え位置を指定するプロパティです。
|
|
908
|
-
* This property specifies the vertical alignment position.
|
|
909
|
-
*
|
|
910
|
-
* @member {string}
|
|
911
|
-
* @default TextFormatVerticalAlign.TOP
|
|
912
|
-
* @public
|
|
913
|
-
*/
|
|
914
|
-
get verticalAlign() {
|
|
915
|
-
return this._$verticalAlign;
|
|
916
|
-
}
|
|
917
|
-
set verticalAlign(vertical_align) {
|
|
918
|
-
if (vertical_align !== this._$verticalAlign) {
|
|
919
|
-
this._$verticalAlign = vertical_align;
|
|
920
|
-
this._$reset();
|
|
921
|
-
}
|
|
922
|
-
}
|
|
923
|
-
/**
|
|
924
|
-
* @description テキストフィールドのテキストを折り返すかどうかを示すブール値です。
|
|
925
|
-
* A Boolean value that indicates whether the text field has word wrap.
|
|
926
|
-
*
|
|
927
|
-
* @member {boolean}
|
|
928
|
-
* @default false
|
|
929
|
-
* @public
|
|
930
|
-
*/
|
|
931
|
-
get wordWrap() {
|
|
932
|
-
return this._$wordWrap;
|
|
933
|
-
}
|
|
934
|
-
set wordWrap(word_wrap) {
|
|
935
|
-
if (this._$wordWrap !== word_wrap) {
|
|
936
|
-
this._$wordWrap = !!word_wrap;
|
|
937
|
-
this._$reset();
|
|
938
|
-
}
|
|
939
|
-
}
|
|
940
|
-
/**
|
|
941
|
-
* @description 表示オブジェクトの幅を示します(ピクセル単位)。
|
|
942
|
-
* Indicates the width of the display object, in pixels.
|
|
943
|
-
*
|
|
944
|
-
* @member {number}
|
|
945
|
-
* @public
|
|
946
|
-
*/
|
|
947
|
-
get width() {
|
|
948
|
-
return super.width;
|
|
949
|
-
}
|
|
950
|
-
set width(width) {
|
|
951
|
-
width = +width;
|
|
952
|
-
if (!$isNaN(width) && width > -1) {
|
|
953
|
-
const bounds = this._$getBounds(null);
|
|
954
|
-
const xMin = $Math.abs(bounds.xMin);
|
|
955
|
-
this._$originBounds.xMax = width + xMin;
|
|
956
|
-
this._$originBounds.xMin = xMin;
|
|
957
|
-
this._$bounds.xMax = this._$originBounds.xMax;
|
|
958
|
-
this._$bounds.xMin = this._$originBounds.xMin;
|
|
959
|
-
super.width = width;
|
|
960
|
-
this._$reload();
|
|
961
|
-
}
|
|
962
|
-
}
|
|
963
|
-
/**
|
|
964
|
-
* @description 表示オブジェクトの高さを示します(ピクセル単位)。
|
|
965
|
-
* Indicates the height of the display object, in pixels.
|
|
966
|
-
*
|
|
967
|
-
* @member {number}
|
|
968
|
-
* @public
|
|
969
|
-
*/
|
|
970
|
-
get height() {
|
|
971
|
-
return super.height;
|
|
972
|
-
}
|
|
973
|
-
set height(height) {
|
|
974
|
-
height = +height;
|
|
975
|
-
if (!$isNaN(height) && height > -1) {
|
|
976
|
-
const bounds = this._$getBounds(null);
|
|
977
|
-
const yMin = $Math.abs(bounds.yMin);
|
|
978
|
-
this._$originBounds.yMax = height + yMin;
|
|
979
|
-
this._$bounds.yMax = this._$originBounds.yMax;
|
|
980
|
-
this._$bounds.yMin = this._$originBounds.yMin;
|
|
981
|
-
super.height = height;
|
|
982
|
-
this._$reload();
|
|
983
|
-
}
|
|
984
|
-
}
|
|
985
|
-
/**
|
|
986
|
-
* @description 親 DisplayObjectContainer のローカル座標を基準にした
|
|
987
|
-
* DisplayObject インスタンスの x 座標を示します。
|
|
988
|
-
* Indicates the x coordinate
|
|
989
|
-
* of the DisplayObject instance relative to the local coordinates
|
|
990
|
-
* of the parent DisplayObjectContainer.
|
|
991
|
-
*
|
|
992
|
-
* @member {number}
|
|
993
|
-
* @public
|
|
994
|
-
*/
|
|
995
|
-
get x() {
|
|
996
|
-
const matrix = this._$transform.matrix;
|
|
997
|
-
const bounds = this._$getBounds(null);
|
|
998
|
-
return matrix._$matrix[4] + bounds.xMin;
|
|
999
|
-
}
|
|
1000
|
-
set x(x) {
|
|
1001
|
-
const bounds = this._$getBounds(null);
|
|
1002
|
-
super.x = x - bounds.xMin;
|
|
1003
|
-
}
|
|
1004
|
-
/**
|
|
1005
|
-
* @description 親 DisplayObjectContainer のローカル座標を基準にした
|
|
1006
|
-
* DisplayObject インスタンスの y 座標を示します。
|
|
1007
|
-
* Indicates the y coordinate
|
|
1008
|
-
* of the DisplayObject instance relative to the local coordinates
|
|
1009
|
-
* of the parent DisplayObjectContainer.
|
|
1010
|
-
*
|
|
1011
|
-
* @member {number}
|
|
1012
|
-
* @public
|
|
1013
|
-
*/
|
|
1014
|
-
get y() {
|
|
1015
|
-
const matrix = this._$transform.matrix;
|
|
1016
|
-
const bounds = this._$getBounds(null);
|
|
1017
|
-
return matrix._$matrix[5] + bounds.yMin;
|
|
1018
|
-
}
|
|
1019
|
-
set y(y) {
|
|
1020
|
-
const bounds = this._$getBounds(null);
|
|
1021
|
-
super.y = y - bounds.yMin;
|
|
1022
|
-
}
|
|
1023
|
-
/**
|
|
1024
|
-
* @description newText パラメーターで指定されたストリングを、
|
|
1025
|
-
* テキストフィールドのテキストの最後に付加します。
|
|
1026
|
-
* Appends the string specified by the newText parameter
|
|
1027
|
-
* to the end of the text of the text field.
|
|
1028
|
-
*
|
|
1029
|
-
* @param {string} new_text
|
|
1030
|
-
* @return void
|
|
1031
|
-
* @method
|
|
1032
|
-
* @public
|
|
1033
|
-
*/
|
|
1034
|
-
appendText(new_text) {
|
|
1035
|
-
const currentText = this.text;
|
|
1036
|
-
this.text = currentText + `${new_text}`;
|
|
1037
|
-
}
|
|
1038
|
-
/**
|
|
1039
|
-
* @description beginIndex パラメーターと endIndex パラメーターで指定された範囲の
|
|
1040
|
-
* テキストのフォーマット情報を含む TextFormat オブジェクトを返します。
|
|
1041
|
-
* Returns a TextFormat object that contains formatting information
|
|
1042
|
-
* for the range of text that the beginIndex and endIndex parameters specify.
|
|
1043
|
-
*
|
|
1044
|
-
* @param {int} [begin_index=-1]
|
|
1045
|
-
* @param {int} [end_index=-1]
|
|
1046
|
-
* @return {TextFormat}
|
|
1047
|
-
* @method
|
|
1048
|
-
* @public
|
|
1049
|
-
*/
|
|
1050
|
-
getTextFormat(begin_index = -1, end_index = -1) {
|
|
1051
|
-
begin_index |= 0;
|
|
1052
|
-
end_index |= 0;
|
|
1053
|
-
const data = this._$getTextData();
|
|
1054
|
-
const length = end_index > -1 ? end_index : data.length;
|
|
1055
|
-
let init = false;
|
|
1056
|
-
let textFormat = new TextFormat();
|
|
1057
|
-
let idx = begin_index > -1 ? begin_index : 0;
|
|
1058
|
-
for (; idx < length; ++idx) {
|
|
1059
|
-
if (data[idx].mode === "break") {
|
|
1060
|
-
continue;
|
|
1061
|
-
}
|
|
1062
|
-
const tf = data[idx].textFormat;
|
|
1063
|
-
if (!init) {
|
|
1064
|
-
init = true;
|
|
1065
|
-
textFormat = tf._$clone();
|
|
1066
|
-
continue;
|
|
1067
|
-
}
|
|
1068
|
-
textFormat.align = textFormat.align !== tf.align ? null : tf.align;
|
|
1069
|
-
textFormat.blockIndent = textFormat.blockIndent !== tf.blockIndent ? null : tf.blockIndent;
|
|
1070
|
-
textFormat.bold = textFormat.bold !== tf.bold ? null : tf.bold;
|
|
1071
|
-
textFormat.color = textFormat.color !== tf.color ? null : tf.color;
|
|
1072
|
-
textFormat.font = textFormat.font !== tf.font ? null : tf.font;
|
|
1073
|
-
textFormat.indent = textFormat.indent !== tf.indent ? null : tf.indent;
|
|
1074
|
-
textFormat.italic = textFormat.italic !== tf.italic ? null : tf.italic;
|
|
1075
|
-
textFormat.leading = textFormat.leading !== tf.leading ? null : tf.leading;
|
|
1076
|
-
textFormat.leftMargin = textFormat.leftMargin !== tf.leftMargin ? null : tf.leftMargin;
|
|
1077
|
-
textFormat.letterSpacing = textFormat.letterSpacing !== tf.letterSpacing ? null : tf.letterSpacing;
|
|
1078
|
-
textFormat.rightMargin = textFormat.rightMargin !== tf.rightMargin ? null : tf.rightMargin;
|
|
1079
|
-
textFormat.size = textFormat.size !== tf.size ? null : tf.size;
|
|
1080
|
-
textFormat.underline = textFormat.underline !== tf.underline ? null : tf.underline;
|
|
1081
|
-
}
|
|
1082
|
-
return textFormat;
|
|
1083
|
-
}
|
|
1084
|
-
/**
|
|
1085
|
-
* @description lineIndex パラメーターで指定された行のテキストを返します。
|
|
1086
|
-
* Returns the text of the line specified by the lineIndex parameter.
|
|
1087
|
-
*
|
|
1088
|
-
* @param {number} line_index
|
|
1089
|
-
* @return {string}
|
|
1090
|
-
* @public
|
|
1091
|
-
*/
|
|
1092
|
-
getLineText(line_index) {
|
|
1093
|
-
if (!this._$text && !this._$htmlText) {
|
|
1094
|
-
return "";
|
|
1095
|
-
}
|
|
1096
|
-
line_index |= 0;
|
|
1097
|
-
let lineText = "";
|
|
1098
|
-
const textData = this._$getTextData();
|
|
1099
|
-
for (let idx = 0; idx < textData.length; idx++) {
|
|
1100
|
-
const obj = textData[idx];
|
|
1101
|
-
if (obj.yIndex > line_index) {
|
|
1102
|
-
break;
|
|
1103
|
-
}
|
|
1104
|
-
if (obj.yIndex !== line_index) {
|
|
1105
|
-
continue;
|
|
1106
|
-
}
|
|
1107
|
-
if (obj.mode !== "text") {
|
|
1108
|
-
continue;
|
|
1109
|
-
}
|
|
1110
|
-
lineText += obj.text;
|
|
1111
|
-
}
|
|
1112
|
-
return lineText;
|
|
1113
|
-
}
|
|
1114
|
-
/**
|
|
1115
|
-
* @description beginIndex パラメーターと endIndex パラメーターで指定された文字範囲を、
|
|
1116
|
-
* newText パラメーターの内容に置き換えます。
|
|
1117
|
-
* Replaces the range of characters that the beginIndex
|
|
1118
|
-
* and endIndex parameters specify with the contents of the newText parameter.
|
|
1119
|
-
*
|
|
1120
|
-
* @param {number} begin_index
|
|
1121
|
-
* @param {number} end_index
|
|
1122
|
-
* @param {string} new_text
|
|
1123
|
-
* @return {void}
|
|
1124
|
-
* @method
|
|
1125
|
-
* @public
|
|
1126
|
-
*/
|
|
1127
|
-
replaceText(begin_index, end_index, new_text) {
|
|
1128
|
-
begin_index |= 0;
|
|
1129
|
-
end_index |= 0;
|
|
1130
|
-
if (begin_index > -1 && end_index > -1 && end_index >= begin_index) {
|
|
1131
|
-
const text = this.text;
|
|
1132
|
-
if (begin_index >= text.length) {
|
|
1133
|
-
if (end_index >= text.length && end_index >= begin_index) {
|
|
1134
|
-
this.text = text + `${new_text}`;
|
|
1135
|
-
}
|
|
1136
|
-
}
|
|
1137
|
-
else {
|
|
1138
|
-
this.text = text.slice(0, begin_index)
|
|
1139
|
-
+ `${new_text}`
|
|
1140
|
-
+ text.slice(end_index, text.length);
|
|
1141
|
-
}
|
|
1142
|
-
}
|
|
1143
|
-
}
|
|
1144
|
-
/**
|
|
1145
|
-
* @description format パラメーターで指定したテキストフォーマットを、
|
|
1146
|
-
* テキストフィールド内の指定されたテキストに適用します。
|
|
1147
|
-
* Applies the text formatting that the format parameter specifies
|
|
1148
|
-
* to the specified text in a text field.
|
|
1149
|
-
*
|
|
1150
|
-
* @param {TextFormat} text_format
|
|
1151
|
-
* @param {number} [begin_index=-1]
|
|
1152
|
-
* @param {number} [end_index=-1]
|
|
1153
|
-
* @return {void}
|
|
1154
|
-
* @method
|
|
1155
|
-
* @public
|
|
1156
|
-
*/
|
|
1157
|
-
setTextFormat(text_format, begin_index = -1, end_index = -1) {
|
|
1158
|
-
// setup
|
|
1159
|
-
begin_index |= 0;
|
|
1160
|
-
end_index |= 0;
|
|
1161
|
-
const textData = this._$getTextData();
|
|
1162
|
-
this._$reset();
|
|
1163
|
-
switch (true) {
|
|
1164
|
-
case begin_index === -1 && end_index === -1:
|
|
1165
|
-
for (let idx = 0; idx < textData.length; ++idx) {
|
|
1166
|
-
this._$textFormatTable[idx] = text_format._$clone();
|
|
1167
|
-
}
|
|
1168
|
-
break;
|
|
1169
|
-
case begin_index > -1 && end_index === -1:
|
|
1170
|
-
{
|
|
1171
|
-
let idx = begin_index + 1;
|
|
1172
|
-
let obj = textData[idx];
|
|
1173
|
-
if (obj.mode === "wrap") {
|
|
1174
|
-
obj = textData[++idx];
|
|
1175
|
-
}
|
|
1176
|
-
this._$textFormatTable[idx] = text_format._$clone();
|
|
1177
|
-
}
|
|
1178
|
-
break;
|
|
1179
|
-
case begin_index > -1 && end_index > -1 && end_index > begin_index:
|
|
1180
|
-
{
|
|
1181
|
-
let offset = 0;
|
|
1182
|
-
for (let idx = begin_index; idx < end_index; ++idx) {
|
|
1183
|
-
const obj = textData[idx];
|
|
1184
|
-
if (!obj) {
|
|
1185
|
-
continue;
|
|
1186
|
-
}
|
|
1187
|
-
if (obj.mode === "wrap" || obj.mode === "break") {
|
|
1188
|
-
++end_index;
|
|
1189
|
-
--offset;
|
|
1190
|
-
continue;
|
|
1191
|
-
}
|
|
1192
|
-
this._$textFormatTable[idx + offset] = text_format._$clone();
|
|
1193
|
-
}
|
|
1194
|
-
}
|
|
1195
|
-
break;
|
|
1196
|
-
}
|
|
1197
|
-
this._$getTextData();
|
|
1198
|
-
this._$resize();
|
|
1199
|
-
}
|
|
1200
|
-
/**
|
|
1201
|
-
* @return {array}
|
|
1202
|
-
* @method
|
|
1203
|
-
* @private
|
|
1204
|
-
*/
|
|
1205
|
-
_$getTextData() {
|
|
1206
|
-
if (!this._$createdTextData) {
|
|
1207
|
-
this._$createdTextData = true;
|
|
1208
|
-
// reset
|
|
1209
|
-
this._$textData.length = 0;
|
|
1210
|
-
this._$imageData.length = 0;
|
|
1211
|
-
this._$heightTable.length = 0;
|
|
1212
|
-
this._$textHeightTable.length = 0;
|
|
1213
|
-
this._$objectTable.length = 0;
|
|
1214
|
-
this._$widthTable.length = 0;
|
|
1215
|
-
this._$heightCache.clear();
|
|
1216
|
-
let tfCopyOffset = -1;
|
|
1217
|
-
if (this._$isHTML) {
|
|
1218
|
-
// html text
|
|
1219
|
-
let htmlText = this._$htmlText;
|
|
1220
|
-
const index = htmlText.search(/(< .*>|<>)/g);
|
|
1221
|
-
if (index > -1) {
|
|
1222
|
-
htmlText = htmlText.slice(0, index);
|
|
1223
|
-
}
|
|
1224
|
-
htmlText = htmlText.replace(/\r\n/g, "\r\r");
|
|
1225
|
-
if ($P_TAG.innerHTML !== htmlText) {
|
|
1226
|
-
$P_TAG.textContent = "";
|
|
1227
|
-
$P_TAG.insertAdjacentHTML("afterbegin", htmlText);
|
|
1228
|
-
}
|
|
1229
|
-
// setup
|
|
1230
|
-
let tf = this._$defaultTextFormat;
|
|
1231
|
-
if (this._$textData.length in this._$textFormatTable) {
|
|
1232
|
-
const tft = this._$textFormatTable[this._$textData.length]._$clone();
|
|
1233
|
-
tft._$merge(tf);
|
|
1234
|
-
tf = tft;
|
|
1235
|
-
}
|
|
1236
|
-
// init
|
|
1237
|
-
this._$totalWidth = 0;
|
|
1238
|
-
this._$heightTable[0] = 0;
|
|
1239
|
-
this._$textHeightTable[0] = this._$getTextHeight(tf);
|
|
1240
|
-
this._$widthTable[0] = 0;
|
|
1241
|
-
const obj = {
|
|
1242
|
-
"mode": "break",
|
|
1243
|
-
"x": 0,
|
|
1244
|
-
"yIndex": 0,
|
|
1245
|
-
"textFormat": tf._$clone()
|
|
1246
|
-
};
|
|
1247
|
-
this._$objectTable[0] = obj;
|
|
1248
|
-
this._$textData[0] = obj;
|
|
1249
|
-
this._$parseTag($P_TAG, tf._$clone(), tfCopyOffset);
|
|
1250
|
-
}
|
|
1251
|
-
else {
|
|
1252
|
-
// plain text
|
|
1253
|
-
const texts = this._$multiline
|
|
1254
|
-
? this._$text.split("\n")
|
|
1255
|
-
: [this._$text.replace("\n", "")];
|
|
1256
|
-
for (let idx = 0; idx < texts.length; ++idx) {
|
|
1257
|
-
// reset
|
|
1258
|
-
this._$totalWidth = 0;
|
|
1259
|
-
let tf = this.defaultTextFormat;
|
|
1260
|
-
const yIndex = this._$wordWrap || this._$multiline
|
|
1261
|
-
? this._$heightTable.length
|
|
1262
|
-
: 0;
|
|
1263
|
-
this._$heightTable[yIndex] = 0;
|
|
1264
|
-
this._$textHeightTable[yIndex] = this._$getTextHeight(tf);
|
|
1265
|
-
this._$widthTable[yIndex] = 0;
|
|
1266
|
-
if (yIndex) {
|
|
1267
|
-
this._$heightTable[yIndex] = this._$heightTable[yIndex - 1];
|
|
1268
|
-
this._$textHeightTable[yIndex] = this._$textHeightTable[yIndex - 1];
|
|
1269
|
-
}
|
|
1270
|
-
if (this._$textData.length in this._$textFormatTable) {
|
|
1271
|
-
const tft = this._$textFormatTable[this._$textData.length]._$clone();
|
|
1272
|
-
tft._$merge(tf);
|
|
1273
|
-
tf = tft;
|
|
1274
|
-
}
|
|
1275
|
-
const obj = {
|
|
1276
|
-
"mode": "break",
|
|
1277
|
-
"x": 0,
|
|
1278
|
-
"yIndex": yIndex,
|
|
1279
|
-
"textFormat": tf._$clone()
|
|
1280
|
-
};
|
|
1281
|
-
tf = this.defaultTextFormat;
|
|
1282
|
-
this._$objectTable[yIndex] = obj;
|
|
1283
|
-
this._$textData[this._$textData.length] = obj;
|
|
1284
|
-
// parse text data
|
|
1285
|
-
const text = texts[idx];
|
|
1286
|
-
if (text) {
|
|
1287
|
-
tfCopyOffset = this._$parseText(text, tf, tfCopyOffset);
|
|
1288
|
-
}
|
|
1289
|
-
}
|
|
1290
|
-
}
|
|
1291
|
-
// clear
|
|
1292
|
-
this._$heightCache.clear();
|
|
1293
|
-
}
|
|
1294
|
-
return this._$textData;
|
|
1295
|
-
}
|
|
1296
|
-
/**
|
|
1297
|
-
* @param {Element} tag
|
|
1298
|
-
* @param {TextFormat} text_format
|
|
1299
|
-
* @param {number} tf_copy_offset
|
|
1300
|
-
* @return {void}
|
|
1301
|
-
* @private
|
|
1302
|
-
*/
|
|
1303
|
-
_$parseTag(tag, text_format, tf_copy_offset) {
|
|
1304
|
-
const childNodes = tag.childNodes;
|
|
1305
|
-
const length = childNodes.length;
|
|
1306
|
-
for (let idx = 0; idx < length; ++idx) {
|
|
1307
|
-
let tf = text_format._$clone();
|
|
1308
|
-
const node = childNodes[idx];
|
|
1309
|
-
if (node.nodeType === 3) {
|
|
1310
|
-
tf_copy_offset = this._$parseText(node.nodeValue || "", tf, tf_copy_offset);
|
|
1311
|
-
continue;
|
|
1312
|
-
}
|
|
1313
|
-
switch (node.nodeName) {
|
|
1314
|
-
case "P":
|
|
1315
|
-
{
|
|
1316
|
-
if (node.hasAttribute("align")) {
|
|
1317
|
-
const align = node.getAttribute("align");
|
|
1318
|
-
if (align === "center" || align === "left" || align === "right") {
|
|
1319
|
-
tf.align = align;
|
|
1320
|
-
if (this._$textData.length === 1) {
|
|
1321
|
-
this._$textData[0].textFormat.align = tf.align;
|
|
1322
|
-
}
|
|
1323
|
-
}
|
|
1324
|
-
}
|
|
1325
|
-
this._$parseTag(node, tf, tf_copy_offset);
|
|
1326
|
-
if (!this._$multiline) {
|
|
1327
|
-
break;
|
|
1328
|
-
}
|
|
1329
|
-
// reset
|
|
1330
|
-
this._$totalWidth = this._$getImageOffsetX();
|
|
1331
|
-
const yIndex = this._$heightTable.length;
|
|
1332
|
-
this._$heightTable[yIndex] = 0;
|
|
1333
|
-
this._$textHeightTable[yIndex] = 0;
|
|
1334
|
-
this._$widthTable[yIndex] = 0;
|
|
1335
|
-
if (yIndex) {
|
|
1336
|
-
this._$heightTable[yIndex] = this._$heightTable[yIndex - 1];
|
|
1337
|
-
this._$textHeightTable[yIndex] = this._$textHeightTable[yIndex - 1];
|
|
1338
|
-
}
|
|
1339
|
-
if (this._$textData.length in this._$textFormatTable) {
|
|
1340
|
-
const tft = this._$textFormatTable[this._$textData.length]._$clone();
|
|
1341
|
-
tft._$merge(tf);
|
|
1342
|
-
tf = tft;
|
|
1343
|
-
}
|
|
1344
|
-
const obj = {
|
|
1345
|
-
"mode": "break",
|
|
1346
|
-
"x": 0,
|
|
1347
|
-
"yIndex": yIndex,
|
|
1348
|
-
"textFormat": tf
|
|
1349
|
-
};
|
|
1350
|
-
this._$objectTable[yIndex] = obj;
|
|
1351
|
-
this._$textData.push(obj);
|
|
1352
|
-
}
|
|
1353
|
-
break;
|
|
1354
|
-
case "B": // bold
|
|
1355
|
-
tf.bold = true;
|
|
1356
|
-
this._$parseTag(node, tf, tf_copy_offset);
|
|
1357
|
-
break;
|
|
1358
|
-
case "I": // italic
|
|
1359
|
-
tf.italic = true;
|
|
1360
|
-
this._$parseTag(node, tf, tf_copy_offset);
|
|
1361
|
-
break;
|
|
1362
|
-
case "U": // underline
|
|
1363
|
-
tf.underline = true;
|
|
1364
|
-
this._$parseTag(node, tf, tf_copy_offset);
|
|
1365
|
-
break;
|
|
1366
|
-
case "FONT": // FONT
|
|
1367
|
-
if (node.hasAttribute("face")) {
|
|
1368
|
-
tf.font = node.getAttribute("face");
|
|
1369
|
-
}
|
|
1370
|
-
if (node.hasAttribute("size")) {
|
|
1371
|
-
const size = node.getAttribute("size");
|
|
1372
|
-
if (size) {
|
|
1373
|
-
tf.size = +size;
|
|
1374
|
-
}
|
|
1375
|
-
}
|
|
1376
|
-
if (node.hasAttribute("color")) {
|
|
1377
|
-
tf.color = $toColorInt(node.getAttribute("color"));
|
|
1378
|
-
}
|
|
1379
|
-
if (node.hasAttribute("letterSpacing")) {
|
|
1380
|
-
const letterSpacing = node.getAttribute("size");
|
|
1381
|
-
if (letterSpacing) {
|
|
1382
|
-
tf.letterSpacing = +letterSpacing;
|
|
1383
|
-
}
|
|
1384
|
-
}
|
|
1385
|
-
this._$parseTag(node, tf, tf_copy_offset);
|
|
1386
|
-
break;
|
|
1387
|
-
case "BR": // br
|
|
1388
|
-
{
|
|
1389
|
-
if (!this._$multiline) {
|
|
1390
|
-
break;
|
|
1391
|
-
}
|
|
1392
|
-
// add y index
|
|
1393
|
-
const yIndex = this._$heightTable.length;
|
|
1394
|
-
this._$heightTable[yIndex] = this._$heightTable[yIndex - 1];
|
|
1395
|
-
this._$textHeightTable[yIndex] = this._$textHeightTable[yIndex - 1];
|
|
1396
|
-
this._$widthTable[yIndex] = 0;
|
|
1397
|
-
// reset
|
|
1398
|
-
this._$totalWidth = this._$getImageOffsetX();
|
|
1399
|
-
// new clone
|
|
1400
|
-
tf.indent = 0;
|
|
1401
|
-
// set x offset
|
|
1402
|
-
const obj = {
|
|
1403
|
-
"mode": "break",
|
|
1404
|
-
"x": 0,
|
|
1405
|
-
"yIndex": yIndex,
|
|
1406
|
-
"textFormat": tf
|
|
1407
|
-
};
|
|
1408
|
-
this._$objectTable[yIndex] = obj;
|
|
1409
|
-
this._$textData[this._$textData.length] = obj;
|
|
1410
|
-
}
|
|
1411
|
-
break;
|
|
1412
|
-
case "IMG":
|
|
1413
|
-
{
|
|
1414
|
-
if (!node.hasAttribute("src")) {
|
|
1415
|
-
break;
|
|
1416
|
-
}
|
|
1417
|
-
const src = node.getAttribute("src");
|
|
1418
|
-
if (!src) {
|
|
1419
|
-
break;
|
|
1420
|
-
}
|
|
1421
|
-
let width = 0;
|
|
1422
|
-
if (node.hasAttribute("width")) {
|
|
1423
|
-
const attribute = node.getAttribute("width");
|
|
1424
|
-
if (attribute) {
|
|
1425
|
-
width = +attribute;
|
|
1426
|
-
}
|
|
1427
|
-
}
|
|
1428
|
-
let height = 0;
|
|
1429
|
-
if (node.hasAttribute("height")) {
|
|
1430
|
-
const attribute = node.getAttribute("height");
|
|
1431
|
-
if (attribute) {
|
|
1432
|
-
height = +attribute;
|
|
1433
|
-
}
|
|
1434
|
-
}
|
|
1435
|
-
let vspace = 8;
|
|
1436
|
-
if (node.hasAttribute("vspace")) {
|
|
1437
|
-
const attribute = node.getAttribute("vspace");
|
|
1438
|
-
if (attribute) {
|
|
1439
|
-
vspace = +attribute;
|
|
1440
|
-
}
|
|
1441
|
-
}
|
|
1442
|
-
let hspace = 8;
|
|
1443
|
-
if (node.hasAttribute("hspace")) {
|
|
1444
|
-
const attribute = node.getAttribute("hspace");
|
|
1445
|
-
if (attribute) {
|
|
1446
|
-
hspace = +attribute;
|
|
1447
|
-
}
|
|
1448
|
-
}
|
|
1449
|
-
let totalTextHeight = 0;
|
|
1450
|
-
for (let idx = 0; idx < this._$textHeightTable.length; idx++) {
|
|
1451
|
-
totalTextHeight += this._$textHeightTable[idx];
|
|
1452
|
-
}
|
|
1453
|
-
const image = new Image();
|
|
1454
|
-
const obj = {
|
|
1455
|
-
"mode": "image",
|
|
1456
|
-
"image": image,
|
|
1457
|
-
"src": src,
|
|
1458
|
-
"loaded": false,
|
|
1459
|
-
"x": 0,
|
|
1460
|
-
"y": totalTextHeight,
|
|
1461
|
-
"width": width,
|
|
1462
|
-
"height": height,
|
|
1463
|
-
"hspace": hspace,
|
|
1464
|
-
"vspace": vspace,
|
|
1465
|
-
"textFormat": tf._$clone()
|
|
1466
|
-
};
|
|
1467
|
-
image.crossOrigin = "anonymous";
|
|
1468
|
-
image.addEventListener("load", () => {
|
|
1469
|
-
if (!obj.width) {
|
|
1470
|
-
obj.width = image.width;
|
|
1471
|
-
}
|
|
1472
|
-
if (!obj.height) {
|
|
1473
|
-
obj.height = image.height;
|
|
1474
|
-
}
|
|
1475
|
-
obj.loaded = true;
|
|
1476
|
-
this._$reload();
|
|
1477
|
-
});
|
|
1478
|
-
image.src = src;
|
|
1479
|
-
if (this._$imageData.length > 0) {
|
|
1480
|
-
const prevImage = this._$imageData[this._$imageData.length - 1];
|
|
1481
|
-
const imageBottom = prevImage.y + prevImage.height + prevImage.vspace * 2;
|
|
1482
|
-
obj.y = $Math.max(totalTextHeight, imageBottom);
|
|
1483
|
-
}
|
|
1484
|
-
this._$textData[this._$textData.length] = obj;
|
|
1485
|
-
this._$imageData[this._$imageData.length] = obj;
|
|
1486
|
-
}
|
|
1487
|
-
break;
|
|
1488
|
-
default:
|
|
1489
|
-
this._$parseTag(node, tf, tf_copy_offset);
|
|
1490
|
-
break;
|
|
1491
|
-
}
|
|
1492
|
-
}
|
|
1493
|
-
}
|
|
1494
|
-
/**
|
|
1495
|
-
* @param {string} text
|
|
1496
|
-
* @param {TextFormat} text_format
|
|
1497
|
-
* @param {number} tf_copy_offset
|
|
1498
|
-
* @returns {number}
|
|
1499
|
-
* @method
|
|
1500
|
-
* @private
|
|
1501
|
-
*/
|
|
1502
|
-
_$parseText(text, text_format, tf_copy_offset) {
|
|
1503
|
-
let yIndex = this._$heightTable.length - 1;
|
|
1504
|
-
// new format
|
|
1505
|
-
let tf = text_format._$clone();
|
|
1506
|
-
const matrix = this._$transform.concatenatedMatrix._$matrix;
|
|
1507
|
-
const boundsWidth = (this._$originBounds.xMax - this._$originBounds.xMin)
|
|
1508
|
-
* (matrix[0] / matrix[3]);
|
|
1509
|
-
$poolFloat32Array6(matrix);
|
|
1510
|
-
const maxWidth = boundsWidth - tf._$widthMargin() - 4;
|
|
1511
|
-
for (let idx = 0; idx < text.length; ++idx) {
|
|
1512
|
-
tf = text_format._$clone();
|
|
1513
|
-
if (this._$textData.length + tf_copy_offset in this._$textFormatTable) {
|
|
1514
|
-
const tft = this._$textFormatTable[this._$textData.length + tf_copy_offset]._$clone();
|
|
1515
|
-
tft._$merge(tf);
|
|
1516
|
-
tf = tft;
|
|
1517
|
-
}
|
|
1518
|
-
// reset object
|
|
1519
|
-
const obj = {
|
|
1520
|
-
"mode": "text",
|
|
1521
|
-
"text": text[idx],
|
|
1522
|
-
"x": 0,
|
|
1523
|
-
"width": 0,
|
|
1524
|
-
"height": 0,
|
|
1525
|
-
"yIndex": yIndex,
|
|
1526
|
-
"textFormat": tf
|
|
1527
|
-
};
|
|
1528
|
-
let breakCode = false;
|
|
1529
|
-
if (this._$multiline) {
|
|
1530
|
-
breakCode = obj.text === "\n" || obj.text === "\r" || obj.text === "\n\r";
|
|
1531
|
-
}
|
|
1532
|
-
const leading = yIndex ? tf.leading || 0 : 0;
|
|
1533
|
-
let width = 0;
|
|
1534
|
-
let height = 0;
|
|
1535
|
-
let textHeight = 0;
|
|
1536
|
-
let wrapObj;
|
|
1537
|
-
if (!$textContext) {
|
|
1538
|
-
continue;
|
|
1539
|
-
}
|
|
1540
|
-
$textContext.font = tf._$generateFontStyle();
|
|
1541
|
-
width = $textContext.measureText(obj.text || "").width;
|
|
1542
|
-
width += tf.letterSpacing || 0;
|
|
1543
|
-
height = this._$getTextHeight(tf);
|
|
1544
|
-
textHeight = height + leading;
|
|
1545
|
-
obj.height = height;
|
|
1546
|
-
if (breakCode ||
|
|
1547
|
-
this._$wordWrap && this._$totalWidth + width > maxWidth) {
|
|
1548
|
-
// add y index
|
|
1549
|
-
this._$widthTable[++yIndex] = 0;
|
|
1550
|
-
obj.yIndex = yIndex;
|
|
1551
|
-
this._$heightTable[yIndex] = this._$heightTable[yIndex - 1];
|
|
1552
|
-
this._$textHeightTable[yIndex] = this._$textHeightTable[yIndex - 1];
|
|
1553
|
-
// reset
|
|
1554
|
-
this._$totalWidth = this._$getImageOffsetX();
|
|
1555
|
-
// new clone
|
|
1556
|
-
tf = tf._$clone();
|
|
1557
|
-
tf.indent = 0;
|
|
1558
|
-
// set x offset
|
|
1559
|
-
const mode = breakCode ? "break" : "wrap";
|
|
1560
|
-
wrapObj = {
|
|
1561
|
-
"mode": mode,
|
|
1562
|
-
"x": 0,
|
|
1563
|
-
"yIndex": yIndex,
|
|
1564
|
-
"textFormat": tf
|
|
1565
|
-
};
|
|
1566
|
-
this._$objectTable[yIndex] = wrapObj;
|
|
1567
|
-
if (!breakCode) {
|
|
1568
|
-
--tf_copy_offset;
|
|
1569
|
-
}
|
|
1570
|
-
let text = obj.text || "";
|
|
1571
|
-
let chunkLength = 0;
|
|
1572
|
-
let isSeparated = true;
|
|
1573
|
-
const pattern = /[0-9a-zA-Z?!;:.,?!。、;:〜]/g;
|
|
1574
|
-
while (text.match(pattern)) {
|
|
1575
|
-
++chunkLength;
|
|
1576
|
-
const prevObj = this._$textData[this._$textData.length - chunkLength];
|
|
1577
|
-
if (prevObj.mode !== "text") {
|
|
1578
|
-
isSeparated = false;
|
|
1579
|
-
break;
|
|
1580
|
-
}
|
|
1581
|
-
text = prevObj.text || "";
|
|
1582
|
-
}
|
|
1583
|
-
if (chunkLength > 1 && this._$textData) {
|
|
1584
|
-
const text = this._$textData[this._$textData.length - chunkLength + 1].text || "";
|
|
1585
|
-
if (text.match(/[0-9a-zA-Z]/g)) {
|
|
1586
|
-
--chunkLength;
|
|
1587
|
-
}
|
|
1588
|
-
}
|
|
1589
|
-
if (chunkLength > 0 && isSeparated) {
|
|
1590
|
-
const insertIdx = this._$textData.length - chunkLength;
|
|
1591
|
-
this._$textData.splice(insertIdx, 0, wrapObj);
|
|
1592
|
-
// prev line
|
|
1593
|
-
let offset = 1;
|
|
1594
|
-
let targetObj = this._$textData[insertIdx - offset];
|
|
1595
|
-
this._$widthTable[yIndex - 1] = 0;
|
|
1596
|
-
this._$heightTable[yIndex - 1] = 0;
|
|
1597
|
-
this._$textHeightTable[yIndex - 1] = 0;
|
|
1598
|
-
while (targetObj.mode === "text") {
|
|
1599
|
-
height = this._$getTextHeight(targetObj.textFormat);
|
|
1600
|
-
textHeight = height + leading;
|
|
1601
|
-
this._$widthTable[yIndex - 1] += targetObj.width || 0;
|
|
1602
|
-
this._$heightTable[yIndex - 1] = $Math.max(this._$heightTable[yIndex - 1], height);
|
|
1603
|
-
this._$textHeightTable[yIndex - 1] = $Math.max(this._$textHeightTable[yIndex - 1], textHeight);
|
|
1604
|
-
++offset;
|
|
1605
|
-
targetObj = this._$textData[insertIdx - offset];
|
|
1606
|
-
}
|
|
1607
|
-
// new line
|
|
1608
|
-
offset = 1;
|
|
1609
|
-
while (this._$textData.length > insertIdx + offset) {
|
|
1610
|
-
targetObj = this._$textData[insertIdx + offset];
|
|
1611
|
-
++offset;
|
|
1612
|
-
height = this._$getTextHeight(targetObj.textFormat);
|
|
1613
|
-
textHeight = height + leading;
|
|
1614
|
-
this._$heightTable[yIndex] = $Math.max(this._$heightTable[yIndex], height);
|
|
1615
|
-
this._$textHeightTable[yIndex] = $Math.max(this._$textHeightTable[yIndex], textHeight);
|
|
1616
|
-
targetObj.x = this._$totalWidth;
|
|
1617
|
-
targetObj.yIndex = yIndex;
|
|
1618
|
-
this._$totalWidth += targetObj.width || 0;
|
|
1619
|
-
}
|
|
1620
|
-
}
|
|
1621
|
-
else {
|
|
1622
|
-
this._$textData[this._$textData.length] = wrapObj;
|
|
1623
|
-
}
|
|
1624
|
-
}
|
|
1625
|
-
if (!breakCode) {
|
|
1626
|
-
// width data
|
|
1627
|
-
obj.width = width;
|
|
1628
|
-
obj.x = this._$totalWidth;
|
|
1629
|
-
this._$totalWidth += width;
|
|
1630
|
-
if (this._$widthTable) {
|
|
1631
|
-
this._$widthTable[yIndex] = $Math.max(this._$widthTable[yIndex], this._$totalWidth);
|
|
1632
|
-
}
|
|
1633
|
-
// height data
|
|
1634
|
-
this._$heightTable[yIndex] = $Math.max(this._$heightTable[yIndex], height);
|
|
1635
|
-
this._$textHeightTable[yIndex] = $Math.max(this._$textHeightTable[yIndex], textHeight);
|
|
1636
|
-
this._$textData[this._$textData.length] = obj;
|
|
1637
|
-
}
|
|
1638
|
-
}
|
|
1639
|
-
return tf_copy_offset;
|
|
1640
|
-
}
|
|
1641
|
-
/**
|
|
1642
|
-
* @param {TextFormat} text_format
|
|
1643
|
-
* @return {number}
|
|
1644
|
-
* @private
|
|
1645
|
-
*/
|
|
1646
|
-
_$getTextHeight(text_format) {
|
|
1647
|
-
const size = text_format.size || 0;
|
|
1648
|
-
const font = text_format.font || "";
|
|
1649
|
-
const weight = text_format.bold ? "bold" : "normal";
|
|
1650
|
-
// use cache
|
|
1651
|
-
const key = `${size}_${font}_${weight}`;
|
|
1652
|
-
if (this._$heightCache.has(key)) {
|
|
1653
|
-
return this._$heightCache.get(key) || 0;
|
|
1654
|
-
}
|
|
1655
|
-
// update dom data
|
|
1656
|
-
const style = $DIV.style;
|
|
1657
|
-
const fontSize = `${size}px`;
|
|
1658
|
-
if (style.fontSize !== fontSize) {
|
|
1659
|
-
style.fontSize = fontSize;
|
|
1660
|
-
}
|
|
1661
|
-
if (style.fontFamily !== font) {
|
|
1662
|
-
style.fontFamily = font;
|
|
1663
|
-
}
|
|
1664
|
-
if (style.fontWeight !== weight) {
|
|
1665
|
-
style.fontWeight = weight;
|
|
1666
|
-
}
|
|
1667
|
-
const height = 10 > size
|
|
1668
|
-
? $DIV.clientHeight * size * 0.1
|
|
1669
|
-
: $DIV.clientHeight;
|
|
1670
|
-
// cache
|
|
1671
|
-
this._$heightCache.set(key, height);
|
|
1672
|
-
return height;
|
|
1673
|
-
}
|
|
1674
|
-
/**
|
|
1675
|
-
* @return {number}
|
|
1676
|
-
* @private
|
|
1677
|
-
*/
|
|
1678
|
-
_$getImageOffsetX() {
|
|
1679
|
-
if (!this._$imageData.length) {
|
|
1680
|
-
return 0;
|
|
1681
|
-
}
|
|
1682
|
-
let totalTextHeight = 0;
|
|
1683
|
-
for (let idx = 0; idx < this._$textHeightTable.length; ++idx) {
|
|
1684
|
-
totalTextHeight += this._$textHeightTable[idx];
|
|
1685
|
-
}
|
|
1686
|
-
if (this._$imageData) {
|
|
1687
|
-
for (let idx = 0; idx < this._$imageData.length; ++idx) {
|
|
1688
|
-
const image = this._$imageData[idx];
|
|
1689
|
-
const imageHeight = image.height + image.vspace * 2;
|
|
1690
|
-
if (image.y <= totalTextHeight
|
|
1691
|
-
&& totalTextHeight < image.y + imageHeight) {
|
|
1692
|
-
return image.width + image.hspace * 2;
|
|
1693
|
-
}
|
|
1694
|
-
}
|
|
1695
|
-
}
|
|
1696
|
-
return 0;
|
|
1697
|
-
}
|
|
1698
|
-
/**
|
|
1699
|
-
* @return {void}
|
|
1700
|
-
* @method
|
|
1701
|
-
* @private
|
|
1702
|
-
*/
|
|
1703
|
-
_$reset() {
|
|
1704
|
-
this._$createdTextData = false;
|
|
1705
|
-
this._$textData.length = 0;
|
|
1706
|
-
this._$imageData.length = 0;
|
|
1707
|
-
this._$heightTable.length = 0;
|
|
1708
|
-
this._$textHeightTable.length = 0;
|
|
1709
|
-
this._$widthTable.length = 0;
|
|
1710
|
-
this._$objectTable.length = 0;
|
|
1711
|
-
this._$textHeight = null;
|
|
1712
|
-
this._$textWidth = null;
|
|
1713
|
-
this._$totalWidth = 0;
|
|
1714
|
-
this._$maxScrollH = null;
|
|
1715
|
-
this._$maxScrollV = null;
|
|
1716
|
-
this._$doChanged();
|
|
1717
|
-
$doUpdated();
|
|
1718
|
-
// cache clear
|
|
1719
|
-
const player = $currentPlayer();
|
|
1720
|
-
player.cacheStore.removeCache(this._$instanceId);
|
|
1721
|
-
}
|
|
1722
|
-
/**
|
|
1723
|
-
* @return {void}
|
|
1724
|
-
* @method
|
|
1725
|
-
* @private
|
|
1726
|
-
*/
|
|
1727
|
-
_$reload() {
|
|
1728
|
-
this._$reset();
|
|
1729
|
-
this._$getTextData();
|
|
1730
|
-
if (this._$autoSize === "none" && this._$autoFontSize) {
|
|
1731
|
-
let fontSize = this._$defaultTextFormat.size || 0;
|
|
1732
|
-
const cacheSize = fontSize;
|
|
1733
|
-
if (this.width && this.textWidth
|
|
1734
|
-
&& this.textWidth > this.width) {
|
|
1735
|
-
while (this.textWidth > this.width) {
|
|
1736
|
-
this._$defaultTextFormat.size = fontSize--;
|
|
1737
|
-
if (1 > fontSize) {
|
|
1738
|
-
this._$defaultTextFormat.size = 1;
|
|
1739
|
-
break;
|
|
1740
|
-
}
|
|
1741
|
-
this._$reset();
|
|
1742
|
-
this._$getTextData();
|
|
1743
|
-
}
|
|
1744
|
-
}
|
|
1745
|
-
if (this.height && this.textHeight
|
|
1746
|
-
&& this.textHeight > this.height) {
|
|
1747
|
-
while (this.textHeight > this.height) {
|
|
1748
|
-
this._$defaultTextFormat.size = fontSize--;
|
|
1749
|
-
if (1 > fontSize) {
|
|
1750
|
-
this._$defaultTextFormat.size = 1;
|
|
1751
|
-
break;
|
|
1752
|
-
}
|
|
1753
|
-
this._$reset();
|
|
1754
|
-
this._$getTextData();
|
|
1755
|
-
}
|
|
1756
|
-
}
|
|
1757
|
-
// restore
|
|
1758
|
-
this._$defaultTextFormat.size = cacheSize;
|
|
1759
|
-
}
|
|
1760
|
-
this._$resize();
|
|
1761
|
-
}
|
|
1762
|
-
/**
|
|
1763
|
-
* @return {void}
|
|
1764
|
-
* @method
|
|
1765
|
-
* @private
|
|
1766
|
-
*/
|
|
1767
|
-
_$resize() {
|
|
1768
|
-
// update bounds
|
|
1769
|
-
if (this._$autoSize !== "none") {
|
|
1770
|
-
const tf = this._$defaultTextFormat;
|
|
1771
|
-
const width = this.textWidth + 4 + tf._$widthMargin();
|
|
1772
|
-
if (this._$wordWrap) {
|
|
1773
|
-
this._$bounds.xMax = this._$originBounds.xMax;
|
|
1774
|
-
this._$bounds.xMin = this._$originBounds.xMin;
|
|
1775
|
-
}
|
|
1776
|
-
else {
|
|
1777
|
-
switch (this._$autoSize) {
|
|
1778
|
-
case "left":
|
|
1779
|
-
this._$bounds.xMax = width + this._$bounds.xMin;
|
|
1780
|
-
break;
|
|
1781
|
-
case "center":
|
|
1782
|
-
this._$bounds.xMax = width + this._$bounds.xMin;
|
|
1783
|
-
break;
|
|
1784
|
-
case "right":
|
|
1785
|
-
this._$bounds.xMax = this._$originBounds.xMax
|
|
1786
|
-
- (this._$originBounds.xMax - this._$originBounds.xMin
|
|
1787
|
-
- (width - this._$originBounds.xMin));
|
|
1788
|
-
break;
|
|
1789
|
-
default:
|
|
1790
|
-
break;
|
|
1791
|
-
}
|
|
1792
|
-
}
|
|
1793
|
-
// set height
|
|
1794
|
-
this._$bounds.yMax = this.textHeight
|
|
1795
|
-
+ 4 + this._$originBounds.yMin;
|
|
1796
|
-
}
|
|
1797
|
-
else {
|
|
1798
|
-
if (this._$scrollEnabled && !this._$scrollSprite) {
|
|
1799
|
-
this._$scrollSprite = new Sprite();
|
|
1800
|
-
this._$scrollSprite
|
|
1801
|
-
.graphics
|
|
1802
|
-
.beginFill("#000", 0.3)
|
|
1803
|
-
.drawRoundRect(0, 0, 3, 3, 3);
|
|
1804
|
-
this._$scrollSprite.scale9Grid = new Rectangle(1.5, 1.5, 0.1, 0.1);
|
|
1805
|
-
}
|
|
1806
|
-
}
|
|
1807
|
-
}
|
|
1808
|
-
/**
|
|
1809
|
-
* @param {object} obj
|
|
1810
|
-
* @param {number} width
|
|
1811
|
-
* @return {number}
|
|
1812
|
-
* @private
|
|
1813
|
-
*/
|
|
1814
|
-
_$getAlignOffset(obj, width) {
|
|
1815
|
-
// default
|
|
1816
|
-
const totalWidth = this._$widthTable[obj.yIndex];
|
|
1817
|
-
const textFormat = obj.textFormat;
|
|
1818
|
-
let indent = 0;
|
|
1819
|
-
indent += textFormat.blockIndent || 0;
|
|
1820
|
-
indent += textFormat.leftMargin || 0;
|
|
1821
|
-
const rightMargin = textFormat.rightMargin || 0;
|
|
1822
|
-
switch (true) {
|
|
1823
|
-
// wordWrap case
|
|
1824
|
-
case !this._$wordWrap && totalWidth > width:
|
|
1825
|
-
return $Math.max(0, indent);
|
|
1826
|
-
case textFormat.align === "center": // format CENTER
|
|
1827
|
-
case this._$autoSize === "center": // autoSize CENTER
|
|
1828
|
-
return $Math.max(0, width / 2 - indent - rightMargin - totalWidth / 2);
|
|
1829
|
-
case textFormat.align === "right": // format RIGHT
|
|
1830
|
-
case this._$autoSize === "right": // autoSize RIGHT
|
|
1831
|
-
return $Math.max(0, width - indent - totalWidth - rightMargin - 2);
|
|
1832
|
-
// autoSize LEFT
|
|
1833
|
-
// format LEFT
|
|
1834
|
-
default:
|
|
1835
|
-
return $Math.max(0, indent + 2);
|
|
1836
|
-
}
|
|
1837
|
-
}
|
|
1838
|
-
/**
|
|
1839
|
-
* @param {Float32Array} [matrix=null]
|
|
1840
|
-
* @returns {object}
|
|
1841
|
-
* @method
|
|
1842
|
-
* @private
|
|
1843
|
-
*/
|
|
1844
|
-
_$getBounds(matrix = null) {
|
|
1845
|
-
if (matrix) {
|
|
1846
|
-
let multiMatrix = matrix;
|
|
1847
|
-
const rawMatrix = this._$transform._$rawMatrix();
|
|
1848
|
-
if (rawMatrix[0] !== 1 || rawMatrix[1] !== 0
|
|
1849
|
-
|| rawMatrix[2] !== 0 || rawMatrix[3] !== 1
|
|
1850
|
-
|| rawMatrix[4] !== 0 || rawMatrix[5] !== 0) {
|
|
1851
|
-
multiMatrix = $multiplicationMatrix(matrix, rawMatrix);
|
|
1852
|
-
}
|
|
1853
|
-
return $boundsMatrix(this._$bounds, multiMatrix);
|
|
1854
|
-
}
|
|
1855
|
-
return $getBoundsObject(this._$bounds.xMin, this._$bounds.xMax, this._$bounds.yMin, this._$bounds.yMax);
|
|
1856
|
-
}
|
|
1857
|
-
/**
|
|
1858
|
-
* @param {object} character
|
|
1859
|
-
* @return {void}
|
|
1860
|
-
* @method
|
|
1861
|
-
* @private
|
|
1862
|
-
*/
|
|
1863
|
-
_$buildCharacter(character) {
|
|
1864
|
-
const textFormat = this._$defaultTextFormat;
|
|
1865
|
-
textFormat.font = character.font;
|
|
1866
|
-
textFormat.size = character.size | 0;
|
|
1867
|
-
textFormat.align = character.align;
|
|
1868
|
-
textFormat.color = character.color | 0;
|
|
1869
|
-
textFormat.leading = character.leading;
|
|
1870
|
-
textFormat.letterSpacing = character.letterSpacing;
|
|
1871
|
-
textFormat.leftMargin = character.leftMargin;
|
|
1872
|
-
textFormat.rightMargin = character.rightMargin;
|
|
1873
|
-
switch (character.fontType) {
|
|
1874
|
-
case 1:
|
|
1875
|
-
textFormat.bold = true;
|
|
1876
|
-
break;
|
|
1877
|
-
case 2:
|
|
1878
|
-
textFormat.italic = true;
|
|
1879
|
-
break;
|
|
1880
|
-
case 3:
|
|
1881
|
-
textFormat.bold = true;
|
|
1882
|
-
textFormat.italic = true;
|
|
1883
|
-
break;
|
|
1884
|
-
}
|
|
1885
|
-
// setup
|
|
1886
|
-
this._$type = character.inputType;
|
|
1887
|
-
this._$multiline = !!character.multiline;
|
|
1888
|
-
this._$wordWrap = !!character.wordWrap;
|
|
1889
|
-
this._$border = !!character.border;
|
|
1890
|
-
this._$scrollEnabled = !!character.scroll;
|
|
1891
|
-
this._$thickness = character.thickness | 0;
|
|
1892
|
-
this._$thicknessColor = character.thicknessColor | 0;
|
|
1893
|
-
// bounds
|
|
1894
|
-
this._$bounds.xMin = character.originBounds.xMin;
|
|
1895
|
-
this._$bounds.xMax = character.originBounds.xMax;
|
|
1896
|
-
this._$bounds.yMin = character.originBounds.yMin;
|
|
1897
|
-
this._$bounds.yMax = character.originBounds.yMax;
|
|
1898
|
-
this._$originBounds.xMin = character.originBounds.xMin;
|
|
1899
|
-
this._$originBounds.xMax = character.originBounds.xMax;
|
|
1900
|
-
this._$originBounds.yMin = character.originBounds.yMin;
|
|
1901
|
-
this._$originBounds.yMax = character.originBounds.yMax;
|
|
1902
|
-
switch (character.autoSize) {
|
|
1903
|
-
case 1:
|
|
1904
|
-
this.autoSize = character.align;
|
|
1905
|
-
break;
|
|
1906
|
-
case 2:
|
|
1907
|
-
this.autoFontSize = true;
|
|
1908
|
-
break;
|
|
1909
|
-
}
|
|
1910
|
-
this.text = character.text;
|
|
1911
|
-
if ($rendererWorker && this._$stage) {
|
|
1912
|
-
this._$createWorkerInstance();
|
|
1913
|
-
}
|
|
1914
|
-
}
|
|
1915
|
-
/**
|
|
1916
|
-
* @param {object} character
|
|
1917
|
-
* @return {void}
|
|
1918
|
-
* @method
|
|
1919
|
-
* @private
|
|
1920
|
-
*/
|
|
1921
|
-
_$sync(character) {
|
|
1922
|
-
this._$buildCharacter(character);
|
|
1923
|
-
}
|
|
1924
|
-
/**
|
|
1925
|
-
* @param {object} tag
|
|
1926
|
-
* @param {DisplayObjectContainer} parent
|
|
1927
|
-
* @return {object}
|
|
1928
|
-
* @method
|
|
1929
|
-
* @private
|
|
1930
|
-
*/
|
|
1931
|
-
_$build(tag, parent) {
|
|
1932
|
-
const character = this
|
|
1933
|
-
._$baseBuild(tag, parent);
|
|
1934
|
-
this._$buildCharacter(character);
|
|
1935
|
-
return character;
|
|
1936
|
-
}
|
|
1937
|
-
/**
|
|
1938
|
-
* @param {CanvasToWebGLContext} context
|
|
1939
|
-
* @param {Float32Array} matrix
|
|
1940
|
-
* @returns {void}
|
|
1941
|
-
* @method
|
|
1942
|
-
* @private
|
|
1943
|
-
*/
|
|
1944
|
-
_$clip(context, matrix) {
|
|
1945
|
-
// size
|
|
1946
|
-
const bounds = this._$getBounds();
|
|
1947
|
-
const xMax = bounds.xMax;
|
|
1948
|
-
const xMin = bounds.xMin;
|
|
1949
|
-
const yMax = bounds.yMax;
|
|
1950
|
-
const yMin = bounds.yMin;
|
|
1951
|
-
$poolBoundsObject(bounds);
|
|
1952
|
-
const width = $Math.ceil($Math.abs(xMax - xMin));
|
|
1953
|
-
const height = $Math.ceil($Math.abs(yMax - yMin));
|
|
1954
|
-
if (!width || !height) {
|
|
1955
|
-
return;
|
|
1956
|
-
}
|
|
1957
|
-
let multiMatrix = matrix;
|
|
1958
|
-
const rawMatrix = this._$transform._$rawMatrix();
|
|
1959
|
-
if (rawMatrix[0] !== 1 || rawMatrix[1] !== 0
|
|
1960
|
-
|| rawMatrix[2] !== 0 || rawMatrix[3] !== 1
|
|
1961
|
-
|| rawMatrix[4] !== 0 || rawMatrix[5] !== 0) {
|
|
1962
|
-
multiMatrix = $multiplicationMatrix(matrix, rawMatrix);
|
|
1963
|
-
}
|
|
1964
|
-
context.reset();
|
|
1965
|
-
context.setTransform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
|
|
1966
|
-
context.beginPath();
|
|
1967
|
-
context.moveTo(0, 0);
|
|
1968
|
-
context.lineTo(width, 0);
|
|
1969
|
-
context.lineTo(width, height);
|
|
1970
|
-
context.lineTo(0, height);
|
|
1971
|
-
context.lineTo(0, 0);
|
|
1972
|
-
context.clip();
|
|
1973
|
-
if (multiMatrix !== matrix) {
|
|
1974
|
-
$poolFloat32Array6(multiMatrix);
|
|
1975
|
-
}
|
|
1976
|
-
}
|
|
1977
|
-
/**
|
|
1978
|
-
* @param {CanvasToWebGLContext} context
|
|
1979
|
-
* @param {Float32Array} matrix
|
|
1980
|
-
* @param {Float32Array} color_transform
|
|
1981
|
-
* @return {void}
|
|
1982
|
-
* @method
|
|
1983
|
-
* @private
|
|
1984
|
-
*/
|
|
1985
|
-
_$draw(context, matrix, color_transform) {
|
|
1986
|
-
if (!this._$visible || this._$textAreaActive) {
|
|
1987
|
-
return;
|
|
1988
|
-
}
|
|
1989
|
-
if (!this._$background && !this._$border && !this.text) {
|
|
1990
|
-
return;
|
|
1991
|
-
}
|
|
1992
|
-
let multiColor = color_transform;
|
|
1993
|
-
const rawColor = this._$transform._$rawColorTransform();
|
|
1994
|
-
if (rawColor[0] !== 1 || rawColor[1] !== 1
|
|
1995
|
-
|| rawColor[2] !== 1 || rawColor[3] !== 1
|
|
1996
|
-
|| rawColor[4] !== 0 || rawColor[5] !== 0
|
|
1997
|
-
|| rawColor[6] !== 0 || rawColor[7] !== 0) {
|
|
1998
|
-
multiColor = $multiplicationColor(color_transform, rawColor);
|
|
1999
|
-
}
|
|
2000
|
-
const alpha = $clamp(multiColor[3] + multiColor[7] / 255, 0, 1);
|
|
2001
|
-
if (!alpha) {
|
|
2002
|
-
return;
|
|
2003
|
-
}
|
|
2004
|
-
let multiMatrix = matrix;
|
|
2005
|
-
const rawMatrix = this._$transform._$rawMatrix();
|
|
2006
|
-
if (rawMatrix[0] !== 1 || rawMatrix[1] !== 0
|
|
2007
|
-
|| rawMatrix[2] !== 0 || rawMatrix[3] !== 1
|
|
2008
|
-
|| rawMatrix[4] !== 0 || rawMatrix[5] !== 0) {
|
|
2009
|
-
multiMatrix = $multiplicationMatrix(matrix, rawMatrix);
|
|
2010
|
-
}
|
|
2011
|
-
const baseBounds = this._$getBounds(null);
|
|
2012
|
-
baseBounds.xMin -= this._$thickness;
|
|
2013
|
-
baseBounds.xMax += this._$thickness;
|
|
2014
|
-
baseBounds.yMin -= this._$thickness;
|
|
2015
|
-
baseBounds.yMax += this._$thickness;
|
|
2016
|
-
const bounds = $boundsMatrix(baseBounds, multiMatrix);
|
|
2017
|
-
const xMax = +bounds.xMax;
|
|
2018
|
-
const xMin = +bounds.xMin;
|
|
2019
|
-
const yMax = +bounds.yMax;
|
|
2020
|
-
const yMin = +bounds.yMin;
|
|
2021
|
-
$poolBoundsObject(bounds);
|
|
2022
|
-
const width = $Math.ceil($Math.abs(xMax - xMin));
|
|
2023
|
-
const height = $Math.ceil($Math.abs(yMax - yMin));
|
|
2024
|
-
switch (true) {
|
|
2025
|
-
case width === 0:
|
|
2026
|
-
case height === 0:
|
|
2027
|
-
case width === -$Infinity:
|
|
2028
|
-
case height === -$Infinity:
|
|
2029
|
-
case width === $Infinity:
|
|
2030
|
-
case height === $Infinity:
|
|
2031
|
-
return;
|
|
2032
|
-
default:
|
|
2033
|
-
break;
|
|
2034
|
-
}
|
|
2035
|
-
if (0 > xMin + width || 0 > yMin + height) {
|
|
2036
|
-
return;
|
|
2037
|
-
}
|
|
2038
|
-
// cache current buffer
|
|
2039
|
-
const manager = context.frameBuffer;
|
|
2040
|
-
const currentAttachment = manager.currentAttachment;
|
|
2041
|
-
if (!currentAttachment
|
|
2042
|
-
|| xMin > currentAttachment.width
|
|
2043
|
-
|| yMin > currentAttachment.height) {
|
|
2044
|
-
return;
|
|
2045
|
-
}
|
|
2046
|
-
let xScale = +$Math.sqrt(multiMatrix[0] * multiMatrix[0]
|
|
2047
|
-
+ multiMatrix[1] * multiMatrix[1]);
|
|
2048
|
-
if (!$Number.isInteger(xScale)) {
|
|
2049
|
-
const value = xScale.toString();
|
|
2050
|
-
const index = value.indexOf("e");
|
|
2051
|
-
if (index !== -1) {
|
|
2052
|
-
xScale = +value.slice(0, index);
|
|
2053
|
-
}
|
|
2054
|
-
xScale = +xScale.toFixed(4);
|
|
2055
|
-
}
|
|
2056
|
-
let yScale = +$Math.sqrt(multiMatrix[2] * multiMatrix[2]
|
|
2057
|
-
+ multiMatrix[3] * multiMatrix[3]);
|
|
2058
|
-
if (!$Number.isInteger(yScale)) {
|
|
2059
|
-
const value = yScale.toString();
|
|
2060
|
-
const index = value.indexOf("e");
|
|
2061
|
-
if (index !== -1) {
|
|
2062
|
-
yScale = +value.slice(0, index);
|
|
2063
|
-
}
|
|
2064
|
-
yScale = +yScale.toFixed(4);
|
|
2065
|
-
}
|
|
2066
|
-
const filters = this._$filters || this.filters;
|
|
2067
|
-
if (0 > xMin + width || 0 > yMin + height) {
|
|
2068
|
-
if (filters.length && this._$canApply(filters)) {
|
|
2069
|
-
let rect = new Rectangle(0, 0, width, height);
|
|
2070
|
-
for (let idx = 0; idx < filters.length; ++idx) {
|
|
2071
|
-
rect = filters[idx]._$generateFilterRect(rect, xScale, yScale);
|
|
2072
|
-
}
|
|
2073
|
-
if (0 > rect.x + rect.width || 0 > rect.y + rect.height) {
|
|
2074
|
-
return;
|
|
2075
|
-
}
|
|
2076
|
-
}
|
|
2077
|
-
else {
|
|
2078
|
-
return;
|
|
2079
|
-
}
|
|
2080
|
-
}
|
|
2081
|
-
const blendMode = this._$blendMode || this.blendMode;
|
|
2082
|
-
const keys = $getArray(xScale, yScale);
|
|
2083
|
-
const instanceId = this._$instanceId;
|
|
2084
|
-
const player = $currentPlayer();
|
|
2085
|
-
const cacheStore = player.cacheStore;
|
|
2086
|
-
const cacheKeys = cacheStore.generateKeys(instanceId, keys);
|
|
2087
|
-
let texture = cacheStore.get(cacheKeys);
|
|
2088
|
-
// texture is small or renew
|
|
2089
|
-
if (this._$isUpdated()) {
|
|
2090
|
-
cacheStore.removeCache(instanceId);
|
|
2091
|
-
texture = null;
|
|
2092
|
-
}
|
|
2093
|
-
if (!texture) {
|
|
2094
|
-
// resize
|
|
2095
|
-
const lineWidth = $Math.min(1, $Math.max(xScale, yScale));
|
|
2096
|
-
const baseWidth = $Math.ceil($Math.abs(baseBounds.xMax - baseBounds.xMin) * xScale);
|
|
2097
|
-
const baseHeight = $Math.ceil($Math.abs(baseBounds.yMax - baseBounds.yMin) * yScale);
|
|
2098
|
-
// alpha reset
|
|
2099
|
-
multiColor[3] = 1;
|
|
2100
|
-
// new canvas
|
|
2101
|
-
const canvas = cacheStore.getCanvas();
|
|
2102
|
-
canvas.width = baseWidth + lineWidth * 2;
|
|
2103
|
-
canvas.height = baseHeight + lineWidth * 2;
|
|
2104
|
-
const ctx = canvas.getContext("2d");
|
|
2105
|
-
if (!ctx) {
|
|
2106
|
-
throw new Error("the context is null.");
|
|
2107
|
-
}
|
|
2108
|
-
// border and background
|
|
2109
|
-
if (this._$background || this._$border) {
|
|
2110
|
-
ctx.beginPath();
|
|
2111
|
-
ctx.moveTo(0, 0);
|
|
2112
|
-
ctx.lineTo(baseWidth, 0);
|
|
2113
|
-
ctx.lineTo(baseWidth, baseHeight);
|
|
2114
|
-
ctx.lineTo(0, baseHeight);
|
|
2115
|
-
ctx.lineTo(0, 0);
|
|
2116
|
-
if (this._$background) {
|
|
2117
|
-
const rgb = $intToRGBA(this._$backgroundColor);
|
|
2118
|
-
const alpha = $Math.max(0, $Math.min(rgb.A * 255 * multiColor[3] + multiColor[7], 255)) / 255;
|
|
2119
|
-
ctx.fillStyle = `rgba(${rgb.R},${rgb.G},${rgb.B},${alpha})`;
|
|
2120
|
-
ctx.fill();
|
|
2121
|
-
}
|
|
2122
|
-
if (this._$border) {
|
|
2123
|
-
const rgb = $intToRGBA(this._$borderColor);
|
|
2124
|
-
const alpha = $Math.max(0, $Math.min(rgb.A * 255 * multiColor[3] + multiColor[7], 255)) / 255;
|
|
2125
|
-
ctx.lineWidth = lineWidth;
|
|
2126
|
-
ctx.strokeStyle = `rgba(${rgb.R},${rgb.G},${rgb.B},${alpha})`;
|
|
2127
|
-
ctx.stroke();
|
|
2128
|
-
}
|
|
2129
|
-
}
|
|
2130
|
-
// mask start
|
|
2131
|
-
ctx.save();
|
|
2132
|
-
ctx.beginPath();
|
|
2133
|
-
ctx.moveTo(2, 2);
|
|
2134
|
-
ctx.lineTo(baseWidth - 2, 2);
|
|
2135
|
-
ctx.lineTo(baseWidth - 2, baseHeight - 2);
|
|
2136
|
-
ctx.lineTo(2, baseHeight - 2);
|
|
2137
|
-
ctx.lineTo(2, 2);
|
|
2138
|
-
ctx.clip();
|
|
2139
|
-
ctx.beginPath();
|
|
2140
|
-
ctx.setTransform(xScale, 0, 0, yScale, 0, 0);
|
|
2141
|
-
this._$doDraw(ctx, matrix, multiColor, baseWidth / xScale);
|
|
2142
|
-
ctx.restore();
|
|
2143
|
-
texture = manager.createTextureFromCanvas(ctx.canvas);
|
|
2144
|
-
// set cache
|
|
2145
|
-
cacheStore.set(cacheKeys, texture);
|
|
2146
|
-
// destroy cache
|
|
2147
|
-
cacheStore.destroy(ctx);
|
|
2148
|
-
}
|
|
2149
|
-
let drawFilter = false;
|
|
2150
|
-
let offsetX = 0;
|
|
2151
|
-
let offsetY = 0;
|
|
2152
|
-
if (filters && filters.length
|
|
2153
|
-
&& this._$canApply(filters)) {
|
|
2154
|
-
drawFilter = true;
|
|
2155
|
-
texture = this._$drawFilter(context, texture, multiMatrix, filters, width, height);
|
|
2156
|
-
offsetX = texture._$offsetX;
|
|
2157
|
-
offsetY = texture._$offsetY;
|
|
2158
|
-
}
|
|
2159
|
-
const radianX = $Math.atan2(multiMatrix[1], multiMatrix[0]);
|
|
2160
|
-
const radianY = $Math.atan2(-multiMatrix[2], multiMatrix[3]);
|
|
2161
|
-
if (!drawFilter && (radianX || radianY)) {
|
|
2162
|
-
const tx = baseBounds.xMin * xScale;
|
|
2163
|
-
const ty = baseBounds.yMin * yScale;
|
|
2164
|
-
const cosX = $Math.cos(radianX);
|
|
2165
|
-
const sinX = $Math.sin(radianX);
|
|
2166
|
-
const cosY = $Math.cos(radianY);
|
|
2167
|
-
const sinY = $Math.sin(radianY);
|
|
2168
|
-
context.setTransform(cosX, sinX, -sinY, cosY, tx * cosX - ty * sinY + multiMatrix[4], tx * sinX + ty * cosY + multiMatrix[5]);
|
|
2169
|
-
}
|
|
2170
|
-
else {
|
|
2171
|
-
context.setTransform(1, 0, 0, 1, xMin - offsetX, yMin - offsetY);
|
|
2172
|
-
}
|
|
2173
|
-
// draw
|
|
2174
|
-
context.reset();
|
|
2175
|
-
context.globalAlpha = alpha;
|
|
2176
|
-
context.imageSmoothingEnabled = true;
|
|
2177
|
-
context.globalCompositeOperation = blendMode;
|
|
2178
|
-
context.drawImage(texture, 0, 0, texture.width, texture.height, multiColor);
|
|
2179
|
-
// get cache
|
|
2180
|
-
$poolArray(cacheKeys);
|
|
2181
|
-
$poolBoundsObject(baseBounds);
|
|
2182
|
-
// pool
|
|
2183
|
-
if (multiMatrix !== matrix) {
|
|
2184
|
-
$poolFloat32Array6(multiMatrix);
|
|
2185
|
-
}
|
|
2186
|
-
if (multiColor !== color_transform) {
|
|
2187
|
-
$poolFloat32Array8(multiColor);
|
|
2188
|
-
}
|
|
2189
|
-
}
|
|
2190
|
-
/**
|
|
2191
|
-
* @param {CanvasRenderingContext2D} context
|
|
2192
|
-
* @param {Float32Array} matrix
|
|
2193
|
-
* @param {Float32Array} color_transform
|
|
2194
|
-
* @param {number} width
|
|
2195
|
-
* @return {void}
|
|
2196
|
-
* @method
|
|
2197
|
-
* @private
|
|
2198
|
-
*/
|
|
2199
|
-
_$doDraw(context, matrix, color_transform, width) {
|
|
2200
|
-
// init
|
|
2201
|
-
const textData = this._$getTextData();
|
|
2202
|
-
const limitWidth = this.width;
|
|
2203
|
-
const limitHeight = this.height;
|
|
2204
|
-
// setup
|
|
2205
|
-
let xOffset = 0;
|
|
2206
|
-
let offsetHeight = 0;
|
|
2207
|
-
let currentV = 0;
|
|
2208
|
-
let yOffset = 0;
|
|
2209
|
-
if (this._$verticalAlign !== "top"
|
|
2210
|
-
&& this.height > this.textHeight) {
|
|
2211
|
-
switch (this._$verticalAlign) {
|
|
2212
|
-
case "middle":
|
|
2213
|
-
yOffset = (this.height - this.textHeight + 2) / 2;
|
|
2214
|
-
break;
|
|
2215
|
-
case "bottom":
|
|
2216
|
-
yOffset = this.height - this.textHeight + 2;
|
|
2217
|
-
break;
|
|
2218
|
-
}
|
|
2219
|
-
}
|
|
2220
|
-
for (let idx = 0; idx < textData.length; ++idx) {
|
|
2221
|
-
const obj = textData[idx];
|
|
2222
|
-
if (obj.width === 0) {
|
|
2223
|
-
continue;
|
|
2224
|
-
}
|
|
2225
|
-
// check
|
|
2226
|
-
const offsetWidth = xOffset + obj.x;
|
|
2227
|
-
if (this._$autoSize === "none"
|
|
2228
|
-
&& (offsetHeight > limitHeight || offsetWidth > limitWidth)) {
|
|
2229
|
-
continue;
|
|
2230
|
-
}
|
|
2231
|
-
const tf = obj.textFormat;
|
|
2232
|
-
// color
|
|
2233
|
-
const rgb = $intToRGBA(tf.color || 0);
|
|
2234
|
-
const alpha = $Math.max(0, $Math.min(rgb.A * 255 * color_transform[3] + color_transform[7], 255)) / 255;
|
|
2235
|
-
context.fillStyle = `rgba(${rgb.R},${rgb.G},${rgb.B},${alpha})`;
|
|
2236
|
-
if (this._$thickness) {
|
|
2237
|
-
const rgb = $intToRGBA(this._$thicknessColor);
|
|
2238
|
-
const alpha = $Math.max(0, $Math.min(rgb.A * 255 * color_transform[3] + color_transform[7], 255)) / 255;
|
|
2239
|
-
context.lineWidth = this._$thickness;
|
|
2240
|
-
context.strokeStyle = `rgba(${rgb.R},${rgb.G},${rgb.B},${alpha})`;
|
|
2241
|
-
}
|
|
2242
|
-
const yIndex = obj.yIndex | 0;
|
|
2243
|
-
switch (obj.mode) {
|
|
2244
|
-
case "break":
|
|
2245
|
-
case "wrap":
|
|
2246
|
-
currentV++;
|
|
2247
|
-
if (this.scrollV > currentV) {
|
|
2248
|
-
continue;
|
|
2249
|
-
}
|
|
2250
|
-
offsetHeight += this._$textHeightTable[yIndex];
|
|
2251
|
-
xOffset = this._$getAlignOffset(this._$objectTable[yIndex], width);
|
|
2252
|
-
if (tf.underline) {
|
|
2253
|
-
const offset = tf.size ? tf.size / 12 : 0;
|
|
2254
|
-
const rgb = $intToRGBA(tf.color || 0);
|
|
2255
|
-
const alpha = $Math.max(0, $Math.min(rgb.A * 255 * color_transform[3] + color_transform[7], 255)) / 255;
|
|
2256
|
-
context.lineWidth = $Math.max(1, 1 / $Math.min(matrix[0], matrix[3]));
|
|
2257
|
-
context.strokeStyle = `rgba(${rgb.R},${rgb.G},${rgb.B},${alpha})`;
|
|
2258
|
-
context.beginPath();
|
|
2259
|
-
context.moveTo(xOffset, yOffset + offsetHeight - offset);
|
|
2260
|
-
context.lineTo(xOffset + this._$widthTable[yIndex], yOffset + offsetHeight - offset);
|
|
2261
|
-
context.stroke();
|
|
2262
|
-
}
|
|
2263
|
-
break;
|
|
2264
|
-
case "text":
|
|
2265
|
-
{
|
|
2266
|
-
if (this.scrollV > currentV) {
|
|
2267
|
-
continue;
|
|
2268
|
-
}
|
|
2269
|
-
let offsetY = offsetHeight - this._$heightTable[0];
|
|
2270
|
-
if (!$isSafari && tf.size) {
|
|
2271
|
-
offsetY += $devicePixelRatio * (tf.size / 12);
|
|
2272
|
-
}
|
|
2273
|
-
context.beginPath();
|
|
2274
|
-
context.textBaseline = "top";
|
|
2275
|
-
context.font = $generateFontStyle(tf.font || "", tf.size || 0, !!tf.italic, !!tf.bold);
|
|
2276
|
-
if (this._$thickness) {
|
|
2277
|
-
context.strokeText(obj.text, offsetWidth, yOffset + offsetY);
|
|
2278
|
-
}
|
|
2279
|
-
context.fillText(obj.text, offsetWidth, yOffset + offsetY);
|
|
2280
|
-
}
|
|
2281
|
-
break;
|
|
2282
|
-
case "image":
|
|
2283
|
-
if (!obj.loaded) {
|
|
2284
|
-
continue;
|
|
2285
|
-
}
|
|
2286
|
-
context.beginPath();
|
|
2287
|
-
context.drawImage(obj.image, obj.hspace, yOffset + obj.y, obj.width, obj.height);
|
|
2288
|
-
break;
|
|
2289
|
-
}
|
|
2290
|
-
}
|
|
2291
|
-
}
|
|
2292
|
-
/**
|
|
2293
|
-
* @param {CanvasRenderingContext2D} context
|
|
2294
|
-
* @param {Float32Array} matrix
|
|
2295
|
-
* @param {object} options
|
|
2296
|
-
* @return {boolean}
|
|
2297
|
-
* @method
|
|
2298
|
-
* @private
|
|
2299
|
-
*/
|
|
2300
|
-
_$mouseHit(context, matrix, options) {
|
|
2301
|
-
if (!this._$visible) {
|
|
2302
|
-
return false;
|
|
2303
|
-
}
|
|
2304
|
-
return this._$hit(context, matrix, options);
|
|
2305
|
-
}
|
|
2306
|
-
/**
|
|
2307
|
-
* @param {CanvasRenderingContext2D} context
|
|
2308
|
-
* @param {Float32Array} matrix
|
|
2309
|
-
* @param {object} options
|
|
2310
|
-
* @return {boolean}
|
|
2311
|
-
* @method
|
|
2312
|
-
* @private
|
|
2313
|
-
*/
|
|
2314
|
-
_$hit(context, matrix, options) {
|
|
2315
|
-
let multiMatrix = matrix;
|
|
2316
|
-
const rawMatrix = this._$transform._$rawMatrix();
|
|
2317
|
-
if (rawMatrix[0] !== 1 || rawMatrix[1] !== 0
|
|
2318
|
-
|| rawMatrix[2] !== 0 || rawMatrix[3] !== 1
|
|
2319
|
-
|| rawMatrix[4] !== 0 || rawMatrix[5] !== 0) {
|
|
2320
|
-
multiMatrix = $multiplicationMatrix(matrix, rawMatrix);
|
|
2321
|
-
}
|
|
2322
|
-
const baseBounds = this._$getBounds(null);
|
|
2323
|
-
const bounds = $boundsMatrix(baseBounds, multiMatrix);
|
|
2324
|
-
const xMax = +bounds.xMax;
|
|
2325
|
-
const xMin = +bounds.xMin;
|
|
2326
|
-
const yMax = +bounds.yMax;
|
|
2327
|
-
const yMin = +bounds.yMin;
|
|
2328
|
-
$poolBoundsObject(bounds);
|
|
2329
|
-
$poolBoundsObject(baseBounds);
|
|
2330
|
-
const width = $Math.ceil($Math.abs(xMax - xMin));
|
|
2331
|
-
const height = $Math.ceil($Math.abs(yMax - yMin));
|
|
2332
|
-
context.setTransform(1, 0, 0, 1, xMin, yMin);
|
|
2333
|
-
context.beginPath();
|
|
2334
|
-
context.moveTo(0, 0);
|
|
2335
|
-
context.lineTo(width, 0);
|
|
2336
|
-
context.lineTo(width, height);
|
|
2337
|
-
context.lineTo(0, height);
|
|
2338
|
-
context.lineTo(0, 0);
|
|
2339
|
-
if (multiMatrix !== matrix) {
|
|
2340
|
-
$poolFloat32Array6(multiMatrix);
|
|
2341
|
-
}
|
|
2342
|
-
return context.isPointInPath(options.x, options.y);
|
|
2343
|
-
}
|
|
2344
|
-
/**
|
|
2345
|
-
* @param {number} scale
|
|
2346
|
-
* @return {void}
|
|
2347
|
-
* @method
|
|
2348
|
-
* @private
|
|
2349
|
-
*/
|
|
2350
|
-
_$createTextAreaElement(scale) {
|
|
2351
|
-
// new text area
|
|
2352
|
-
if (!this._$textarea) {
|
|
2353
|
-
this._$textarea = $document.createElement("textarea");
|
|
2354
|
-
this._$textarea.value = this.text;
|
|
2355
|
-
this._$textarea.id = `${$PREFIX}_TextField_${this._$instanceId}`;
|
|
2356
|
-
if (!this._$wordWrap) {
|
|
2357
|
-
this._$textarea.wrap = "off";
|
|
2358
|
-
}
|
|
2359
|
-
const textFormat = this._$defaultTextFormat;
|
|
2360
|
-
// setup
|
|
2361
|
-
let style = "";
|
|
2362
|
-
style += "position: absolute;";
|
|
2363
|
-
style += "outline: 0;";
|
|
2364
|
-
style += `padding: 2px 2px 2px ${$Math.max(3, textFormat.leftMargin || 0)}px;`;
|
|
2365
|
-
style += "margin: 0;";
|
|
2366
|
-
style += "appearance: none;";
|
|
2367
|
-
style += "resize: none;";
|
|
2368
|
-
style += "overflow: hidden;";
|
|
2369
|
-
style += `z-index: ${0x7fffffff};`;
|
|
2370
|
-
style += "vertical-align: top;";
|
|
2371
|
-
this._$textarea.setAttribute("style", style);
|
|
2372
|
-
// add blur event
|
|
2373
|
-
this._$textarea.addEventListener(`${$PREFIX}_blur`, (event) => {
|
|
2374
|
-
// set new text
|
|
2375
|
-
const element = event.target;
|
|
2376
|
-
let value = element.value;
|
|
2377
|
-
if (value && this._$restrict) {
|
|
2378
|
-
let pattern = this._$restrict;
|
|
2379
|
-
if (pattern[0] !== "[") {
|
|
2380
|
-
pattern = "[" + pattern;
|
|
2381
|
-
}
|
|
2382
|
-
if (pattern[pattern.length - 1] !== "]") {
|
|
2383
|
-
pattern += "]";
|
|
2384
|
-
}
|
|
2385
|
-
const found = value.match(new $RegExp(pattern, "gm"));
|
|
2386
|
-
value = found ? found.join("") : "";
|
|
2387
|
-
}
|
|
2388
|
-
const player = $currentPlayer();
|
|
2389
|
-
const div = $document.getElementById(player.contentElementId);
|
|
2390
|
-
if (div) {
|
|
2391
|
-
const element = $document.getElementById(`${$PREFIX}_TextField_${this._$instanceId}`);
|
|
2392
|
-
if (element) {
|
|
2393
|
-
element.remove();
|
|
2394
|
-
}
|
|
2395
|
-
}
|
|
2396
|
-
this.text = value;
|
|
2397
|
-
this._$focus = false;
|
|
2398
|
-
this._$textAreaActive = false;
|
|
2399
|
-
this._$doChanged();
|
|
2400
|
-
$doUpdated();
|
|
2401
|
-
});
|
|
2402
|
-
// input event
|
|
2403
|
-
this._$textarea.addEventListener("input", (event) => {
|
|
2404
|
-
// set new text
|
|
2405
|
-
const element = event.target;
|
|
2406
|
-
const player = $currentPlayer();
|
|
2407
|
-
let value = element.value;
|
|
2408
|
-
// SafariではInputEvent.isComposingがundefined
|
|
2409
|
-
if (this._$restrict && !this._$isComposing && value) {
|
|
2410
|
-
let pattern = this._$restrict;
|
|
2411
|
-
if (pattern[0] !== "[") {
|
|
2412
|
-
pattern = "[" + pattern;
|
|
2413
|
-
}
|
|
2414
|
-
if (pattern[pattern.length - 1] !== "]") {
|
|
2415
|
-
pattern += "]";
|
|
2416
|
-
}
|
|
2417
|
-
const found = value.match(new $RegExp(pattern, "gm"));
|
|
2418
|
-
value = found ? found.join("") : "";
|
|
2419
|
-
}
|
|
2420
|
-
if (!this._$isComposing && this.text !== value) {
|
|
2421
|
-
// update
|
|
2422
|
-
this.text = value;
|
|
2423
|
-
element.value = value;
|
|
2424
|
-
if (this.willTrigger(Next2DEvent.CHANGE)) {
|
|
2425
|
-
this.dispatchEvent(new Next2DEvent(Next2DEvent.CHANGE, true));
|
|
2426
|
-
}
|
|
2427
|
-
// setup
|
|
2428
|
-
// const element = this._$textarea;
|
|
2429
|
-
const matrix = this._$transform.concatenatedMatrix;
|
|
2430
|
-
const bounds = this._$getBounds(null);
|
|
2431
|
-
element.style.left = `${$Math.floor((matrix.tx + bounds.xMin + player.x / player._$scale / $devicePixelRatio) * player._$scale)}px`;
|
|
2432
|
-
element.style.top = `${$Math.floor((matrix.ty + bounds.yMin + player.y / player._$scale / $devicePixelRatio) * player._$scale)}px`;
|
|
2433
|
-
element.style.width = `${$Math.ceil((this.width - 1) * player._$scale)}px`;
|
|
2434
|
-
element.style.height = `${$Math.ceil((this.height - 1) * player._$scale)}px`;
|
|
2435
|
-
}
|
|
2436
|
-
});
|
|
2437
|
-
// IME入力開始時のevent
|
|
2438
|
-
this._$textarea.addEventListener("compositionstart", () => {
|
|
2439
|
-
this._$isComposing = true;
|
|
2440
|
-
});
|
|
2441
|
-
// IME入力確定時のevent
|
|
2442
|
-
this._$textarea.addEventListener("compositionend", (event) => {
|
|
2443
|
-
this._$isComposing = false;
|
|
2444
|
-
const element = event.target;
|
|
2445
|
-
let value = element.value;
|
|
2446
|
-
if (!this._$restrict || !value) {
|
|
2447
|
-
return;
|
|
2448
|
-
}
|
|
2449
|
-
let pattern = this._$restrict;
|
|
2450
|
-
if (pattern[0] !== "[") {
|
|
2451
|
-
pattern = "[" + pattern;
|
|
2452
|
-
}
|
|
2453
|
-
if (pattern[pattern.length - 1] !== "]") {
|
|
2454
|
-
pattern += "]";
|
|
2455
|
-
}
|
|
2456
|
-
const found = value.match(new $RegExp(pattern, "gm"));
|
|
2457
|
-
value = found ? found.join("") : "";
|
|
2458
|
-
// update
|
|
2459
|
-
this.text = value;
|
|
2460
|
-
element.value = value;
|
|
2461
|
-
});
|
|
2462
|
-
// add click event
|
|
2463
|
-
this._$textarea.addEventListener("click", () => {
|
|
2464
|
-
if (this.willTrigger(Next2DMouseEvent.CLICK)) {
|
|
2465
|
-
this.dispatchEvent(new Next2DMouseEvent(Next2DMouseEvent.CLICK));
|
|
2466
|
-
}
|
|
2467
|
-
});
|
|
2468
|
-
// add mousewheel event
|
|
2469
|
-
this._$textarea.addEventListener($MOUSE_WHEEL, (event) => {
|
|
2470
|
-
this.scrollV += event.deltaY;
|
|
2471
|
-
});
|
|
2472
|
-
// add scroll event
|
|
2473
|
-
this._$textarea.addEventListener($SCROLL, (event) => {
|
|
2474
|
-
const element = event.target;
|
|
2475
|
-
this.scrollV = element.scrollTop
|
|
2476
|
-
/ (element.scrollHeight - element.clientHeight)
|
|
2477
|
-
* this.maxScrollV + 1;
|
|
2478
|
-
});
|
|
2479
|
-
// down event
|
|
2480
|
-
this._$textarea.addEventListener($TOUCH_START, () => {
|
|
2481
|
-
const player = $currentPlayer();
|
|
2482
|
-
player._$state = "down";
|
|
2483
|
-
});
|
|
2484
|
-
// up event
|
|
2485
|
-
this._$textarea.addEventListener($TOUCH_END, () => {
|
|
2486
|
-
const player = $currentPlayer();
|
|
2487
|
-
player._$state = "up";
|
|
2488
|
-
});
|
|
2489
|
-
// down event
|
|
2490
|
-
this._$textarea.addEventListener($MOUSE_DOWN, () => {
|
|
2491
|
-
const player = $currentPlayer();
|
|
2492
|
-
player._$state = "down";
|
|
2493
|
-
});
|
|
2494
|
-
// up event
|
|
2495
|
-
this._$textarea.addEventListener($MOUSE_UP, () => {
|
|
2496
|
-
const player = $currentPlayer();
|
|
2497
|
-
player._$state = "up";
|
|
2498
|
-
});
|
|
2499
|
-
}
|
|
2500
|
-
// change style
|
|
2501
|
-
const tf = this._$defaultTextFormat;
|
|
2502
|
-
const fontSize = tf.size
|
|
2503
|
-
? $Math.ceil(tf.size * scale * this._$transform.concatenatedMatrix.d)
|
|
2504
|
-
: 0;
|
|
2505
|
-
this._$textarea.style.fontSize = `${fontSize}px`;
|
|
2506
|
-
this._$textarea.style.fontFamily = tf.font || "Times New Roman";
|
|
2507
|
-
this._$textarea.style.lineHeight = `${(fontSize + $Math.max(0, tf.leading || 0)) / fontSize}em`;
|
|
2508
|
-
if (this._$autoSize !== "none") {
|
|
2509
|
-
this._$textarea.style.textAlign = "center";
|
|
2510
|
-
}
|
|
2511
|
-
else {
|
|
2512
|
-
this._$textarea.style.textAlign = tf.align || "none";
|
|
2513
|
-
}
|
|
2514
|
-
this._$textarea.addEventListener("keydown", (event) => {
|
|
2515
|
-
const element = event.target;
|
|
2516
|
-
let value = element.value;
|
|
2517
|
-
// SafariではInputEvent.isComposingがundefined
|
|
2518
|
-
if (this._$restrict && !this._$isComposing && value) {
|
|
2519
|
-
let pattern = this._$restrict;
|
|
2520
|
-
if (pattern[0] !== "[") {
|
|
2521
|
-
pattern = "[" + pattern;
|
|
2522
|
-
}
|
|
2523
|
-
if (pattern[pattern.length - 1] !== "]") {
|
|
2524
|
-
pattern += "]";
|
|
2525
|
-
}
|
|
2526
|
-
const found = value.match(new $RegExp(pattern, "gm"));
|
|
2527
|
-
value = found ? found.join("") : "";
|
|
2528
|
-
}
|
|
2529
|
-
// update
|
|
2530
|
-
if (!this._$isComposing) {
|
|
2531
|
-
this.text = value;
|
|
2532
|
-
element.value = value;
|
|
2533
|
-
}
|
|
2534
|
-
// enter off
|
|
2535
|
-
if (event.code === "Enter" && !this._$multiline) {
|
|
2536
|
-
return false;
|
|
2537
|
-
}
|
|
2538
|
-
});
|
|
2539
|
-
const style = this._$textarea.style;
|
|
2540
|
-
if (this._$border) {
|
|
2541
|
-
style.border = `solid 1px #${this.borderColor.toString(16)}`;
|
|
2542
|
-
}
|
|
2543
|
-
else {
|
|
2544
|
-
style.border = "none";
|
|
2545
|
-
}
|
|
2546
|
-
if (this._$border || this._$background) {
|
|
2547
|
-
style.backgroundColor = `#${this.backgroundColor.toString(16)}`;
|
|
2548
|
-
}
|
|
2549
|
-
else {
|
|
2550
|
-
style.backgroundColor = "transparent";
|
|
2551
|
-
}
|
|
2552
|
-
//reset
|
|
2553
|
-
this._$textarea.maxLength = this._$maxChars ? this._$maxChars : 0x7fffffff;
|
|
2554
|
-
}
|
|
2555
|
-
/**
|
|
2556
|
-
* @return {void}
|
|
2557
|
-
* @method
|
|
2558
|
-
* @private
|
|
2559
|
-
*/
|
|
2560
|
-
_$createWorkerInstance() {
|
|
2561
|
-
if (this._$created || !$rendererWorker) {
|
|
2562
|
-
return;
|
|
2563
|
-
}
|
|
2564
|
-
this._$created = true;
|
|
2565
|
-
const bounds = this._$getBounds();
|
|
2566
|
-
const message = {
|
|
2567
|
-
"command": "createTextField",
|
|
2568
|
-
"instanceId": this._$instanceId,
|
|
2569
|
-
"parentId": this._$parent ? this._$parent._$instanceId : -1,
|
|
2570
|
-
"xMin": bounds.xMin,
|
|
2571
|
-
"yMin": bounds.yMin,
|
|
2572
|
-
"xMax": bounds.xMax,
|
|
2573
|
-
"yMax": bounds.yMax,
|
|
2574
|
-
"textData": this._$getTextData(),
|
|
2575
|
-
"scrollV": this.scrollV,
|
|
2576
|
-
"widthTable": this._$widthTable,
|
|
2577
|
-
"heightTable": this._$heightTable,
|
|
2578
|
-
"textHeightTable": this._$textHeightTable,
|
|
2579
|
-
"objectTable": this._$objectTable,
|
|
2580
|
-
"limitWidth": this.width,
|
|
2581
|
-
"limitHeight": this.height,
|
|
2582
|
-
"textHeight": this.textHeight,
|
|
2583
|
-
"verticalAlign": this._$verticalAlign,
|
|
2584
|
-
"autoSize": this._$autoSize,
|
|
2585
|
-
"wordWrap": this._$wordWrap,
|
|
2586
|
-
"border": this._$border,
|
|
2587
|
-
"background": this._$background,
|
|
2588
|
-
"thickness": this._$thickness
|
|
2589
|
-
};
|
|
2590
|
-
if (this._$border) {
|
|
2591
|
-
message.borderColor = this._$borderColor;
|
|
2592
|
-
}
|
|
2593
|
-
if (this._$background) {
|
|
2594
|
-
message.backgroundColor = this._$backgroundColor;
|
|
2595
|
-
}
|
|
2596
|
-
if (this._$thickness) {
|
|
2597
|
-
message.thicknessColor = this._$backgroundColor;
|
|
2598
|
-
}
|
|
2599
|
-
if (this._$characterId > -1) {
|
|
2600
|
-
message.characterId = this._$characterId;
|
|
2601
|
-
}
|
|
2602
|
-
if (this._$loaderInfo) {
|
|
2603
|
-
message.loaderInfoId = this._$loaderInfo._$id;
|
|
2604
|
-
}
|
|
2605
|
-
if (this._$scale9Grid) {
|
|
2606
|
-
message.grid = {
|
|
2607
|
-
"x": this._$scale9Grid.x,
|
|
2608
|
-
"y": this._$scale9Grid.y,
|
|
2609
|
-
"w": this._$scale9Grid.width,
|
|
2610
|
-
"h": this._$scale9Grid.height
|
|
2611
|
-
};
|
|
2612
|
-
}
|
|
2613
|
-
$rendererWorker.postMessage(message);
|
|
2614
|
-
}
|
|
2615
|
-
/**
|
|
2616
|
-
* @return {void}
|
|
2617
|
-
* @method
|
|
2618
|
-
* @private
|
|
2619
|
-
*/
|
|
2620
|
-
_$postProperty() {
|
|
2621
|
-
if (!$rendererWorker) {
|
|
2622
|
-
return;
|
|
2623
|
-
}
|
|
2624
|
-
const message = this._$createMessage();
|
|
2625
|
-
message.textAreaActive = this._$textAreaActive;
|
|
2626
|
-
const bounds = this._$getBounds(null);
|
|
2627
|
-
message.xMin = bounds.xMin;
|
|
2628
|
-
message.yMin = bounds.yMin;
|
|
2629
|
-
message.xMax = bounds.xMax;
|
|
2630
|
-
message.yMax = bounds.yMax;
|
|
2631
|
-
$poolBoundsObject(bounds);
|
|
2632
|
-
if (this._$isUpdated()) {
|
|
2633
|
-
message.textData = this._$getTextData();
|
|
2634
|
-
message.scrollV = this.scrollV;
|
|
2635
|
-
message.widthTable = this._$widthTable;
|
|
2636
|
-
message.heightTable = this._$heightTable;
|
|
2637
|
-
message.textHeightTable = this._$textHeightTable;
|
|
2638
|
-
message.objectTable = this._$objectTable;
|
|
2639
|
-
message.limitWidth = this.width;
|
|
2640
|
-
message.limitHeight = this.height;
|
|
2641
|
-
message.textHeight = this.textHeight;
|
|
2642
|
-
message.verticalAlign = this._$verticalAlign;
|
|
2643
|
-
message.autoSize = this._$autoSize;
|
|
2644
|
-
message.wordWrap = this._$wordWrap;
|
|
2645
|
-
message.border = this._$border;
|
|
2646
|
-
if (this._$border) {
|
|
2647
|
-
message.borderColor = this._$borderColor;
|
|
2648
|
-
}
|
|
2649
|
-
message.background = this._$background;
|
|
2650
|
-
if (this._$background) {
|
|
2651
|
-
message.backgroundColor = this._$backgroundColor;
|
|
2652
|
-
}
|
|
2653
|
-
message.thickness = this._$thickness;
|
|
2654
|
-
if (this._$thickness) {
|
|
2655
|
-
message.thicknessColor = this._$backgroundColor;
|
|
2656
|
-
}
|
|
2657
|
-
}
|
|
2658
|
-
$rendererWorker.postMessage(message);
|
|
2659
|
-
this._$posted = true;
|
|
2660
|
-
this._$updated = false;
|
|
2661
|
-
}
|
|
2662
|
-
}
|