@pixi-ui-editor/runtime-pixi 0.7.1 → 0.9.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/SceneViewport.d.ts.map +1 -1
- package/dist/assets/bitmapFonts.js.map +1 -1
- package/dist/assets/fonts.js.map +1 -1
- package/dist/assets/sounds.js.map +1 -1
- package/dist/assets/spine.js.map +1 -1
- package/dist/assets/textures.js.map +1 -1
- package/dist/controls.d.ts +25 -1
- package/dist/controls.d.ts.map +1 -1
- package/dist/controls.js +42 -2
- package/dist/controls.js.map +1 -1
- package/dist/document.d.ts.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/layoutGroups.d.ts.map +1 -1
- package/dist/layoutGroups.js.map +1 -1
- package/dist/localization.d.ts.map +1 -1
- package/dist/localization.js.map +1 -1
- package/dist/pageGroup.d.ts.map +1 -1
- package/dist/pageGroup.js.map +1 -1
- package/dist/particles.d.ts.map +1 -1
- package/dist/particles.js.map +1 -1
- package/dist/scene.d.ts.map +1 -1
- package/dist/scene.js +36 -0
- package/dist/scene.js.map +1 -1
- package/dist/scrollView.d.ts.map +1 -1
- package/dist/scrollView.js.map +1 -1
- package/dist/views/ButtonNodeView.d.ts +12 -0
- package/dist/views/ButtonNodeView.d.ts.map +1 -1
- package/dist/views/ButtonNodeView.js +25 -7
- package/dist/views/ButtonNodeView.js.map +1 -1
- package/dist/views/CheckboxNodeView.d.ts.map +1 -1
- package/dist/views/InputNodeView.d.ts.map +1 -1
- package/dist/views/ItemTableNodeView.d.ts +57 -0
- package/dist/views/ItemTableNodeView.d.ts.map +1 -0
- package/dist/views/ItemTableNodeView.js +100 -0
- package/dist/views/ItemTableNodeView.js.map +1 -0
- package/dist/views/NodeView.d.ts +15 -1
- package/dist/views/NodeView.d.ts.map +1 -1
- package/dist/views/NodeView.js +19 -2
- package/dist/views/NodeView.js.map +1 -1
- package/dist/views/PageGroupNodeView.d.ts.map +1 -1
- package/dist/views/PaginationNodeView.d.ts +38 -2
- package/dist/views/PaginationNodeView.d.ts.map +1 -1
- package/dist/views/PaginationNodeView.js +85 -28
- package/dist/views/PaginationNodeView.js.map +1 -1
- package/dist/views/ParticleEmitterNodeView.d.ts.map +1 -1
- package/dist/views/ScrollViewNodeView.d.ts.map +1 -1
- package/dist/views/SpineNodeView.d.ts.map +1 -1
- package/dist/views/StagedButtonNodeView.d.ts +12 -1
- package/dist/views/StagedButtonNodeView.d.ts.map +1 -1
- package/dist/views/StagedButtonNodeView.js +27 -9
- package/dist/views/StagedButtonNodeView.js.map +1 -1
- package/dist/views/ValueControlNodeViews.d.ts.map +1 -1
- package/dist/views/basic.d.ts +27 -1
- package/dist/views/basic.d.ts.map +1 -1
- package/dist/views/basic.js +44 -0
- package/dist/views/basic.js.map +1 -1
- package/dist/views/createNodeView.d.ts.map +1 -1
- package/dist/views/createNodeView.js +8 -1
- package/dist/views/createNodeView.js.map +1 -1
- package/package.json +5 -2
package/dist/scrollView.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scrollView.d.ts","sourceRoot":"","sources":["../src/scrollView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,KAAK,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChG,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,kFAAkF;AAClF,eAAO,MAAM,6BAA6B,EAAE,MAAM,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC,WAAW,CAAC,EAAE,QAAQ,CAIrG,CAAC;AAEF;;;;;;;GA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UAAU,GAAG,IAAI,CAKnE;CACF"}
|
package/dist/scrollView.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scrollView.js","sourceRoot":"","sources":["../src/scrollView.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAIpC,kFAAkF;AAClF,MAAM,CAAC,MAAM,6BAA6B,GAAgE;IACxG,QAAQ,EAAE,UAAU;IACpB,UAAU,EAAE,YAAY;IACxB,IAAI,EAAE,eAAe;CACtB,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,OAAO,mBAAoB,SAAQ,SAAS;IAI3B;
|
|
1
|
+
{"version":3,"file":"scrollView.js","sourceRoot":"","sources":["../src/scrollView.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAIpC,kFAAkF;AAClF,MAAM,CAAC,MAAM,6BAA6B,GAAgE;IACxG,QAAQ,EAAE,UAAU;IACpB,UAAU,EAAE,YAAY;IACxB,IAAI,EAAE,eAAe;CACtB,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,OAAO,mBAAoB,SAAQ,SAAS;IAI3B,QAAQ;IAA6B,SAAS;IAH3D,SAAS,GAAG,CAAC,CAAC;IACd,UAAU,GAAG,CAAC,CAAC;IAEvB,YAAqB,QAAkB,EAAmB,SAAsB;QAC9E,KAAK,EAAE,CAAC;wBADW,QAAQ;yBAA6B,SAAS;QAEjE,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC3B,CAAC;IAED,IAAa,KAAK,KAAa,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IACvD,IAAa,KAAK,CAAC,KAAa,IAAI,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC;IAC7D,IAAa,MAAM,KAAa,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;IACzD,IAAa,MAAM,CAAC,KAAa,IAAI,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,CAAC,CAAC;IAE/D,IAAI,CAAC,IAAY,EAAE,OAAwB,EAAE,IAAgB;QAC3D,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC;QAC5B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC;QAC9B,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;QACjD,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC;IACrB,CAAC;CACF","sourcesContent":["import { type LayoutProfileId, type ScrollViewNode, type UINode } from \"@pixi-ui-editor/schema\";\r\nimport type { ListType } from \"@pixi/ui\";\r\nimport { Container } from \"pixi.js\";\r\nimport type { LayoutSize } from \"./layout.js\";\r\nimport { NodeView } from \"./views/NodeView.js\";\r\n\r\n/** `@pixi/ui`'s `List` only knows \"vertical\" | \"horizontal\" | \"bidirectional\". */\r\nexport const SCROLL_DIRECTION_TO_LIST_TYPE: Record<ScrollViewNode[\"scrollView\"][\"direction\"], ListType> = {\r\n vertical: \"vertical\",\r\n horizontal: \"horizontal\",\r\n both: \"bidirectional\",\r\n};\r\n\r\n/**\r\n * Runtime-only position owner for one direct scroll-view child. `@pixi/ui`'s `List` arranges items\r\n * by reading `Container.width`/`height` and writing `x`/`y` directly; a bare `NodeView` reports 0 for\r\n * both when it renders nothing (same issue the base grab-rectangle works around for hit testing), so\r\n * this wrapper reports the child's own logical rectangle instead. `List` owns only this wrapper's\r\n * position — the wrapped `NodeView` keeps its own pivot/rotation/scale/visibility contract via\r\n * `updateManaged`, exactly like a layout group's `LayoutItemContainer`.\r\n */\r\nexport class ScrollItemContainer extends Container {\r\n private itemWidth = 0;\r\n private itemHeight = 0;\r\n\r\n constructor(readonly nodeView: NodeView, private readonly onResized?: () => void) {\r\n super();\r\n super.addChild(nodeView);\r\n }\r\n\r\n override get width(): number { return this.itemWidth; }\r\n override set width(value: number) { this.itemWidth = value; }\r\n override get height(): number { return this.itemHeight; }\r\n override set height(value: number) { this.itemHeight = value; }\r\n\r\n sync(node: UINode, profile: LayoutProfileId, size: LayoutSize): void {\r\n this.itemWidth = size.width;\r\n this.itemHeight = size.height;\r\n this.nodeView.updateManaged(node, profile, size);\r\n this.onResized?.();\r\n }\r\n}\r\n"]}
|
|
@@ -23,11 +23,23 @@ export declare class ButtonNodeView extends NodeView {
|
|
|
23
23
|
private soundAssetIds;
|
|
24
24
|
private enabledState;
|
|
25
25
|
constructor(node: ButtonNode, textures: ReadonlyMap<string, Texture> | undefined, interaction: SceneInteractionMode, sounds?: ReadonlyMap<string, Sound>);
|
|
26
|
+
/**
|
|
27
|
+
* Invisible (alpha 0) but still hit-testable: Pixi's `containsPoint` hit-tests the fill's geometry
|
|
28
|
+
* regardless of its alpha. Painted with a real size *before* the view ever reaches `FancyButton`:
|
|
29
|
+
* `FancyButton` reads `defaultView`'s bounds exactly once, synchronously during construction, to
|
|
30
|
+
* freeze its own `hitArea` — it never re-reads them afterwards. A `Graphics` still at its default
|
|
31
|
+
* (0, 0) size at that moment would freeze a zero-size, permanently unclickable hit area.
|
|
32
|
+
*/
|
|
33
|
+
private static paintPlaceholder;
|
|
26
34
|
private static createStateView;
|
|
27
35
|
/**
|
|
28
36
|
* (Re)builds `FancyButton` and its four state views. `FancyButton` has no API to replace a view
|
|
29
37
|
* after construction, so any change to a view's *type* — nine-slice toggled, or an asset
|
|
30
38
|
* finishing an async load — goes through here instead of `syncContent`'s cheap in-place path.
|
|
39
|
+
*
|
|
40
|
+
* `size` is the best size known *right now*: the resolved layout rectangle when called from
|
|
41
|
+
* `syncContent`, or the authored transform when called from the constructor (before any layout
|
|
42
|
+
* pass has run). Only feeds the initial placeholder paint above — see its doc comment for why.
|
|
31
43
|
*/
|
|
32
44
|
private buildButton;
|
|
33
45
|
/** In authoring mode `enabled` may only drive the visuals: `FancyButton` couples it to `eventMode`. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonNodeView.d.ts","sourceRoot":"","sources":["../../src/views/ButtonNodeView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,KAAK,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACjH,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAgD,OAAO,EAAE,MAAM,SAAS,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,KAAK,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAEpE,MAAM,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC,CAAC;AAK7D;;;;;;;;GAQG;AACH,qBAAa,cAAe,SAAQ,QAAQ;IAC1C,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,UAAU,CAAqC;IACvD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAuB;IACnD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAyC;IAChE,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,YAAY,CAAU;
|
|
1
|
+
{"version":3,"file":"ButtonNodeView.d.ts","sourceRoot":"","sources":["../../src/views/ButtonNodeView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,KAAK,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACjH,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAgD,OAAO,EAAE,MAAM,SAAS,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,KAAK,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAEpE,MAAM,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,EAAE;IAAE,I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I,OAAO,IAAI,WAAW,CAAC,SAAS,CAAC,CAAgC;IACrE,IAAI,KAAK,IAAI,WAAW,CAAC,OAAO,CAAC,CAA8B;CAChE"}
|
|
@@ -29,9 +29,22 @@ export class ButtonNodeView extends NodeView {
|
|
|
29
29
|
this.buildButton(node);
|
|
30
30
|
this.applyEnabled(node.enabled);
|
|
31
31
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Invisible (alpha 0) but still hit-testable: Pixi's `containsPoint` hit-tests the fill's geometry
|
|
34
|
+
* regardless of its alpha. Painted with a real size *before* the view ever reaches `FancyButton`:
|
|
35
|
+
* `FancyButton` reads `defaultView`'s bounds exactly once, synchronously during construction, to
|
|
36
|
+
* freeze its own `hitArea` — it never re-reads them afterwards. A `Graphics` still at its default
|
|
37
|
+
* (0, 0) size at that moment would freeze a zero-size, permanently unclickable hit area.
|
|
38
|
+
*/
|
|
39
|
+
static paintPlaceholder(graphics, width, height) {
|
|
40
|
+
graphics.clear().rect(0, 0, width, height).fill({ color: 0x000000, alpha: 0 });
|
|
41
|
+
}
|
|
42
|
+
static createStateView(texture, nineSlice, size) {
|
|
43
|
+
if (texture === undefined) {
|
|
44
|
+
const graphics = new Graphics();
|
|
45
|
+
ButtonNodeView.paintPlaceholder(graphics, size.width, size.height);
|
|
46
|
+
return graphics;
|
|
47
|
+
}
|
|
35
48
|
return nineSlice === undefined
|
|
36
49
|
? new Sprite(texture)
|
|
37
50
|
: new NineSliceSprite({ texture, leftWidth: nineSlice.left, topHeight: nineSlice.top, rightWidth: nineSlice.right, bottomHeight: nineSlice.bottom });
|
|
@@ -40,14 +53,19 @@ export class ButtonNodeView extends NodeView {
|
|
|
40
53
|
* (Re)builds `FancyButton` and its four state views. `FancyButton` has no API to replace a view
|
|
41
54
|
* after construction, so any change to a view's *type* — nine-slice toggled, or an asset
|
|
42
55
|
* finishing an async load — goes through here instead of `syncContent`'s cheap in-place path.
|
|
56
|
+
*
|
|
57
|
+
* `size` is the best size known *right now*: the resolved layout rectangle when called from
|
|
58
|
+
* `syncContent`, or the authored transform when called from the constructor (before any layout
|
|
59
|
+
* pass has run). Only feeds the initial placeholder paint above — see its doc comment for why.
|
|
43
60
|
*/
|
|
44
|
-
buildButton(node) {
|
|
61
|
+
buildButton(node, size) {
|
|
45
62
|
const nineSlice = node.nineSlice;
|
|
63
|
+
const resolvedSize = size ?? { width: node.transform.width, height: node.transform.height };
|
|
46
64
|
const normalTexture = this.textureFor(node.states.normalAssetId);
|
|
47
65
|
const stateViews = {};
|
|
48
66
|
const viewFor = (state, assetId) => {
|
|
49
67
|
const texture = (assetId === undefined ? undefined : this.textureFor(assetId)) ?? normalTexture;
|
|
50
|
-
const view = ButtonNodeView.createStateView(texture, nineSlice);
|
|
68
|
+
const view = ButtonNodeView.createStateView(texture, nineSlice, resolvedSize);
|
|
51
69
|
stateViews[state] = view;
|
|
52
70
|
return view;
|
|
53
71
|
};
|
|
@@ -103,7 +121,7 @@ export class ButtonNodeView extends NodeView {
|
|
|
103
121
|
}
|
|
104
122
|
}
|
|
105
123
|
if (needsRebuild) {
|
|
106
|
-
this.buildButton(node);
|
|
124
|
+
this.buildButton(node, transform);
|
|
107
125
|
}
|
|
108
126
|
else {
|
|
109
127
|
for (const state of BUTTON_STATE_KEYS) {
|
|
@@ -129,7 +147,7 @@ export class ButtonNodeView extends NodeView {
|
|
|
129
147
|
view.setSize(transform.width, transform.height);
|
|
130
148
|
}
|
|
131
149
|
else if (view instanceof Graphics) {
|
|
132
|
-
|
|
150
|
+
ButtonNodeView.paintPlaceholder(view, transform.width, transform.height);
|
|
133
151
|
}
|
|
134
152
|
}
|
|
135
153
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonNodeView.js","sourceRoot":"","sources":["../../src/views/ButtonNodeView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAwD,MAAM,wBAAwB,CAAC;AACjH,OAAO,EAAE,W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/C,CAAC;IAED,mGAAmG;IACnG,QAAQ,CAAC,KAAqB;QAC5B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC;IAClD,CAAC;IAED,IAAI,OAAO,KAA6B,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;IACrE,IAAI,MAAM,KAA4B,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IAClE,IAAI,IAAI,KAA0B,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IAC5D,IAAI,OAAO,KAA6B,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;IACrE,IAAI,KAAK,KAA2B,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;CAChE","sourcesContent":["import { BUTTON_STATE_KEYS, type ButtonStateKey, type LayoutPadding, type UINode } from \"@pixi-ui-editor/schema\";\r\nimport { FancyButton } from \"@pixi/ui\";\r\nimport type { Sound } from \"@pixi/sound\";\r\nimport { Container, Graphics, NineSliceSprite, Sprite, Texture } from \"pixi.js\";\r\nimport { NodeView, type SceneInteractionMode } from \"./NodeView.js\";\r\n\r\nexport type ButtonNode = Extract<UINode, { type: \"button\" }>;\r\n\r\nconst FANCY_STATE_BY_KEY = { normal: \"default\", hover: \"hover\", pressed: \"pressed\", disabled: \"disabled\" } as const;\r\nconst KEY_BY_FANCY_STATE = { default: \"normal\", hover: \"hover\", pressed: \"pressed\", disabled: \"disabled\" } as const;\r\n\r\n/**\r\n * Adapts a button node to `@pixi/ui`'s `FancyButton`, which owns the pointer state machine —\r\n * this class never reimplements it. Optional states fall back to the normal image, and runtime\r\n * changes to `enabled` or the current state stay in the view: they never touch the document.\r\n *\r\n * `nineSlice`, when set, applies the same borders to all four state views (`NineSliceSprite`\r\n * instead of `Sprite`) — the button's frame shape is normally the same regardless of which state\r\n * image is currently shown.\r\n */\r\nexport class ButtonNodeView extends NodeView {\r\n private button!: FancyButton;\r\n private stateViews!: Record<ButtonStateKey, Container>;\r\n private readonly interaction: SceneInteractionMode;\r\n private readonly sounds: ReadonlyMap<string, Sound> | undefined;\r\n private soundAssetIds: ButtonNode[\"sounds\"];\r\n private enabledState: boolean;\r\n\r\n constructor(node: ButtonNode, textures: ReadonlyMap<string, Texture> | undefined, interaction: SceneInteractionMode, sounds?: ReadonlyMap<string, Sound>) {\r\n super(textures);\r\n this.interaction = interaction;\r\n this.sounds = sounds;\r\n this.soundAssetIds = node.sounds;\r\n this.enabledState = node.enabled;\r\n this.buildButton(node);\r\n this.applyEnabled(node.enabled);\r\n }\r\n\r\n private static createStateView(texture: Texture | undefined, nineSlice: LayoutPadding | undefined): Container {\r\n if (texture === undefined) return new Graphics();\r\n return nineSlice === undefined\r\n ? new Sprite(texture)\r\n : new NineSliceSprite({ texture, leftWidth: nineSlice.left, topHeight: nineSlice.top, rightWidth: nineSlice.right, bottomHeight: nineSlice.bottom });\r\n }\r\n\r\n /**\r\n * (Re)builds `FancyButton` and its four state views. `FancyButton` has no API to replace a view\r\n * after construction, so any change to a view's *type* — nine-slice toggled, or an asset\r\n * finishing an async load — goes through here instead of `syncContent`'s cheap in-place path.\r\n */\r\n private buildButton(node: ButtonNode): void {\r\n const nineSlice = node.nineSlice;\r\n const normalTexture = this.textureFor(node.states.normalAssetId);\r\n const stateViews = {} as Record<ButtonStateKey, Container>;\r\n const viewFor = (state: ButtonStateKey, assetId: string | undefined): Container => {\r\n const texture = (assetId === undefined ? undefined : this.textureFor(assetId)) ?? normalTexture;\r\n const view = ButtonNodeView.createStateView(texture, nineSlice);\r\n stateViews[state] = view;\r\n return view;\r\n };\r\n\r\n const button = new FancyButton({\r\n defaultView: viewFor(\"normal\", node.states.normalAssetId),\r\n hoverView: viewFor(\"hover\", node.states.hoverAssetId),\r\n pressedView: viewFor(\"pressed\", node.states.pressedAssetId),\r\n disabledView: viewFor(\"disabled\", node.states.disabledAssetId),\r\n });\r\n // Authoring-сцена инертна: FancyButton уже включил себе eventMode \"static\", снимаем его до applyEnabled.\r\n // Выделение и drag при этом не страдают: попадание ловит hitArea базового NodeView, а не это поддерево.\r\n if (this.interaction === \"authoring\") button.eventMode = \"none\";\r\n else if (this.sounds !== undefined) {\r\n button.onPress.connect(() => { const result = this.soundAssetIds?.pressAssetId === undefined ? undefined : this.sounds?.get(this.soundAssetIds.pressAssetId)?.play(); if (result instanceof Promise) void result.catch(() => undefined); });\r\n button.onHover.connect(() => { const result = this.soundAssetIds?.hoverAssetId === undefined ? undefined : this.sounds?.get(this.soundAssetIds.hoverAssetId)?.play(); if (result instanceof Promise) void result.catch(() => undefined); });\r\n }\r\n this.button = button;\r\n this.stateViews = stateViews;\r\n this.setContent(button);\r\n }\r\n\r\n /** In authoring mode `enabled` may only drive the visuals: `FancyButton` couples it to `eventMode`. */\r\n private applyEnabled(enabled: boolean): void {\r\n this.enabledState = enabled;\r\n if (this.interaction === \"runtime\") this.button.enabled = enabled;\r\n else this.button.setState(enabled ? \"default\" : \"disabled\");\r\n }\r\n\r\n protected syncContent(node: UINode, transform: UINode[\"transform\"]): void {\r\n if (node.type !== \"button\") return;\r\n this.soundAssetIds = node.sounds;\r\n const nineSlice = node.nineSlice;\r\n const normalTexture = this.textureFor(node.states.normalAssetId);\r\n\r\n // A state view's required *type* (Graphics/Sprite/NineSliceSprite) may no longer match what's\r\n // needed — nine-slice toggled, or a texture finished loading after this view had to fall back\r\n // to Graphics. FancyButton can't swap a view after construction, so that goes through a full\r\n // rebuild; everything else (texture identity, border values, size) updates the live views in\r\n // place, which is the path a nine-slice gizmo drag runs every frame.\r\n let needsRebuild = false;\r\n for (const state of BUTTON_STATE_KEYS) {\r\n const assetId = node.states[`${state}AssetId`];\r\n const texture = (assetId === undefined ? undefined : this.textureFor(assetId)) ?? normalTexture;\r\n const view = this.stateViews[state];\r\n const wantsNineSlice = texture !== undefined && nineSlice !== undefined;\r\n const matches = texture === undefined ? view instanceof Graphics : wantsNineSlice ? view instanceof NineSliceSprite : view instanceof Sprite && !(view instanceof NineSliceSprite);\r\n if (!matches) { needsRebuild = true; break; }\r\n }\r\n\r\n if (needsRebuild) {\r\n this.buildButton(node);\r\n } else {\r\n for (const state of BUTTON_STATE_KEYS) {\r\n const view = this.stateViews[state];\r\n const assetId = node.states[`${state}AssetId`];\r\n const texture = (assetId === undefined ? undefined : this.textureFor(assetId)) ?? normalTexture;\r\n // Set the texture before the layout size: Sprite/NineSliceSprite preserve scale when their\r\n // texture changes, so sizing first would shift visual bounds for a differently-sized source.\r\n if (view instanceof NineSliceSprite) {\r\n if (texture !== undefined && view.texture !== texture) view.texture = texture;\r\n if (nineSlice !== undefined) {\r\n view.leftWidth = nineSlice.left;\r\n view.topHeight = nineSlice.top;\r\n view.rightWidth = nineSlice.right;\r\n view.bottomHeight = nineSlice.bottom;\r\n }\r\n view.setSize(transform.width, transform.height);\r\n } else if (view instanceof Sprite) {\r\n if (texture !== undefined && view.texture !== texture) view.texture = texture;\r\n view.setSize(transform.width, transform.height);\r\n } else if (view instanceof Graphics) {\r\n view.clear().rect(0, 0, transform.width, transform.height).fill(0x4a5568).stroke({ width: 1, color: 0x94a3b8 });\r\n }\r\n }\r\n }\r\n\r\n // Только на изменение документа: иначе любой пересчёт layout сбрасывал бы transient preview state.\r\n if (node.enabled !== this.enabledState) this.applyEnabled(node.enabled);\r\n }\r\n\r\n /** Editor-only live preview of nine-slice border edits while dragging the canvas gizmo. */\r\n previewNineSlice(nineSlice: LayoutPadding): void {\r\n for (const state of BUTTON_STATE_KEYS) {\r\n const view = this.stateViews[state];\r\n if (!(view instanceof NineSliceSprite)) continue;\r\n view.leftWidth = nineSlice.left;\r\n view.topHeight = nineSlice.top;\r\n view.rightWidth = nineSlice.right;\r\n view.bottomHeight = nineSlice.bottom;\r\n }\r\n }\r\n\r\n get enabled(): boolean {\r\n return this.enabledState;\r\n }\r\n\r\n set enabled(value: boolean) {\r\n this.applyEnabled(value);\r\n }\r\n\r\n get state(): ButtonStateKey {\r\n return KEY_BY_FANCY_STATE[this.button.state];\r\n }\r\n\r\n /** Forces a visual state without changing `enabled`, so a disabled button still emits no press. */\r\n setState(state: ButtonStateKey): void {\r\n this.button.setState(FANCY_STATE_BY_KEY[state]);\r\n }\r\n\r\n get onPress(): FancyButton[\"onPress\"] { return this.button.onPress; }\r\n get onDown(): FancyButton[\"onDown\"] { return this.button.onDown; }\r\n get onUp(): FancyButton[\"onUp\"] { return this.button.onUp; }\r\n get onHover(): FancyButton[\"onHover\"] { return this.button.onHover; }\r\n get onOut(): FancyButton[\"onOut\"] { return this.button.onOut; }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"ButtonNodeView.js","sourceRoot":"","sources":["../../src/views/ButtonNodeView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAwD,MAAM,wBAAwB,CAAC;AACjH,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,OAAO,EAAa,QAAQ,EAAE,eAAe,EAAE,MAAM,EAAW,MAAM,SAAS,CAAC;AAChF,OAAO,EAAE,QAAQ,EAA6B,MAAM,eAAe,CAAC;AAIpE,MAAM,kBAAkB,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAW,CAAC;AACpH,MAAM,kBAAkB,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAW,CAAC;AAEpH;;;;;;;;GAQG;AACH,MAAM,OAAO,cAAe,SAAQ,QAAQ;IAClC,MAAM,CAAe;IACrB,UAAU,CAAqC;IACtC,WAAW,CAAuB;IAClC,MAAM,CAAyC;IACxD,aAAa,CAAuB;IACpC,YAAY,CAAU;IAE9B,YAAY,IAAgB,EAAE,QAAkD,EAAE,WAAiC,EAA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,IAAI,OAAO,KAA6B,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;IACrE,IAAI,MAAM,KAA4B,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IAClE,IAAI,IAAI,KAA0B,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IAC5D,IAAI,OAAO,KAA6B,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;IACrE,IAAI,KAAK,KAA2B,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;CAChE","sourcesContent":["import { BUTTON_STATE_KEYS, type ButtonStateKey, type LayoutPadding, type UINode } from \"@pixi-ui-editor/schema\";\r\nimport { FancyButton } from \"@pixi/ui\";\r\nimport type { Sound } from \"@pixi/sound\";\r\nimport { Container, Graphics, NineSliceSprite, Sprite, Texture } from \"pixi.js\";\r\nimport { NodeView, type SceneInteractionMode } from \"./NodeView.js\";\r\n\r\nexport type ButtonNode = Extract<UINode, { type: \"button\" }>;\r\n\r\nconst FANCY_STATE_BY_KEY = { normal: \"default\", hover: \"hover\", pressed: \"pressed\", disabled: \"disabled\" } as const;\r\nconst KEY_BY_FANCY_STATE = { default: \"normal\", hover: \"hover\", pressed: \"pressed\", disabled: \"disabled\" } as const;\r\n\r\n/**\r\n * Adapts a button node to `@pixi/ui`'s `FancyButton`, which owns the pointer state machine —\r\n * this class never reimplements it. Optional states fall back to the normal image, and runtime\r\n * changes to `enabled` or the current state stay in the view: they never touch the document.\r\n *\r\n * `nineSlice`, when set, applies the same borders to all four state views (`NineSliceSprite`\r\n * instead of `Sprite`) — the button's frame shape is normally the same regardless of which state\r\n * image is currently shown.\r\n */\r\nexport class ButtonNodeView extends NodeView {\r\n private button!: FancyButton;\r\n private stateViews!: Record<ButtonStateKey, Container>;\r\n private readonly interaction: SceneInteractionMode;\r\n private readonly sounds: ReadonlyMap<string, Sound> | undefined;\r\n private soundAssetIds: ButtonNode[\"sounds\"];\r\n private enabledState: boolean;\r\n\r\n constructor(node: ButtonNode, textures: ReadonlyMap<string, Texture> | undefined, interaction: SceneInteractionMode, sounds?: ReadonlyMap<string, Sound>) {\r\n super(textures);\r\n this.interaction = interaction;\r\n this.sounds = sounds;\r\n this.soundAssetIds = node.sounds;\r\n this.enabledState = node.enabled;\r\n this.buildButton(node);\r\n this.applyEnabled(node.enabled);\r\n }\r\n\r\n /**\r\n * Invisible (alpha 0) but still hit-testable: Pixi's `containsPoint` hit-tests the fill's geometry\r\n * regardless of its alpha. Painted with a real size *before* the view ever reaches `FancyButton`:\r\n * `FancyButton` reads `defaultView`'s bounds exactly once, synchronously during construction, to\r\n * freeze its own `hitArea` — it never re-reads them afterwards. A `Graphics` still at its default\r\n * (0, 0) size at that moment would freeze a zero-size, permanently unclickable hit area.\r\n */\r\n private static paintPlaceholder(graphics: Graphics, width: number, height: number): void {\r\n graphics.clear().rect(0, 0, width, height).fill({ color: 0x000000, alpha: 0 });\r\n }\r\n\r\n private static createStateView(texture: Texture | undefined, nineSlice: LayoutPadding | undefined, size: { width: number; height: number }): Container {\r\n if (texture === undefined) {\r\n const graphics = new Graphics();\r\n ButtonNodeView.paintPlaceholder(graphics, size.width, size.height);\r\n return graphics;\r\n }\r\n return nineSlice === undefined\r\n ? new Sprite(texture)\r\n : new NineSliceSprite({ texture, leftWidth: nineSlice.left, topHeight: nineSlice.top, rightWidth: nineSlice.right, bottomHeight: nineSlice.bottom });\r\n }\r\n\r\n /**\r\n * (Re)builds `FancyButton` and its four state views. `FancyButton` has no API to replace a view\r\n * after construction, so any change to a view's *type* — nine-slice toggled, or an asset\r\n * finishing an async load — goes through here instead of `syncContent`'s cheap in-place path.\r\n *\r\n * `size` is the best size known *right now*: the resolved layout rectangle when called from\r\n * `syncContent`, or the authored transform when called from the constructor (before any layout\r\n * pass has run). Only feeds the initial placeholder paint above — see its doc comment for why.\r\n */\r\n private buildButton(node: ButtonNode, size?: { width: number; height: number }): void {\r\n const nineSlice = node.nineSlice;\r\n const resolvedSize = size ?? { width: node.transform.width, height: node.transform.height };\r\n const normalTexture = this.textureFor(node.states.normalAssetId);\r\n const stateViews = {} as Record<ButtonStateKey, Container>;\r\n const viewFor = (state: ButtonStateKey, assetId: string | undefined): Container => {\r\n const texture = (assetId === undefined ? undefined : this.textureFor(assetId)) ?? normalTexture;\r\n const view = ButtonNodeView.createStateView(texture, nineSlice, resolvedSize);\r\n stateViews[state] = view;\r\n return view;\r\n };\r\n\r\n const button = new FancyButton({\r\n defaultView: viewFor(\"normal\", node.states.normalAssetId),\r\n hoverView: viewFor(\"hover\", node.states.hoverAssetId),\r\n pressedView: viewFor(\"pressed\", node.states.pressedAssetId),\r\n disabledView: viewFor(\"disabled\", node.states.disabledAssetId),\r\n });\r\n // Authoring-сцена инертна: FancyButton уже включил себе eventMode \"static\", снимаем его до applyEnabled.\r\n // Выделение и drag при этом не страдают: попадание ловит hitArea базового NodeView, а не это поддерево.\r\n if (this.interaction === \"authoring\") button.eventMode = \"none\";\r\n else if (this.sounds !== undefined) {\r\n button.onPress.connect(() => { const result = this.soundAssetIds?.pressAssetId === undefined ? undefined : this.sounds?.get(this.soundAssetIds.pressAssetId)?.play(); if (result instanceof Promise) void result.catch(() => undefined); });\r\n button.onHover.connect(() => { const result = this.soundAssetIds?.hoverAssetId === undefined ? undefined : this.sounds?.get(this.soundAssetIds.hoverAssetId)?.play(); if (result instanceof Promise) void result.catch(() => undefined); });\r\n }\r\n this.button = button;\r\n this.stateViews = stateViews;\r\n this.setContent(button);\r\n }\r\n\r\n /** In authoring mode `enabled` may only drive the visuals: `FancyButton` couples it to `eventMode`. */\r\n private applyEnabled(enabled: boolean): void {\r\n this.enabledState = enabled;\r\n if (this.interaction === \"runtime\") this.button.enabled = enabled;\r\n else this.button.setState(enabled ? \"default\" : \"disabled\");\r\n }\r\n\r\n protected syncContent(node: UINode, transform: UINode[\"transform\"]): void {\r\n if (node.type !== \"button\") return;\r\n this.soundAssetIds = node.sounds;\r\n const nineSlice = node.nineSlice;\r\n const normalTexture = this.textureFor(node.states.normalAssetId);\r\n\r\n // A state view's required *type* (Graphics/Sprite/NineSliceSprite) may no longer match what's\r\n // needed — nine-slice toggled, or a texture finished loading after this view had to fall back\r\n // to Graphics. FancyButton can't swap a view after construction, so that goes through a full\r\n // rebuild; everything else (texture identity, border values, size) updates the live views in\r\n // place, which is the path a nine-slice gizmo drag runs every frame.\r\n let needsRebuild = false;\r\n for (const state of BUTTON_STATE_KEYS) {\r\n const assetId = node.states[`${state}AssetId`];\r\n const texture = (assetId === undefined ? undefined : this.textureFor(assetId)) ?? normalTexture;\r\n const view = this.stateViews[state];\r\n const wantsNineSlice = texture !== undefined && nineSlice !== undefined;\r\n const matches = texture === undefined ? view instanceof Graphics : wantsNineSlice ? view instanceof NineSliceSprite : view instanceof Sprite && !(view instanceof NineSliceSprite);\r\n if (!matches) { needsRebuild = true; break; }\r\n }\r\n\r\n if (needsRebuild) {\r\n this.buildButton(node, transform);\r\n } else {\r\n for (const state of BUTTON_STATE_KEYS) {\r\n const view = this.stateViews[state];\r\n const assetId = node.states[`${state}AssetId`];\r\n const texture = (assetId === undefined ? undefined : this.textureFor(assetId)) ?? normalTexture;\r\n // Set the texture before the layout size: Sprite/NineSliceSprite preserve scale when their\r\n // texture changes, so sizing first would shift visual bounds for a differently-sized source.\r\n if (view instanceof NineSliceSprite) {\r\n if (texture !== undefined && view.texture !== texture) view.texture = texture;\r\n if (nineSlice !== undefined) {\r\n view.leftWidth = nineSlice.left;\r\n view.topHeight = nineSlice.top;\r\n view.rightWidth = nineSlice.right;\r\n view.bottomHeight = nineSlice.bottom;\r\n }\r\n view.setSize(transform.width, transform.height);\r\n } else if (view instanceof Sprite) {\r\n if (texture !== undefined && view.texture !== texture) view.texture = texture;\r\n view.setSize(transform.width, transform.height);\r\n } else if (view instanceof Graphics) {\r\n ButtonNodeView.paintPlaceholder(view, transform.width, transform.height);\r\n }\r\n }\r\n }\r\n\r\n // Только на изменение документа: иначе любой пересчёт layout сбрасывал бы transient preview state.\r\n if (node.enabled !== this.enabledState) this.applyEnabled(node.enabled);\r\n }\r\n\r\n /** Editor-only live preview of nine-slice border edits while dragging the canvas gizmo. */\r\n previewNineSlice(nineSlice: LayoutPadding): void {\r\n for (const state of BUTTON_STATE_KEYS) {\r\n const view = this.stateViews[state];\r\n if (!(view instanceof NineSliceSprite)) continue;\r\n view.leftWidth = nineSlice.left;\r\n view.topHeight = nineSlice.top;\r\n view.rightWidth = nineSlice.right;\r\n view.bottomHeight = nineSlice.bottom;\r\n }\r\n }\r\n\r\n get enabled(): boolean {\r\n return this.enabledState;\r\n }\r\n\r\n set enabled(value: boolean) {\r\n this.applyEnabled(value);\r\n }\r\n\r\n get state(): ButtonStateKey {\r\n return KEY_BY_FANCY_STATE[this.button.state];\r\n }\r\n\r\n /** Forces a visual state without changing `enabled`, so a disabled button still emits no press. */\r\n setState(state: ButtonStateKey): void {\r\n this.button.setState(FANCY_STATE_BY_KEY[state]);\r\n }\r\n\r\n get onPress(): FancyButton[\"onPress\"] { return this.button.onPress; }\r\n get onDown(): FancyButton[\"onDown\"] { return this.button.onDown; }\r\n get onUp(): FancyButton[\"onUp\"] { return this.button.onUp; }\r\n get onHover(): FancyButton[\"onHover\"] { return this.button.onHover; }\r\n get onOut(): FancyButton[\"onOut\"] { return this.button.onOut; }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckboxNodeView.d.ts","sourceRoot":"","sources":["../../src/views/CheckboxNodeView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,gBAAgB,EAAE,KAAK,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACjG,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAU,OAAO,EAAE,MAAM,SAAS,CAAC;AAC1C,OA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AW,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAAE,WAAW,EAAE,oBAAoB,EAAE,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,EA4BjK;IAED,SAAS,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,WAAW,CAAC,GAAG,IAAI,CA2BxE;IAED,0GAA0G;IAC1G,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,IAAI,KAAK,CAAC,IAAI,EAAE,MAAM,EAErB;IAED,4FAA4F;IAC5F,KAAK,IAAI,IAAI,CAEZ;IAED,0EAA0E;IAC1E,IAAI,IAAI,IAAI,CAEX;IAED,IAAI,QAAQ,IAAI,KAAK,CAAC,UAAU,CAAC,CAEhC;IAED,IAAI,OAAO,IAAI,KAAK,CAAC,SAAS,CAAC,CAE9B;CACF"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { type LayoutProfileId, type UINode } from "@pixi-ui-editor/schema";
|
|
2
|
+
import { Container } from "pixi.js";
|
|
3
|
+
import { NodeView } from "./NodeView.js";
|
|
4
|
+
/**
|
|
5
|
+
* Узел фиксированной вместимости: держит авторский список узлов (`items`, ссылки по адресу — их
|
|
6
|
+
* разрешает `scene.ts`, тем же приёмом, что цели spine-коннекторов) и показывает только первые
|
|
7
|
+
* `visibleCount` из них — остальные скрыты всегда, а не «на этой странице». Автор раскладывает
|
|
8
|
+
* элементы под максимум, а сколько их реально помещается, задаётся на профиль: в разной ориентации
|
|
9
|
+
* экрана на экран влезает разное число строк.
|
|
10
|
+
*
|
|
11
|
+
* Список именно авторский, а не дети: элемент обычно уже лежит там, где его выравнивает layout-группа.
|
|
12
|
+
*
|
|
13
|
+
* Узел намеренно ничего больше не делает. Он не страницы (`PageGroupNodeView` показывает ровно
|
|
14
|
+
* одного ребёнка и растягивает его на себя), не раскладка (позицию элементы сохраняют свою) и ничего не
|
|
15
|
+
* знает ни про какие данные: чем наполнить видимые элементы и когда, решает игровой код через
|
|
16
|
+
* generic API из `controls.ts` (`getItemTableViewVisibleItems`, `getItemTableViewItem`,
|
|
17
|
+
* `setItemTableViewVisibleCount`, `setItemTableViewItemsVisible`). Связка «переключили страницу →
|
|
18
|
+
* перезаполнили элементы» тоже принадлежит игре: `PaginationNodeView.onPageChange` и эта таблица
|
|
19
|
+
* ничего друг о друге не знают.
|
|
20
|
+
*
|
|
21
|
+
* Видимость складывается с авторской: элемент, скрытый в документе, не станет видимым из-за
|
|
22
|
+
* вместимости, а скрытый вместимостью держится флагом `NodeView.hiddenByOwner` (см. `applyVisibility`).
|
|
23
|
+
*/
|
|
24
|
+
export declare class ItemTableNodeView extends NodeView {
|
|
25
|
+
private itemViews;
|
|
26
|
+
private authoredVisibleCount;
|
|
27
|
+
/** Транзиентное переопределение от игрового кода; `undefined` — авторское значение профиля. */
|
|
28
|
+
private runtimeVisibleCount?;
|
|
29
|
+
/** Транзиентный «скрыть/показать всё» поверх вместимости; `undefined` — вместимость решает сама. */
|
|
30
|
+
private forcedItemsVisible?;
|
|
31
|
+
/**
|
|
32
|
+
* Разрешённые views авторского списка `items`, позиционно выровненные с ним (`scene.ts`). Ссылка,
|
|
33
|
+
* которая ни во что не разрешилась, сохраняет свою дырку `undefined`, чтобы остальные элементы не
|
|
34
|
+
* сдвинулись; сама висячая ссылка — ошибка валидации документа, а не забота этого вида.
|
|
35
|
+
*/
|
|
36
|
+
setItems(views: readonly (Container | undefined)[]): void;
|
|
37
|
+
/** Элементы в авторском порядке; нерезолвенные ссылки пропущены. */
|
|
38
|
+
get items(): Container[];
|
|
39
|
+
get visibleCount(): number;
|
|
40
|
+
/** Транзиентно меняет вместимость; `undefined` возвращает авторское значение профиля. */
|
|
41
|
+
set visibleCount(value: number | undefined);
|
|
42
|
+
/** Элементы, показанные прямо сейчас, в авторском порядке. */
|
|
43
|
+
get visibleItems(): Container[];
|
|
44
|
+
/** Индекс — позиция в авторском списке, а не среди показанных: адресация не «плавает». */
|
|
45
|
+
itemAt(index: number): Container | undefined;
|
|
46
|
+
/** Показывает или прячет все элементы разом; `undefined` возвращает управление вместимости. */
|
|
47
|
+
setItemsVisible(visible: boolean | undefined): void;
|
|
48
|
+
/**
|
|
49
|
+
* Проход по элементам: влезающие включены, остальные выключены. Помимо самого `visible` ставится
|
|
50
|
+
* `hiddenByOwner`, потому что `visible` узла пересчитывается из документа на каждом обновлении —
|
|
51
|
+
* в том числе из колбэка layout-движка, который для элемента внутри layout-группы срабатывает
|
|
52
|
+
* позже прохода таблицы и без флага вернул бы скрытый элемент обратно.
|
|
53
|
+
*/
|
|
54
|
+
private applyVisibility;
|
|
55
|
+
protected syncContent(node: UINode, _transform: UINode["transform"], profile: LayoutProfileId): void;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=ItemTableNodeView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ItemTableNodeView.d.ts","sourceRoot":"","sources":["../../src/views/ItemTableNodeView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,KAAK,eAAe,EAAE,KAAK,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACzG,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,iBAAkB,SAAQ,QAAQ;IAC7C,OAAO,CAAC,SAAS,CAAiC;IAClD,OAAO,CAAC,oBAAoB,CAAK;IACjC,+FAA+F;IAC/F,OAAO,CAAC,mBAAmB,CAAC,CAAS;IACrC,oGAAoG;IACpG,OAAO,CAAC,kBAAkB,CAAC,CAAU;IAErC;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,SAAS,GAAG,SAAS,CAAC,EAAE,GAAG,IAAI,CASxD;IAED,oEAAoE;IACpE,IAAI,KAAK,IAAI,SAAS,EAAE,CAEvB;IAED,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED,yFAAyF;IACzF,IAAI,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAGzC;IAED,8DAA8D;IAC9D,IAAI,YAAY,IAAI,SAAS,EAAE,CAE9B;IAED,0FAA0F;IAC1F,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAE3C;IAED,+FAA+F;IAC/F,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,CAGlD;IAED;;;;;OAKG;IACH,OAAO,CAAC,eAAe;IAcvB,SAAS,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,eAAe,GAAG,IAAI,CAInG;CACF"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { resolveItemTableVisibleCount } from "@pixi-ui-editor/schema";
|
|
2
|
+
import { NodeView } from "./NodeView.js";
|
|
3
|
+
/**
|
|
4
|
+
* Узел фиксированной вместимости: держит авторский список узлов (`items`, ссылки по адресу — их
|
|
5
|
+
* разрешает `scene.ts`, тем же приёмом, что цели spine-коннекторов) и показывает только первые
|
|
6
|
+
* `visibleCount` из них — остальные скрыты всегда, а не «на этой странице». Автор раскладывает
|
|
7
|
+
* элементы под максимум, а сколько их реально помещается, задаётся на профиль: в разной ориентации
|
|
8
|
+
* экрана на экран влезает разное число строк.
|
|
9
|
+
*
|
|
10
|
+
* Список именно авторский, а не дети: элемент обычно уже лежит там, где его выравнивает layout-группа.
|
|
11
|
+
*
|
|
12
|
+
* Узел намеренно ничего больше не делает. Он не страницы (`PageGroupNodeView` показывает ровно
|
|
13
|
+
* одного ребёнка и растягивает его на себя), не раскладка (позицию элементы сохраняют свою) и ничего не
|
|
14
|
+
* знает ни про какие данные: чем наполнить видимые элементы и когда, решает игровой код через
|
|
15
|
+
* generic API из `controls.ts` (`getItemTableViewVisibleItems`, `getItemTableViewItem`,
|
|
16
|
+
* `setItemTableViewVisibleCount`, `setItemTableViewItemsVisible`). Связка «переключили страницу →
|
|
17
|
+
* перезаполнили элементы» тоже принадлежит игре: `PaginationNodeView.onPageChange` и эта таблица
|
|
18
|
+
* ничего друг о друге не знают.
|
|
19
|
+
*
|
|
20
|
+
* Видимость складывается с авторской: элемент, скрытый в документе, не станет видимым из-за
|
|
21
|
+
* вместимости, а скрытый вместимостью держится флагом `NodeView.hiddenByOwner` (см. `applyVisibility`).
|
|
22
|
+
*/
|
|
23
|
+
export class ItemTableNodeView extends NodeView {
|
|
24
|
+
itemViews = [];
|
|
25
|
+
authoredVisibleCount = 0;
|
|
26
|
+
/** Транзиентное переопределение от игрового кода; `undefined` — авторское значение профиля. */
|
|
27
|
+
runtimeVisibleCount;
|
|
28
|
+
/** Транзиентный «скрыть/показать всё» поверх вместимости; `undefined` — вместимость решает сама. */
|
|
29
|
+
forcedItemsVisible;
|
|
30
|
+
/**
|
|
31
|
+
* Разрешённые views авторского списка `items`, позиционно выровненные с ним (`scene.ts`). Ссылка,
|
|
32
|
+
* которая ни во что не разрешилась, сохраняет свою дырку `undefined`, чтобы остальные элементы не
|
|
33
|
+
* сдвинулись; сама висячая ссылка — ошибка валидации документа, а не забота этого вида.
|
|
34
|
+
*/
|
|
35
|
+
setItems(views) {
|
|
36
|
+
// Выбывшие из списка возвращаются под управление документа: иначе узел, убранный из таблицы,
|
|
37
|
+
// остался бы скрытым её прежней вместимостью навсегда.
|
|
38
|
+
const next = new Set(views);
|
|
39
|
+
for (const previous of this.itemViews) {
|
|
40
|
+
if (previous instanceof NodeView && !next.has(previous)) {
|
|
41
|
+
previous.hiddenByOwner = false;
|
|
42
|
+
previous.visible = previous.documentVisible;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
this.itemViews = [...views];
|
|
46
|
+
this.applyVisibility();
|
|
47
|
+
}
|
|
48
|
+
/** Элементы в авторском порядке; нерезолвенные ссылки пропущены. */
|
|
49
|
+
get items() {
|
|
50
|
+
return this.itemViews.filter((item) => item !== undefined);
|
|
51
|
+
}
|
|
52
|
+
get visibleCount() {
|
|
53
|
+
return this.runtimeVisibleCount ?? this.authoredVisibleCount;
|
|
54
|
+
}
|
|
55
|
+
/** Транзиентно меняет вместимость; `undefined` возвращает авторское значение профиля. */
|
|
56
|
+
set visibleCount(value) {
|
|
57
|
+
this.runtimeVisibleCount = value === undefined ? undefined : Math.max(0, Math.round(value));
|
|
58
|
+
this.applyVisibility();
|
|
59
|
+
}
|
|
60
|
+
/** Элементы, показанные прямо сейчас, в авторском порядке. */
|
|
61
|
+
get visibleItems() {
|
|
62
|
+
return this.items.filter((item) => item.visible);
|
|
63
|
+
}
|
|
64
|
+
/** Индекс — позиция в авторском списке, а не среди показанных: адресация не «плавает». */
|
|
65
|
+
itemAt(index) {
|
|
66
|
+
return this.itemViews[index];
|
|
67
|
+
}
|
|
68
|
+
/** Показывает или прячет все элементы разом; `undefined` возвращает управление вместимости. */
|
|
69
|
+
setItemsVisible(visible) {
|
|
70
|
+
this.forcedItemsVisible = visible;
|
|
71
|
+
this.applyVisibility();
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Проход по элементам: влезающие включены, остальные выключены. Помимо самого `visible` ставится
|
|
75
|
+
* `hiddenByOwner`, потому что `visible` узла пересчитывается из документа на каждом обновлении —
|
|
76
|
+
* в том числе из колбэка layout-движка, который для элемента внутри layout-группы срабатывает
|
|
77
|
+
* позже прохода таблицы и без флага вернул бы скрытый элемент обратно.
|
|
78
|
+
*/
|
|
79
|
+
applyVisibility() {
|
|
80
|
+
const count = this.visibleCount;
|
|
81
|
+
this.itemViews.forEach((item, index) => {
|
|
82
|
+
if (item === undefined)
|
|
83
|
+
return;
|
|
84
|
+
const enabled = this.forcedItemsVisible ?? index < count;
|
|
85
|
+
if (item instanceof NodeView) {
|
|
86
|
+
item.hiddenByOwner = !enabled;
|
|
87
|
+
item.visible = enabled && item.documentVisible;
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
item.visible = enabled;
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
syncContent(node, _transform, profile) {
|
|
94
|
+
if (node.type !== "item-table")
|
|
95
|
+
return;
|
|
96
|
+
this.authoredVisibleCount = resolveItemTableVisibleCount(node, profile);
|
|
97
|
+
this.applyVisibility();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=ItemTableNodeView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ItemTableNodeView.js","sourceRoot":"","sources":["../../src/views/ItemTableNodeView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAqC,MAAM,wBAAwB,CAAC;AAEzG,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,OAAO,iBAAkB,SAAQ,QAAQ;IACrC,SAAS,GAA8B,EAAE,CAAC;IAC1C,oBAAoB,GAAG,CAAC,CAAC;IACjC,+FAA+F;IACvF,mBAAmB,CAAU;IACrC,oGAAoG;IAC5F,kBAAkB,CAAW;IAErC;;;;OAIG;IACH,QAAQ,CAAC,KAAyC;QAChD,6FAA6F;QAC7F,uDAAuD;QACvD,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;QAC5B,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACtC,IAAI,QAAQ,YAAY,QAAQ,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAAC,QAAQ,CAAC,aAAa,GAAG,KAAK,CAAC;gBAAC,QAAQ,CAAC,OAAO,GAAG,QAAQ,CAAC,eAAe,CAAC;YAAC,CAAC;QAC3I,CAAC;QACD,IAAI,CAAC,SAAS,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC;QAC5B,IAAI,CAAC,eAAe,EAAE,CAAC;IACzB,CAA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,IAAI,CAAC,aAAa,GAAG,CAAC,OAAO,CAAC;gBAC9B,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,IAAI,CAAC,eAAe,CAAC;gBAC/C,OAAO;YACT,CAAC;YACD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACzB,CAAC,CAAC,CAAC;IACL,CAAC;IAES,WAAW,CAAC,IAAY,EAAE,UAA+B,EAAE,OAAwB;QAC3F,IAAI,IAAI,CAAC,IAAI,KAAK,YAAY;YAAE,OAAO;QACvC,IAAI,CAAC,oBAAoB,GAAG,4BAA4B,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACxE,IAAI,CAAC,eAAe,EAAE,CAAC;IACzB,CAAC;CACF","sourcesContent":["import { resolveItemTableVisibleCount, type LayoutProfileId, type UINode } from \"@pixi-ui-editor/schema\";\r\nimport { Container } from \"pixi.js\";\r\nimport { NodeView } from \"./NodeView.js\";\r\n\r\n/**\r\n * Узел фиксированной вместимости: держит авторский список узлов (`items`, ссылки по адресу — их\r\n * разрешает `scene.ts`, тем же приёмом, что цели spine-коннекторов) и показывает только первые\r\n * `visibleCount` из них — остальные скрыты всегда, а не «на этой странице». Автор раскладывает\r\n * элементы под максимум, а сколько их реально помещается, задаётся на профиль: в разной ориентации\r\n * экрана на экран влезает разное число строк.\r\n *\r\n * Список именно авторский, а не дети: элемент обычно уже лежит там, где его выравнивает layout-группа.\r\n *\r\n * Узел намеренно ничего больше не делает. Он не страницы (`PageGroupNodeView` показывает ровно\r\n * одного ребёнка и растягивает его на себя), не раскладка (позицию элементы сохраняют свою) и ничего не\r\n * знает ни про какие данные: чем наполнить видимые элементы и когда, решает игровой код через\r\n * generic API из `controls.ts` (`getItemTableViewVisibleItems`, `getItemTableViewItem`,\r\n * `setItemTableViewVisibleCount`, `setItemTableViewItemsVisible`). Связка «переключили страницу →\r\n * перезаполнили элементы» тоже принадлежит игре: `PaginationNodeView.onPageChange` и эта таблица\r\n * ничего друг о друге не знают.\r\n *\r\n * Видимость складывается с авторской: элемент, скрытый в документе, не станет видимым из-за\r\n * вместимости, а скрытый вместимостью держится флагом `NodeView.hiddenByOwner` (см. `applyVisibility`).\r\n */\r\nexport class ItemTableNodeView extends NodeView {\r\n private itemViews: (Container | undefined)[] = [];\r\n private authoredVisibleCount = 0;\r\n /** Транзиентное переопределение от игрового кода; `undefined` — авторское значение профиля. */\r\n private runtimeVisibleCount?: number;\r\n /** Транзиентный «скрыть/показать всё» поверх вместимости; `undefined` — вместимость решает сама. */\r\n private forcedItemsVisible?: boolean;\r\n\r\n /**\r\n * Разрешённые views авторского списка `items`, позиционно выровненные с ним (`scene.ts`). Ссылка,\r\n * которая ни во что не разрешилась, сохраняет свою дырку `undefined`, чтобы остальные элементы не\r\n * сдвинулись; сама висячая ссылка — ошибка валидации документа, а не забота этого вида.\r\n */\r\n setItems(views: readonly (Container | undefined)[]): void {\r\n // Выбывшие из списка возвращаются под управление документа: иначе узел, убранный из таблицы,\r\n // остался бы скрытым её прежней вместимостью навсегда.\r\n const next = new Set(views);\r\n for (const previous of this.itemViews) {\r\n if (previous instanceof NodeView && !next.has(previous)) { previous.hiddenByOwner = false; previous.visible = previous.documentVisible; }\r\n }\r\n this.itemViews = [...views];\r\n this.applyVisibility();\r\n }\r\n\r\n /** Элементы в авторском порядке; нерезолвенные ссылки пропущены. */\r\n get items(): Container[] {\r\n return this.itemViews.filter((item): item is Container => item !== undefined);\r\n }\r\n\r\n get visibleCount(): number {\r\n return this.runtimeVisibleCount ?? this.authoredVisibleCount;\r\n }\r\n\r\n /** Транзиентно меняет вместимость; `undefined` возвращает авторское значение профиля. */\r\n set visibleCount(value: number | undefined) {\r\n this.runtimeVisibleCount = value === undefined ? undefined : Math.max(0, Math.round(value));\r\n this.applyVisibility();\r\n }\r\n\r\n /** Элементы, показанные прямо сейчас, в авторском порядке. */\r\n get visibleItems(): Container[] {\r\n return this.items.filter((item) => item.visible);\r\n }\r\n\r\n /** Индекс — позиция в авторском списке, а не среди показанных: адресация не «плавает». */\r\n itemAt(index: number): Container | undefined {\r\n return this.itemViews[index];\r\n }\r\n\r\n /** Показывает или прячет все элементы разом; `undefined` возвращает управление вместимости. */\r\n setItemsVisible(visible: boolean | undefined): void {\r\n this.forcedItemsVisible = visible;\r\n this.applyVisibility();\r\n }\r\n\r\n /**\r\n * Проход по элементам: влезающие включены, остальные выключены. Помимо самого `visible` ставится\r\n * `hiddenByOwner`, потому что `visible` узла пересчитывается из документа на каждом обновлении —\r\n * в том числе из колбэка layout-движка, который для элемента внутри layout-группы срабатывает\r\n * позже прохода таблицы и без флага вернул бы скрытый элемент обратно.\r\n */\r\n private applyVisibility(): void {\r\n const count = this.visibleCount;\r\n this.itemViews.forEach((item, index) => {\r\n if (item === undefined) return;\r\n const enabled = this.forcedItemsVisible ?? index < count;\r\n if (item instanceof NodeView) {\r\n item.hiddenByOwner = !enabled;\r\n item.visible = enabled && item.documentVisible;\r\n return;\r\n }\r\n item.visible = enabled;\r\n });\r\n }\r\n\r\n protected syncContent(node: UINode, _transform: UINode[\"transform\"], profile: LayoutProfileId): void {\r\n if (node.type !== \"item-table\") return;\r\n this.authoredVisibleCount = resolveItemTableVisibleCount(node, profile);\r\n this.applyVisibility();\r\n }\r\n}\r\n"]}
|
package/dist/views/NodeView.d.ts
CHANGED
|
@@ -22,8 +22,20 @@ export declare abstract class NodeView extends Container {
|
|
|
22
22
|
/** Authored/computed RectTransform-like rectangle; unlike Pixi bounds it also exists without content. */
|
|
23
23
|
protected layoutWidth: number;
|
|
24
24
|
protected layoutHeight: number;
|
|
25
|
+
/**
|
|
26
|
+
* Скрыт ли узел владельцем-вместимостью (`ItemTableNodeView`) поверх авторской видимости.
|
|
27
|
+
*
|
|
28
|
+
* Флаг живёт здесь, а не только в самом владельце, потому что `visible` заново выводится из
|
|
29
|
+
* документа на каждом обновлении — в том числе в `updateManaged`, который для элемента внутри
|
|
30
|
+
* layout-группы дёргает сам layout-движок своим колбэком `onLayout` (см. `LayoutItemContainer`),
|
|
31
|
+
* то есть уже после того, как владелец закончил свой проход. Одно присваивание `visible` снаружи
|
|
32
|
+
* пережило бы ровно до следующего пересчёта раскладки; сложение с этим флагом переживает любой.
|
|
33
|
+
*/
|
|
34
|
+
hiddenByOwner: boolean;
|
|
35
|
+
/** Visibility last resolved from the document, before `hiddenByOwner` is applied on top. */
|
|
36
|
+
private authoredVisible;
|
|
25
37
|
constructor(textures?: ReadonlyMap<string, Texture>);
|
|
26
|
-
protected textureFor(assetId: string): Texture | undefined;
|
|
38
|
+
protected textureFor(assetId: string | undefined): Texture | undefined;
|
|
27
39
|
/**
|
|
28
40
|
* Makes every node selectable and draggable by its layout rectangle, whatever it renders.
|
|
29
41
|
*
|
|
@@ -49,6 +61,8 @@ export declare abstract class NodeView extends Container {
|
|
|
49
61
|
/** Applies the rectangle owned by a direct parent's layout solver. */
|
|
50
62
|
updateManaged(node: UINode, profile: LayoutProfileId, size: LayoutSize): void;
|
|
51
63
|
get layoutRectangle(): LayoutSize;
|
|
64
|
+
/** Авторская видимость узла отдельно от `visible`, поверх которой применяется `hiddenByOwner`. */
|
|
65
|
+
get documentVisible(): boolean;
|
|
52
66
|
getSpine(): Spine | undefined;
|
|
53
67
|
/**
|
|
54
68
|
* Rasterizes canvas-based content (`TextNodeView`) at a higher pixel density than the renderer's
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeView.d.ts","sourceRoot":"","sources":["../../src/views/NodeView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAC;AACxD,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAa,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,SAAS,CAAC;AACxE,OAAO,EAAqD,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAElG;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAAG,WAAW,GAAG,SAAS,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CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,EAGlD;IAED,SAAS,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAErE;IAED;;;;;;;;;;;;OAYG;IACH,aAAa,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAEvC;IAED,mGAAmG;IACnG,SAAS,CAAC,UAAU,CAAC,OAAO,EAAE,SAAS,GAAG,IAAI,CAI7C;IAED,kGAAkG;IAClG,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,eAAe,GAAG,IAAI,CAAC;IAE7G,OAAO,CAAC,sBAAsB;IAwB9B,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,UAAU,CAAC,EAAE,UAAU,GAAG,IAAI,CAG5E;IAED,mGAAmG;IACnG,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,WAAW,CAAC,EAAE,OAAO,UAAO,EAAE,OAAO,GAAE,eAA2B,GAAG,IAAI,CAEhH;IAED,sEAAsE;IACtE,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,UAAU,GAAG,IAAI,CAG5E;IAED,IAAI,eAAe,IAAI,UAAU,CAEhC;IAED,kGAAkG;IAClG,IAAI,eAAe,IAAI,OAAO,CAE7B;IAED,QAAQ,IAAI,KAAK,GAAG,SAAS,CAE5B;IAED;;;;;;OAMG;IACH,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAG;CACnD"}
|
package/dist/views/NodeView.js
CHANGED
|
@@ -15,12 +15,24 @@ export class NodeView extends Container {
|
|
|
15
15
|
/** Authored/computed RectTransform-like rectangle; unlike Pixi bounds it also exists without content. */
|
|
16
16
|
layoutWidth = 0;
|
|
17
17
|
layoutHeight = 0;
|
|
18
|
+
/**
|
|
19
|
+
* Скрыт ли узел владельцем-вместимостью (`ItemTableNodeView`) поверх авторской видимости.
|
|
20
|
+
*
|
|
21
|
+
* Флаг живёт здесь, а не только в самом владельце, потому что `visible` заново выводится из
|
|
22
|
+
* документа на каждом обновлении — в том числе в `updateManaged`, который для элемента внутри
|
|
23
|
+
* layout-группы дёргает сам layout-движок своим колбэком `onLayout` (см. `LayoutItemContainer`),
|
|
24
|
+
* то есть уже после того, как владелец закончил свой проход. Одно присваивание `visible` снаружи
|
|
25
|
+
* пережило бы ровно до следующего пересчёта раскладки; сложение с этим флагом переживает любой.
|
|
26
|
+
*/
|
|
27
|
+
hiddenByOwner = false;
|
|
28
|
+
/** Visibility last resolved from the document, before `hiddenByOwner` is applied on top. */
|
|
29
|
+
authoredVisible = true;
|
|
18
30
|
constructor(textures) {
|
|
19
31
|
super();
|
|
20
32
|
this.textures = textures;
|
|
21
33
|
}
|
|
22
34
|
textureFor(assetId) {
|
|
23
|
-
return this.textures?.get(assetId);
|
|
35
|
+
return assetId === undefined ? undefined : this.textures?.get(assetId);
|
|
24
36
|
}
|
|
25
37
|
/**
|
|
26
38
|
* Makes every node selectable and draggable by its layout rectangle, whatever it renders.
|
|
@@ -59,7 +71,8 @@ export class NodeView extends Container {
|
|
|
59
71
|
this.position.set(managedByLayout ? pivotX : transform.x, managedByLayout ? pivotY : transform.y);
|
|
60
72
|
this.rotation = transform.rotation;
|
|
61
73
|
this.scale.set(transform.scaleX, transform.scaleY);
|
|
62
|
-
this.
|
|
74
|
+
this.authoredVisible = visible;
|
|
75
|
+
this.visible = visible && !this.hiddenByOwner;
|
|
63
76
|
this.layoutWidth = transform.width;
|
|
64
77
|
this.layoutHeight = transform.height;
|
|
65
78
|
// Тот же прямоугольник, что видит пользователь: grab-зона не зависит от содержимого ноды.
|
|
@@ -84,6 +97,10 @@ export class NodeView extends Container {
|
|
|
84
97
|
get layoutRectangle() {
|
|
85
98
|
return { width: this.layoutWidth, height: this.layoutHeight };
|
|
86
99
|
}
|
|
100
|
+
/** Авторская видимость узла отдельно от `visible`, поверх которой применяется `hiddenByOwner`. */
|
|
101
|
+
get documentVisible() {
|
|
102
|
+
return this.authoredVisible;
|
|
103
|
+
}
|
|
87
104
|
getSpine() {
|
|
88
105
|
return this.content instanceof Spine ? this.content : undefined;
|
|
89
106
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeView.js","sourceRoot":"","sources":["../../src/views/NodeView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAC;AAExD,OAAO,EAAE,SAAS,EAAE,SAAS,EAA2B,MAAM,SAAS,CAAC;AACxE,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAmB,MAAM,cAAc,CAAC;AASlG;;;;GAIG;AACH,MAAM,OAAgB,QAAS,SAAQ,SAAS;IACpC,OAAO,CAAa;IAC9B,4FAA4F;IACzE,QAAQ,CAA2C;IACtE,6FAA6F;IAC5E,QAAQ,GAAG,IAAI,SAAS,EAAE,CAAC;IAC5C,yGAAyG;IAC/F,WAAW,GAAG,CAAC,CAAC;IAChB,YAAY,GAAG,CAAC,CAAC;IAE3B,YAAY,QAAuC;QACjD,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAES,UAAU,CAAC,OAAe;QAClC,OAAO,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,aAAa,CAAC,KAAgB;QAC5B,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAClD,CAAC;IAED,mGAAmG;IACzF,UAAU,CAAC,OAAkB;QACrC,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YAA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I,CAAC,YAAY,EAAE,CAAC;IAChE,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,OAAO,YAAY,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;IAClE,CAAC;IAED;;;;;;OAMG;IACH,oBAAoB,CAAC,WAAmB,IAAS,CAAC;CACnD","sourcesContent":["import { Spine } from \"@esotericsoftware/spine-pixi-v8\";\r\nimport { type LayoutProfileId, type UINode } from \"@pixi-ui-editor/schema\";\r\nimport { Container, Rectangle, Texture, type PointData } from \"pixi.js\";\r\nimport { resolveAnchoredTransform, resolveProfileTransform, type LayoutSize } from \"../layout.js\";\r\n\r\n/**\r\n * Whether a built scene is an inert authoring surface or a live one.\r\n * The editor canvas builds `authoring` scenes so controls never swallow selection and drag\r\n * gestures; Preview and the consuming app build `runtime` scenes with real pointer handling.\r\n */\r\nexport type SceneInteractionMode = \"authoring\" | \"runtime\";\r\n\r\n/**\r\n * Base display object for every schema node type. The whole layout contract — profile overrides,\r\n * anchors, pivot, position, scale, visibility — lives here once; subclasses only synchronize their\r\n * type-specific content against the resolved layout rectangle.\r\n */\r\nexport abstract class NodeView extends Container {\r\n protected content?: Container;\r\n /** A mutable scene texture map: assets may be loaded after this stable view was created. */\r\n protected readonly textures: ReadonlyMap<string, Texture> | undefined;\r\n /** Node's own grab rectangle in local space, kept equal to its resolved layout rectangle. */\r\n private readonly grabRect = new Rectangle();\r\n /** Authored/computed RectTransform-like rectangle; unlike Pixi bounds it also exists without content. */\r\n protected layoutWidth = 0;\r\n protected layoutHeight = 0;\r\n\r\n constructor(textures?: ReadonlyMap<string, Texture>) {\r\n super();\r\n this.textures = textures;\r\n }\r\n\r\n protected textureFor(assetId: string): Texture | undefined {\r\n return this.textures?.get(assetId);\r\n }\r\n\r\n /**\r\n * Makes every node selectable and draggable by its layout rectangle, whatever it renders.\r\n *\r\n * Lives here rather than in a subclass because a bare `Container` has no `containsPoint` of its\r\n * own: without this, Pixi could only find a node through whatever content the subclass happens to\r\n * draw, so nodes that draw nothing (container) or keep their content out of hit testing (button,\r\n * whose `@pixi/ui` view is inert while authoring) would silently stop being selectable.\r\n *\r\n * Deliberately `containsPoint` and NOT `hitArea`: Pixi's `hitPruneFn` drops a container together\r\n * with its whole subtree once the point falls outside its `hitArea`, which would make any child\r\n * reaching past its parent's rectangle visible but unclickable. `containsPoint` never clips\r\n * children — they are hit-tested first and independently, so a child always stays grabbable.\r\n */\r\n containsPoint(point: PointData): boolean {\r\n return this.grabRect.contains(point.x, point.y);\r\n }\r\n\r\n /** Заменяет содержимое ноды: прежнее снимается со сцены и уничтожается, чтобы не копить сироты. */\r\n protected setContent(content: Container): void {\r\n if (this.content !== undefined) { this.removeChild(this.content); this.content.destroy(); }\r\n this.content = content;\r\n this.addChild(content);\r\n }\r\n\r\n /** Syncs type-specific content to the resolved layout rectangle; layout math itself is shared. */\r\n protected abstract syncContent(node: UINode, transform: UINode[\"transform\"], profile: LayoutProfileId): void;\r\n\r\n private applyResolvedTransform(node: UINode, transform: UINode[\"transform\"], visible: boolean, managedByLayout: boolean, profile: LayoutProfileId): void {\r\n this.syncContent(node, transform, profile);\r\n\r\n const pivotX = (transform.pivotX ?? 0) * transform.width;\r\n const pivotY = (transform.pivotY ?? 0) * transform.height;\r\n this.pivot.set(pivotX, pivotY);\r\n // x/y are the pivot offset from the resolved anchor. Thus a centred anchor and pivot at\r\n // zero offsets place the visual centre exactly at the parent's centre.\r\n // A managed child is positioned by its technical Yoga item. Its own NodeView keeps only the\r\n // pivot offset inside that computed rectangle; authored x/y and anchors do not participate.\r\n this.position.set(managedByLayout ? pivotX : transform.x, managedByLayout ? pivotY : transform.y);\r\n this.rotation = transform.rotation;\r\n this.scale.set(transform.scaleX, transform.scaleY);\r\n this.visible = visible;\r\n this.layoutWidth = transform.width;\r\n this.layoutHeight = transform.height;\r\n // Тот же прямоугольник, что видит пользователь: grab-зона не зависит от содержимого ноды.\r\n this.grabRect.x = 0;\r\n this.grabRect.y = 0;\r\n this.grabRect.width = transform.width;\r\n this.grabRect.height = transform.height;\r\n }\r\n\r\n update(node: UINode, profile: LayoutProfileId, parentSize?: LayoutSize): void {\r\n const resolved = resolveProfileTransform(node, profile);\r\n this.applyResolvedTransform(node, resolveAnchoredTransform(resolved.transform, parentSize), resolved.visible, false, profile);\r\n }\r\n\r\n /** Applies a transient editor rectangle without deriving it from content-dependent Pixi bounds. */\r\n preview(node: UINode, transform: UINode[\"transform\"], visible = true, profile: LayoutProfileId = \"desktop\"): void {\r\n this.applyResolvedTransform(node, transform, visible, false, profile);\r\n }\r\n\r\n /** Applies the rectangle owned by a direct parent's layout solver. */\r\n updateManaged(node: UINode, profile: LayoutProfileId, size: LayoutSize): void {\r\n const resolved = resolveProfileTransform(node, profile);\r\n this.applyResolvedTransform(node, { ...resolved.transform, x: 0, y: 0, width: size.width, height: size.height }, resolved.visible, true, profile);\r\n }\r\n\r\n get layoutRectangle(): LayoutSize {\r\n return { width: this.layoutWidth, height: this.layoutHeight };\r\n }\r\n\r\n getSpine(): Spine | undefined {\r\n return this.content instanceof Spine ? this.content : undefined;\r\n }\r\n\r\n /**\r\n * Rasterizes canvas-based content (`TextNodeView`) at a higher pixel density than the renderer's\r\n * own backing resolution, so an authoring camera zoomed in doesn't magnify an already-rasterized\r\n * bitmap past its source resolution and read as blurred. A no-op base implementation: sprite/\r\n * graphics/bitmap-text content is either GPU-native (always crisp under zoom) or, for bitmap-text,\r\n * has its resolution fixed by the installed `BitmapFont` and can't be changed per instance.\r\n */\r\n setContentResolution(_resolution: number): void {}\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"NodeView.js","sourceRoot":"","sources":["../../src/views/NodeView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAC;AAExD,OAAO,EAAE,SAAS,EAAE,SAAS,EAA2B,MAAM,SAAS,CAAC;AACxE,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAmB,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IACH,oBAAoB,CAAC,WAAmB,IAAS,CAAC;CACnD","sourcesContent":["import { Spine } from \"@esotericsoftware/spine-pixi-v8\";\r\nimport { type LayoutProfileId, type UINode } from \"@pixi-ui-editor/schema\";\r\nimport { Container, Rectangle, Texture, type PointData } from \"pixi.js\";\r\nimport { resolveAnchoredTransform, resolveProfileTransform, type LayoutSize } from \"../layout.js\";\r\n\r\n/**\r\n * Whether a built scene is an inert authoring surface or a live one.\r\n * The editor canvas builds `authoring` scenes so controls never swallow selection and drag\r\n * gestures; Preview and the consuming app build `runtime` scenes with real pointer handling.\r\n */\r\nexport type SceneInteractionMode = \"authoring\" | \"runtime\";\r\n\r\n/**\r\n * Base display object for every schema node type. The whole layout contract — profile overrides,\r\n * anchors, pivot, position, scale, visibility — lives here once; subclasses only synchronize their\r\n * type-specific content against the resolved layout rectangle.\r\n */\r\nexport abstract class NodeView extends Container {\r\n protected content?: Container;\r\n /** A mutable scene texture map: assets may be loaded after this stable view was created. */\r\n protected readonly textures: ReadonlyMap<string, Texture> | undefined;\r\n /** Node's own grab rectangle in local space, kept equal to its resolved layout rectangle. */\r\n private readonly grabRect = new Rectangle();\r\n /** Authored/computed RectTransform-like rectangle; unlike Pixi bounds it also exists without content. */\r\n protected layoutWidth = 0;\r\n protected layoutHeight = 0;\r\n /**\r\n * Скрыт ли узел владельцем-вместимостью (`ItemTableNodeView`) поверх авторской видимости.\r\n *\r\n * Флаг живёт здесь, а не только в самом владельце, потому что `visible` заново выводится из\r\n * документа на каждом обновлении — в том числе в `updateManaged`, который для элемента внутри\r\n * layout-группы дёргает сам layout-движок своим колбэком `onLayout` (см. `LayoutItemContainer`),\r\n * то есть уже после того, как владелец закончил свой проход. Одно присваивание `visible` снаружи\r\n * пережило бы ровно до следующего пересчёта раскладки; сложение с этим флагом переживает любой.\r\n */\r\n hiddenByOwner = false;\r\n /** Visibility last resolved from the document, before `hiddenByOwner` is applied on top. */\r\n private authoredVisible = true;\r\n\r\n constructor(textures?: ReadonlyMap<string, Texture>) {\r\n super();\r\n this.textures = textures;\r\n }\r\n\r\n protected textureFor(assetId: string | undefined): Texture | undefined {\r\n return assetId === undefined ? undefined : this.textures?.get(assetId);\r\n }\r\n\r\n /**\r\n * Makes every node selectable and draggable by its layout rectangle, whatever it renders.\r\n *\r\n * Lives here rather than in a subclass because a bare `Container` has no `containsPoint` of its\r\n * own: without this, Pixi could only find a node through whatever content the subclass happens to\r\n * draw, so nodes that draw nothing (container) or keep their content out of hit testing (button,\r\n * whose `@pixi/ui` view is inert while authoring) would silently stop being selectable.\r\n *\r\n * Deliberately `containsPoint` and NOT `hitArea`: Pixi's `hitPruneFn` drops a container together\r\n * with its whole subtree once the point falls outside its `hitArea`, which would make any child\r\n * reaching past its parent's rectangle visible but unclickable. `containsPoint` never clips\r\n * children — they are hit-tested first and independently, so a child always stays grabbable.\r\n */\r\n containsPoint(point: PointData): boolean {\r\n return this.grabRect.contains(point.x, point.y);\r\n }\r\n\r\n /** Заменяет содержимое ноды: прежнее снимается со сцены и уничтожается, чтобы не копить сироты. */\r\n protected setContent(content: Container): void {\r\n if (this.content !== undefined) { this.removeChild(this.content); this.content.destroy(); }\r\n this.content = content;\r\n this.addChild(content);\r\n }\r\n\r\n /** Syncs type-specific content to the resolved layout rectangle; layout math itself is shared. */\r\n protected abstract syncContent(node: UINode, transform: UINode[\"transform\"], profile: LayoutProfileId): void;\r\n\r\n private applyResolvedTransform(node: UINode, transform: UINode[\"transform\"], visible: boolean, managedByLayout: boolean, profile: LayoutProfileId): void {\r\n this.syncContent(node, transform, profile);\r\n\r\n const pivotX = (transform.pivotX ?? 0) * transform.width;\r\n const pivotY = (transform.pivotY ?? 0) * transform.height;\r\n this.pivot.set(pivotX, pivotY);\r\n // x/y are the pivot offset from the resolved anchor. Thus a centred anchor and pivot at\r\n // zero offsets place the visual centre exactly at the parent's centre.\r\n // A managed child is positioned by its technical Yoga item. Its own NodeView keeps only the\r\n // pivot offset inside that computed rectangle; authored x/y and anchors do not participate.\r\n this.position.set(managedByLayout ? pivotX : transform.x, managedByLayout ? pivotY : transform.y);\r\n this.rotation = transform.rotation;\r\n this.scale.set(transform.scaleX, transform.scaleY);\r\n this.authoredVisible = visible;\r\n this.visible = visible && !this.hiddenByOwner;\r\n this.layoutWidth = transform.width;\r\n this.layoutHeight = transform.height;\r\n // Тот же прямоугольник, что видит пользователь: grab-зона не зависит от содержимого ноды.\r\n this.grabRect.x = 0;\r\n this.grabRect.y = 0;\r\n this.grabRect.width = transform.width;\r\n this.grabRect.height = transform.height;\r\n }\r\n\r\n update(node: UINode, profile: LayoutProfileId, parentSize?: LayoutSize): void {\r\n const resolved = resolveProfileTransform(node, profile);\r\n this.applyResolvedTransform(node, resolveAnchoredTransform(resolved.transform, parentSize), resolved.visible, false, profile);\r\n }\r\n\r\n /** Applies a transient editor rectangle without deriving it from content-dependent Pixi bounds. */\r\n preview(node: UINode, transform: UINode[\"transform\"], visible = true, profile: LayoutProfileId = \"desktop\"): void {\r\n this.applyResolvedTransform(node, transform, visible, false, profile);\r\n }\r\n\r\n /** Applies the rectangle owned by a direct parent's layout solver. */\r\n updateManaged(node: UINode, profile: LayoutProfileId, size: LayoutSize): void {\r\n const resolved = resolveProfileTransform(node, profile);\r\n this.applyResolvedTransform(node, { ...resolved.transform, x: 0, y: 0, width: size.width, height: size.height }, resolved.visible, true, profile);\r\n }\r\n\r\n get layoutRectangle(): LayoutSize {\r\n return { width: this.layoutWidth, height: this.layoutHeight };\r\n }\r\n\r\n /** Авторская видимость узла отдельно от `visible`, поверх которой применяется `hiddenByOwner`. */\r\n get documentVisible(): boolean {\r\n return this.authoredVisible;\r\n }\r\n\r\n getSpine(): Spine | undefined {\r\n return this.content instanceof Spine ? this.content : undefined;\r\n }\r\n\r\n /**\r\n * Rasterizes canvas-based content (`TextNodeView`) at a higher pixel density than the renderer's\r\n * own backing resolution, so an authoring camera zoomed in doesn't magnify an already-rasterized\r\n * bitmap past its source resolution and read as blurred. A no-op base implementation: sprite/\r\n * graphics/bitmap-text content is either GPU-native (always crisp under zoom) or, for bitmap-text,\r\n * has its resolution fixed by the installed `BitmapFont` and can't be changed per instance.\r\n */\r\n setContentResolution(_resolution: number): void {}\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PageGroupNodeView.d.ts","sourceRoot":"","sources":["../../src/views/PageGroupNodeView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAe,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,YAAY,EAAE,aAAa,EAAE,CAAC;AAE9B;;;;;;;;;;;;;;GAcG;AACH,qBAAa,iBAAkB,SAAQ,QAAQ;IAC7C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAmB;IACzC,OAAO,CAAC,WAAW,CAAS;
|
|
1
|
+
{"version":3,"file":"PageGroupNodeView.d.ts","sourceRoot":"","sources":["../../src/views/PageGroupNodeView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAe,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,YAAY,EAAE,aAAa,EAAE,CAAC;AAE9B;;;;;;;;;;;;;;GAcG;AACH,qBAAa,iBAAkB,SAAQ,QAAQ;IAC7C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAmB;IACzC,OAAO,CAAC,WAAW,CAAS;IAE5B,YAAY,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,S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