@wcardinal/wcardinal-ui 0.299.0 → 0.301.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.
@@ -3,6 +3,7 @@ import { DButtonBaseWhen } from "./d-button-base-when";
3
3
  import { DButtonGroup } from "./d-button-group";
4
4
  import { DImageBase, DImageBaseEvents, DImageBaseOptions, DThemeImageBase } from "./d-image-base";
5
5
  import { DOnOptions } from "./d-on-options";
6
+ import { DBaseStateSet } from "./d-base-state-set";
6
7
  /**
7
8
  * {@link DButtonBase} events.
8
9
  */
@@ -19,6 +20,18 @@ export interface DButtonBaseEvents<VALUE, EMITTER> extends DImageBaseEvents<VALU
19
20
  * @param emitter an emitter
20
21
  */
21
22
  inactive(emitter: EMITTER): void;
23
+ /**
24
+ * Triggered when the button is pressed.
25
+ *
26
+ * @param emitter an emitter
27
+ */
28
+ press(emitter: EMITTER): void;
29
+ /**
30
+ * Triggered when the button is released.
31
+ *
32
+ * @param emitter an emitter
33
+ */
34
+ unpress(emitter: EMITTER): void;
22
35
  }
23
36
  /**
24
37
  * {@link DButtonBase} "on" options.
@@ -86,5 +99,8 @@ export declare class DButtonBase<VALUE = unknown, THEME extends DThemeButtonBase
86
99
  protected onActivateKeyUp(e: KeyboardEvent): void;
87
100
  protected onKeyDown(e: KeyboardEvent): boolean;
88
101
  protected onKeyUp(e: KeyboardEvent): boolean;
102
+ protected onStateChange(newState: DBaseStateSet, oldState: DBaseStateSet): void;
103
+ protected onPress(): void;
104
+ protected onUnpress(): void;
89
105
  destroy(): void;
90
106
  }
@@ -219,6 +219,8 @@ export interface DDiagramSerializedText {
219
219
  [12]: number;
220
220
  /** A clipping. (0: Off, 1: On) */
221
221
  [13]: number;
222
+ /** A fitting. (0: Off, 1: On) */
223
+ [14]: number;
222
224
  }
223
225
  /**
224
226
  * A serialized item.
@@ -31,6 +31,7 @@ export interface EShapeTextLike {
31
31
  direction: EShapeTextDirection;
32
32
  padding: EShapeTextOffsetLike;
33
33
  clipping: boolean;
34
+ fitting: boolean;
34
35
  }
35
36
  export interface EShapeTextAtlasCharacter {
36
37
  x: number;
@@ -63,7 +64,7 @@ export interface EShapeText extends EShapeTextLike {
63
64
  atlas?: EShapeTextAtlas;
64
65
  world?: number[];
65
66
  copy(target?: DeepPartial<EShapeTextLike>): this;
66
- set(value?: string, color?: number, alpha?: number, family?: string, size?: number, weight?: EShapeTextWeight, style?: EShapeTextStyle, direction?: EShapeTextDirection, clipping?: boolean): this;
67
+ set(value?: string, color?: number, alpha?: number, family?: string, size?: number, weight?: EShapeTextWeight, style?: EShapeTextStyle, direction?: EShapeTextDirection, clipping?: boolean, fitting?: boolean): this;
67
68
  toObject(): EShapeTextLike;
68
69
  serialize(manager: EShapeResourceManagerSerialization): number;
69
70
  deserialize(target: number, manager: EShapeResourceManagerDeserialization): void;
@@ -11,4 +11,4 @@ export declare const toTextBufferCount: (shape: EShape) => number;
11
11
  export declare const buildTextClipping: (clippings: Float32Array, voffset: number, vcount: number) => void;
12
12
  export declare const buildTextIndex: (indices: Uint16Array | Uint32Array, voffset: number, ioffset: number, icount: number) => void;
13
13
  export declare const buildTextStep: (steps: Float32Array, voffset: number, vcount: number, textAtlas: EShapeTextAtlas | undefined, textSize: number, textOutlineWidth: number, textWeight: EShapeTextWeight, scaleX: number, scaleY: number) => void;
14
- export declare const buildTextVertex: (vertices: Float32Array, uvs: Float32Array, voffset: number, vcount: number, originX: number, originY: number, sizeX: number, sizeY: number, textAtlas: EShapeTextAtlas, textSize: number, textValue: string, textStyle: EShapeTextStyle, textAlignHorizontal: EShapeTextAlignHorizontal, textAlignVertical: EShapeTextAlignVertical, textOffsetHorizontal: number, textOffsetVertical: number, textSpacingHorizontal: number, textSpacingVertical: number, textDirection: EShapeTextDirection, textPaddingHorizontal: number, textPaddingVertical: number, textClipping: boolean, textWorld: number[], textureUvs: TextureUvs, internalTransform: Matrix) => void;
14
+ export declare const buildTextVertex: (vertices: Float32Array, uvs: Float32Array, voffset: number, vcount: number, originX: number, originY: number, sizeX: number, sizeY: number, textAtlas: EShapeTextAtlas, textSize: number, textValue: string, textStyle: EShapeTextStyle, textAlignHorizontal: EShapeTextAlignHorizontal, textAlignVertical: EShapeTextAlignVertical, textOffsetHorizontal: number, textOffsetVertical: number, textSpacingHorizontal: number, textSpacingVertical: number, textDirection: EShapeTextDirection, textPaddingHorizontal: number, textPaddingVertical: number, textClipping: boolean, textFitting: boolean, textWorld: number[], textureUvs: TextureUvs, internalTransform: Matrix) => void;
@@ -36,6 +36,7 @@ export declare class BuilderText implements Builder {
36
36
  protected paddingHorizontal: number;
37
37
  protected paddingVertical: number;
38
38
  protected clipping: boolean;
39
+ protected fitting: boolean;
39
40
  constructor(vertexOffset: number, indexOffset: number, vertexCount: number, indexCount: number);
40
41
  init(buffer: EShapeBuffer): void;
41
42
  isCompatible(shape: EShape): boolean;
@@ -25,6 +25,7 @@ export declare class EShapeTextImpl implements EShapeText {
25
25
  protected _direction: EShapeTextDirection;
26
26
  readonly padding: EShapeTextOffset;
27
27
  protected _clipping: boolean;
28
+ protected _fitting: boolean;
28
29
  texture?: Texture;
29
30
  atlas?: EShapeTextAtlas;
30
31
  world?: number[];
@@ -49,8 +50,10 @@ export declare class EShapeTextImpl implements EShapeText {
49
50
  set direction(direction: EShapeTextDirection);
50
51
  get clipping(): boolean;
51
52
  set clipping(clipping: boolean);
53
+ get fitting(): boolean;
54
+ set fitting(fitting: boolean);
52
55
  copy(target?: DeepPartial<EShapeTextLike>): this;
53
- set(value?: string, color?: number, alpha?: number, family?: string, size?: number, weight?: EShapeTextWeight, style?: EShapeTextStyle, direction?: EShapeTextDirection, clipping?: boolean): this;
56
+ set(value?: string, color?: number, alpha?: number, family?: string, size?: number, weight?: EShapeTextWeight, style?: EShapeTextStyle, direction?: EShapeTextDirection, clipping?: boolean, fitting?: boolean): this;
54
57
  toObject(): EShapeTextLike;
55
58
  serialize(manager: EShapeResourceManagerSerialization): number;
56
59
  deserialize(target: number, manager: EShapeResourceManagerDeserialization): void;
@@ -72,13 +72,15 @@ var DButtonBase = /** @class */ (function (_super) {
72
72
  }
73
73
  };
74
74
  this.on(UtilPointerEvent.down, function () {
75
- _this.state.isPressed = true;
76
- var layer = DApplications.getLayer(_this);
77
- if (layer) {
78
- interactionManager = layer.renderer.plugins.interaction;
79
- interactionManager.on(UtilPointerEvent.up, onUp);
80
- interactionManager.on(UtilPointerEvent.upoutside, onUp);
81
- interactionManager.on(UtilPointerEvent.cancel, onUp);
75
+ if (_this.state.isActionable) {
76
+ _this.state.isPressed = true;
77
+ var layer = DApplications.getLayer(_this);
78
+ if (layer) {
79
+ interactionManager = layer.renderer.plugins.interaction;
80
+ interactionManager.on(UtilPointerEvent.up, onUp);
81
+ interactionManager.on(UtilPointerEvent.upoutside, onUp);
82
+ interactionManager.on(UtilPointerEvent.cancel, onUp);
83
+ }
82
84
  }
83
85
  });
84
86
  };
@@ -173,6 +175,23 @@ var DButtonBase = /** @class */ (function (_super) {
173
175
  }
174
176
  return _super.prototype.onKeyUp.call(this, e);
175
177
  };
