@wcardinal/wcardinal-ui 0.440.0 → 0.442.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/types/wcardinal/ui/util/dynamic-atlas.d.ts +1 -0
- package/dist/wcardinal/ui/d-dynamic-text.js +3 -8
- package/dist/wcardinal/ui/d-dynamic-text.js.map +1 -1
- package/dist/wcardinal/ui/d-image-piece-layouter-part-container.js +1 -1
- package/dist/wcardinal/ui/d-image-piece-layouter-part-container.js.map +1 -1
- package/dist/wcardinal/ui/shape/e-shape-container.js +7 -0
- package/dist/wcardinal/ui/shape/e-shape-container.js.map +1 -1
- package/dist/wcardinal/ui/util/dynamic-atlas.js +9 -2
- package/dist/wcardinal/ui/util/dynamic-atlas.js.map +1 -1
- package/dist/wcardinal-ui-theme-dark-en-us.js +1 -1
- package/dist/wcardinal-ui-theme-dark-en-us.min.js +1 -1
- package/dist/wcardinal-ui-theme-dark-ja-jp.js +1 -1
- package/dist/wcardinal-ui-theme-dark-ja-jp.min.js +1 -1
- package/dist/wcardinal-ui-theme-dark.js +1 -1
- package/dist/wcardinal-ui-theme-dark.min.js +1 -1
- package/dist/wcardinal-ui-theme-white-en-us.js +1 -1
- package/dist/wcardinal-ui-theme-white-en-us.min.js +1 -1
- package/dist/wcardinal-ui-theme-white-ja-jp.js +1 -1
- package/dist/wcardinal-ui-theme-white-ja-jp.min.js +1 -1
- package/dist/wcardinal-ui-theme-white.js +1 -1
- package/dist/wcardinal-ui-theme-white.min.js +1 -1
- package/dist/wcardinal-ui.cjs.js +21 -12
- package/dist/wcardinal-ui.js +21 -12
- package/dist/wcardinal-ui.min.js +2 -2
- package/dist/wcardinal-ui.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -205,18 +205,13 @@ var DDynamicText = /** @class */ (function (_super) {
|
|
|
205
205
|
if (styleClipping || styleFitting || styleWordWrap) {
|
|
206
206
|
var parent_1 = this.parent;
|
|
207
207
|
if (parent_1 instanceof DBase) {
|
|
208
|
-
var
|
|
209
|
-
|
|
210
|
-
parent_1.padding.getRight() -
|
|
211
|
-
modifier.delta.width;
|
|
208
|
+
var padding = parent_1.padding;
|
|
209
|
+
var width = parent_1.width - padding.getLeft() - padding.getRight() - modifier.delta.width;
|
|
212
210
|
if (modifier.width !== width) {
|
|
213
211
|
modifier.width = width;
|
|
214
212
|
isChanged = true;
|
|
215
213
|
}
|
|
216
|
-
var height = parent_1.height -
|
|
217
|
-
parent_1.padding.getTop() -
|
|
218
|
-
parent_1.padding.getBottom() -
|
|
219
|
-
modifier.delta.height;
|
|
214
|
+
var height = parent_1.height - padding.getTop() - padding.getBottom() - modifier.delta.height;
|
|
220
215
|
if (modifier.height !== height) {
|
|
221
216
|
modifier.height = height;
|
|
222
217
|
isChanged = true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"d-dynamic-text.js","sourceRoot":"","sources":["../../../src/main/typescript/wcardinal/ui/d-dynamic-text.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAEH,OAAO,EAAE,IAAI,EAAE,YAAY,EAAY,OAAO,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAE7E,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAiB5C;IAAkC,gCAAI;IAcrC,sBAAY,KAAwB;QAApC,YACC,kBAAM,IAAI,oBAAoB,EAAE,EAAE,IAAI,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,SA0BlE;QAxBA,KAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE;YAClB,KAAI,CAAC,aAAa,EAAE,CA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G,KAAK,CAAC;QACpB,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAES,uCAAgB,GAA1B;QACC,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,IAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC/B,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC9E,CAAC;IAES,8BAAO,GAAjB,UAAkB,QAAmB;QACpC,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,iBAAM,OAAO,YAAC,QAAS,CAAC,CAAC;IAC1B,CAAC;IACF,mBAAC;AAAD,CAAC,AA1PD,CAAkC,IAAI,GA0PrC","sourcesContent":["/*\n * Copyright (C) 2019 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { Mesh, MeshMaterial, Renderer, Texture } from \"pixi.js\";\nimport { DApplications } from \"./d-applications\";\nimport { DBase } from \"./d-base\";\nimport { DDynamicTextGeometry } from \"./d-dynamic-text-geometry\";\nimport { DDynamicTextStyle } from \"./d-dynamic-text-style\";\nimport { DDynamicTextStyleWordWrap } from \"./d-dynamic-text-style-word-wrap\";\nimport { DynamicFontAtlas } from \"./util/dynamic-font-atlas\";\nimport { UtilFont } from \"./util/util-font\";\n\nexport interface DDynamicTextClippingDelta {\n\twidth: number;\n\theight: number;\n}\n\nexport interface DDynamicTextModifier {\n\tclipping: boolean;\n\tfitting: boolean;\n\twordWrap: DDynamicTextStyleWordWrap;\n\twidth: number;\n\theight: number;\n\tlineHeight: number;\n\tdelta: DDynamicTextClippingDelta;\n}\n\nexport class DDynamicText extends Mesh {\n\tprotected _style: DDynamicTextStyle;\n\tprotected _text: string;\n\tprotected _textApproved: string;\n\tprotected _isDirty: boolean;\n\tprotected _isGeometryDirty: boolean;\n\tprotected _atlas: DynamicFontAtlas | null;\n\tprotected _atlasRevisionUpdated: number;\n\tprotected _width: number;\n\tprotected _height: number;\n\tprotected _modifier: DDynamicTextModifier;\n\n\treadonly geometry!: DDynamicTextGeometry;\n\n\tconstructor(style: DDynamicTextStyle) {\n\t\tsuper(new DDynamicTextGeometry(), new MeshMaterial(Texture.EMPTY));\n\n\t\tthis._style = style;\n\t\tstyle.on(\"change\", () => {\n\t\t\tthis.onStyleChange();\n\t\t});\n\t\tthis._text = \"\";\n\t\tthis._textApproved = \"\";\n\t\tthis._isDirty = true;\n\t\tthis._isGeometryDirty = true;\n\t\tthis._atlas = null;\n\t\tthis._atlasRevisionUpdated = 0;\n\t\tthis._width = 0;\n\t\tthis._height = 0;\n\t\tthis._modifier = {\n\t\t\tclipping: false,\n\t\t\tfitting: false,\n\t\t\twordWrap: DDynamicTextStyleWordWrap.NONE,\n\t\t\twidth: 0,\n\t\t\theight: 0,\n\t\t\tlineHeight: 0,\n\t\t\tdelta: {\n\t\t\t\twidth: 0,\n\t\t\t\theight: 0\n\t\t\t}\n\t\t};\n\t}\n\n\tprotected onStyleChange(): void {\n\t\tthis._isDirty = true;\n\t\tthis._isGeometryDirty = true;\n\t\tthis._atlas = null;\n\t\tthis.update_();\n\t}\n\n\tprotected update_(): void {\n\t\tconst layer = DApplications.getLayer(this);\n\t\tif (layer) {\n\t\t\tif (this._isDirty) {\n\t\t\t\tthis._isDirty = false;\n\n\t\t\t\tconst text = this._text;\n\t\t\t\tconst textApproved = this._textApproved;\n\t\t\t\tthis._textApproved = text;\n\t\t\t\tconst style = this._style;\n\t\t\t\tconst fontId = style.fontId;\n\t\t\t\tconst fontIdApproved = style.fontIdApproved;\n\t\t\t\tconst fontIdFontSize = style.fontIdFontSize;\n\t\t\t\tconst fill = style.fill;\n\t\t\t\tconst fillApproved = style.fillApproved;\n\t\t\t\tstyle.approve();\n\n\t\t\t\tconst atlases = layer.getDynamicFontAtlases();\n\t\t\t\tif (text !== textApproved || fontId !== fontIdApproved || fill !== fillApproved) {\n\t\t\t\t\tatlases.add(fontId, fontIdFontSize, fill, text);\n\t\t\t\t\tatlases.remove(fontIdApproved, fillApproved, textApproved);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tget text(): string {\n\t\treturn this._text;\n\t}\n\n\tset text(text: string) {\n\t\tif (this._text !== text) {\n\t\t\tthis._text = text;\n\t\t\tif (!this._style.unfit()) {\n\t\t\t\tthis._isDirty = true;\n\t\t\t\tthis._isGeometryDirty = true;\n\t\t\t\tthis.update_();\n\t\t\t}\n\t\t}\n\t}\n\n\t// @ts-ignore\n\tget width(): number {\n\t\tthis.update();\n\t\treturn Math.abs(this.scale.x) * this.geometry.width;\n\t}\n\n\tset width(width: number) {\n\t\tthis.update();\n\t\tconst geometryWidth = this.geometry.width;\n\t\tif (+1e-4 < geometryWidth) {\n\t\t\tconst newScale = width / geometryWidth;\n\t\t\tthis.scale.x = 0 <= this.scale.x ? +newScale : -newScale;\n\t\t}\n\t}\n\n\t// @ts-ignore\n\tget height(): number {\n\t\tthis.update();\n\t\treturn Math.abs(this.scale.y) * this.geometry.height;\n\t}\n\n\tset height(height: number) {\n\t\tthis.update();\n\t\tconst geometryHeight = this.geometry.height;\n\t\tif (+1e-4 < geometryHeight) {\n\t\t\tconst newScale = height / geometryHeight;\n\t\t\tthis.scale.y = 0 <= this.scale.y ? +newScale : -newScale;\n\t\t}\n\t}\n\n\tget clipped(): boolean {\n\t\treturn this.geometry.clipped;\n\t}\n\n\tget style(): DDynamicTextStyle {\n\t\treturn this._style;\n\t}\n\n\tupdate(): void {\n\t\tthis.update_();\n\n\t\tconst style = this._style;\n\t\tlet atlas = this._atlas;\n\t\tif (atlas == null) {\n\t\t\tconst layer = DApplications.getLayer(this);\n\t\t\tif (layer) {\n\t\t\t\tatlas = layer.getDynamicFontAtlases().get(style.fontId, style.fill);\n\t\t\t\tif (atlas != null) {\n\t\t\t\t\tthis._atlasRevisionUpdated = atlas.getRevisionUpdate();\n\t\t\t\t\tthis._atlas = atlas;\n\t\t\t\t\tthis.texture = atlas.texture;\n\t\t\t\t\tthis._isGeometryDirty = true;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tconst revisionUpdate = atlas.getRevisionUpdate();\n\t\t\tif (revisionUpdate !== this._atlasRevisionUpdated) {\n\t\t\t\tthis._atlasRevisionUpdated = revisionUpdate;\n\t\t\t\tthis._isGeometryDirty = true;\n\t\t\t}\n\t\t}\n\n\t\tconst modifier = this._modifier;\n\t\tif (this.updateClipping(style, modifier)) {\n\t\t\tthis._isGeometryDirty = true;\n\t\t}\n\n\t\tif (this._isGeometryDirty) {\n\t\t\tthis._isGeometryDirty = false;\n\t\t\tconst geometry = this.geometry;\n\t\t\tgeometry.update(this._text, atlas, modifier);\n\n\t\t\tif (modifier.fitting && !style.isFontFitted && geometry.scaled) {\n\t\t\t\tconst oldScale = geometry.scale;\n\t\t\t\tconst oldFontSize = style.fontSize;\n\t\t\t\tconst newFontId = style.toFontId(Math.ceil(oldFontSize * oldScale * 1000) / 1000);\n\t\t\t\tconst newFontSize = UtilFont.toSize(newFontId);\n\t\t\t\tconst newScale = newFontSize / oldFontSize;\n\t\t\t\tconst newLineHeight = style.lineHeight * newScale;\n\t\t\t\tif (style.fit(newFontSize, newLineHeight)) {\n\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\tDApplications.update(this);\n\t\t\t\t\t}, 0);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected updateClipping(style: DDynamicTextStyle, modifier: DDynamicTextModifier): boolean {\n\t\tlet isChanged = false;\n\n\t\tconst styleClipping = style.clipping;\n\t\tif (modifier.clipping !== styleClipping) {\n\t\t\tmodifier.clipping = styleClipping;\n\t\t\tisChanged = true;\n\t\t}\n\n\t\tconst styleFitting = style.fitting;\n\t\tif (modifier.fitting !== styleFitting) {\n\t\t\tmodifier.fitting = styleFitting;\n\t\t\tisChanged = true;\n\t\t}\n\n\t\tconst styleWordWrap = style.wordWrap;\n\t\tif (modifier.wordWrap !== styleWordWrap) {\n\t\t\tmodifier.wordWrap = styleWordWrap;\n\t\t\tisChanged = true;\n\t\t}\n\n\t\tconst styleLineHeight = styleFitting ? style.lineHeightFitted : style.lineHeight;\n\t\tif (modifier.lineHeight !== styleLineHeight) {\n\t\t\tmodifier.lineHeight = styleLineHeight;\n\t\t\tisChanged = true;\n\t\t}\n\n\t\tif (styleClipping || styleFitting || styleWordWrap) {\n\t\t\tconst parent = this.parent;\n\t\t\tif (parent instanceof DBase) {\n\t\t\t\tconst width =\n\t\t\t\t\tparent.width -\n\t\t\t\t\tparent.padding.getLeft() -\n\t\t\t\t\tparent.padding.getRight() -\n\t\t\t\t\tmodifier.delta.width;\n\t\t\t\tif (modifier.width !== width) {\n\t\t\t\t\tmodifier.width = width;\n\t\t\t\t\tisChanged = true;\n\t\t\t\t}\n\n\t\t\t\tconst height =\n\t\t\t\t\tparent.height -\n\t\t\t\t\tparent.padding.getTop() -\n\t\t\t\t\tparent.padding.getBottom() -\n\t\t\t\t\tmodifier.delta.height;\n\t\t\t\tif (modifier.height !== height) {\n\t\t\t\t\tmodifier.height = height;\n\t\t\t\t\tisChanged = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn isChanged;\n\t}\n\n\tsetClippingDelta(width: number, height: number): void {\n\t\tconst delta = this._modifier.delta;\n\t\tdelta.width = width;\n\t\tdelta.height = height;\n\t}\n\n\tprotected _calculateBounds(): void {\n\t\tthis.update();\n\t\tconst geometry = this.geometry;\n\t\tthis._bounds.addFrame(this.transform, 0, 0, geometry.width, geometry.height);\n\t}\n\n\tprotected _render(renderer?: Renderer): void {\n\t\tthis.update();\n\t\tsuper._render(renderer!);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"d-dynamic-text.js","sourceRoot":"","sources":["../../../src/main/typescript/wcardinal/ui/d-dynamic-text.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAEH,OAAO,EAAE,IAAI,EAAE,YAAY,EAAY,OAAO,EA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BAC7B,QAAQ,CAAC,KAAK,GAAG,KAAK,CAAC;oBACvB,SAAS,GAAG,IAAI,CAAC;iBACjB;gBAED,IAAM,MAAM,GACX,QAAM,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,SAAS,EAAE,GAAG,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC;gBAChF,IAAI,QAAQ,CAAC,MAAM,KAAK,MAAM,EAAE;oBAC/B,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC;oBACzB,SAAS,GAAG,IAAI,CAAC;iBACjB;aACD;SACD;QAED,OAAO,SAAS,CAAC;IAClB,CAAC;IAED,uCAAgB,GAAhB,UAAiB,KAAa,EAAE,MAAc;QAC7C,IAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;QACnC,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC;QACpB,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAES,uCAAgB,GAA1B;QACC,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,IAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC/B,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC9E,CAAC;IAES,8BAAO,GAAjB,UAAkB,QAAmB;QACpC,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,iBAAM,OAAO,YAAC,QAAS,CAAC,CAAC;IAC1B,CAAC;IACF,mBAAC;AAAD,CAAC,AArPD,CAAkC,IAAI,GAqPrC","sourcesContent":["/*\n * Copyright (C) 2019 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { Mesh, MeshMaterial, Renderer, Texture } from \"pixi.js\";\nimport { DApplications } from \"./d-applications\";\nimport { DBase } from \"./d-base\";\nimport { DDynamicTextGeometry } from \"./d-dynamic-text-geometry\";\nimport { DDynamicTextStyle } from \"./d-dynamic-text-style\";\nimport { DDynamicTextStyleWordWrap } from \"./d-dynamic-text-style-word-wrap\";\nimport { DynamicFontAtlas } from \"./util/dynamic-font-atlas\";\nimport { UtilFont } from \"./util/util-font\";\n\nexport interface DDynamicTextClippingDelta {\n\twidth: number;\n\theight: number;\n}\n\nexport interface DDynamicTextModifier {\n\tclipping: boolean;\n\tfitting: boolean;\n\twordWrap: DDynamicTextStyleWordWrap;\n\twidth: number;\n\theight: number;\n\tlineHeight: number;\n\tdelta: DDynamicTextClippingDelta;\n}\n\nexport class DDynamicText extends Mesh {\n\tprotected _style: DDynamicTextStyle;\n\tprotected _text: string;\n\tprotected _textApproved: string;\n\tprotected _isDirty: boolean;\n\tprotected _isGeometryDirty: boolean;\n\tprotected _atlas: DynamicFontAtlas | null;\n\tprotected _atlasRevisionUpdated: number;\n\tprotected _width: number;\n\tprotected _height: number;\n\tprotected _modifier: DDynamicTextModifier;\n\n\treadonly geometry!: DDynamicTextGeometry;\n\n\tconstructor(style: DDynamicTextStyle) {\n\t\tsuper(new DDynamicTextGeometry(), new MeshMaterial(Texture.EMPTY));\n\n\t\tthis._style = style;\n\t\tstyle.on(\"change\", () => {\n\t\t\tthis.onStyleChange();\n\t\t});\n\t\tthis._text = \"\";\n\t\tthis._textApproved = \"\";\n\t\tthis._isDirty = true;\n\t\tthis._isGeometryDirty = true;\n\t\tthis._atlas = null;\n\t\tthis._atlasRevisionUpdated = 0;\n\t\tthis._width = 0;\n\t\tthis._height = 0;\n\t\tthis._modifier = {\n\t\t\tclipping: false,\n\t\t\tfitting: false,\n\t\t\twordWrap: DDynamicTextStyleWordWrap.NONE,\n\t\t\twidth: 0,\n\t\t\theight: 0,\n\t\t\tlineHeight: 0,\n\t\t\tdelta: {\n\t\t\t\twidth: 0,\n\t\t\t\theight: 0\n\t\t\t}\n\t\t};\n\t}\n\n\tprotected onStyleChange(): void {\n\t\tthis._isDirty = true;\n\t\tthis._isGeometryDirty = true;\n\t\tthis._atlas = null;\n\t\tthis.update_();\n\t}\n\n\tprotected update_(): void {\n\t\tconst layer = DApplications.getLayer(this);\n\t\tif (layer) {\n\t\t\tif (this._isDirty) {\n\t\t\t\tthis._isDirty = false;\n\n\t\t\t\tconst text = this._text;\n\t\t\t\tconst textApproved = this._textApproved;\n\t\t\t\tthis._textApproved = text;\n\t\t\t\tconst style = this._style;\n\t\t\t\tconst fontId = style.fontId;\n\t\t\t\tconst fontIdApproved = style.fontIdApproved;\n\t\t\t\tconst fontIdFontSize = style.fontIdFontSize;\n\t\t\t\tconst fill = style.fill;\n\t\t\t\tconst fillApproved = style.fillApproved;\n\t\t\t\tstyle.approve();\n\n\t\t\t\tconst atlases = layer.getDynamicFontAtlases();\n\t\t\t\tif (text !== textApproved || fontId !== fontIdApproved || fill !== fillApproved) {\n\t\t\t\t\tatlases.add(fontId, fontIdFontSize, fill, text);\n\t\t\t\t\tatlases.remove(fontIdApproved, fillApproved, textApproved);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tget text(): string {\n\t\treturn this._text;\n\t}\n\n\tset text(text: string) {\n\t\tif (this._text !== text) {\n\t\t\tthis._text = text;\n\t\t\tif (!this._style.unfit()) {\n\t\t\t\tthis._isDirty = true;\n\t\t\t\tthis._isGeometryDirty = true;\n\t\t\t\tthis.update_();\n\t\t\t}\n\t\t}\n\t}\n\n\t// @ts-ignore\n\tget width(): number {\n\t\tthis.update();\n\t\treturn Math.abs(this.scale.x) * this.geometry.width;\n\t}\n\n\tset width(width: number) {\n\t\tthis.update();\n\t\tconst geometryWidth = this.geometry.width;\n\t\tif (+1e-4 < geometryWidth) {\n\t\t\tconst newScale = width / geometryWidth;\n\t\t\tthis.scale.x = 0 <= this.scale.x ? +newScale : -newScale;\n\t\t}\n\t}\n\n\t// @ts-ignore\n\tget height(): number {\n\t\tthis.update();\n\t\treturn Math.abs(this.scale.y) * this.geometry.height;\n\t}\n\n\tset height(height: number) {\n\t\tthis.update();\n\t\tconst geometryHeight = this.geometry.height;\n\t\tif (+1e-4 < geometryHeight) {\n\t\t\tconst newScale = height / geometryHeight;\n\t\t\tthis.scale.y = 0 <= this.scale.y ? +newScale : -newScale;\n\t\t}\n\t}\n\n\tget clipped(): boolean {\n\t\treturn this.geometry.clipped;\n\t}\n\n\tget style(): DDynamicTextStyle {\n\t\treturn this._style;\n\t}\n\n\tupdate(): void {\n\t\tthis.update_();\n\n\t\tconst style = this._style;\n\t\tlet atlas = this._atlas;\n\t\tif (atlas == null) {\n\t\t\tconst layer = DApplications.getLayer(this);\n\t\t\tif (layer) {\n\t\t\t\tatlas = layer.getDynamicFontAtlases().get(style.fontId, style.fill);\n\t\t\t\tif (atlas != null) {\n\t\t\t\t\tthis._atlasRevisionUpdated = atlas.getRevisionUpdate();\n\t\t\t\t\tthis._atlas = atlas;\n\t\t\t\t\tthis.texture = atlas.texture;\n\t\t\t\t\tthis._isGeometryDirty = true;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tconst revisionUpdate = atlas.getRevisionUpdate();\n\t\t\tif (revisionUpdate !== this._atlasRevisionUpdated) {\n\t\t\t\tthis._atlasRevisionUpdated = revisionUpdate;\n\t\t\t\tthis._isGeometryDirty = true;\n\t\t\t}\n\t\t}\n\n\t\tconst modifier = this._modifier;\n\t\tif (this.updateClipping(style, modifier)) {\n\t\t\tthis._isGeometryDirty = true;\n\t\t}\n\n\t\tif (this._isGeometryDirty) {\n\t\t\tthis._isGeometryDirty = false;\n\t\t\tconst geometry = this.geometry;\n\t\t\tgeometry.update(this._text, atlas, modifier);\n\n\t\t\tif (modifier.fitting && !style.isFontFitted && geometry.scaled) {\n\t\t\t\tconst oldScale = geometry.scale;\n\t\t\t\tconst oldFontSize = style.fontSize;\n\t\t\t\tconst newFontId = style.toFontId(Math.ceil(oldFontSize * oldScale * 1000) / 1000);\n\t\t\t\tconst newFontSize = UtilFont.toSize(newFontId);\n\t\t\t\tconst newScale = newFontSize / oldFontSize;\n\t\t\t\tconst newLineHeight = style.lineHeight * newScale;\n\t\t\t\tif (style.fit(newFontSize, newLineHeight)) {\n\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\tDApplications.update(this);\n\t\t\t\t\t}, 0);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected updateClipping(style: DDynamicTextStyle, modifier: DDynamicTextModifier): boolean {\n\t\tlet isChanged = false;\n\n\t\tconst styleClipping = style.clipping;\n\t\tif (modifier.clipping !== styleClipping) {\n\t\t\tmodifier.clipping = styleClipping;\n\t\t\tisChanged = true;\n\t\t}\n\n\t\tconst styleFitting = style.fitting;\n\t\tif (modifier.fitting !== styleFitting) {\n\t\t\tmodifier.fitting = styleFitting;\n\t\t\tisChanged = true;\n\t\t}\n\n\t\tconst styleWordWrap = style.wordWrap;\n\t\tif (modifier.wordWrap !== styleWordWrap) {\n\t\t\tmodifier.wordWrap = styleWordWrap;\n\t\t\tisChanged = true;\n\t\t}\n\n\t\tconst styleLineHeight = styleFitting ? style.lineHeightFitted : style.lineHeight;\n\t\tif (modifier.lineHeight !== styleLineHeight) {\n\t\t\tmodifier.lineHeight = styleLineHeight;\n\t\t\tisChanged = true;\n\t\t}\n\n\t\tif (styleClipping || styleFitting || styleWordWrap) {\n\t\t\tconst parent = this.parent;\n\t\t\tif (parent instanceof DBase) {\n\t\t\t\tconst padding = parent.padding;\n\t\t\t\tconst width =\n\t\t\t\t\tparent.width - padding.getLeft() - padding.getRight() - modifier.delta.width;\n\t\t\t\tif (modifier.width !== width) {\n\t\t\t\t\tmodifier.width = width;\n\t\t\t\t\tisChanged = true;\n\t\t\t\t}\n\n\t\t\t\tconst height =\n\t\t\t\t\tparent.height - padding.getTop() - padding.getBottom() - modifier.delta.height;\n\t\t\t\tif (modifier.height !== height) {\n\t\t\t\t\tmodifier.height = height;\n\t\t\t\t\tisChanged = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn isChanged;\n\t}\n\n\tsetClippingDelta(width: number, height: number): void {\n\t\tconst delta = this._modifier.delta;\n\t\tdelta.width = width;\n\t\tdelta.height = height;\n\t}\n\n\tprotected _calculateBounds(): void {\n\t\tthis.update();\n\t\tconst geometry = this.geometry;\n\t\tthis._bounds.addFrame(this.transform, 0, 0, geometry.width, geometry.height);\n\t}\n\n\tprotected _render(renderer?: Renderer): void {\n\t\tthis.update();\n\t\tsuper._render(renderer!);\n\t}\n}\n"]}
|
|
@@ -128,6 +128,7 @@ var DImagePieceLayouterPartContainer = /** @class */ (function () {
|
|
|
128
128
|
var textWidth = 0;
|
|
129
129
|
var textHeight = 0;
|
|
130
130
|
if (text != null) {
|
|
131
|
+
text.setClippingDelta(leftSize + rightSize, topSize + bottomSize);
|
|
131
132
|
textWidth = text.width;
|
|
132
133
|
textHeight = text.height;
|
|
133
134
|
}
|
|
@@ -162,7 +163,6 @@ var DImagePieceLayouterPartContainer = /** @class */ (function () {
|
|
|
162
163
|
}
|
|
163
164
|
if (text != null) {
|
|
164
165
|
text.position.set(textX, textY);
|
|
165
|
-
text.setClippingDelta(leftSize + rightSize, topSize + bottomSize);
|
|
166
166
|
}
|
|
167
167
|
left.execute(textX - leftSize);
|
|
168
168
|
center.execute(0, 0, textX * 2 + textWidth);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"d-image-piece-layouter-part-container.js","sourceRoot":"","sources":["../../../src/main/typescript/wcardinal/ui/d-image-piece-layouter-part-container.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGpD,OAAO,EAAE,6BAA6B,EAAE,MAAM,sCAAsC,CAAC;AACrF,OAAO,EAAE,6BAA6B,EAAE,MAAM,sCAAsC,CAAC;AACrF,OAAO,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AACjF,OAAO,EAAE,6BAA6B,EAAE,MAAM,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,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,GAAG,CAAC,GAAG,SAAS,CAAC,CAAC;YAC5C,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK,GAAG,SAAS,GAAG,SAAS,CAAC,CAAC;YAChD,GAAG,CAAC,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,CAAC;YAC7B,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,GAAG,CAAC,GAAG,UAAU,CAAC,CAAC;YAC7C,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK,GAAG,UAAU,GAAG,UAAU,CAAC,CAAC;SACnD;aAAM;YACN,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YACpB,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;YACrC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;YAC7B,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAClB,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;YACtC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;SAChC;IACF,CAAC;IACF,uCAAC;AAAD,CAAC,AA3LD,IA2LC","sourcesContent":["import { DAlignHorizontal } from \"./d-align-horizontal\";\nimport { DAlignVertical } from \"./d-align-vertical\";\nimport { DDynamicText } from \"./d-dynamic-text\";\nimport { DImagePiece } from \"./d-image-piece\";\nimport { DImagePieceLayouterPartBottom } from \"./d-image-piece-layouter-part-bottom\";\nimport { DImagePieceLayouterPartCenter } from \"./d-image-piece-layouter-part-center\";\nimport { DImagePieceLayouterPartLeft } from \"./d-image-piece-layouter-part-left\";\nimport { DImagePieceLayouterPartMiddle } from \"./d-image-piece-layouter-part-middle\";\nimport { DImagePieceLayouterPartRight } from \"./d-image-piece-layouter-part-right\";\nimport { DImagePieceLayouterPartTop } from \"./d-image-piece-layouter-part-top\";\nimport { DTextPieceAlign } from \"./d-text-piece-align\";\n\nexport class DImagePieceLayouterPartContainer {\n\tleft: DImagePieceLayouterPartLeft;\n\tcenter: DImagePieceLayouterPartCenter;\n\tright: DImagePieceLayouterPartRight;\n\ttop: DImagePieceLayouterPartTop;\n\tmiddle: DImagePieceLayouterPartMiddle;\n\tbottom: DImagePieceLayouterPartBottom;\n\n\ttext?: DDynamicText | null;\n\n\tconstructor() {\n\t\tthis.left = new DImagePieceLayouterPartLeft();\n\t\tthis.center = new DImagePieceLayouterPartCenter();\n\t\tthis.right = new DImagePieceLayouterPartRight();\n\t\tthis.top = new DImagePieceLayouterPartTop();\n\t\tthis.middle = new DImagePieceLayouterPartMiddle();\n\t\tthis.bottom = new DImagePieceLayouterPartBottom();\n\t}\n\n\tclear(): void {\n\t\tthis.left.clear();\n\t\tthis.center.clear();\n\t\tthis.right.clear();\n\t\tthis.top.clear();\n\t\tthis.middle.clear();\n\t\tthis.bottom.clear();\n\t\tthis.text = undefined;\n\t}\n\n\tadd(image: DImagePiece): void {\n\t\tconst object = image.object;\n\t\tif (object != null) {\n\t\t\tconst bound = object.getLocalBounds();\n\t\t\tconst margin = image.margin;\n\t\t\tconst align = image.align;\n\t\t\tswitch (align.horizontal) {\n\t\t\t\tcase DAlignHorizontal.LEFT:\n\t\t\t\t\tthis.left.add(image, bound, margin.horizontal);\n\t\t\t\t\tbreak;\n\t\t\t\tcase DAlignHorizontal.CENTER:\n\t\t\t\t\tthis.center.add(image, bound, margin.horizontal);\n\t\t\t\t\tbreak;\n\t\t\t\tcase DAlignHorizontal.RIGHT:\n\t\t\t\t\tthis.right.add(image, bound, margin.horizontal);\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\tswitch (align.vertical) {\n\t\t\t\tcase DAlignVertical.TOP:\n\t\t\t\t\tthis.top.add(image, bound, margin.vertical);\n\t\t\t\t\tbreak;\n\t\t\t\tcase DAlignVertical.MIDDLE:\n\t\t\t\t\tthis.middle.add(image, bound, margin.vertical);\n\t\t\t\t\tbreak;\n\t\t\t\tcase DAlignVertical.BOTTOM:\n\t\t\t\t\tthis.bottom.add(image, bound, margin.vertical);\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tset(text: DDynamicText | null): void {\n\t\tthis.left.set(text);\n\t\tthis.center.set(text);\n\t\tthis.right.set(text);\n\t\tthis.top.set(text);\n\t\tthis.middle.set(text);\n\t\tthis.bottom.set(text);\n\t\tthis.text = text;\n\t}\n\n\tget width(): number {\n\t\tconst text = this.text;\n\t\tconst left = this.left;\n\t\tconst leftSize = left.size;\n\t\tconst center = this.center;\n\t\tconst centerSize = center.size;\n\t\tconst right = this.right;\n\t\tconst rightSize = right.size;\n\t\tif (text !== undefined) {\n\t\t\tif (text !== null) {\n\t\t\t\treturn Math.max(leftSize + text.width + rightSize, centerSize);\n\t\t\t} else {\n\t\t\t\treturn Math.max(leftSize + rightSize, centerSize);\n\t\t\t}\n\t\t} else {\n\t\t\treturn Math.max(leftSize, rightSize, centerSize);\n\t\t}\n\t}\n\n\tget height(): number {\n\t\tconst text = this.text;\n\t\tconst top = this.top;\n\t\tconst topSize = top.size;\n\t\tconst middle = this.middle;\n\t\tconst middleSize = middle.size;\n\t\tconst bottom = this.bottom;\n\t\tconst bottomSize = bottom.size;\n\t\tif (text !== undefined) {\n\t\t\tif (text !== null) {\n\t\t\t\treturn Math.max(topSize + text.height + bottomSize, middleSize);\n\t\t\t} else {\n\t\t\t\treturn Math.max(topSize + bottomSize, middleSize);\n\t\t\t}\n\t\t} else {\n\t\t\treturn Math.max(topSize, bottomSize, middleSize);\n\t\t}\n\t}\n\n\texecute(\n\t\tpleft: number,\n\t\tptop: number,\n\t\tpright: number,\n\t\tpbottom: number,\n\t\ttextAlign: DTextPieceAlign,\n\t\twidth: number,\n\t\theight: number\n\t): void {\n\t\tconst left = this.left;\n\t\tconst center = this.center;\n\t\tconst right = this.right;\n\t\tconst top = this.top;\n\t\tconst middle = this.middle;\n\t\tconst bottom = this.bottom;\n\n\t\tconst text = this.text;\n\t\tif (text !== undefined) {\n\t\t\tconst leftSize = left.size;\n\t\t\tconst rightSize = right.size;\n\t\t\tconst topSize = top.size;\n\t\t\tconst bottomSize = bottom.size;\n\n\t\t\tlet textX = 0;\n\t\t\tlet textWidth = 0;\n\t\t\tlet textHeight = 0;\n\t\t\tif (text != null) {\n\t\t\t\ttextWidth = text.width;\n\t\t\t\ttextHeight = text.height;\n\t\t\t}\n\t\t\tswitch (textAlign.horizontal) {\n\t\t\t\tcase DAlignHorizontal.LEFT:\n\t\t\t\t\ttextX = pleft + leftSize;\n\t\t\t\t\tbreak;\n\t\t\t\tcase DAlignHorizontal.CENTER:\n\t\t\t\t\ttextX =\n\t\t\t\t\t\tpleft +\n\t\t\t\t\t\t(width - pleft - pright - (leftSize + textWidth + rightSize)) * 0.5 +\n\t\t\t\t\t\tleftSize;\n\t\t\t\t\tbreak;\n\t\t\t\tcase DAlignHorizontal.RIGHT:\n\t\t\t\t\ttextX = width - pright - rightSize - textWidth;\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tlet textY = 0;\n\t\t\tswitch (textAlign.vertical) {\n\t\t\t\tcase DAlignVertical.TOP:\n\t\t\t\t\ttextY = ptop + topSize;\n\t\t\t\t\tbreak;\n\t\t\t\tcase DAlignVertical.MIDDLE:\n\t\t\t\t\ttextY =\n\t\t\t\t\t\tptop +\n\t\t\t\t\t\t(height - ptop - pbottom - (topSize + textHeight + bottomSize)) * 0.5 +\n\t\t\t\t\t\ttopSize;\n\t\t\t\t\tbreak;\n\t\t\t\tcase DAlignVertical.BOTTOM:\n\t\t\t\t\ttextY = height - pbottom - bottomSize - textHeight;\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (text != null) {\n\t\t\t\ttext.position.set(textX, textY);\n\t\t\t\ttext.setClippingDelta(leftSize + rightSize, topSize + bottomSize);\n\t\t\t}\n\t\t\tleft.execute(textX - leftSize);\n\t\t\tcenter.execute(0, 0, textX * 2 + textWidth);\n\t\t\tright.execute(0, textX + textWidth + rightSize);\n\t\t\ttop.execute(textY - topSize);\n\t\t\tmiddle.execute(0, 0, textY * 2 + textHeight);\n\t\t\tbottom.execute(0, textY + textHeight + bottomSize);\n\t\t} else {\n\t\t\tleft.execute(pleft);\n\t\t\tcenter.execute(pleft, pright, width);\n\t\t\tright.execute(pright, width);\n\t\t\ttop.execute(ptop);\n\t\t\tmiddle.execute(ptop, pbottom, height);\n\t\t\tbottom.execute(pbottom, height);\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"d-image-piece-layouter-part-container.js","sourceRoot":"","sources":["../../../src/main/typescript/wcardinal/ui/d-image-piece-layouter-part-container.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGpD,OAAO,EAAE,6BAA6B,EAAE,MAAM,sCAAsC,CAAC;AACrF,OAAO,EAAE,6BAA6B,EAAE,MAAM,sCAAsC,CAAC;AACrF,OAAO,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AACjF,OAAO,EAAE,6BAA6B,EAAE,MAAM,sCAAsC,CAAC;AACrF,OAAO,EAAE,4BAA4B,EAAE,MAAM,qCAAqC,CAAC;AACnF,OAAO,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;AAG/E;IAUC;QACC,IAAI,CAAC,IAAI,GAAG,IAAI,2BAA2B,EAAE,CAAC;QAC9C,IAAI,CAAC,MAAM,GAAG,IAAI,6BAA6B,EAAE,CAAC;QAClD,IAAI,CAAC,KAAK,GAAG,IAAI,4BAA4B,EAAE,CAAC;QAChD,IAAI,CAAC,GAAG,GAAG,IAAI,0BAA0B,EAAE,CAAC;QAC5C,IAAI,CAAC,MAAM,GAAG,IAAI,6BAA6B,EAAE,CAAC;QAClD,IAAI,CAAC,M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CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YACpB,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;YACrC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;YAC7B,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAClB,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;YACtC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;SAChC;IACF,CAAC;IACF,uCAAC;AAAD,CAAC,AA3LD,IA2LC","sourcesContent":["import { DAlignHorizontal } from \"./d-align-horizontal\";\nimport { DAlignVertical } from \"./d-align-vertical\";\nimport { DDynamicText } from \"./d-dynamic-text\";\nimport { DImagePiece } from \"./d-image-piece\";\nimport { DImagePieceLayouterPartBottom } from \"./d-image-piece-layouter-part-bottom\";\nimport { DImagePieceLayouterPartCenter } from \"./d-image-piece-layouter-part-center\";\nimport { DImagePieceLayouterPartLeft } from \"./d-image-piece-layouter-part-left\";\nimport { DImagePieceLayouterPartMiddle } from \"./d-image-piece-layouter-part-middle\";\nimport { DImagePieceLayouterPartRight } from \"./d-image-piece-layouter-part-right\";\nimport { DImagePieceLayouterPartTop } from \"./d-image-piece-layouter-part-top\";\nimport { DTextPieceAlign } from \"./d-text-piece-align\";\n\nexport class DImagePieceLayouterPartContainer {\n\tleft: DImagePieceLayouterPartLeft;\n\tcenter: DImagePieceLayouterPartCenter;\n\tright: DImagePieceLayouterPartRight;\n\ttop: DImagePieceLayouterPartTop;\n\tmiddle: DImagePieceLayouterPartMiddle;\n\tbottom: DImagePieceLayouterPartBottom;\n\n\ttext?: DDynamicText | null;\n\n\tconstructor() {\n\t\tthis.left = new DImagePieceLayouterPartLeft();\n\t\tthis.center = new DImagePieceLayouterPartCenter();\n\t\tthis.right = new DImagePieceLayouterPartRight();\n\t\tthis.top = new DImagePieceLayouterPartTop();\n\t\tthis.middle = new DImagePieceLayouterPartMiddle();\n\t\tthis.bottom = new DImagePieceLayouterPartBottom();\n\t}\n\n\tclear(): void {\n\t\tthis.left.clear();\n\t\tthis.center.clear();\n\t\tthis.right.clear();\n\t\tthis.top.clear();\n\t\tthis.middle.clear();\n\t\tthis.bottom.clear();\n\t\tthis.text = undefined;\n\t}\n\n\tadd(image: DImagePiece): void {\n\t\tconst object = image.object;\n\t\tif (object != null) {\n\t\t\tconst bound = object.getLocalBounds();\n\t\t\tconst margin = image.margin;\n\t\t\tconst align = image.align;\n\t\t\tswitch (align.horizontal) {\n\t\t\t\tcase DAlignHorizontal.LEFT:\n\t\t\t\t\tthis.left.add(image, bound, margin.horizontal);\n\t\t\t\t\tbreak;\n\t\t\t\tcase DAlignHorizontal.CENTER:\n\t\t\t\t\tthis.center.add(image, bound, margin.horizontal);\n\t\t\t\t\tbreak;\n\t\t\t\tcase DAlignHorizontal.RIGHT:\n\t\t\t\t\tthis.right.add(image, bound, margin.horizontal);\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\tswitch (align.vertical) {\n\t\t\t\tcase DAlignVertical.TOP:\n\t\t\t\t\tthis.top.add(image, bound, margin.vertical);\n\t\t\t\t\tbreak;\n\t\t\t\tcase DAlignVertical.MIDDLE:\n\t\t\t\t\tthis.middle.add(image, bound, margin.vertical);\n\t\t\t\t\tbreak;\n\t\t\t\tcase DAlignVertical.BOTTOM:\n\t\t\t\t\tthis.bottom.add(image, bound, margin.vertical);\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tset(text: DDynamicText | null): void {\n\t\tthis.left.set(text);\n\t\tthis.center.set(text);\n\t\tthis.right.set(text);\n\t\tthis.top.set(text);\n\t\tthis.middle.set(text);\n\t\tthis.bottom.set(text);\n\t\tthis.text = text;\n\t}\n\n\tget width(): number {\n\t\tconst text = this.text;\n\t\tconst left = this.left;\n\t\tconst leftSize = left.size;\n\t\tconst center = this.center;\n\t\tconst centerSize = center.size;\n\t\tconst right = this.right;\n\t\tconst rightSize = right.size;\n\t\tif (text !== undefined) {\n\t\t\tif (text !== null) {\n\t\t\t\treturn Math.max(leftSize + text.width + rightSize, centerSize);\n\t\t\t} else {\n\t\t\t\treturn Math.max(leftSize + rightSize, centerSize);\n\t\t\t}\n\t\t} else {\n\t\t\treturn Math.max(leftSize, rightSize, centerSize);\n\t\t}\n\t}\n\n\tget height(): number {\n\t\tconst text = this.text;\n\t\tconst top = this.top;\n\t\tconst topSize = top.size;\n\t\tconst middle = this.middle;\n\t\tconst middleSize = middle.size;\n\t\tconst bottom = this.bottom;\n\t\tconst bottomSize = bottom.size;\n\t\tif (text !== undefined) {\n\t\t\tif (text !== null) {\n\t\t\t\treturn Math.max(topSize + text.height + bottomSize, middleSize);\n\t\t\t} else {\n\t\t\t\treturn Math.max(topSize + bottomSize, middleSize);\n\t\t\t}\n\t\t} else {\n\t\t\treturn Math.max(topSize, bottomSize, middleSize);\n\t\t}\n\t}\n\n\texecute(\n\t\tpleft: number,\n\t\tptop: number,\n\t\tpright: number,\n\t\tpbottom: number,\n\t\ttextAlign: DTextPieceAlign,\n\t\twidth: number,\n\t\theight: number\n\t): void {\n\t\tconst left = this.left;\n\t\tconst center = this.center;\n\t\tconst right = this.right;\n\t\tconst top = this.top;\n\t\tconst middle = this.middle;\n\t\tconst bottom = this.bottom;\n\n\t\tconst text = this.text;\n\t\tif (text !== undefined) {\n\t\t\tconst leftSize = left.size;\n\t\t\tconst rightSize = right.size;\n\t\t\tconst topSize = top.size;\n\t\t\tconst bottomSize = bottom.size;\n\n\t\t\tlet textX = 0;\n\t\t\tlet textWidth = 0;\n\t\t\tlet textHeight = 0;\n\t\t\tif (text != null) {\n\t\t\t\ttext.setClippingDelta(leftSize + rightSize, topSize + bottomSize);\n\t\t\t\ttextWidth = text.width;\n\t\t\t\ttextHeight = text.height;\n\t\t\t}\n\t\t\tswitch (textAlign.horizontal) {\n\t\t\t\tcase DAlignHorizontal.LEFT:\n\t\t\t\t\ttextX = pleft + leftSize;\n\t\t\t\t\tbreak;\n\t\t\t\tcase DAlignHorizontal.CENTER:\n\t\t\t\t\ttextX =\n\t\t\t\t\t\tpleft +\n\t\t\t\t\t\t(width - pleft - pright - (leftSize + textWidth + rightSize)) * 0.5 +\n\t\t\t\t\t\tleftSize;\n\t\t\t\t\tbreak;\n\t\t\t\tcase DAlignHorizontal.RIGHT:\n\t\t\t\t\ttextX = width - pright - rightSize - textWidth;\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tlet textY = 0;\n\t\t\tswitch (textAlign.vertical) {\n\t\t\t\tcase DAlignVertical.TOP:\n\t\t\t\t\ttextY = ptop + topSize;\n\t\t\t\t\tbreak;\n\t\t\t\tcase DAlignVertical.MIDDLE:\n\t\t\t\t\ttextY =\n\t\t\t\t\t\tptop +\n\t\t\t\t\t\t(height - ptop - pbottom - (topSize + textHeight + bottomSize)) * 0.5 +\n\t\t\t\t\t\ttopSize;\n\t\t\t\t\tbreak;\n\t\t\t\tcase DAlignVertical.BOTTOM:\n\t\t\t\t\ttextY = height - pbottom - bottomSize - textHeight;\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (text != null) {\n\t\t\t\ttext.position.set(textX, textY);\n\t\t\t}\n\t\t\tleft.execute(textX - leftSize);\n\t\t\tcenter.execute(0, 0, textX * 2 + textWidth);\n\t\t\tright.execute(0, textX + textWidth + rightSize);\n\t\t\ttop.execute(textY - topSize);\n\t\t\tmiddle.execute(0, 0, textY * 2 + textHeight);\n\t\t\tbottom.execute(0, textY + textHeight + bottomSize);\n\t\t} else {\n\t\t\tleft.execute(pleft);\n\t\t\tcenter.execute(pleft, pright, width);\n\t\t\tright.execute(pright, width);\n\t\t\ttop.execute(ptop);\n\t\t\tmiddle.execute(ptop, pbottom, height);\n\t\t\tbottom.execute(pbottom, height);\n\t\t}\n\t}\n}\n"]}
|
|
@@ -159,6 +159,13 @@ var EShapeContainer = /** @class */ (function (_super) {
|
|
|
159
159
|
children[i].destroy();
|
|
160
160
|
}
|
|
161
161
|
children.length = 0;
|
|
162
|
+
// Atlas
|
|
163
|
+
var atlas = this._atlas;
|
|
164
|
+
if (atlas != null) {
|
|
165
|
+
atlas.destroy();
|
|
166
|
+
}
|
|
167
|
+
// Font Atlas
|
|
168
|
+
this._fontAtlases.destroy();
|
|
162
169
|
//
|
|
163
170
|
_super.prototype.destroy.call(this);
|
|
164
171
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"e-shape-container.js","sourceRoot":"","sources":["../../../../src/main/typescript/wcardinal/ui/shape/e-shape-container.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAEH,OAAO,EAAE,aAAa,EAAU,KAAK,EAAY,MAAM,SAAS,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAGzE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD;IAAqC,mCAAa;IAoBjD;QAAA,YACC,iBAAO,SAkBP;QAtCS,oBAAc,GAA0B,IAAI,CAAC;QAsBtD,KAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;QACnB,KAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,KAAI,CAAC,WAAW,GAAG,CAAC,CAAC;QACrB,KAAI,CAAC,mBAAmB,GAAG,CAAC,CAAC,CAAC;QAE9B,KAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,KAAI,CAAC,YAAY,GAAG,IAAI,qBAAqB,EAAE,CAAC;QAEhD,KAAI,CAAC,WAAW,GAAG,CAAC,CAAC;QACrB,KAAI,CAAC,aAAa,GAAG,CAAC,CAAC,CAAC,CAAC,2CAA2C;QACpE,KAAI,CAAC,WAAW,GAAG,CAAC,CAAC;QACrB,KAAI,CAAC,aAAa,GAAG,CAAC,CAAC,CAAC,CAAC,6CAA6C;QAEtE,KAAI,CAAC,KAAK,G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AAC,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE;YAC9C,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SACtB;QACD,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;QAEpB,EAAE;QACF,iBAAM,OAAO,WAAE,CAAC;IACjB,CAAC;IACF,sBAAC;AAAD,CAAC,AAvMD,CAAqC,aAAa,GAuMjD","sourcesContent":["/*\n * Copyright (C) 2019 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { DisplayObject, IPoint, Point, Renderer } from \"pixi.js\";\nimport { DynamicAtlas } from \"../util/dynamic-atlas\";\nimport { DynamicSDFFontAtlases } from \"../util/dynamic-sdf-font-atlases\";\nimport { EShape } from \"./e-shape\";\nimport { EShapeBuffer } from \"./e-shape-buffer\";\nimport { EShapeRenderer } from \"./e-shape-renderer\";\n\nexport class EShapeContainer extends DisplayObject {\n\tprotected _shapeRenderer: EShapeRenderer | null = null;\n\n\treadonly children: EShape[];\n\tprotected _shape: EShape | null;\n\tprotected _childrenId: number;\n\tprotected _childrenIdRendered: number;\n\n\tprotected _atlas: DynamicAtlas | null;\n\tprotected _fontAtlases: DynamicSDFFontAtlases;\n\n\tprotected _pixelScale: number;\n\tprotected _pixelScaleId: number;\n\tprotected _shapeScale: number;\n\tprotected _shapeScaleId: number;\n\n\tprotected _work: Point;\n\n\tprotected _buffers: EShapeBuffer[];\n\n\tconstructor() {\n\t\tsuper();\n\n\t\tthis.children = [];\n\t\tthis._shape = null;\n\t\tthis._childrenId = 0;\n\t\tthis._childrenIdRendered = -1;\n\n\t\tthis._atlas = null;\n\t\tthis._fontAtlases = new DynamicSDFFontAtlases();\n\n\t\tthis._pixelScale = 1;\n\t\tthis._pixelScaleId = -2; // Since this._shapeScaleId starts from -1.\n\t\tthis._shapeScale = 1;\n\t\tthis._shapeScaleId = -1; // Since Transform._worldID starts from zero.\n\n\t\tthis._work = new Point();\n\n\t\tthis._buffers = [];\n\t}\n\n\tcalculateBounds(): void {\n\t\tthis._bounds.clear();\n\t}\n\n\tonChildTransformChange(): void {\n\t\t// DO NOTHING\n\t}\n\n\ttoDirty(): number {\n\t\treturn (this._childrenId += 1);\n\t}\n\n\tisDirty(): boolean {\n\t\treturn this._childrenIdRendered < this._childrenId;\n\t}\n\n\trender(renderer: Renderer): void {\n\t\tif (!this.visible || this.worldAlpha <= 0 || !this.renderable) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst childrenId = this._childrenId;\n\t\tconst childrenIdRendered = this._childrenIdRendered;\n\t\tthis._childrenIdRendered = childrenId;\n\t\tconst isChildrenDirty = childrenIdRendered < childrenId;\n\n\t\tlet shapeRenderer: EShapeRenderer | null = this._shapeRenderer;\n\t\tif (shapeRenderer == null) {\n\t\t\tshapeRenderer = this._shapeRenderer = new EShapeRenderer(renderer);\n\t\t}\n\t\trenderer.batch.setObjectRenderer(shapeRenderer);\n\n\t\tconst mask = this.mask;\n\t\tconst shape = this._shape;\n\t\tconst shapes = this.children;\n\t\tif (mask) {\n\t\t\trenderer.mask.push(this, mask);\n\t\t\tshapeRenderer.render_(this, shape, shapes, isChildrenDirty);\n\t\t\trenderer.mask.pop(this);\n\t\t} else {\n\t\t\tshapeRenderer.render_(this, shape, shapes, isChildrenDirty);\n\t\t}\n\t}\n\n\tcontainsPoint(point: Point): boolean {\n\t\treturn false;\n\t}\n\n\tgetFontAtlases(): DynamicSDFFontAtlases {\n\t\treturn this._fontAtlases;\n\t}\n\n\tgetAtlas(resolution: number): DynamicAtlas {\n\t\tlet atlas = this._atlas;\n\t\tif (atlas == null) {\n\t\t\tatlas = new DynamicAtlas(resolution);\n\t\t\tthis._atlas = atlas;\n\t\t}\n\t\treturn atlas;\n\t}\n\n\tgetBuffers(): EShapeBuffer[] {\n\t\treturn this._buffers;\n\t}\n\n\ttoShapeScale(): number {\n\t\tthis.updateTransform();\n\t\tconst transform = this.transform;\n\t\tconst worldID = (transform as any)._worldID;\n\t\tif (worldID !== this._shapeScaleId) {\n\t\t\tthis._shapeScaleId = worldID;\n\t\t\tconst worldTransform = transform.worldTransform;\n\t\t\tconst a = worldTransform.a;\n\t\t\tconst b = worldTransform.b;\n\t\t\tthis._shapeScale = 1 / Math.sqrt(a * a + b * b);\n\t\t}\n\t\treturn this._shapeScale;\n\t}\n\n\tgetShapeScale(): number {\n\t\treturn this._shapeScale;\n\t}\n\n\ttoPixelScale(resolution: number): number {\n\t\tconst shapeScale = this.toShapeScale();\n\t\tconst shapeScaleId = this._shapeScaleId;\n\t\tif (this._pixelScaleId !== shapeScaleId) {\n\t\t\tthis._pixelScaleId = shapeScaleId;\n\t\t\tthis._pixelScale = (1 / resolution) * shapeScale;\n\t\t}\n\t\treturn this._pixelScale;\n\t}\n\n\tgetPixelScale(): number {\n\t\treturn this._pixelScale;\n\t}\n\n\ttoAntialiasWeight(resolution: number): number {\n\t\treturn 1.25 / resolution;\n\t}\n\n\thitTest(global: IPoint, onHit?: (shape: EShape) => boolean): EShape | null {\n\t\tconst local = this._work;\n\t\tconst children = this.children;\n\t\tfor (let i = children.length - 1; 0 <= i; --i) {\n\t\t\tconst child = children[i];\n\t\t\tif (child.visible) {\n\t\t\t\tchild.toLocal(global, undefined, local);\n\t\t\t\tconst result = child.contains(local.x, local.y);\n\t\t\t\tif (result != null) {\n\t\t\t\t\tif (onHit == null || onHit(result)) {\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\thitTestBBox(global: IPoint, onHit?: (shape: EShape) => boolean): EShape | null {\n\t\tconst local = this._work;\n\t\tconst children = this.children;\n\t\tfor (let i = children.length - 1; 0 <= i; --i) {\n\t\t\tconst child = children[i];\n\t\t\tif (child.visible) {\n\t\t\t\tchild.toLocal(global, undefined, local);\n\t\t\t\tif (child.containsBBox(local.x, local.y)) {\n\t\t\t\t\tif (onHit == null || onHit(child)) {\n\t\t\t\t\t\treturn child;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tdestroy(): void {\n\t\t// Buffer\n\t\tconst buffers = this._buffers;\n\t\tif (buffers != null) {\n\t\t\tfor (let i = 0, imax = buffers.length; i < imax; ++i) {\n\t\t\t\tbuffers[i].destroy();\n\t\t\t}\n\t\t}\n\t\tthis._buffers.length = 0;\n\n\t\t// Shapes\n\t\tconst children = this.children;\n\t\tfor (let i = children.length - 1; 0 <= i; --i) {\n\t\t\tchildren[i].destroy();\n\t\t}\n\t\tchildren.length = 0;\n\n\t\t//\n\t\tsuper.destroy();\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"e-shape-container.js","sourceRoot":"","sources":["../../../../src/main/typescript/wcardinal/ui/shape/e-shape-container.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAEH,OAAO,EAAE,aAAa,EAAU,KAAK,EAAY,MAAM,SAAS,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAGzE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD;IAAqC,mCAAa;IAoBjD;QAAA,YACC,iBAAO,SAkBP;QAtCS,oBAAc,GAA0B,IAAI,CAAC;QAsBtD,KAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;QACnB,KAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,KAAI,CAAC,WAAW,GAAG,CAAC,CAAC;QACrB,KAAI,CAAC,mBAAmB,GAAG,CAAC,CAAC,CAAC;QAE9B,KAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,KAAI,CAAC,YAAY,GAAG,IAAI,qBAAqB,EAAE,CAAC;QAEhD,KAAI,CAAC,WAAW,GAAG,CAAC,CAAC;QACrB,KAAI,CAAC,aAAa,GAAG,CAAC,CAAC,CAAC,CAAC,2CAA2C;QACpE,KAAI,CAAC,WAAW,GAAG,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GAAG,IAAI,CAAC,QAAQ,CAAC;QAC/B,KAAK,IAAI,CAAC,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE;YAC9C,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SACtB;QACD,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;QAEpB,QAAQ;QACR,IAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,KAAK,IAAI,IAAI,EAAE;YAClB,KAAK,CAAC,OAAO,EAAE,CAAC;SAChB;QAED,aAAa;QACb,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;QAE5B,EAAE;QACF,iBAAM,OAAO,WAAE,CAAC;IACjB,CAAC;IACF,sBAAC;AAAD,CAAC,AAhND,CAAqC,aAAa,GAgNjD","sourcesContent":["/*\n * Copyright (C) 2019 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { DisplayObject, IPoint, Point, Renderer } from \"pixi.js\";\nimport { DynamicAtlas } from \"../util/dynamic-atlas\";\nimport { DynamicSDFFontAtlases } from \"../util/dynamic-sdf-font-atlases\";\nimport { EShape } from \"./e-shape\";\nimport { EShapeBuffer } from \"./e-shape-buffer\";\nimport { EShapeRenderer } from \"./e-shape-renderer\";\n\nexport class EShapeContainer extends DisplayObject {\n\tprotected _shapeRenderer: EShapeRenderer | null = null;\n\n\treadonly children: EShape[];\n\tprotected _shape: EShape | null;\n\tprotected _childrenId: number;\n\tprotected _childrenIdRendered: number;\n\n\tprotected _atlas: DynamicAtlas | null;\n\tprotected _fontAtlases: DynamicSDFFontAtlases;\n\n\tprotected _pixelScale: number;\n\tprotected _pixelScaleId: number;\n\tprotected _shapeScale: number;\n\tprotected _shapeScaleId: number;\n\n\tprotected _work: Point;\n\n\tprotected _buffers: EShapeBuffer[];\n\n\tconstructor() {\n\t\tsuper();\n\n\t\tthis.children = [];\n\t\tthis._shape = null;\n\t\tthis._childrenId = 0;\n\t\tthis._childrenIdRendered = -1;\n\n\t\tthis._atlas = null;\n\t\tthis._fontAtlases = new DynamicSDFFontAtlases();\n\n\t\tthis._pixelScale = 1;\n\t\tthis._pixelScaleId = -2; // Since this._shapeScaleId starts from -1.\n\t\tthis._shapeScale = 1;\n\t\tthis._shapeScaleId = -1; // Since Transform._worldID starts from zero.\n\n\t\tthis._work = new Point();\n\n\t\tthis._buffers = [];\n\t}\n\n\tcalculateBounds(): void {\n\t\tthis._bounds.clear();\n\t}\n\n\tonChildTransformChange(): void {\n\t\t// DO NOTHING\n\t}\n\n\ttoDirty(): number {\n\t\treturn (this._childrenId += 1);\n\t}\n\n\tisDirty(): boolean {\n\t\treturn this._childrenIdRendered < this._childrenId;\n\t}\n\n\trender(renderer: Renderer): void {\n\t\tif (!this.visible || this.worldAlpha <= 0 || !this.renderable) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst childrenId = this._childrenId;\n\t\tconst childrenIdRendered = this._childrenIdRendered;\n\t\tthis._childrenIdRendered = childrenId;\n\t\tconst isChildrenDirty = childrenIdRendered < childrenId;\n\n\t\tlet shapeRenderer: EShapeRenderer | null = this._shapeRenderer;\n\t\tif (shapeRenderer == null) {\n\t\t\tshapeRenderer = this._shapeRenderer = new EShapeRenderer(renderer);\n\t\t}\n\t\trenderer.batch.setObjectRenderer(shapeRenderer);\n\n\t\tconst mask = this.mask;\n\t\tconst shape = this._shape;\n\t\tconst shapes = this.children;\n\t\tif (mask) {\n\t\t\trenderer.mask.push(this, mask);\n\t\t\tshapeRenderer.render_(this, shape, shapes, isChildrenDirty);\n\t\t\trenderer.mask.pop(this);\n\t\t} else {\n\t\t\tshapeRenderer.render_(this, shape, shapes, isChildrenDirty);\n\t\t}\n\t}\n\n\tcontainsPoint(point: Point): boolean {\n\t\treturn false;\n\t}\n\n\tgetFontAtlases(): DynamicSDFFontAtlases {\n\t\treturn this._fontAtlases;\n\t}\n\n\tgetAtlas(resolution: number): DynamicAtlas {\n\t\tlet atlas = this._atlas;\n\t\tif (atlas == null) {\n\t\t\tatlas = new DynamicAtlas(resolution);\n\t\t\tthis._atlas = atlas;\n\t\t}\n\t\treturn atlas;\n\t}\n\n\tgetBuffers(): EShapeBuffer[] {\n\t\treturn this._buffers;\n\t}\n\n\ttoShapeScale(): number {\n\t\tthis.updateTransform();\n\t\tconst transform = this.transform;\n\t\tconst worldID = (transform as any)._worldID;\n\t\tif (worldID !== this._shapeScaleId) {\n\t\t\tthis._shapeScaleId = worldID;\n\t\t\tconst worldTransform = transform.worldTransform;\n\t\t\tconst a = worldTransform.a;\n\t\t\tconst b = worldTransform.b;\n\t\t\tthis._shapeScale = 1 / Math.sqrt(a * a + b * b);\n\t\t}\n\t\treturn this._shapeScale;\n\t}\n\n\tgetShapeScale(): number {\n\t\treturn this._shapeScale;\n\t}\n\n\ttoPixelScale(resolution: number): number {\n\t\tconst shapeScale = this.toShapeScale();\n\t\tconst shapeScaleId = this._shapeScaleId;\n\t\tif (this._pixelScaleId !== shapeScaleId) {\n\t\t\tthis._pixelScaleId = shapeScaleId;\n\t\t\tthis._pixelScale = (1 / resolution) * shapeScale;\n\t\t}\n\t\treturn this._pixelScale;\n\t}\n\n\tgetPixelScale(): number {\n\t\treturn this._pixelScale;\n\t}\n\n\ttoAntialiasWeight(resolution: number): number {\n\t\treturn 1.25 / resolution;\n\t}\n\n\thitTest(global: IPoint, onHit?: (shape: EShape) => boolean): EShape | null {\n\t\tconst local = this._work;\n\t\tconst children = this.children;\n\t\tfor (let i = children.length - 1; 0 <= i; --i) {\n\t\t\tconst child = children[i];\n\t\t\tif (child.visible) {\n\t\t\t\tchild.toLocal(global, undefined, local);\n\t\t\t\tconst result = child.contains(local.x, local.y);\n\t\t\t\tif (result != null) {\n\t\t\t\t\tif (onHit == null || onHit(result)) {\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\thitTestBBox(global: IPoint, onHit?: (shape: EShape) => boolean): EShape | null {\n\t\tconst local = this._work;\n\t\tconst children = this.children;\n\t\tfor (let i = children.length - 1; 0 <= i; --i) {\n\t\t\tconst child = children[i];\n\t\t\tif (child.visible) {\n\t\t\t\tchild.toLocal(global, undefined, local);\n\t\t\t\tif (child.containsBBox(local.x, local.y)) {\n\t\t\t\t\tif (onHit == null || onHit(child)) {\n\t\t\t\t\t\treturn child;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tdestroy(): void {\n\t\t// Buffer\n\t\tconst buffers = this._buffers;\n\t\tif (buffers != null) {\n\t\t\tfor (let i = 0, imax = buffers.length; i < imax; ++i) {\n\t\t\t\tbuffers[i].destroy();\n\t\t\t}\n\t\t}\n\t\tthis._buffers.length = 0;\n\n\t\t// Shapes\n\t\tconst children = this.children;\n\t\tfor (let i = children.length - 1; 0 <= i; --i) {\n\t\t\tchildren[i].destroy();\n\t\t}\n\t\tchildren.length = 0;\n\n\t\t// Atlas\n\t\tconst atlas = this._atlas;\n\t\tif (atlas != null) {\n\t\t\tatlas.destroy();\n\t\t}\n\n\t\t// Font Atlas\n\t\tthis._fontAtlases.destroy();\n\n\t\t//\n\t\tsuper.destroy();\n\t}\n}\n"]}
|
|
@@ -10,10 +10,11 @@ var DynamicAtlas = /** @class */ (function () {
|
|
|
10
10
|
function DynamicAtlas(resolution) {
|
|
11
11
|
var canvas = (this._canvas = document.createElement("canvas"));
|
|
12
12
|
canvas.width = canvas.height = 256;
|
|
13
|
-
var baseTexture =
|
|
13
|
+
var baseTexture = BaseTexture.from(canvas, {
|
|
14
14
|
mipmap: MIPMAP_MODES.OFF,
|
|
15
15
|
resolution: resolution
|
|
16
|
-
})
|
|
16
|
+
});
|
|
17
|
+
this._baseTexture = baseTexture;
|
|
17
18
|
this._idToDatum = {};
|
|
18
19
|
this._sortedData = [];
|
|
19
20
|
this._predefined = {
|
|
@@ -167,6 +168,12 @@ var DynamicAtlas = /** @class */ (function () {
|
|
|
167
168
|
}
|
|
168
169
|
}
|
|
169
170
|
};
|
|
171
|
+
DynamicAtlas.prototype.destroy = function () {
|
|
172
|
+
var baseTexture = this._baseTexture;
|
|
173
|
+
if (baseTexture != null) {
|
|
174
|
+
baseTexture.destroy();
|
|
175
|
+
}
|
|
176
|
+
};
|
|
170
177
|
DynamicAtlas.ITEM_COMPARATOR = function (a, b) {
|
|
171
178
|
if (a.ref <= 0) {
|
|
172
179
|
if (b.ref <= 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic-atlas.js","sourceRoot":"","sources":["../../../../src/main/typescript/wcardinal/ui/util/dynamic-atlas.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAW,MAAM,SAAS,CAAC;AAE7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,IAAM,oBAAoB,GAAG,IAAI,CAAC;AAElC;IAUC,sBAAY,UAAkB;QAC7B,IAAM,MAAM,GAAG,CAAC,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC;QACjE,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC;QAEnC,IAAM,WAAW,GAAG,CAAC,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE;YACjE,MAAM,EAAE,YAAY,CAAC,GAAG;YACxB,UAAU,YAAA;SACV,CAAC,CAAC,CAAC;QAEJ,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,WAAW,GAAG;YAClB,KAAK,EAAE,IAAI,qBAAqB,CAAC,OAAO,EAAE,EAAE,EAAE,E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AAG,UAAC,CAAmB,EAAE,CAAmB;QACjE,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE;YACf,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE;gBACf,OAAO,CAAC,CAAC;aACT;iBAAM;gBACN,OAAO,CAAC,CAAC,CAAC;aACV;SACD;aAAM;YACN,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE;gBACf,OAAO,CAAC,CAAC,CAAC;aACV;SACD;QAED,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE;YACpC,OAAO,CAAC,CAAC,CAAC;SACV;aAAM,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE;YAC3C,OAAO,CAAC,CAAC,CAAC;SACV;aAAM;YACN,OAAO,CAAC,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC;SACrC;IACF,CAAC,CAAC;IACH,mBAAC;CAAA,AAlND,IAkNC;SAlNY,YAAY","sourcesContent":["/*\n * Copyright (C) 2019 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { BaseTexture, MIPMAP_MODES, Texture } from \"pixi.js\";\nimport { DynamicAtlasItem } from \"./dynamic-atlas-item\";\nimport { DynamicAtlasItemEmpty } from \"./dynamic-atlas-item-empty\";\nimport { DynamicAtlasItemWhite } from \"./dynamic-atlas-item-white\";\n\nconst MAXIMUM_TEXTURE_SIZE = 4096;\n\nexport class DynamicAtlas {\n\tprotected static INSTANCE: DynamicAtlas | null;\n\n\tprotected _canvas: HTMLCanvasElement;\n\tprotected _sortedData: DynamicAtlasItem[];\n\tprotected _idToDatum: Record<string, DynamicAtlasItem>;\n\tprotected _baseTexture: BaseTexture;\n\tprotected _isDirty: boolean;\n\tprotected _predefined: Record<string, DynamicAtlasItem>;\n\n\tconstructor(resolution: number) {\n\t\tconst canvas = (this._canvas = document.createElement(\"canvas\"));\n\t\tcanvas.width = canvas.height = 256;\n\n\t\tconst baseTexture = (this._baseTexture = BaseTexture.from(canvas, {\n\t\t\tmipmap: MIPMAP_MODES.OFF,\n\t\t\tresolution\n\t\t}));\n\n\t\tthis._idToDatum = {};\n\t\tthis._sortedData = [];\n\t\tthis._predefined = {\n\t\t\tempty: new DynamicAtlasItemEmpty(\"empty\", 10, 10, 0, baseTexture),\n\t\t\twhite: new DynamicAtlasItemWhite(\"white\", 10, 10, 0, baseTexture)\n\t\t};\n\n\t\tthis._isDirty = true;\n\t}\n\n\tupdateFrames(width: number, data: DynamicAtlasItem[]): number {\n\t\tconst padding = 4;\n\t\tlet x = padding;\n\t\tlet y = padding;\n\t\tlet maxRowHeight = 0;\n\t\tfor (let i = 0, imax = data.length; i < imax; ++i) {\n\t\t\tconst datum = data[i];\n\t\t\tif (width < x + datum.frame.width + padding) {\n\t\t\t\tx = padding;\n\t\t\t\ty += maxRowHeight + padding;\n\t\t\t\tmaxRowHeight = 0;\n\t\t\t}\n\t\t\tdatum.frame.x = x | 0;\n\t\t\tdatum.frame.y = y | 0;\n\t\t\tx += datum.frame.width + padding;\n\t\t\tmaxRowHeight = Math.max(maxRowHeight, datum.frame.height);\n\t\t}\n\n\t\tconst minHeight = y + maxRowHeight + padding;\n\t\tlet result = 256;\n\t\twhile (result < minHeight) {\n\t\t\tresult <<= 1;\n\t\t}\n\t\treturn Math.min(MAXIMUM_TEXTURE_SIZE, result);\n\t}\n\n\trenderFrames(width: number, height: number, data: DynamicAtlasItem[]): void {\n\t\tconst canvas = this._canvas;\n\t\tcanvas.width = width;\n\t\tcanvas.height = height;\n\t\tconst context = canvas.getContext(\"2d\");\n\t\tif (context != null) {\n\t\t\tfor (let i = 0, imax = data.length; i < imax; ++i) {\n\t\t\t\tconst datum = data[i];\n\t\t\t\tdatum.render(context);\n\t\t\t}\n\t\t}\n\t}\n\n\tapplyFrames(data: DynamicAtlasItem[]): void {\n\t\tfor (let i = 0, imax = data.length; i < imax; ++i) {\n\t\t\tconst datum = data[i];\n\t\t\tdatum.applyFrame();\n\t\t}\n\t}\n\n\tcalcCanvasWidth(data: DynamicAtlasItem[]): number {\n\t\tlet result = 512;\n\t\tfor (let i = data.length - 1; 0 <= i; --i) {\n\t\t\tconst datum = data[i];\n\t\t\tconst size = Math.max(datum.frame.width, datum.frame.height);\n\t\t\twhile (result < size) {\n\t\t\t\tresult <<= 1;\n\t\t\t}\n\t\t}\n\t\treturn Math.min(MAXIMUM_TEXTURE_SIZE, result << 1);\n\t}\n\n\tcleanup(data: DynamicAtlasItem[]): void {\n\t\tdata.sort(DynamicAtlas.ITEM_COMPARATOR);\n\t\tfor (let i = data.length - 1; 0 <= i; --i) {\n\t\t\tconst datum = data[i];\n\t\t\tif (0 < datum.ref) {\n\t\t\t\tdata.length = i + 1;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tdata.length = 0;\n\t}\n\n\tbegin(): void {\n\t\tconst data = this._sortedData;\n\t\tfor (let i = 0, imax = data.length; i < imax; ++i) {\n\t\t\tconst datum = data[i];\n\t\t\tdatum.ref = 0;\n\t\t}\n\n\t\tthis._isDirty = false;\n\t}\n\n\tend(): void {\n\t\tconst idToDatum = this._idToDatum;\n\t\tconst data = this._sortedData;\n\t\tfor (let i = 0, imax = data.length; i < imax; ++i) {\n\t\t\tconst datum = data[i];\n\t\t\tif (datum.ref <= 0) {\n\t\t\t\tif (!(datum.id in this._predefined)) {\n\t\t\t\t\tdatum.destroy();\n\t\t\t\t}\n\t\t\t\tdelete idToDatum[datum.id];\n\t\t\t\tthis._isDirty = true;\n\t\t\t}\n\t\t}\n\t}\n\n\trepack(forcibly?: boolean): void {\n\t\tif (forcibly === true || this._isDirty) {\n\t\t\tthis._isDirty = false;\n\t\t\tconst data = this._sortedData;\n\t\t\tthis.cleanup(data);\n\t\t\tconst canvasWidth = this.calcCanvasWidth(data);\n\t\t\tconst canvasHeight = this.updateFrames(canvasWidth, data);\n\t\t\tthis.renderFrames(canvasWidth, canvasHeight, data);\n\t\t\tthis._baseTexture.setRealSize(canvasWidth, canvasHeight);\n\t\t\tthis.applyFrames(data);\n\t\t}\n\t}\n\n\tget(id: string): DynamicAtlasItem | null {\n\t\tconst idToDatum = this._idToDatum;\n\t\tconst datum = idToDatum[id];\n\t\tif (datum != null) {\n\t\t\tdatum.ref += 1;\n\t\t\treturn datum;\n\t\t} else {\n\t\t\tconst predefined = this._predefined[id];\n\t\t\tif (predefined != null) {\n\t\t\t\tthis.set(id, predefined);\n\t\t\t\treturn predefined;\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\n\tset(id: string, item: DynamicAtlasItem): DynamicAtlasItem | undefined {\n\t\tconst result = this._idToDatum[id];\n\t\titem.ref += 1;\n\t\tthis._idToDatum[id] = item;\n\t\tthis._sortedData.push(item);\n\t\tthis._isDirty = true;\n\t\treturn result;\n\t}\n\n\ttoDirty(): void {\n\t\tthis._isDirty = true;\n\t}\n\n\tgetDefaultTexture(): Texture {\n\t\treturn this.get(\"white\")!.texture;\n\t}\n\n\tgetBaseTexture(): BaseTexture {\n\t\treturn this._baseTexture;\n\t}\n\n\trelease(id: string): void {\n\t\tconst idToDatum = this._idToDatum;\n\t\tconst datum = idToDatum[id];\n\t\tif (datum != null) {\n\t\t\tdatum.ref -= 1;\n\t\t\tif (datum.ref <= 0) {\n\t\t\t\tif (!(datum.id in this._predefined)) {\n\t\t\t\t\tdatum.destroy();\n\t\t\t\t}\n\t\t\t\tdelete idToDatum[id];\n\t\t\t\tthis._isDirty = true;\n\t\t\t}\n\t\t}\n\t}\n\n\tstatic ITEM_COMPARATOR = (a: DynamicAtlasItem, b: DynamicAtlasItem): number => {\n\t\tif (a.ref <= 0) {\n\t\t\tif (b.ref <= 0) {\n\t\t\t\treturn 0;\n\t\t\t} else {\n\t\t\t\treturn +1;\n\t\t\t}\n\t\t} else {\n\t\t\tif (b.ref <= 0) {\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}\n\n\t\tif (a.frame.height < b.frame.height) {\n\t\t\treturn -1;\n\t\t} else if (b.frame.height < a.frame.height) {\n\t\t\treturn +1;\n\t\t} else {\n\t\t\treturn a.frame.width - b.frame.width;\n\t\t}\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dynamic-atlas.js","sourceRoot":"","sources":["../../../../src/main/typescript/wcardinal/ui/util/dynamic-atlas.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAW,MAAM,SAAS,CAAC;AAE7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,IAAM,oBAAoB,GAAG,IAAI,CAAC;AAElC;IAUC,sBAAY,UAAkB;QAC7B,IAAM,MAAM,GAAG,CAAC,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC;QACjE,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC;QAEnC,IAAM,WAAW,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE;YAC5C,MAAM,EAAE,YAAY,CAAC,GAAG;YACxB,UAAU,YAAA;SACV,CAAC,CAAC;QACH,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAEhC,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,WAAW,GAAG;YAClB,KAAK,EAAE,IAAI,qBAAqB,CAAC,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,WAAW,CAAC;YACjE,KAAK,EAAE,IAAI,qBAAqB,CAAC,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,WAAW,CAAC;SACjE,CAAC;QAEF,IAAI,CAAC,QAAQ,GAAG,IAAI,CAA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ACjE,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE;YACf,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE;gBACf,OAAO,CAAC,CAAC;aACT;iBAAM;gBACN,OAAO,CAAC,CAAC,CAAC;aACV;SACD;aAAM;YACN,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE;gBACf,OAAO,CAAC,CAAC,CAAC;aACV;SACD;QAED,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE;YACpC,OAAO,CAAC,CAAC,CAAC;SACV;aAAM,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE;YAC3C,OAAO,CAAC,CAAC,CAAC;SACV;aAAM;YACN,OAAO,CAAC,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC;SACrC;IACF,CAAC,CAAC;IACH,mBAAC;CAAA,AA1ND,IA0NC;SA1NY,YAAY","sourcesContent":["/*\n * Copyright (C) 2019 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { BaseTexture, MIPMAP_MODES, Texture } from \"pixi.js\";\nimport { DynamicAtlasItem } from \"./dynamic-atlas-item\";\nimport { DynamicAtlasItemEmpty } from \"./dynamic-atlas-item-empty\";\nimport { DynamicAtlasItemWhite } from \"./dynamic-atlas-item-white\";\n\nconst MAXIMUM_TEXTURE_SIZE = 4096;\n\nexport class DynamicAtlas {\n\tprotected static INSTANCE: DynamicAtlas | null;\n\n\tprotected _canvas: HTMLCanvasElement;\n\tprotected _sortedData: DynamicAtlasItem[];\n\tprotected _idToDatum: Record<string, DynamicAtlasItem>;\n\tprotected _baseTexture: BaseTexture;\n\tprotected _isDirty: boolean;\n\tprotected _predefined: Record<string, DynamicAtlasItem>;\n\n\tconstructor(resolution: number) {\n\t\tconst canvas = (this._canvas = document.createElement(\"canvas\"));\n\t\tcanvas.width = canvas.height = 256;\n\n\t\tconst baseTexture = BaseTexture.from(canvas, {\n\t\t\tmipmap: MIPMAP_MODES.OFF,\n\t\t\tresolution\n\t\t});\n\t\tthis._baseTexture = baseTexture;\n\n\t\tthis._idToDatum = {};\n\t\tthis._sortedData = [];\n\t\tthis._predefined = {\n\t\t\tempty: new DynamicAtlasItemEmpty(\"empty\", 10, 10, 0, baseTexture),\n\t\t\twhite: new DynamicAtlasItemWhite(\"white\", 10, 10, 0, baseTexture)\n\t\t};\n\n\t\tthis._isDirty = true;\n\t}\n\n\tupdateFrames(width: number, data: DynamicAtlasItem[]): number {\n\t\tconst padding = 4;\n\t\tlet x = padding;\n\t\tlet y = padding;\n\t\tlet maxRowHeight = 0;\n\t\tfor (let i = 0, imax = data.length; i < imax; ++i) {\n\t\t\tconst datum = data[i];\n\t\t\tif (width < x + datum.frame.width + padding) {\n\t\t\t\tx = padding;\n\t\t\t\ty += maxRowHeight + padding;\n\t\t\t\tmaxRowHeight = 0;\n\t\t\t}\n\t\t\tdatum.frame.x = x | 0;\n\t\t\tdatum.frame.y = y | 0;\n\t\t\tx += datum.frame.width + padding;\n\t\t\tmaxRowHeight = Math.max(maxRowHeight, datum.frame.height);\n\t\t}\n\n\t\tconst minHeight = y + maxRowHeight + padding;\n\t\tlet result = 256;\n\t\twhile (result < minHeight) {\n\t\t\tresult <<= 1;\n\t\t}\n\t\treturn Math.min(MAXIMUM_TEXTURE_SIZE, result);\n\t}\n\n\trenderFrames(width: number, height: number, data: DynamicAtlasItem[]): void {\n\t\tconst canvas = this._canvas;\n\t\tcanvas.width = width;\n\t\tcanvas.height = height;\n\t\tconst context = canvas.getContext(\"2d\");\n\t\tif (context != null) {\n\t\t\tfor (let i = 0, imax = data.length; i < imax; ++i) {\n\t\t\t\tconst datum = data[i];\n\t\t\t\tdatum.render(context);\n\t\t\t}\n\t\t}\n\t}\n\n\tapplyFrames(data: DynamicAtlasItem[]): void {\n\t\tfor (let i = 0, imax = data.length; i < imax; ++i) {\n\t\t\tconst datum = data[i];\n\t\t\tdatum.applyFrame();\n\t\t}\n\t}\n\n\tcalcCanvasWidth(data: DynamicAtlasItem[]): number {\n\t\tlet result = 512;\n\t\tfor (let i = data.length - 1; 0 <= i; --i) {\n\t\t\tconst datum = data[i];\n\t\t\tconst size = Math.max(datum.frame.width, datum.frame.height);\n\t\t\twhile (result < size) {\n\t\t\t\tresult <<= 1;\n\t\t\t}\n\t\t}\n\t\treturn Math.min(MAXIMUM_TEXTURE_SIZE, result << 1);\n\t}\n\n\tcleanup(data: DynamicAtlasItem[]): void {\n\t\tdata.sort(DynamicAtlas.ITEM_COMPARATOR);\n\t\tfor (let i = data.length - 1; 0 <= i; --i) {\n\t\t\tconst datum = data[i];\n\t\t\tif (0 < datum.ref) {\n\t\t\t\tdata.length = i + 1;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tdata.length = 0;\n\t}\n\n\tbegin(): void {\n\t\tconst data = this._sortedData;\n\t\tfor (let i = 0, imax = data.length; i < imax; ++i) {\n\t\t\tconst datum = data[i];\n\t\t\tdatum.ref = 0;\n\t\t}\n\n\t\tthis._isDirty = false;\n\t}\n\n\tend(): void {\n\t\tconst idToDatum = this._idToDatum;\n\t\tconst data = this._sortedData;\n\t\tfor (let i = 0, imax = data.length; i < imax; ++i) {\n\t\t\tconst datum = data[i];\n\t\t\tif (datum.ref <= 0) {\n\t\t\t\tif (!(datum.id in this._predefined)) {\n\t\t\t\t\tdatum.destroy();\n\t\t\t\t}\n\t\t\t\tdelete idToDatum[datum.id];\n\t\t\t\tthis._isDirty = true;\n\t\t\t}\n\t\t}\n\t}\n\n\trepack(forcibly?: boolean): void {\n\t\tif (forcibly === true || this._isDirty) {\n\t\t\tthis._isDirty = false;\n\t\t\tconst data = this._sortedData;\n\t\t\tthis.cleanup(data);\n\t\t\tconst canvasWidth = this.calcCanvasWidth(data);\n\t\t\tconst canvasHeight = this.updateFrames(canvasWidth, data);\n\t\t\tthis.renderFrames(canvasWidth, canvasHeight, data);\n\t\t\tthis._baseTexture.setRealSize(canvasWidth, canvasHeight);\n\t\t\tthis.applyFrames(data);\n\t\t}\n\t}\n\n\tget(id: string): DynamicAtlasItem | null {\n\t\tconst idToDatum = this._idToDatum;\n\t\tconst datum = idToDatum[id];\n\t\tif (datum != null) {\n\t\t\tdatum.ref += 1;\n\t\t\treturn datum;\n\t\t} else {\n\t\t\tconst predefined = this._predefined[id];\n\t\t\tif (predefined != null) {\n\t\t\t\tthis.set(id, predefined);\n\t\t\t\treturn predefined;\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\n\tset(id: string, item: DynamicAtlasItem): DynamicAtlasItem | undefined {\n\t\tconst result = this._idToDatum[id];\n\t\titem.ref += 1;\n\t\tthis._idToDatum[id] = item;\n\t\tthis._sortedData.push(item);\n\t\tthis._isDirty = true;\n\t\treturn result;\n\t}\n\n\ttoDirty(): void {\n\t\tthis._isDirty = true;\n\t}\n\n\tgetDefaultTexture(): Texture {\n\t\treturn this.get(\"white\")!.texture;\n\t}\n\n\tgetBaseTexture(): BaseTexture {\n\t\treturn this._baseTexture;\n\t}\n\n\trelease(id: string): void {\n\t\tconst idToDatum = this._idToDatum;\n\t\tconst datum = idToDatum[id];\n\t\tif (datum != null) {\n\t\t\tdatum.ref -= 1;\n\t\t\tif (datum.ref <= 0) {\n\t\t\t\tif (!(datum.id in this._predefined)) {\n\t\t\t\t\tdatum.destroy();\n\t\t\t\t}\n\t\t\t\tdelete idToDatum[id];\n\t\t\t\tthis._isDirty = true;\n\t\t\t}\n\t\t}\n\t}\n\n\tdestroy(): void {\n\t\tconst baseTexture = this._baseTexture;\n\t\tif (baseTexture != null) {\n\t\t\tbaseTexture.destroy();\n\t\t}\n\t}\n\n\tstatic ITEM_COMPARATOR = (a: DynamicAtlasItem, b: DynamicAtlasItem): number => {\n\t\tif (a.ref <= 0) {\n\t\t\tif (b.ref <= 0) {\n\t\t\t\treturn 0;\n\t\t\t} else {\n\t\t\t\treturn +1;\n\t\t\t}\n\t\t} else {\n\t\t\tif (b.ref <= 0) {\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}\n\n\t\tif (a.frame.height < b.frame.height) {\n\t\t\treturn -1;\n\t\t} else if (b.frame.height < a.frame.height) {\n\t\t\treturn +1;\n\t\t} else {\n\t\t\treturn a.frame.width - b.frame.width;\n\t\t}\n\t};\n}\n"]}
|
package/dist/wcardinal-ui.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Winter Cardinal UI v0.
|
|
2
|
+
Winter Cardinal UI v0.442.0
|
|
3
3
|
Copyright (C) 2019 Toshiba Corporation
|
|
4
4
|
SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
|
|
@@ -15085,10 +15085,11 @@ var DynamicAtlas = /** @class */ (function () {
|
|
|
15085
15085
|
function DynamicAtlas(resolution) {
|
|
15086
15086
|
var canvas = (this._canvas = document.createElement("canvas"));
|
|
15087
15087
|
canvas.width = canvas.height = 256;
|
|
15088
|
-
var baseTexture =
|
|
15088
|
+
var baseTexture = pixi_js.BaseTexture.from(canvas, {
|
|
15089
15089
|
mipmap: pixi_js.MIPMAP_MODES.OFF,
|
|
15090
15090
|
resolution: resolution
|
|
15091
|
-
})
|
|
15091
|
+
});
|
|
15092
|
+
this._baseTexture = baseTexture;
|
|
15092
15093
|
this._idToDatum = {};
|
|
15093
15094
|
this._sortedData = [];
|
|
15094
15095
|
this._predefined = {
|
|
@@ -15242,6 +15243,12 @@ var DynamicAtlas = /** @class */ (function () {
|
|
|
15242
15243
|
}
|
|
15243
15244
|
}
|
|
15244
15245
|
};
|
|
15246
|
+
DynamicAtlas.prototype.destroy = function () {
|
|
15247
|
+
var baseTexture = this._baseTexture;
|
|
15248
|
+
if (baseTexture != null) {
|
|
15249
|
+
baseTexture.destroy();
|
|
15250
|
+
}
|
|
15251
|
+
};
|
|
15245
15252
|
DynamicAtlas.ITEM_COMPARATOR = function (a, b) {
|
|
15246
15253
|
if (a.ref <= 0) {
|
|
15247
15254
|
if (b.ref <= 0) {
|
|
@@ -16729,6 +16736,13 @@ var EShapeContainer = /** @class */ (function (_super) {
|
|
|
16729
16736
|
children[i].destroy();
|
|
16730
16737
|
}
|
|
16731
16738
|
children.length = 0;
|
|
16739
|
+
// Atlas
|
|
16740
|
+
var atlas = this._atlas;
|
|
16741
|
+
if (atlas != null) {
|
|
16742
|
+
atlas.destroy();
|
|
16743
|
+
}
|
|
16744
|
+
// Font Atlas
|
|
16745
|
+
this._fontAtlases.destroy();
|
|
16732
16746
|
//
|
|
16733
16747
|
_super.prototype.destroy.call(this);
|
|
16734
16748
|
};
|
|
@@ -31763,6 +31777,7 @@ var DImagePieceLayouterPartContainer = /** @class */ (function () {
|
|
|
31763
31777
|
var textWidth = 0;
|
|
31764
31778
|
var textHeight = 0;
|
|
31765
31779
|
if (text != null) {
|
|
31780
|
+
text.setClippingDelta(leftSize + rightSize, topSize + bottomSize);
|
|
31766
31781
|
textWidth = text.width;
|
|
31767
31782
|
textHeight = text.height;
|
|
31768
31783
|
}
|
|
@@ -31797,7 +31812,6 @@ var DImagePieceLayouterPartContainer = /** @class */ (function () {
|
|
|
31797
31812
|
}
|
|
31798
31813
|
if (text != null) {
|
|
31799
31814
|
text.position.set(textX, textY);
|
|
31800
|
-
text.setClippingDelta(leftSize + rightSize, topSize + bottomSize);
|
|
31801
31815
|
}
|
|
31802
31816
|
left.execute(textX - leftSize);
|
|
31803
31817
|
center.execute(0, 0, textX * 2 + textWidth);
|
|
@@ -32842,18 +32856,13 @@ var DDynamicText = /** @class */ (function (_super) {
|
|
|
32842
32856
|
if (styleClipping || styleFitting || styleWordWrap) {
|
|
32843
32857
|
var parent_1 = this.parent;
|
|
32844
32858
|
if (parent_1 instanceof DBase) {
|
|
32845
|
-
var
|
|
32846
|
-
|
|
32847
|
-
parent_1.padding.getRight() -
|
|
32848
|
-
modifier.delta.width;
|
|
32859
|
+
var padding = parent_1.padding;
|
|
32860
|
+
var width = parent_1.width - padding.getLeft() - padding.getRight() - modifier.delta.width;
|
|
32849
32861
|
if (modifier.width !== width) {
|
|
32850
32862
|
modifier.width = width;
|
|
32851
32863
|
isChanged = true;
|
|
32852
32864
|
}
|
|
32853
|
-
var height = parent_1.height -
|
|
32854
|
-
parent_1.padding.getTop() -
|
|
32855
|
-
parent_1.padding.getBottom() -
|
|
32856
|
-
modifier.delta.height;
|
|
32865
|
+
var height = parent_1.height - padding.getTop() - padding.getBottom() - modifier.delta.height;
|
|
32857
32866
|
if (modifier.height !== height) {
|
|
32858
32867
|
modifier.height = height;
|
|
32859
32868
|
isChanged = true;
|
package/dist/wcardinal-ui.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Winter Cardinal UI v0.
|
|
2
|
+
Winter Cardinal UI v0.442.0
|
|
3
3
|
Copyright (C) 2019 Toshiba Corporation
|
|
4
4
|
SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
|
|
@@ -15082,10 +15082,11 @@
|
|
|
15082
15082
|
function DynamicAtlas(resolution) {
|
|
15083
15083
|
var canvas = (this._canvas = document.createElement("canvas"));
|
|
15084
15084
|
canvas.width = canvas.height = 256;
|
|
15085
|
-
var baseTexture =
|
|
15085
|
+
var baseTexture = pixi_js.BaseTexture.from(canvas, {
|
|
15086
15086
|
mipmap: pixi_js.MIPMAP_MODES.OFF,
|
|
15087
15087
|
resolution: resolution
|
|
15088
|
-
})
|
|
15088
|
+
});
|
|
15089
|
+
this._baseTexture = baseTexture;
|
|
15089
15090
|
this._idToDatum = {};
|
|
15090
15091
|
this._sortedData = [];
|
|
15091
15092
|
this._predefined = {
|
|
@@ -15239,6 +15240,12 @@
|
|
|
15239
15240
|
}
|
|
15240
15241
|
}
|
|
15241
15242
|
};
|
|
15243
|
+
DynamicAtlas.prototype.destroy = function () {
|
|
15244
|
+
var baseTexture = this._baseTexture;
|
|
15245
|
+
if (baseTexture != null) {
|
|
15246
|
+
baseTexture.destroy();
|
|
15247
|
+
}
|
|
15248
|
+
};
|
|
15242
15249
|
DynamicAtlas.ITEM_COMPARATOR = function (a, b) {
|
|
15243
15250
|
if (a.ref <= 0) {
|
|
15244
15251
|
if (b.ref <= 0) {
|
|
@@ -16726,6 +16733,13 @@
|
|
|
16726
16733
|
children[i].destroy();
|
|
16727
16734
|
}
|
|
16728
16735
|
children.length = 0;
|
|
16736
|
+
// Atlas
|
|
16737
|
+
var atlas = this._atlas;
|
|
16738
|
+
if (atlas != null) {
|
|
16739
|
+
atlas.destroy();
|
|
16740
|
+
}
|
|
16741
|
+
// Font Atlas
|
|
16742
|
+
this._fontAtlases.destroy();
|
|
16729
16743
|
//
|
|
16730
16744
|
_super.prototype.destroy.call(this);
|
|
16731
16745
|
};
|
|
@@ -31760,6 +31774,7 @@
|
|
|
31760
31774
|
var textWidth = 0;
|
|
31761
31775
|
var textHeight = 0;
|
|
31762
31776
|
if (text != null) {
|
|
31777
|
+
text.setClippingDelta(leftSize + rightSize, topSize + bottomSize);
|
|
31763
31778
|
textWidth = text.width;
|
|
31764
31779
|
textHeight = text.height;
|
|
31765
31780
|
}
|
|
@@ -31794,7 +31809,6 @@
|
|
|
31794
31809
|
}
|
|
31795
31810
|
if (text != null) {
|
|
31796
31811
|
text.position.set(textX, textY);
|
|
31797
|
-
text.setClippingDelta(leftSize + rightSize, topSize + bottomSize);
|
|
31798
31812
|
}
|
|
31799
31813
|
left.execute(textX - leftSize);
|
|
31800
31814
|
center.execute(0, 0, textX * 2 + textWidth);
|
|
@@ -32839,18 +32853,13 @@
|
|
|
32839
32853
|
if (styleClipping || styleFitting || styleWordWrap) {
|
|
32840
32854
|
var parent_1 = this.parent;
|
|
32841
32855
|
if (parent_1 instanceof DBase) {
|
|
32842
|
-
var
|
|
32843
|
-
|
|
32844
|
-
parent_1.padding.getRight() -
|
|
32845
|
-
modifier.delta.width;
|
|
32856
|
+
var padding = parent_1.padding;
|
|
32857
|
+
var width = parent_1.width - padding.getLeft() - padding.getRight() - modifier.delta.width;
|
|
32846
32858
|
if (modifier.width !== width) {
|
|
32847
32859
|
modifier.width = width;
|
|
32848
32860
|
isChanged = true;
|
|
32849
32861
|
}
|
|
32850
|
-
var height = parent_1.height -
|
|
32851
|
-
parent_1.padding.getTop() -
|
|
32852
|
-
parent_1.padding.getBottom() -
|
|
32853
|
-
modifier.delta.height;
|
|
32862
|
+
var height = parent_1.height - padding.getTop() - padding.getBottom() - modifier.delta.height;
|
|
32854
32863
|
if (modifier.height !== height) {
|
|
32855
32864
|
modifier.height = height;
|
|
32856
32865
|
isChanged = true;
|