178
+ DButtonBase.prototype.onStateChange = function (newState, oldState) {
179
+ _super.prototype.onStateChange.call(this, newState, oldState);
180
+ if (newState.isPressed) {
181
+ if (!oldState.isPressed) {
182
+ this.onPress();
183
+ }
184
+ }
185
+ else if (oldState.isPressed) {
186
+ this.onUnpress();
187
+ }
188
+ };
189
+ DButtonBase.prototype.onPress = function () {
190
+ this.emit("press", this);
191
+ };
192
+ DButtonBase.prototype.onUnpress = function () {
193
+ this.emit("unpress", this);
194
+ };
176
195
  DButtonBase.prototype.destroy = function () {
177
196
  var _a, _b;
178
197
  (_b = (_a = this._options) === null || _a === void 0 ? void 0 : _a.group) === null || _b === void 0 ? void 0 : _b.remove(this);
@@ -1 +1 @@
1
- {"version":3,"file":"d-button-base.js","sourceRoot":"","sources":["../../../src/main/typescript/wcardinal/ui/d-button-base.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAGH,OAAO,EAAE,aAAa,EAAE,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AAK,CAAC;aAC7B;SACD;IACF,CAAC;IAES,+BAAS,GAAnB,UAAoB,CAAgB;QACnC,IAAI,iBAAiB,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE;YACvC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;SAC1B;QAED,OAAO,iBAAM,SAAS,YAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IAES,6BAAO,GAAjB,UAAkB,CAAgB;QACjC,IAAI,iBAAiB,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE;YACvC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;SACxB;QAED,OAAO,iBAAM,OAAO,YAAC,CAAC,CAAC,CAAC;IACzB,CAAC;IAED,6BAAO,GAAP;;QACC,MAAA,MAAA,IAAI,CAAC,QAAQ,0CAAE,KAAK,0CAAE,MAAM,CAAC,IAAI,CAAC,CAAC;QACnC,iBAAM,OAAO,WAAE,CAAC;IACjB,CAAC;IACF,kBAAC;AAAD,CAAC,AA7LD,CAIU,UAAU,GAyLnB","sourcesContent":["/*\n * Copyright (C) 2019 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { interaction } from \"pixi.js\";\nimport { DApplications } from \"./d-applications\";\nimport { DButtonBaseWhen } from \"./d-button-base-when\";\nimport { DButtonGroup } from \"./d-button-group\";\nimport { DImageBase, DImageBaseEvents, DImageBaseOptions, DThemeImageBase } from \"./d-image-base\";\nimport { DOnOptions } from \"./d-on-options\";\nimport { toEnum } from \"./util/to-enum\";\nimport { UtilKeyboardEvent } from \"./util/util-keyboard-event\";\nimport { UtilPointerEvent } from \"./util/util-pointer-event\";\n\n/**\n * {@link DButtonBase} events.\n */\nexport interface DButtonBaseEvents<VALUE, EMITTER> extends DImageBaseEvents<VALUE, EMITTER> {\n\t/**\n\t * Triggered when the button is activated.\n\t *\n\t * @param emitter an emitter\n\t */\n\tactive(emitter: EMITTER): void;\n\n\t/**\n\t * Triggered when the button is inactivated.\n\t *\n\t * @param emitter an emitter\n\t */\n\tinactive(emitter: EMITTER): void;\n}\n\n/**\n * {@link DButtonBase} \"on\" options.\n */\nexport interface DButtonBaseOnOptions<VALUE, EMITTER>\n\textends Partial<DButtonBaseEvents<VALUE, EMITTER>>,\n\t\tDOnOptions {}\n\n/**\n * {@link DButtonBase} options.\n */\nexport interface DButtonBaseOptions<\n\tVALUE = unknown,\n\tTHEME extends DThemeButtonBase<VALUE> = DThemeButtonBase<VALUE>,\n\tEMITTER = any\n> extends DImageBaseOptions<VALUE, THEME, EMITTER> {\n\t/**\n\t * True to turn a toggle mode on.\n\t */\n\ttoggle?: boolean;\n\n\t/**\n\t * A button group.\n\t */\n\tgroup?: DButtonGroup;\n\n\t/**\n\t * An option when to activate a button.\n\t */\n\twhen?: DButtonBaseWhen | keyof typeof DButtonBaseWhen;\n\n\t/**\n\t * Mappings of event names and handlers.\n\t */\n\ton?: DButtonBaseOnOptions<VALUE, EMITTER>;\n}\n\n/**\n * {@link DButtonBase} theme.\n */\nexport interface DThemeButtonBase<VALUE = unknown> extends DThemeImageBase<VALUE> {\n\t/**\n\t * Returns true to turn a toggle mode on.\n\t */\n\tisToggle(): boolean;\n\n\t/**\n\t * Returns when to activate a button.\n\t */\n\tgetWhen(): DButtonBaseWhen;\n}\n\n/**\n * A base class for button classes.\n * See {@link DButtonBaseEvents} for event details.\n */\nexport class DButtonBase<\n\tVALUE = unknown,\n\tTHEME extends DThemeButtonBase<VALUE> = DThemeButtonBase<VALUE>,\n\tOPTIONS extends DButtonBaseOptions<VALUE, THEME> = DButtonBaseOptions<VALUE, THEME>\n> extends DImageBase<VALUE, THEME, OPTIONS> {\n\tprotected _isToggle?: boolean;\n\tprotected _isGrouped?: boolean;\n\tprotected _when?: DButtonBaseWhen;\n\n\tprotected init(options?: OPTIONS): void {\n\t\tsuper.init(options);\n\n\t\tconst theme = this.theme;\n\t\tthis._isToggle = options?.toggle ?? theme.isToggle();\n\t\tthis._when = toEnum(options?.when ?? theme.getWhen(), DButtonBaseWhen);\n\n\t\t// Event handlers\n\t\tthis.on(UtilPointerEvent.tap, (e: interaction.InteractionEvent): void => {\n\t\t\tthis.onClick(e);\n\t\t});\n\t\tthis.initOnPress();\n\n\t\t// Group\n\t\tconst group = options?.group;\n\t\tif (group) {\n\t\t\tgroup.add(this);\n\t\t}\n\t}\n\n\tprotected onShortcut(e: KeyboardEvent): void {\n\t\tif (this.state.isActionable) {\n\t\t\tthis.activate(e);\n\t\t}\n\t\tsuper.onShortcut(e);\n\t}\n\n\tget isToggle(): boolean {\n\t\treturn !!this._isToggle;\n\t}\n\n\tget isGrouped(): boolean {\n\t\treturn !!this._isGrouped;\n\t}\n\n\tset isGrouped(isGrouped: boolean) {\n\t\tthis._isGrouped = isGrouped;\n\t}\n\n\tprotected initOnPress(): void {\n\t\tlet interactionManager: interaction.InteractionManager | null = null;\n\n\t\tconst onUp = (): void => {\n\t\t\tthis.state.isPressed = false;\n\t\t\tif (interactionManager != null) {\n\t\t\t\tinteractionManager.off(UtilPointerEvent.up, onUp);\n\t\t\t\tinteractionManager.off(UtilPointerEvent.upoutside, onUp);\n\t\t\t\tinteractionManager.off(UtilPointerEvent.cancel, onUp);\n\t\t\t\tinteractionManager = null;\n\t\t\t}\n\t\t};\n\n\t\tthis.on(UtilPointerEvent.down, (): void => {\n\t\t\tthis.state.isPressed = true;\n\t\t\tconst layer = DApplications.getLayer(this);\n\t\t\tif (layer) {\n\t\t\t\tinteractionManager = layer.renderer.plugins.interaction;\n\t\t\t\tinteractionManager.on(UtilPointerEvent.up, onUp);\n\t\t\t\tinteractionManager.on(UtilPointerEvent.upoutside, onUp);\n\t\t\t\tinteractionManager.on(UtilPointerEvent.cancel, onUp);\n\t\t\t}\n\t\t});\n\t}\n\n\tprotected getType(): string {\n\t\treturn \"DButton\";\n\t}\n\n\tprotected onClick(e: interaction.InteractionEvent): void {\n\t\tif (this._when === DButtonBaseWhen.CLICKED && this.state.isActionable) {\n\t\t\tthis.activate(e);\n\t\t}\n\t}\n\n\tprotected onDblClick(\n\t\te: MouseEvent | TouchEvent,\n\t\tinteractionManager: interaction.InteractionManager\n\t): boolean {\n\t\tif (this._when === DButtonBaseWhen.DOUBLE_CLICKED && this.state.isActionable) {\n\t\t\tthis.activate(e);\n\t\t}\n\t\treturn super.onDblClick(e, interactionManager);\n\t}\n\n\tactivate(e?: interaction.InteractionEvent | KeyboardEvent | MouseEvent | TouchEvent): void {\n\t\tif (this._isToggle) {\n\t\t\tif (this._isGrouped) {\n\t\t\t\tif (!this.state.isActive) {\n\t\t\t\t\tthis.onToggleStart(e);\n\t\t\t\t\tthis.onToggleEnd(e);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.onToggleStart(e);\n\t\t\t\tthis.onToggleEnd(e);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.onActivate(e);\n\t\t}\n\t}\n\n\tprotected onActivate(\n\t\te?: interaction.InteractionEvent | KeyboardEvent | MouseEvent | TouchEvent\n\t): void {\n\t\tthis.emit(\"active\", this);\n\t}\n\n\tprotected onInactivate(\n\t\te?: interaction.InteractionEvent | KeyboardEvent | MouseEvent | TouchEvent\n\t): void {\n\t\tthis.emit(\"inactive\", this);\n\t}\n\n\ttoggle(): void {\n\t\tif (this.state.isActionable) {\n\t\t\tif (this._isToggle) {\n\t\t\t\tthis.onToggleStart();\n\t\t\t\tthis.onToggleEnd();\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected onToggleStart(\n\t\te?: interaction.InteractionEvent | KeyboardEvent | MouseEvent | TouchEvent\n\t): void {\n\t\tthis.state.isActive = !this.state.isActive;\n\t}\n\n\tprotected onToggleEnd(\n\t\te?: interaction.InteractionEvent | KeyboardEvent | MouseEvent | TouchEvent\n\t): void {\n\t\tif (this.state.isActive) {\n\t\t\tthis.onActivate(e);\n\t\t} else {\n\t\t\tthis.onInactivate(e);\n\t\t}\n\t}\n\n\tprotected onActivateKeyDown(e: KeyboardEvent): void {\n\t\tif (this.state.isActionable) {\n\t\t\tif (this._isToggle) {\n\t\t\t\tthis.onToggleStart(e);\n\t\t\t} else {\n\t\t\t\tthis.state.isPressed = true;\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected onActivateKeyUp(e: KeyboardEvent): void {\n\t\tif (this.state.isActionable) {\n\t\t\tif (this._isToggle) {\n\t\t\t\tthis.onToggleEnd(e);\n\t\t\t} else {\n\t\t\t\tif (this.state.isPressed) {\n\t\t\t\t\tthis.onActivate(e);\n\t\t\t\t}\n\t\t\t\tthis.state.isPressed = false;\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected onKeyDown(e: KeyboardEvent): boolean {\n\t\tif (UtilKeyboardEvent.isActivateKey(e)) {\n\t\t\tthis.onActivateKeyDown(e);\n\t\t}\n\n\t\treturn super.onKeyDown(e);\n\t}\n\n\tprotected onKeyUp(e: KeyboardEvent): boolean {\n\t\tif (UtilKeyboardEvent.isActivateKey(e)) {\n\t\t\tthis.onActivateKeyUp(e);\n\t\t}\n\n\t\treturn super.onKeyUp(e);\n\t}\n\n\tdestroy(): void {\n\t\tthis._options?.group?.remove(this);\n\t\tsuper.destroy();\n\t}\n}\n"]}
1
+ {"version":3,"file":"d-button-base.js","sourceRoot":"","sources":["../../../src/main/typescript/wcardinal/ui/d-button-base.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,UAAU,EAAwD,MAAM,gBAAgB,CAAC;AAElG,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAuF7D;;;GAGG;AACH;IAIU,+BAAiC;IAJ3C;;IAmNA,CAAC;IA1MU,0BAAI,GAAd,UAAe,OAAiB;QAAhC,iBAkBC;;QAj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ACvC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;SACxB;QAED,OAAO,iBAAM,OAAO,YAAC,CAAC,CAAC,CAAC;IACzB,CAAC;IAES,mCAAa,GAAvB,UAAwB,QAAuB,EAAE,QAAuB;QACvE,iBAAM,aAAa,YAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAExC,IAAI,QAAQ,CAAC,SAAS,EAAE;YACvB,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE;gBACxB,IAAI,CAAC,OAAO,EAAE,CAAC;aACf;SACD;aAAM,IAAI,QAAQ,CAAC,SAAS,EAAE;YAC9B,IAAI,CAAC,SAAS,EAAE,CAAC;SACjB;IACF,CAAC;IAES,6BAAO,GAAjB;QACC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC1B,CAAC;IAES,+BAAS,GAAnB;QACC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAC5B,CAAC;IAED,6BAAO,GAAP;;QACC,MAAA,MAAA,IAAI,CAAC,QAAQ,0CAAE,KAAK,0CAAE,MAAM,CAAC,IAAI,CAAC,CAAC;QACnC,iBAAM,OAAO,WAAE,CAAC;IACjB,CAAC;IACF,kBAAC;AAAD,CAAC,AAnND,CAIU,UAAU,GA+MnB","sourcesContent":["/*\n * Copyright (C) 2019 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { interaction } from \"pixi.js\";\nimport { DApplications } from \"./d-applications\";\nimport { DButtonBaseWhen } from \"./d-button-base-when\";\nimport { DButtonGroup } from \"./d-button-group\";\nimport { DImageBase, DImageBaseEvents, DImageBaseOptions, DThemeImageBase } from \"./d-image-base\";\nimport { DOnOptions } from \"./d-on-options\";\nimport { toEnum } from \"./util/to-enum\";\nimport { UtilKeyboardEvent } from \"./util/util-keyboard-event\";\nimport { UtilPointerEvent } from \"./util/util-pointer-event\";\nimport { DBaseStateSet } from \"./d-base-state-set\";\n\n/**\n * {@link DButtonBase} events.\n */\nexport interface DButtonBaseEvents<VALUE, EMITTER> extends DImageBaseEvents<VALUE, EMITTER> {\n\t/**\n\t * Triggered when the button is activated.\n\t *\n\t * @param emitter an emitter\n\t */\n\tactive(emitter: EMITTER): void;\n\n\t/**\n\t * Triggered when the button is inactivated.\n\t *\n\t * @param emitter an emitter\n\t */\n\tinactive(emitter: EMITTER): void;\n\n\t/**\n\t * Triggered when the button is pressed.\n\t *\n\t * @param emitter an emitter\n\t */\n\tpress(emitter: EMITTER): void;\n\n\t/**\n\t * Triggered when the button is released.\n\t *\n\t * @param emitter an emitter\n\t */\n\tunpress(emitter: EMITTER): void;\n}\n\n/**\n * {@link DButtonBase} \"on\" options.\n */\nexport interface DButtonBaseOnOptions<VALUE, EMITTER>\n\textends Partial<DButtonBaseEvents<VALUE, EMITTER>>,\n\t\tDOnOptions {}\n\n/**\n * {@link DButtonBase} options.\n */\nexport interface DButtonBaseOptions<\n\tVALUE = unknown,\n\tTHEME extends DThemeButtonBase<VALUE> = DThemeButtonBase<VALUE>,\n\tEMITTER = any\n> extends DImageBaseOptions<VALUE, THEME, EMITTER> {\n\t/**\n\t * True to turn a toggle mode on.\n\t */\n\ttoggle?: boolean;\n\n\t/**\n\t * A button group.\n\t */\n\tgroup?: DButtonGroup;\n\n\t/**\n\t * An option when to activate a button.\n\t */\n\twhen?: DButtonBaseWhen | keyof typeof DButtonBaseWhen;\n\n\t/**\n\t * Mappings of event names and handlers.\n\t */\n\ton?: DButtonBaseOnOptions<VALUE, EMITTER>;\n}\n\n/**\n * {@link DButtonBase} theme.\n */\nexport interface DThemeButtonBase<VALUE = unknown> extends DThemeImageBase<VALUE> {\n\t/**\n\t * Returns true to turn a toggle mode on.\n\t */\n\tisToggle(): boolean;\n\n\t/**\n\t * Returns when to activate a button.\n\t */\n\tgetWhen(): DButtonBaseWhen;\n}\n\n/**\n * A base class for button classes.\n * See {@link DButtonBaseEvents} for event details.\n */\nexport class DButtonBase<\n\tVALUE = unknown,\n\tTHEME extends DThemeButtonBase<VALUE> = DThemeButtonBase<VALUE>,\n\tOPTIONS extends DButtonBaseOptions<VALUE, THEME> = DButtonBaseOptions<VALUE, THEME>\n> extends DImageBase<VALUE, THEME, OPTIONS> {\n\tprotected _isToggle?: boolean;\n\tprotected _isGrouped?: boolean;\n\tprotected _when?: DButtonBaseWhen;\n\n\tprotected init(options?: OPTIONS): void {\n\t\tsuper.init(options);\n\n\t\tconst theme = this.theme;\n\t\tthis._isToggle = options?.toggle ?? theme.isToggle();\n\t\tthis._when = toEnum(options?.when ?? theme.getWhen(), DButtonBaseWhen);\n\n\t\t// Event handlers\n\t\tthis.on(UtilPointerEvent.tap, (e: interaction.InteractionEvent): void => {\n\t\t\tthis.onClick(e);\n\t\t});\n\t\tthis.initOnPress();\n\n\t\t// Group\n\t\tconst group = options?.group;\n\t\tif (group) {\n\t\t\tgroup.add(this);\n\t\t}\n\t}\n\n\tprotected onShortcut(e: KeyboardEvent): void {\n\t\tif (this.state.isActionable) {\n\t\t\tthis.activate(e);\n\t\t}\n\t\tsuper.onShortcut(e);\n\t}\n\n\tget isToggle(): boolean {\n\t\treturn !!this._isToggle;\n\t}\n\n\tget isGrouped(): boolean {\n\t\treturn !!this._isGrouped;\n\t}\n\n\tset isGrouped(isGrouped: boolean) {\n\t\tthis._isGrouped = isGrouped;\n\t}\n\n\tprotected initOnPress(): void {\n\t\tlet interactionManager: interaction.InteractionManager | null = null;\n\n\t\tconst onUp = (): void => {\n\t\t\tthis.state.isPressed = false;\n\t\t\tif (interactionManager != null) {\n\t\t\t\tinteractionManager.off(UtilPointerEvent.up, onUp);\n\t\t\t\tinteractionManager.off(UtilPointerEvent.upoutside, onUp);\n\t\t\t\tinteractionManager.off(UtilPointerEvent.cancel, onUp);\n\t\t\t\tinteractionManager = null;\n\t\t\t}\n\t\t};\n\n\t\tthis.on(UtilPointerEvent.down, (): void => {\n\t\t\tif (this.state.isActionable) {\n\t\t\t\tthis.state.isPressed = true;\n\t\t\t\tconst layer = DApplications.getLayer(this);\n\t\t\t\tif (layer) {\n\t\t\t\t\tinteractionManager = layer.renderer.plugins.interaction;\n\t\t\t\t\tinteractionManager.on(UtilPointerEvent.up, onUp);\n\t\t\t\t\tinteractionManager.on(UtilPointerEvent.upoutside, onUp);\n\t\t\t\t\tinteractionManager.on(UtilPointerEvent.cancel, onUp);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tprotected getType(): string {\n\t\treturn \"DButton\";\n\t}\n\n\tprotected onClick(e: interaction.InteractionEvent): void {\n\t\tif (this._when === DButtonBaseWhen.CLICKED && this.state.isActionable) {\n\t\t\tthis.activate(e);\n\t\t}\n\t}\n\n\tprotected onDblClick(\n\t\te: MouseEvent | TouchEvent,\n\t\tinteractionManager: interaction.InteractionManager\n\t): boolean {\n\t\tif (this._when === DButtonBaseWhen.DOUBLE_CLICKED && this.state.isActionable) {\n\t\t\tthis.activate(e);\n\t\t}\n\t\treturn super.onDblClick(e, interactionManager);\n\t}\n\n\tactivate(e?: interaction.InteractionEvent | KeyboardEvent | MouseEvent | TouchEvent): void {\n\t\tif (this._isToggle) {\n\t\t\tif (this._isGrouped) {\n\t\t\t\tif (!this.state.isActive) {\n\t\t\t\t\tthis.onToggleStart(e);\n\t\t\t\t\tthis.onToggleEnd(e);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.onToggleStart(e);\n\t\t\t\tthis.onToggleEnd(e);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.onActivate(e);\n\t\t}\n\t}\n\n\tprotected onActivate(\n\t\te?: interaction.InteractionEvent | KeyboardEvent | MouseEvent | TouchEvent\n\t): void {\n\t\tthis.emit(\"active\", this);\n\t}\n\n\tprotected onInactivate(\n\t\te?: interaction.InteractionEvent | KeyboardEvent | MouseEvent | TouchEvent\n\t): void {\n\t\tthis.emit(\"inactive\", this);\n\t}\n\n\ttoggle(): void {\n\t\tif (this.state.isActionable) {\n\t\t\tif (this._isToggle) {\n\t\t\t\tthis.onToggleStart();\n\t\t\t\tthis.onToggleEnd();\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected onToggleStart(\n\t\te?: interaction.InteractionEvent | KeyboardEvent | MouseEvent | TouchEvent\n\t): void {\n\t\tthis.state.isActive = !this.state.isActive;\n\t}\n\n\tprotected onToggleEnd(\n\t\te?: interaction.InteractionEvent | KeyboardEvent | MouseEvent | TouchEvent\n\t): void {\n\t\tif (this.state.isActive) {\n\t\t\tthis.onActivate(e);\n\t\t} else {\n\t\t\tthis.onInactivate(e);\n\t\t}\n\t}\n\n\tprotected onActivateKeyDown(e: KeyboardEvent): void {\n\t\tif (this.state.isActionable) {\n\t\t\tif (this._isToggle) {\n\t\t\t\tthis.onToggleStart(e);\n\t\t\t} else {\n\t\t\t\tthis.state.isPressed = true;\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected onActivateKeyUp(e: KeyboardEvent): void {\n\t\tif (this.state.isActionable) {\n\t\t\tif (this._isToggle) {\n\t\t\t\tthis.onToggleEnd(e);\n\t\t\t} else {\n\t\t\t\tif (this.state.isPressed) {\n\t\t\t\t\tthis.onActivate(e);\n\t\t\t\t}\n\t\t\t\tthis.state.isPressed = false;\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected onKeyDown(e: KeyboardEvent): boolean {\n\t\tif (UtilKeyboardEvent.isActivateKey(e)) {\n\t\t\tthis.onActivateKeyDown(e);\n\t\t}\n\n\t\treturn super.onKeyDown(e);\n\t}\n\n\tprotected onKeyUp(e: KeyboardEvent): boolean {\n\t\tif (UtilKeyboardEvent.isActivateKey(e)) {\n\t\t\tthis.onActivateKeyUp(e);\n\t\t}\n\n\t\treturn super.onKeyUp(e);\n\t}\n\n\tprotected onStateChange(newState: DBaseStateSet, oldState: DBaseStateSet): void {\n\t\tsuper.onStateChange(newState, oldState);\n\n\t\tif (newState.isPressed) {\n\t\t\tif (!oldState.isPressed) {\n\t\t\t\tthis.onPress();\n\t\t\t}\n\t\t} else if (oldState.isPressed) {\n\t\t\tthis.onUnpress();\n\t\t}\n\t}\n\n\tprotected onPress(): void {\n\t\tthis.emit(\"press\", this);\n\t}\n\n\tprotected onUnpress(): void {\n\t\tthis.emit(\"unpress\", this);\n\t}\n\n\tdestroy(): void {\n\t\tthis._options?.group?.remove(this);\n\t\tsuper.destroy();\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"d-diagram-serialized.js","sourceRoot":"","sources":["../../../src/main/typescript/wcardinal/ui/d-diagram-serialized.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAiBH,MAAM,CAAC,IAAM,yBAAyB,GAAW,CAAC,CAAC","sourcesContent":["/*\n * Copyright (C) 2019 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { DDiagramCanvasTileMapping } from \"./d-diagram-canvas-mapping\";\nimport { EShapeCorner } from \"./shape/e-shape-corner\";\nimport { EShapeStrokeSide } from \"./shape/e-shape-stroke-side\";\nimport { EShapeStrokeStyle } from \"./shape/e-shape-stroke-style\";\nimport { EShapeDataValueOrder } from \"./shape/e-shape-data-value-order\";\nimport { EShapeTextStyle, EShapeTextWeight } from \"./shape/e-shape-text\";\nimport { EShapeTextAlignHorizontal } from \"./shape/e-shape-text-align-horizontal\";\nimport { EShapeTextAlignVertical } from \"./shape/e-shape-text-align-vertical\";\nimport { EShapeTextDirection } from \"./shape/e-shape-text-direction\";\nimport { EShapeType } from \"./shape/e-shape-type\";\nimport { ESnapperTargetValueType } from \"./snapper/e-snapper-target-value\";\nimport { EShapeDataValueRangeType } from \"./shape/e-shape-data-value-range\";\nimport { EShapeDataValueType } from \"./shape/e-shape-data-value-type\";\nimport { EShapeDataValueScope } from \"./shape/e-shape-data-value-scope\";\n\nexport const DDiagramSerializedVersion: number = 1;\n\n/**\n * A serialized data range.\n */\nexport interface DDiagramSerializedDataRange {\n\t/** A type. */\n\t[0]: EShapeDataValueRangeType;\n\n\t/** A lower bound. */\n\t[1]: number;\n\n\t/** An upper bound. */\n\t[2]: number;\n}\n\n/**\n * A serialized data value.\n */\nexport interface DDiagramSerializedDataValue {\n\t/**\n\t * A resource index number of an ID.\n\t */\n\t[0]: number;\n\n\t/**\n\t * A resource index number of an initial value expression.\n\t */\n\t[1]: number;\n\n\t/**\n\t * A resource index number of a format expression.\n\t */\n\t[2]: number;\n\n\t/**\n\t * A resource index number of JSON.stringify(DDiagramSerializedDataRange).\n\t */\n\t[3]: number;\n\n\t/**\n\t * A capacity.\n\t */\n\t[4]: number;\n\n\t/**\n\t * A order.\n\t */\n\t[5]: EShapeDataValueOrder;\n\n\t/**\n\t * A type.\n\t */\n\t[6]: EShapeDataValueType | undefined;\n\n\t/**\n\t * A scope.\n\t */\n\t[7]: EShapeDataValueScope | undefined;\n\n\t/**\n\t * A resource index number of an alias.\n\t */\n\t[8]: number | undefined;\n}\n\n/**\n * A serialized system data.\n */\nexport type DDiagramSerializedDataSystem = number[];\n\n/**\n * A serialized data mapping.\n * Each number at the index 2N+0 is a resource index number of the N-th mapping source.\n * Each number at the index 2N+1 is a resource index number of the N-th mapping destination.\n */\nexport type DDiagramSerializedDataMapping = number[];\n\n/**\n * A serialized data with a mapping data.\n */\nexport interface DDiagramSerializedDataWithMapping extends Array<unknown> {\n\t/**\n\t * Each number is a resource index number of JSON.stringify(DDiagramSerializedDataValue).\n\t * The last number is a resource index number of JSON.stringify(DDiagramSerializedDataMapping).\n\t */\n\t[0]: number[];\n\n\t/**\n\t * A resource index number of JSON.stringify(DDiagramSerializedDataSystem).\n\t */\n\t[1]: number | undefined;\n}\n\n/**\n * A serialized data without a mapping data.\n * Each number is a resource index number of JSON.stringify(DDiagramSerializedDataValue).\n */\nexport type DDiagramSerializedDataWithoutMapping = number[];\n\n/**\n * A serialized data.\n */\nexport type DDiagramSerializedData =\n\t| DDiagramSerializedDataWithoutMapping\n\t| DDiagramSerializedDataWithMapping;\n\n/**\n * A serialized fill.\n */\nexport interface DDiagramSerializedFill {\n\t/** 0: Disabled, 1: Enabled */\n\t[0]: number;\n\n\t/** A color. */\n\t[1]: number;\n\n\t/** An alpha. */\n\t[2]: number;\n}\n\n/**\n * A serialized stroke.\n */\nexport interface DDiagramSerializedStroke {\n\t/** 0: Disabled, 1: Enabled */\n\t[0]: number;\n\n\t/** A color. */\n\t[1]: number;\n\n\t/** An alpha. */\n\t[2]: number;\n\n\t/** A width. */\n\t[3]: number;\n\n\t/** An align. */\n\t[4]: number;\n\n\t/** A side. */\n\t[5]: EShapeStrokeSide;\n\n\t/** A style */\n\t[6]: EShapeStrokeStyle | undefined;\n}\n\n/**\n * A serialized text outline.\n */\nexport interface DDiagramSerializedTextOutline {\n\t/** 0: Disabled, 1: Enabled */\n\t[0]: number;\n\n\t/** A color. */\n\t[1]: number;\n\n\t/** An alpha. */\n\t[2]: number;\n\n\t/** A width. */\n\t[3]: number;\n}\n\n/**\n * A serialized text align.\n */\nexport interface DDiagramSerializedTextAlign {\n\t/** A horizontal align. */\n\t[0]: EShapeTextAlignHorizontal;\n\n\t/** A vertical align. */\n\t[1]: EShapeTextAlignVertical;\n}\n\n/**\n * A serialized text offset.\n */\nexport interface DDiagramSerializedTextOffset {\n\t/** A horizontal offset. */\n\t[0]: number;\n\n\t/** A vertical offset. */\n\t[1]: number;\n}\n\n/**\n * A serialized text spacing.\n */\nexport interface DDiagramSerializedTextSpacing {\n\t/** A horizontal spacing. */\n\t[0]: number;\n\n\t/** A vertical spacing. */\n\t[1]: number;\n}\n\n/**\n * A serialized text padding.\n */\nexport interface DDiagramSerializedTextPadding {\n\t/** A horizontal padding. */\n\t[0]: number;\n\n\t/** A vertical padding. */\n\t[1]: number;\n}\n\n/**\n * A serialized text.\n */\nexport interface DDiagramSerializedText {\n\t/** A resource index number of a value. */\n\t[0]: number;\n\n\t/** A color. */\n\t[1]: number;\n\n\t/** An alpha. */\n\t[2]: number;\n\n\t/** A resource index number of a font family. */\n\t[3]: number;\n\n\t/** A size. */\n\t[4]: number;\n\n\t/** A weight. */\n\t[5]: EShapeTextWeight;\n\n\t/**\n\t * A resource index number of JSON.stringify(DDiagramSerializedTextAlign).\n\t */\n\t[6]: number;\n\n\t/**\n\t * A resource index number of JSON.stringify(DDiagramSerializedTextOffset).\n\t */\n\t[7]: number;\n\n\t/** A style. */\n\t[8]: EShapeTextStyle;\n\n\t/**\n\t * A resource index number of JSON.stringify(DDiagramSerializedTextOutline).\n\t */\n\t[9]: number;\n\n\t/**\n\t * A resource index number of JSON.stringify(DDiagramSerializedTextSpacing).\n\t */\n\t[10]: number;\n\n\t/** A direction. */\n\t[11]: EShapeTextDirection;\n\n\t/**\n\t * A resource index number of JSON.stringify(DDiagramSerializedTextPadding).\n\t */\n\t[12]: number;\n\n\t/** A clipping. (0: Off, 1: On) */\n\t[13]: number;\n}\n\n/**\n * A serialized item.\n */\nexport interface DDiagramSerializedItem {\n\t/** A type. */\n\t[0]: EShapeType;\n\n\t/** A resource index number of a ID. */\n\t[1]: number;\n\n\t/** A X-coordinate position. */\n\t[2]: number;\n\n\t/** A Y-coordinate position. */\n\t[3]: number;\n\n\t/** A width. */\n\t[4]: number;\n\n\t/** A height. */\n\t[5]: number;\n\n\t/** A rotation. */\n\t[6]: number;\n\n\t/** A skew. */\n\t[7]: number;\n\n\t/**\n\t * A resource index number of JSON.stringify(DDiagramSerializedFill).\n\t */\n\t[8]: number;\n\n\t/**\n\t * A resource index number of JSON.stringify(DDiagramSerializedStroke).\n\t */\n\t[9]: number;\n\n\t/** A resource index number of a cursor. */\n\t[10]: number;\n\n\t/**\n\t * A resource index number of JSON.stringify(DDiagramSerializedText).\n\t */\n\t[11]: number;\n\n\t/**\n\t * A resource index number of JSON.stringify(DDiagramSerializedData).\n\t */\n\t[12]: number;\n\n\t/** A radius. */\n\t[13]: number;\n\n\t/** A corner. */\n\t[14]: EShapeCorner;\n\n\t/** A resource index number of a shape-specific resource. */\n\t[15]: number;\n\n\t/** A layer index number. */\n\t[16]: number;\n\n\t/** Actions */\n\t[17]: number[];\n\n\t/** A resource index number of an image. */\n\t[18]: number;\n\n\t/**\n\t * A resource index number of a stringified serialized gradient.\n\t * A stringified serialized gradient is a stringified number array,\n\t * JSON.stringify(number[]).\n\t *\n\t * * The first number in the array is a direction in degree.\n\t * * Each number at the index 3N + 1 is a color of a N-th point.\n\t * * Each number at the index 3N + 2 is a alpha of a N-th point.\n\t * * Each number at the index 3N + 3 is a position of a N-th point whose range is [0, 1].\n\t */\n\t[19]: number;\n\n\t/** Children. */\n\t[20]: DDiagramSerializedItem[];\n\n\t/** A X pivot. */\n\t[21]: number;\n\n\t/** A Y pivot. */\n\t[22]: number;\n\n\t/** (interactive ? 1 : 0) | (unfocusable ? 2 : 0) */\n\t[23]: number;\n\n\t/** A resource index number of a shortcut. */\n\t[24]: number;\n\n\t/** A resource index number of a title. */\n\t[25]: number;\n\n\t/** UUID */\n\t[26]: number;\n\n\t/** Added capabilities */\n\t[27]: number;\n\n\t/** Removed capabilities */\n\t[28]: number;\n\n\t/** Locked capabilities */\n\t[29]: number;\n}\n\n/**\n * A serialized layer.\n */\nexport interface DDiagramSerializedLayer {\n\t/** A name or a resource index number of a name*/\n\t[0]: string | number;\n\n\t/**\n\t * A visibility.\n\t *\n\t * * 1st bit\n\t * * 0: Invisible when edit mode\n\t * * 1: Visible when edit mode\n\t * * 2nd bit\n\t * * 0: Invisible when non-edit mode\n\t * * 1: Visible when non-edit mode\n\t */\n\t[1]?: number;\n\n\t/** A X-coordinate position. */\n\t[2]?: number;\n\n\t/** A Y-coordinate position. */\n\t[3]?: number;\n\n\t/** A width. */\n\t[4]?: number;\n\n\t/** A height. */\n\t[5]?: number;\n\n\t/**\n\t * A resource index number of a stringified serialized fill,\n\t * JSON.stringify(DDiagramSerializedFill).\n\t */\n\t[6]?: number;\n\n\t/**\n\t * * 1st bit\n\t * * 0: Not interactive\n\t * * 1: Interactive\n\t * * 2nd bit\n\t * * 0: Not draggable\n\t * * 1: Draggable\n\t * * 3rd bit\n\t * * 0: Not pinchable\n\t * * 1: Pinchable\n\t */\n\t[7]?: number;\n}\n\n/**\n * A serialized snap target.\n */\nexport interface DDiagramSerializedSnapTargetValue {\n\t/** A type. */\n\t[0]: ESnapperTargetValueType;\n\n\t/** A position. */\n\t[1]: number;\n}\n\n/**\n * Serialized snap on guide settings.\n */\nexport interface DDiagramSerializedSnapTarget {\n\t/** Snap on guide (0: Off, 1: On) */\n\t[0]: number;\n\n\t/** A visibility (0: Invisible, 1: Visible). */\n\t[1]: number;\n\n\t/** Snap targets. */\n\t[2]: DDiagramSerializedSnapTargetValue[];\n}\n\n/**\n * Serialized grid snap settings without a visibility option.\n */\nexport interface DDiagramSerializedSnapGridWithoutVisibility {\n\t/** Snap on grid (0: Off, 1: On) */\n\t[0]: number;\n\n\t/** A grid size. */\n\t[1]: number;\n}\n\n/**\n * Serialized grid snap settings with a visibility option.\n */\nexport interface DDiagramSerializedSnapGridWithVisibility {\n\t/** Snap on grid (0: Off, 1: On) */\n\t[0]: number;\n\n\t/** A visibility (0: Invisible, 1: Visible). */\n\t[1]: number;\n\n\t/** A grid size. */\n\t[2]: number;\n}\n\n/**\n * Serialized grid snap settings with a visibility.\n */\nexport type DDiagramSerializedSnapGrid =\n\t| DDiagramSerializedSnapGridWithoutVisibility\n\t| DDiagramSerializedSnapGridWithVisibility;\n\n/**\n * Serialized snap settings.\n */\nexport interface DDiagramSerializedSnap {\n\t/** Snap (0: Off, 1: On). */\n\t[0]: number;\n\n\t/** Snap on targets */\n\t[1]: DDiagramSerializedSnapTarget;\n\n\t/** Snap on grid */\n\t[2]: DDiagramSerializedSnapGrid;\n}\n\n/**\n * Serialized background settings.\n */\nexport interface DDiagramSerializedBackground {\n\tcolor?: number | null;\n\talpha?: number;\n}\n\n/**\n * Serialized tile settings.\n */\nexport interface DDiagramSerializedTile {\n\tmapping?: DDiagramCanvasTileMapping;\n}\n\n/**\n * A serialized diagram.\n */\nexport interface DDiagramSerialized {\n\tversion: number;\n\tid?: number;\n\tname: string;\n\twidth: number;\n\theight: number;\n\tbackground?: DDiagramSerializedBackground;\n\ttile?: DDiagramSerializedTile;\n\tresources: string[];\n\t/** @deprecated in favor of {@link data} */\n\ttags?: string[];\n\tdata?: string[];\n\tpieces?: string[];\n\tlayers: DDiagramSerializedLayer[];\n\titems: DDiagramSerializedItem[];\n\tsnap?: DDiagramSerializedSnap;\n\tthumbnail?: string;\n}\n\nexport type DDiagramSerializedSimpleData = Omit<\n\tDDiagramSerialized,\n\t\"version\" | \"id\" | \"name\" | \"thumbnail\"\n>;\n\n/**\n * A simplified version of a serialized diagram.\n */\nexport interface DDiagramSerializedSimple {\n\tversion: number;\n\tid: number | undefined;\n\tname: string;\n\n\t/**\n\t * A stringified {@link DDiagramSerialized#data}.\n\t *\n\t * @deprecated in favor of {@link DDiagramSerializedSimpleData}.\n\t */\n\ttags?: string;\n\n\t/**\n\t * A stringified {@link DDiagramSerialized#pieces}.\n\t *\n\t * @deprecated in favor of {@link DDiagramSerializedSimpleData}.\n\t */\n\tpieces?: string;\n\n\t/**\n\t * Thumbnail data URL.\n\t */\n\tthumbnail?: string;\n\n\t/**\n\t * A stringified {@link DDiagramSerializedSimpleData}.\n\t */\n\tdata: string;\n}\n\nexport interface DDiagramSerializedName {\n\tid: number;\n\tname: string;\n}\n"]}
1
+ {"version":3,"file":"d-diagram-serialized.js","sourceRoot":"","sources":["../../../src/main/typescript/wcardinal/ui/d-diagram-serialized.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAiBH,MAAM,CAAC,IAAM,yBAAyB,GAAW,CAAC,CAAC","sourcesContent":["/*\n * Copyright (C) 2019 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { DDiagramCanvasTileMapping } from \"./d-diagram-canvas-mapping\";\nimport { EShapeCorner } from \"./shape/e-shape-corner\";\nimport { EShapeStrokeSide } from \"./shape/e-shape-stroke-side\";\nimport { EShapeStrokeStyle } from \"./shape/e-shape-stroke-style\";\nimport { EShapeDataValueOrder } from \"./shape/e-shape-data-value-order\";\nimport { EShapeTextStyle, EShapeTextWeight } from \"./shape/e-shape-text\";\nimport { EShapeTextAlignHorizontal } from \"./shape/e-shape-text-align-horizontal\";\nimport { EShapeTextAlignVertical } from \"./shape/e-shape-text-align-vertical\";\nimport { EShapeTextDirection } from \"./shape/e-shape-text-direction\";\nimport { EShapeType } from \"./shape/e-shape-type\";\nimport { ESnapperTargetValueType } from \"./snapper/e-snapper-target-value\";\nimport { EShapeDataValueRangeType } from \"./shape/e-shape-data-value-range\";\nimport { EShapeDataValueType } from \"./shape/e-shape-data-value-type\";\nimport { EShapeDataValueScope } from \"./shape/e-shape-data-value-scope\";\n\nexport const DDiagramSerializedVersion: number = 1;\n\n/**\n * A serialized data range.\n */\nexport interface DDiagramSerializedDataRange {\n\t/** A type. */\n\t[0]: EShapeDataValueRangeType;\n\n\t/** A lower bound. */\n\t[1]: number;\n\n\t/** An upper bound. */\n\t[2]: number;\n}\n\n/**\n * A serialized data value.\n */\nexport interface DDiagramSerializedDataValue {\n\t/**\n\t * A resource index number of an ID.\n\t */\n\t[0]: number;\n\n\t/**\n\t * A resource index number of an initial value expression.\n\t */\n\t[1]: number;\n\n\t/**\n\t * A resource index number of a format expression.\n\t */\n\t[2]: number;\n\n\t/**\n\t * A resource index number of JSON.stringify(DDiagramSerializedDataRange).\n\t */\n\t[3]: number;\n\n\t/**\n\t * A capacity.\n\t */\n\t[4]: number;\n\n\t/**\n\t * A order.\n\t */\n\t[5]: EShapeDataValueOrder;\n\n\t/**\n\t * A type.\n\t */\n\t[6]: EShapeDataValueType | undefined;\n\n\t/**\n\t * A scope.\n\t */\n\t[7]: EShapeDataValueScope | undefined;\n\n\t/**\n\t * A resource index number of an alias.\n\t */\n\t[8]: number | undefined;\n}\n\n/**\n * A serialized system data.\n */\nexport type DDiagramSerializedDataSystem = number[];\n\n/**\n * A serialized data mapping.\n * Each number at the index 2N+0 is a resource index number of the N-th mapping source.\n * Each number at the index 2N+1 is a resource index number of the N-th mapping destination.\n */\nexport type DDiagramSerializedDataMapping = number[];\n\n/**\n * A serialized data with a mapping data.\n */\nexport interface DDiagramSerializedDataWithMapping extends Array<unknown> {\n\t/**\n\t * Each number is a resource index number of JSON.stringify(DDiagramSerializedDataValue).\n\t * The last number is a resource index number of JSON.stringify(DDiagramSerializedDataMapping).\n\t */\n\t[0]: number[];\n\n\t/**\n\t * A resource index number of JSON.stringify(DDiagramSerializedDataSystem).\n\t */\n\t[1]: number | undefined;\n}\n\n/**\n * A serialized data without a mapping data.\n * Each number is a resource index number of JSON.stringify(DDiagramSerializedDataValue).\n */\nexport type DDiagramSerializedDataWithoutMapping = number[];\n\n/**\n * A serialized data.\n */\nexport type DDiagramSerializedData =\n\t| DDiagramSerializedDataWithoutMapping\n\t| DDiagramSerializedDataWithMapping;\n\n/**\n * A serialized fill.\n */\nexport interface DDiagramSerializedFill {\n\t/** 0: Disabled, 1: Enabled */\n\t[0]: number;\n\n\t/** A color. */\n\t[1]: number;\n\n\t/** An alpha. */\n\t[2]: number;\n}\n\n/**\n * A serialized stroke.\n */\nexport interface DDiagramSerializedStroke {\n\t/** 0: Disabled, 1: Enabled */\n\t[0]: number;\n\n\t/** A color. */\n\t[1]: number;\n\n\t/** An alpha. */\n\t[2]: number;\n\n\t/** A width. */\n\t[3]: number;\n\n\t/** An align. */\n\t[4]: number;\n\n\t/** A side. */\n\t[5]: EShapeStrokeSide;\n\n\t/** A style */\n\t[6]: EShapeStrokeStyle | undefined;\n}\n\n/**\n * A serialized text outline.\n */\nexport interface DDiagramSerializedTextOutline {\n\t/** 0: Disabled, 1: Enabled */\n\t[0]: number;\n\n\t/** A color. */\n\t[1]: number;\n\n\t/** An alpha. */\n\t[2]: number;\n\n\t/** A width. */\n\t[3]: number;\n}\n\n/**\n * A serialized text align.\n */\nexport interface DDiagramSerializedTextAlign {\n\t/** A horizontal align. */\n\t[0]: EShapeTextAlignHorizontal;\n\n\t/** A vertical align. */\n\t[1]: EShapeTextAlignVertical;\n}\n\n/**\n * A serialized text offset.\n */\nexport interface DDiagramSerializedTextOffset {\n\t/** A horizontal offset. */\n\t[0]: number;\n\n\t/** A vertical offset. */\n\t[1]: number;\n}\n\n/**\n * A serialized text spacing.\n */\nexport interface DDiagramSerializedTextSpacing {\n\t/** A horizontal spacing. */\n\t[0]: number;\n\n\t/** A vertical spacing. */\n\t[1]: number;\n}\n\n/**\n * A serialized text padding.\n */\nexport interface DDiagramSerializedTextPadding {\n\t/** A horizontal padding. */\n\t[0]: number;\n\n\t/** A vertical padding. */\n\t[1]: number;\n}\n\n/**\n * A serialized text.\n */\nexport interface DDiagramSerializedText {\n\t/** A resource index number of a value. */\n\t[0]: number;\n\n\t/** A color. */\n\t[1]: number;\n\n\t/** An alpha. */\n\t[2]: number;\n\n\t/** A resource index number of a font family. */\n\t[3]: number;\n\n\t/** A size. */\n\t[4]: number;\n\n\t/** A weight. */\n\t[5]: EShapeTextWeight;\n\n\t/**\n\t * A resource index number of JSON.stringify(DDiagramSerializedTextAlign).\n\t */\n\t[6]: number;\n\n\t/**\n\t * A resource index number of JSON.stringify(DDiagramSerializedTextOffset).\n\t */\n\t[7]: number;\n\n\t/** A style. */\n\t[8]: EShapeTextStyle;\n\n\t/**\n\t * A resource index number of JSON.stringify(DDiagramSerializedTextOutline).\n\t */\n\t[9]: number;\n\n\t/**\n\t * A resource index number of JSON.stringify(DDiagramSerializedTextSpacing).\n\t */\n\t[10]: number;\n\n\t/** A direction. */\n\t[11]: EShapeTextDirection;\n\n\t/**\n\t * A resource index number of JSON.stringify(DDiagramSerializedTextPadding).\n\t */\n\t[12]: number;\n\n\t/** A clipping. (0: Off, 1: On) */\n\t[13]: number;\n\n\t/** A fitting. (0: Off, 1: On) */\n\t[14]: number;\n}\n\n/**\n * A serialized item.\n */\nexport interface DDiagramSerializedItem {\n\t/** A type. */\n\t[0]: EShapeType;\n\n\t/** A resource index number of a ID. */\n\t[1]: number;\n\n\t/** A X-coordinate position. */\n\t[2]: number;\n\n\t/** A Y-coordinate position. */\n\t[3]: number;\n\n\t/** A width. */\n\t[4]: number;\n\n\t/** A height. */\n\t[5]: number;\n\n\t/** A rotation. */\n\t[6]: number;\n\n\t/** A skew. */\n\t[7]: number;\n\n\t/**\n\t * A resource index number of JSON.stringify(DDiagramSerializedFill).\n\t */\n\t[8]: number;\n\n\t/**\n\t * A resource index number of JSON.stringify(DDiagramSerializedStroke).\n\t */\n\t[9]: number;\n\n\t/** A resource index number of a cursor. */\n\t[10]: number;\n\n\t/**\n\t * A resource index number of JSON.stringify(DDiagramSerializedText).\n\t */\n\t[11]: number;\n\n\t/**\n\t * A resource index number of JSON.stringify(DDiagramSerializedData).\n\t */\n\t[12]: number;\n\n\t/** A radius. */\n\t[13]: number;\n\n\t/** A corner. */\n\t[14]: EShapeCorner;\n\n\t/** A resource index number of a shape-specific resource. */\n\t[15]: number;\n\n\t/** A layer index number. */\n\t[16]: number;\n\n\t/** Actions */\n\t[17]: number[];\n\n\t/** A resource index number of an image. */\n\t[18]: number;\n\n\t/**\n\t * A resource index number of a stringified serialized gradient.\n\t * A stringified serialized gradient is a stringified number array,\n\t * JSON.stringify(number[]).\n\t *\n\t * * The first number in the array is a direction in degree.\n\t * * Each number at the index 3N + 1 is a color of a N-th point.\n\t * * Each number at the index 3N + 2 is a alpha of a N-th point.\n\t * * Each number at the index 3N + 3 is a position of a N-th point whose range is [0, 1].\n\t */\n\t[19]: number;\n\n\t/** Children. */\n\t[20]: DDiagramSerializedItem[];\n\n\t/** A X pivot. */\n\t[21]: number;\n\n\t/** A Y pivot. */\n\t[22]: number;\n\n\t/** (interactive ? 1 : 0) | (unfocusable ? 2 : 0) */\n\t[23]: number;\n\n\t/** A resource index number of a shortcut. */\n\t[24]: number;\n\n\t/** A resource index number of a title. */\n\t[25]: number;\n\n\t/** UUID */\n\t[26]: number;\n\n\t/** Added capabilities */\n\t[27]: number;\n\n\t/** Removed capabilities */\n\t[28]: number;\n\n\t/** Locked capabilities */\n\t[29]: number;\n}\n\n/**\n * A serialized layer.\n */\nexport interface DDiagramSerializedLayer {\n\t/** A name or a resource index number of a name*/\n\t[0]: string | number;\n\n\t/**\n\t * A visibility.\n\t *\n\t * * 1st bit\n\t * * 0: Invisible when edit mode\n\t * * 1: Visible when edit mode\n\t * * 2nd bit\n\t * * 0: Invisible when non-edit mode\n\t * * 1: Visible when non-edit mode\n\t */\n\t[1]?: number;\n\n\t/** A X-coordinate position. */\n\t[2]?: number;\n\n\t/** A Y-coordinate position. */\n\t[3]?: number;\n\n\t/** A width. */\n\t[4]?: number;\n\n\t/** A height. */\n\t[5]?: number;\n\n\t/**\n\t * A resource index number of a stringified serialized fill,\n\t * JSON.stringify(DDiagramSerializedFill).\n\t */\n\t[6]?: number;\n\n\t/**\n\t * * 1st bit\n\t * * 0: Not interactive\n\t * * 1: Interactive\n\t * * 2nd bit\n\t * * 0: Not draggable\n\t * * 1: Draggable\n\t * * 3rd bit\n\t * * 0: Not pinchable\n\t * * 1: Pinchable\n\t */\n\t[7]?: number;\n}\n\n/**\n * A serialized snap target.\n */\nexport interface DDiagramSerializedSnapTargetValue {\n\t/** A type. */\n\t[0]: ESnapperTargetValueType;\n\n\t/** A position. */\n\t[1]: number;\n}\n\n/**\n * Serialized snap on guide settings.\n */\nexport interface DDiagramSerializedSnapTarget {\n\t/** Snap on guide (0: Off, 1: On) */\n\t[0]: number;\n\n\t/** A visibility (0: Invisible, 1: Visible). */\n\t[1]: number;\n\n\t/** Snap targets. */\n\t[2]: DDiagramSerializedSnapTargetValue[];\n}\n\n/**\n * Serialized grid snap settings without a visibility option.\n */\nexport interface DDiagramSerializedSnapGridWithoutVisibility {\n\t/** Snap on grid (0: Off, 1: On) */\n\t[0]: number;\n\n\t/** A grid size. */\n\t[1]: number;\n}\n\n/**\n * Serialized grid snap settings with a visibility option.\n */\nexport interface DDiagramSerializedSnapGridWithVisibility {\n\t/** Snap on grid (0: Off, 1: On) */\n\t[0]: number;\n\n\t/** A visibility (0: Invisible, 1: Visible). */\n\t[1]: number;\n\n\t/** A grid size. */\n\t[2]: number;\n}\n\n/**\n * Serialized grid snap settings with a visibility.\n */\nexport type DDiagramSerializedSnapGrid =\n\t| DDiagramSerializedSnapGridWithoutVisibility\n\t| DDiagramSerializedSnapGridWithVisibility;\n\n/**\n * Serialized snap settings.\n */\nexport interface DDiagramSerializedSnap {\n\t/** Snap (0: Off, 1: On). */\n\t[0]: number;\n\n\t/** Snap on targets */\n\t[1]: DDiagramSerializedSnapTarget;\n\n\t/** Snap on grid */\n\t[2]: DDiagramSerializedSnapGrid;\n}\n\n/**\n * Serialized background settings.\n */\nexport interface DDiagramSerializedBackground {\n\tcolor?: number | null;\n\talpha?: number;\n}\n\n/**\n * Serialized tile settings.\n */\nexport interface DDiagramSerializedTile {\n\tmapping?: DDiagramCanvasTileMapping;\n}\n\n/**\n * A serialized diagram.\n */\nexport interface DDiagramSerialized {\n\tversion: number;\n\tid?: number;\n\tname: string;\n\twidth: number;\n\theight: number;\n\tbackground?: DDiagramSerializedBackground;\n\ttile?: DDiagramSerializedTile;\n\tresources: string[];\n\t/** @deprecated in favor of {@link data} */\n\ttags?: string[];\n\tdata?: string[];\n\tpieces?: string[];\n\tlayers: DDiagramSerializedLayer[];\n\titems: DDiagramSerializedItem[];\n\tsnap?: DDiagramSerializedSnap;\n\tthumbnail?: string;\n}\n\nexport type DDiagramSerializedSimpleData = Omit<\n\tDDiagramSerialized,\n\t\"version\" | \"id\" | \"name\" | \"thumbnail\"\n>;\n\n/**\n * A simplified version of a serialized diagram.\n */\nexport interface DDiagramSerializedSimple {\n\tversion: number;\n\tid: number | undefined;\n\tname: string;\n\n\t/**\n\t * A stringified {@link DDiagramSerialized#data}.\n\t *\n\t * @deprecated in favor of {@link DDiagramSerializedSimpleData}.\n\t */\n\ttags?: string;\n\n\t/**\n\t * A stringified {@link DDiagramSerialized#pieces}.\n\t *\n\t * @deprecated in favor of {@link DDiagramSerializedSimpleData}.\n\t */\n\tpieces?: string;\n\n\t/**\n\t * Thumbnail data URL.\n\t */\n\tthumbnail?: string;\n\n\t/**\n\t * A stringified {@link DDiagramSerializedSimpleData}.\n\t */\n\tdata: string;\n}\n\nexport interface DDiagramSerializedName {\n\tid: number;\n\tname: string;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"e-shape-text.js","sourceRoot":"","sources":["../../../../src/main/typescript/wcardinal/ui/shape/e-shape-text.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAWH,MAAM,CAAC,IAAM,gBAAgB,GAAG;IAC/B,MAAM,EAAE,CAAC;IACT,IAAI,EAAE,CAAC;CACE,CAAC;AAIX,MAAM,CAAC,IAAM,eAAe,GAAG;IAC9B,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,CAAC;CACA,CAAC","sourcesContent":["/*\n * Copyright (C) 2019 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { Texture } from \"pixi.js\";\nimport { DeepPartial } from \"../util/deep-partial\";\nimport { EShapeResourceManagerDeserialization } from \"./e-shape-resource-manager-deserialization\";\nimport { EShapeResourceManagerSerialization } from \"./e-shape-resource-manager-serialization\";\nimport { EShapeTextAlign, EShapeTextAlignLike } from \"./e-shape-text-align\";\nimport { EShapeTextDirection } from \"./e-shape-text-direction\";\nimport { EShapeTextOffset, EShapeTextOffsetLike } from \"./e-shape-text-offset\";\nimport { EShapeTextOutline, EShapeTextOutlineLike } from \"./e-shape-text-outline\";\n\nexport const EShapeTextWeight = {\n\tNORMAL: 0,\n\tBOLD: 1\n} as const;\n\nexport type EShapeTextWeight = typeof EShapeTextWeight[keyof typeof EShapeTextWeight];\n\nexport const EShapeTextStyle = {\n\tNORMAL: 0,\n\tITALIC: 1\n} as const;\n\nexport type EShapeTextStyle = typeof EShapeTextStyle[keyof typeof EShapeTextStyle];\n\nexport interface EShapeTextLike {\n\tvalue: string;\n\tcolor: number;\n\talpha: number;\n\tfamily: string;\n\tsize: number;\n\tweight: EShapeTextWeight;\n\talign: EShapeTextAlignLike;\n\toffset: EShapeTextOffsetLike;\n\tstyle: EShapeTextStyle;\n\toutline: EShapeTextOutlineLike;\n\tspacing: EShapeTextOffsetLike;\n\tdirection: EShapeTextDirection;\n\tpadding: EShapeTextOffsetLike;\n\tclipping: boolean;\n}\n\nexport interface EShapeTextAtlasCharacter {\n\tx: number;\n\ty: number;\n\twidth: number;\n\theight: number;\n\tadvance: number;\n\torigin: {\n\t\tx: number;\n\t\ty: number;\n\t};\n}\n\nexport type EShapeTextAtlasCharacters = Record<string, EShapeTextAtlasCharacter>;\n\nexport interface EShapeTextAtlas {\n\twidth: number;\n\theight: number;\n\tfont: {\n\t\tsize: number;\n\t};\n\tcharacters: EShapeTextAtlasCharacters;\n}\n\nexport interface EShapeText extends EShapeTextLike {\n\tenable: boolean;\n\n\talign: EShapeTextAlign;\n\toffset: EShapeTextOffset;\n\toutline: EShapeTextOutline;\n\tspacing: EShapeTextOffset;\n\tpadding: EShapeTextOffset;\n\n\ttexture?: Texture; // Used for rendering and updated when rendered\n\tatlas?: EShapeTextAtlas; // Used for rendering and updated when rendered\n\tworld?: number[]; // Updated when rendered\n\n\tcopy(target?: DeepPartial<EShapeTextLike>): this;\n\tset(\n\t\tvalue?: string,\n\t\tcolor?: number,\n\t\talpha?: number,\n\t\tfamily?: string,\n\t\tsize?: number,\n\t\tweight?: EShapeTextWeight,\n\t\tstyle?: EShapeTextStyle,\n\t\tdirection?: EShapeTextDirection,\n\t\tclipping?: boolean\n\t): this;\n\ttoObject(): EShapeTextLike;\n\tserialize(manager: EShapeResourceManagerSerialization): number;\n\tdeserialize(target: number, manager: EShapeResourceManagerDeserialization): void;\n}\n"]}
1
+ {"version":3,"file":"e-shape-text.js","sourceRoot":"","sources":["../../../../src/main/typescript/wcardinal/ui/shape/e-shape-text.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAWH,MAAM,CAAC,IAAM,gBAAgB,GAAG;IAC/B,MAAM,EAAE,CAAC;IACT,IAAI,EAAE,CAAC;CACE,CAAC;AAIX,MAAM,CAAC,IAAM,eAAe,GAAG;IAC9B,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,CAAC;CACA,CAAC","sourcesContent":["/*\n * Copyright (C) 2019 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { Texture } from \"pixi.js\";\nimport { DeepPartial } from \"../util/deep-partial\";\nimport { EShapeResourceManagerDeserialization } from \"./e-shape-resource-manager-deserialization\";\nimport { EShapeResourceManagerSerialization } from \"./e-shape-resource-manager-serialization\";\nimport { EShapeTextAlign, EShapeTextAlignLike } from \"./e-shape-text-align\";\nimport { EShapeTextDirection } from \"./e-shape-text-direction\";\nimport { EShapeTextOffset, EShapeTextOffsetLike } from \"./e-shape-text-offset\";\nimport { EShapeTextOutline, EShapeTextOutlineLike } from \"./e-shape-text-outline\";\n\nexport const EShapeTextWeight = {\n\tNORMAL: 0,\n\tBOLD: 1\n} as const;\n\nexport type EShapeTextWeight = typeof EShapeTextWeight[keyof typeof EShapeTextWeight];\n\nexport const EShapeTextStyle = {\n\tNORMAL: 0,\n\tITALIC: 1\n} as const;\n\nexport type EShapeTextStyle = typeof EShapeTextStyle[keyof typeof EShapeTextStyle];\n\nexport interface EShapeTextLike {\n\tvalue: string;\n\tcolor: number;\n\talpha: number;\n\tfamily: string;\n\tsize: number;\n\tweight: EShapeTextWeight;\n\talign: EShapeTextAlignLike;\n\toffset: EShapeTextOffsetLike;\n\tstyle: EShapeTextStyle;\n\toutline: EShapeTextOutlineLike;\n\tspacing: EShapeTextOffsetLike;\n\tdirection: EShapeTextDirection;\n\tpadding: EShapeTextOffsetLike;\n\tclipping: boolean;\n\tfitting: boolean;\n}\n\nexport interface EShapeTextAtlasCharacter {\n\tx: number;\n\ty: number;\n\twidth: number;\n\theight: number;\n\tadvance: number;\n\torigin: {\n\t\tx: number;\n\t\ty: number;\n\t};\n}\n\nexport type EShapeTextAtlasCharacters = Record<string, EShapeTextAtlasCharacter>;\n\nexport interface EShapeTextAtlas {\n\twidth: number;\n\theight: number;\n\tfont: {\n\t\tsize: number;\n\t};\n\tcharacters: EShapeTextAtlasCharacters;\n}\n\nexport interface EShapeText extends EShapeTextLike {\n\tenable: boolean;\n\n\talign: EShapeTextAlign;\n\toffset: EShapeTextOffset;\n\toutline: EShapeTextOutline;\n\tspacing: EShapeTextOffset;\n\tpadding: EShapeTextOffset;\n\n\ttexture?: Texture; // Used for rendering and updated when rendered\n\tatlas?: EShapeTextAtlas; // Used for rendering and updated when rendered\n\tworld?: number[]; // Updated when rendered\n\n\tcopy(target?: DeepPartial<EShapeTextLike>): this;\n\tset(\n\t\tvalue?: string,\n\t\tcolor?: number,\n\t\talpha?: number,\n\t\tfamily?: string,\n\t\tsize?: number,\n\t\tweight?: EShapeTextWeight,\n\t\tstyle?: EShapeTextStyle,\n\t\tdirection?: EShapeTextDirection,\n\t\tclipping?: boolean,\n\t\tfitting?: boolean\n\t): this;\n\ttoObject(): EShapeTextLike;\n\tserialize(manager: EShapeResourceManagerSerialization): number;\n\tdeserialize(target: number, manager: EShapeResourceManagerDeserialization): void;\n}\n"]}
@@ -358,7 +358,7 @@ var invertAlignVertical = function (align) {
358
358
  return EShapeTextAlignVertical.OUTSIDE_TOP;
359
359
  }
360
360
  };
361
- export var buildTextVertex = function (vertices, uvs, voffset, vcount, originX, originY, sizeX, sizeY, textAtlas, textSize, textValue, textStyle, textAlignHorizontal, textAlignVertical, textOffsetHorizontal, textOffsetVertical, textSpacingHorizontal, textSpacingVertical, textDirection, textPaddingHorizontal, textPaddingVertical, textClipping, textWorld, textureUvs, internalTransform) {
361
+ export var buildTextVertex = function (vertices, uvs, voffset, vcount, originX, originY, sizeX, sizeY, textAtlas, textSize, textValue, textStyle, textAlignHorizontal, textAlignVertical, textOffsetHorizontal, textOffsetVertical, textSpacingHorizontal, textSpacingVertical, textDirection, textPaddingHorizontal, textPaddingVertical, textClipping, textFitting, textWorld, textureUvs, internalTransform) {
362
362
  // Calculate the transformed positions
363
363
  //
364
364
  // 0 1
@@ -448,6 +448,7 @@ export var buildTextVertex = function (vertices, uvs, voffset, vcount, originX,
448
448
  var textSizeY = textSize * vnl;
449
449
  var lineHeight = Math.max(0, textSize + textSpacingVertical) * vnl;
450
450
  var lineWidth = 0;
451
+ var lineCount = 1;
451
452
  var textAtlasCharacters = textAtlas.characters;
452
453
  var iterator = UtilCharacterIterator.from(textValue);
453
454
  var advancePrevious = 0;
@@ -472,16 +473,41 @@ export var buildTextVertex = function (vertices, uvs, voffset, vcount, originX,
472
473
  width = Math.max(width, lineWidth);
473
474
  lineWidth = 0;
474
475
  height += lineHeight;
476
+ lineCount += 1;
475
477
  }
476
478
  }
479
+ lineWidth += advancePrevious;
480
+ width = Math.max(width, lineWidth);
481
+ height += textSizeY;
482
+ lineWidth = 0;
483
+ if (textFitting && isIn(textAlignHorizontal, textAlignVertical)) {
484
+ var w0 = 0;
485
+ var h0 = 0;
486
+ switch (textDirection) {
487
+ case EShapeTextDirection.LEFT_TO_RIGHT:
488
+ case EShapeTextDirection.RIGHT_TO_LEFT:
489
+ w0 = Math.max(0, hl - textPaddingHorizontal * 2);
490
+ h0 = Math.max(0, vl - textPaddingVertical * 2);
491
+ break;
492
+ case EShapeTextDirection.TOP_TO_BOTTOM:
493
+ case EShapeTextDirection.BOTTOM_TO_TOP:
494
+ w0 = Math.max(0, vl - textPaddingVertical * 2);
495
+ h0 = Math.max(0, hl - textPaddingHorizontal * 2);
496
+ break;
497
+ }
498
+ var w1 = width * hnl * (textSize / textAtlas.font.size);
499
+ var h1 = height;
500
+ var s = Math.min(1, Math.min(w0 / w1, h0 / h1));
501
+ textSize *= s;
502
+ textSizeY *= s;
503
+ lineHeight *= s;
504
+ height *= s;
505
+ }
477
506
  var scaleZ = textSize / textAtlas.font.size;
478
507
  var scaleX = hnl * scaleZ;
479
508
  var scaleY = vnl * scaleZ;
480
- lineWidth += advancePrevious;
481
- width = Math.max(width, lineWidth) * scaleX;
482
- lineWidth = 0;
509
+ width *= scaleX;
483
510
  heightChar *= scaleY;
484
- height += textSizeY;
485
511
  //
486
512
  var tx0 = 0;
487
513
  var ty0 = 0;
@@ -491,80 +517,32 @@ export var buildTextVertex = function (vertices, uvs, voffset, vcount, originX,
491
517
  getTextBBox(textAlignHorizontal, textAlignVertical, textOffsetHorizontal, textOffsetVertical, textPaddingHorizontal, textPaddingVertical, width, height, x0, y0, x1, y1, x2, y2, x3, y3, hnx, hny, vnx, vny, work);
492
518
  tx0 = work.x;
493
519
  ty0 = work.y;
494
- if (textClipping) {
495
- switch (textAlignHorizontal) {
496
- case EShapeTextAlignHorizontal.LEFT:
497
- case EShapeTextAlignHorizontal.CENTER:
498
- case EShapeTextAlignHorizontal.RIGHT:
499
- switch (textAlignVertical) {
500
- case EShapeTextAlignVertical.TOP:
501
- case EShapeTextAlignVertical.MIDDLE:
502
- case EShapeTextAlignVertical.BOTTOM:
503
- lineWidthMaximum = hl - textPaddingHorizontal * 2;
504
- break;
505
- }
506
- break;
507
- }
520
+ if (textClipping && isIn(textAlignHorizontal, textAlignVertical)) {
521
+ lineWidthMaximum = hl - textPaddingHorizontal * 2;
508
522
  }
509
523
  break;
510
524
  case EShapeTextDirection.TOP_TO_BOTTOM:
511
525
  getTextBBox(rotateAlignVerticalRight(textAlignVertical), rotateAlignHorizontalRight(textAlignHorizontal), textOffsetVertical, textOffsetHorizontal, textPaddingVertical, textPaddingHorizontal, width, height, x1, y1, x2, y2, x3, y3, x0, y0, hnx, hny, vnx, vny, work);
512
526
  tx0 = work.x;
513
527
  ty0 = work.y;
514
- if (textClipping) {
515
- switch (textAlignVertical) {
516
- case EShapeTextAlignVertical.TOP:
517
- case EShapeTextAlignVertical.MIDDLE:
518
- case EShapeTextAlignVertical.BOTTOM:
519
- switch (textAlignHorizontal) {
520
- case EShapeTextAlignHorizontal.LEFT:
521
- case EShapeTextAlignHorizontal.CENTER:
522
- case EShapeTextAlignHorizontal.RIGHT:
523
- lineWidthMaximum = vl - textPaddingVertical * 2;
524
- break;
525
- }
526
- break;
527
- }
528
+ if (textClipping && isIn(textAlignHorizontal, textAlignVertical)) {
529
+ lineWidthMaximum = vl - textPaddingVertical * 2;
528
530
  }
529
531
  break;
530
532
  case EShapeTextDirection.BOTTOM_TO_TOP:
531
533
  getTextBBox(rotateAlignVerticalLeft(textAlignVertical), rotateAlignHorizontalLeft(textAlignHorizontal), textOffsetVertical, textOffsetHorizontal, textPaddingVertical, textPaddingHorizontal, width, height, x3, y3, x0, y0, x1, y1, x2, y2, hnx, hny, vnx, vny, work);
532
534
  tx0 = work.x;
533
535
  ty0 = work.y;
534
- if (textClipping) {
535
- switch (textAlignVertical) {
536
- case EShapeTextAlignVertical.TOP:
537
- case EShapeTextAlignVertical.MIDDLE:
538
- case EShapeTextAlignVertical.BOTTOM:
539
- switch (textAlignHorizontal) {
540
- case EShapeTextAlignHorizontal.LEFT:
541
- case EShapeTextAlignHorizontal.CENTER:
542
- case EShapeTextAlignHorizontal.RIGHT:
543
- lineWidthMaximum = vl - textPaddingVertical * 2;
544
- break;
545
- }
546
- break;
547
- }
536
+ if (textClipping && isIn(textAlignHorizontal, textAlignVertical)) {
537
+ lineWidthMaximum = vl - textPaddingVertical * 2;
548
538
  }
549
539
  break;
550
540
  case EShapeTextDirection.RIGHT_TO_LEFT:
551
541
  getTextBBox(invertAlignHorizontal(textAlignHorizontal), invertAlignVertical(textAlignVertical), textOffsetHorizontal, textOffsetVertical, textPaddingHorizontal, textPaddingVertical, width, height, x2, y2, x3, y3, x0, y0, x1, y1, hnx, hny, vnx, vny, work);
552
542
  tx0 = work.x;
553
543
  ty0 = work.y;
554
- if (textClipping) {
555
- switch (textAlignHorizontal) {
556
- case EShapeTextAlignHorizontal.LEFT:
557
- case EShapeTextAlignHorizontal.CENTER:
558
- case EShapeTextAlignHorizontal.RIGHT:
559
- switch (textAlignVertical) {
560
- case EShapeTextAlignVertical.TOP:
561
- case EShapeTextAlignVertical.MIDDLE:
562
- case EShapeTextAlignVertical.BOTTOM:
563
- lineWidthMaximum = hl - textPaddingHorizontal * 2;
564
- break;
565
- }
566
- break;
567
- }
544
+ if (textClipping && isIn(textAlignHorizontal, textAlignVertical)) {
545
+ lineWidthMaximum = hl - textPaddingHorizontal * 2;
568
546
  }
569
547
  break;
570
548
  }
@@ -625,7 +603,7 @@ export var buildTextVertex = function (vertices, uvs, voffset, vcount, originX,
625
603
  lineWidth = 0;
626
604
  advancePrevious = 0;
627
605
  iterator.position = 0;
628
- var lineCount = 0;
606
+ lineCount = 0;
629
607
  var iv = voffset * 2;
630
608
  for (; iterator.hasNext(); iv += 8) {
631
609
  var character = iterator.next();
@@ -713,6 +691,22 @@ export var buildTextVertex = function (vertices, uvs, voffset, vcount, originX,
713
691
  uvs[iv + 1] = uvy0;
714
692
  }
715
693
  };
694
+ var isIn = function (textAlignHorizontal, textAlignVertical) {
695
+ switch (textAlignHorizontal) {
696
+ case EShapeTextAlignHorizontal.LEFT:
697
+ case EShapeTextAlignHorizontal.CENTER:
698
+ case EShapeTextAlignHorizontal.RIGHT:
699
+ switch (textAlignVertical) {
700
+ case EShapeTextAlignVertical.TOP:
701
+ case EShapeTextAlignVertical.MIDDLE:
702
+ case EShapeTextAlignVertical.BOTTOM:
703
+ return true;
704
+ break;
705
+ }
706
+ break;
707
+ }
708
+ return false;
709
+ };
716
710
  var writeCharacterEmpty = function (vertices, uvs, iv, cx0, cy0, cx3, cy3, uvx0, uvy0, uvx3, uvy3) {
717
711
  vertices[iv + 0] = cx0;
718
712
  vertices[iv + 1] = cy0;