pixifact 0.1.5 → 0.2.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/compiler/builtinScenes.d.ts +2 -2
- package/dist/compiler/builtinScenes.js +1 -9
- package/dist/compiler/compileScenes.js +16 -0
- package/dist/compiler/pixiNodeSchema.d.ts +17 -7
- package/dist/compiler/pixiNodeSchema.js +219 -0
- package/dist/compiler/sceneValidation.js +13 -2
- package/dist/compiler/spec.d.ts +5 -1
- package/dist/compiler/templateParser.js +18 -10
- package/dist/compiler/templateSerializer.js +1 -0
- package/dist/compiler/typescriptCompiler.js +53 -8
- package/dist/project/index.d.ts +5 -0
- package/dist/project/index.js +22 -0
- package/dist/runtime/Control.d.ts +18 -0
- package/dist/runtime/Control.js +49 -0
- package/dist/runtime/GridContainer.d.ts +25 -0
- package/dist/runtime/GridContainer.js +115 -0
- package/dist/runtime/Group.d.ts +2 -0
- package/dist/runtime/Group.js +30 -10
- package/dist/runtime/HBoxContainer.d.ts +21 -0
- package/dist/runtime/HBoxContainer.js +74 -0
- package/dist/runtime/Image.d.ts +47 -0
- package/dist/runtime/Image.js +220 -0
- package/dist/runtime/NineImage.d.ts +22 -0
- package/dist/runtime/NineImage.js +54 -0
- package/dist/runtime/Rect.d.ts +48 -0
- package/dist/runtime/Rect.js +162 -0
- package/dist/runtime/ScrollContainer.d.ts +28 -0
- package/dist/runtime/ScrollContainer.js +370 -0
- package/dist/runtime/TileImage.d.ts +27 -0
- package/dist/runtime/TileImage.js +57 -0
- package/dist/runtime/VBoxContainer.d.ts +21 -0
- package/dist/runtime/VBoxContainer.js +74 -0
- package/dist/runtime/frameLayout.d.ts +11 -0
- package/dist/runtime/frameLayout.js +116 -0
- package/dist/runtime/frameLayoutAccessors.d.ts +4 -0
- package/dist/runtime/frameLayoutAccessors.js +7 -0
- package/dist/runtime/index.d.ts +12 -0
- package/dist/runtime/index.js +12 -0
- package/dist/runtime/stackLayout.d.ts +16 -0
- package/dist/runtime/stackLayout.js +59 -0
- package/dist/viewport.d.ts +43 -0
- package/dist/viewport.js +93 -0
- package/package.json +2 -2
- package/dist/builtin-scenes/CenterContainer.d.ts +0 -13
- package/dist/builtin-scenes/CenterContainer.js +0 -71
- package/dist/builtin-scenes/CenterContainer.scene +0 -3
- package/dist/builtin-scenes/CenterContainer.ts +0 -77
- package/dist/builtin-scenes/Control.d.ts +0 -44
- package/dist/builtin-scenes/Control.js +0 -206
- package/dist/builtin-scenes/Control.scene +0 -3
- package/dist/builtin-scenes/Control.ts +0 -233
- package/dist/builtin-scenes/FlexItem.d.ts +0 -45
- package/dist/builtin-scenes/FlexItem.js +0 -164
- package/dist/builtin-scenes/FlexItem.scene +0 -3
- package/dist/builtin-scenes/FlexItem.ts +0 -180
- package/dist/builtin-scenes/FlexLayout.d.ts +0 -29
- package/dist/builtin-scenes/FlexLayout.js +0 -358
- package/dist/builtin-scenes/FlexLayout.scene +0 -3
- package/dist/builtin-scenes/FlexLayout.ts +0 -409
- package/dist/builtin-scenes/HBoxContainer.d.ts +0 -15
- package/dist/builtin-scenes/HBoxContainer.js +0 -70
- package/dist/builtin-scenes/HBoxContainer.scene +0 -3
- package/dist/builtin-scenes/HBoxContainer.ts +0 -75
- package/dist/builtin-scenes/MarginContainer.d.ts +0 -23
- package/dist/builtin-scenes/MarginContainer.js +0 -131
- package/dist/builtin-scenes/MarginContainer.scene +0 -3
- package/dist/builtin-scenes/MarginContainer.ts +0 -139
- package/dist/builtin-scenes/VBoxContainer.d.ts +0 -15
- package/dist/builtin-scenes/VBoxContainer.js +0 -70
- package/dist/builtin-scenes/VBoxContainer.scene +0 -3
- package/dist/builtin-scenes/VBoxContainer.ts +0 -75
- package/dist/builtin-scenes/controlLayout.d.ts +0 -57
- package/dist/builtin-scenes/controlLayout.js +0 -202
- package/dist/builtin-scenes/controlLayout.ts +0 -270
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { Mesh, MeshGeometry, ObservablePoint, Rectangle, Texture } from 'pixi.js';
|
|
2
|
+
import { frameLayoutProp, setFrameLayoutProp } from './frameLayoutAccessors.js';
|
|
3
|
+
const quadIndices = new Uint32Array([0, 1, 2, 0, 2, 3]);
|
|
4
|
+
const initializedImages = new WeakSet();
|
|
5
|
+
export class Image extends Mesh {
|
|
6
|
+
#width = 96;
|
|
7
|
+
#height = 96;
|
|
8
|
+
#fit = 'stretch';
|
|
9
|
+
#anchor = new ObservablePoint({
|
|
10
|
+
_onUpdate: () => this.#syncGeometry(),
|
|
11
|
+
});
|
|
12
|
+
constructor(options = {}) {
|
|
13
|
+
const { texture, width, height, fit, anchorX, anchorY, ...meshOptions } = options;
|
|
14
|
+
super({
|
|
15
|
+
...meshOptions,
|
|
16
|
+
texture: texture ?? Texture.EMPTY,
|
|
17
|
+
geometry: new MeshGeometry({
|
|
18
|
+
positions: new Float32Array(8),
|
|
19
|
+
uvs: new Float32Array(8),
|
|
20
|
+
indices: quadIndices,
|
|
21
|
+
}),
|
|
22
|
+
});
|
|
23
|
+
initializedImages.add(this);
|
|
24
|
+
this.texture.on('update', this.#syncGeometry, this);
|
|
25
|
+
this.#width = width ?? this.#width;
|
|
26
|
+
this.#height = height ?? this.#height;
|
|
27
|
+
this.#fit = fit ?? this.#fit;
|
|
28
|
+
this.#anchor.set(anchorX ?? 0, anchorY ?? 0);
|
|
29
|
+
this.#syncHitArea();
|
|
30
|
+
this.#syncGeometry();
|
|
31
|
+
}
|
|
32
|
+
get width() {
|
|
33
|
+
return this.#width;
|
|
34
|
+
}
|
|
35
|
+
set width(value) {
|
|
36
|
+
this.#setBoxSize(value, this.#height);
|
|
37
|
+
}
|
|
38
|
+
get height() {
|
|
39
|
+
return this.#height;
|
|
40
|
+
}
|
|
41
|
+
set height(value) {
|
|
42
|
+
this.#setBoxSize(this.#width, value);
|
|
43
|
+
}
|
|
44
|
+
getSize(out = { width: 0, height: 0 }) {
|
|
45
|
+
out.width = this.#width;
|
|
46
|
+
out.height = this.#height;
|
|
47
|
+
return out;
|
|
48
|
+
}
|
|
49
|
+
setSize(value, height) {
|
|
50
|
+
if (typeof value === 'number') {
|
|
51
|
+
this.#setBoxSize(value, height ?? value);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
this.#setBoxSize(value.width, value.height ?? value.width);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
get texture() {
|
|
58
|
+
return super.texture;
|
|
59
|
+
}
|
|
60
|
+
set texture(value) {
|
|
61
|
+
if (!initializedImages.has(this)) {
|
|
62
|
+
super.texture = value;
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const currentTexture = super.texture;
|
|
66
|
+
currentTexture?.off('update', this.#syncGeometry, this);
|
|
67
|
+
super.texture = value;
|
|
68
|
+
value.on('update', this.#syncGeometry, this);
|
|
69
|
+
this.#syncGeometry();
|
|
70
|
+
}
|
|
71
|
+
get fit() {
|
|
72
|
+
return this.#fit;
|
|
73
|
+
}
|
|
74
|
+
set fit(value) {
|
|
75
|
+
this.#fit = value;
|
|
76
|
+
this.#syncGeometry();
|
|
77
|
+
}
|
|
78
|
+
get anchor() {
|
|
79
|
+
return this.#anchor;
|
|
80
|
+
}
|
|
81
|
+
set anchor(value) {
|
|
82
|
+
if (typeof value === 'number') {
|
|
83
|
+
this.#anchor.set(value);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
this.#anchor.set(value.x, value.y);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
get left() {
|
|
90
|
+
return this.#layoutProp('left');
|
|
91
|
+
}
|
|
92
|
+
set left(value) {
|
|
93
|
+
this.#setLayoutProp('left', value);
|
|
94
|
+
}
|
|
95
|
+
get right() {
|
|
96
|
+
return this.#layoutProp('right');
|
|
97
|
+
}
|
|
98
|
+
set right(value) {
|
|
99
|
+
this.#setLayoutProp('right', value);
|
|
100
|
+
}
|
|
101
|
+
get top() {
|
|
102
|
+
return this.#layoutProp('top');
|
|
103
|
+
}
|
|
104
|
+
set top(value) {
|
|
105
|
+
this.#setLayoutProp('top', value);
|
|
106
|
+
}
|
|
107
|
+
get bottom() {
|
|
108
|
+
return this.#layoutProp('bottom');
|
|
109
|
+
}
|
|
110
|
+
set bottom(value) {
|
|
111
|
+
this.#setLayoutProp('bottom', value);
|
|
112
|
+
}
|
|
113
|
+
get horizontal() {
|
|
114
|
+
return this.#layoutProp('horizontal');
|
|
115
|
+
}
|
|
116
|
+
set horizontal(value) {
|
|
117
|
+
this.#setLayoutProp('horizontal', value);
|
|
118
|
+
}
|
|
119
|
+
get vertical() {
|
|
120
|
+
return this.#layoutProp('vertical');
|
|
121
|
+
}
|
|
122
|
+
set vertical(value) {
|
|
123
|
+
this.#setLayoutProp('vertical', value);
|
|
124
|
+
}
|
|
125
|
+
#layoutProp(prop) {
|
|
126
|
+
return frameLayoutProp(this, prop);
|
|
127
|
+
}
|
|
128
|
+
#setLayoutProp(prop, value) {
|
|
129
|
+
setFrameLayoutProp(this, prop, value);
|
|
130
|
+
}
|
|
131
|
+
#setBoxSize(width, height) {
|
|
132
|
+
this.#width = width;
|
|
133
|
+
this.#height = height;
|
|
134
|
+
this.#syncHitArea();
|
|
135
|
+
this.#syncGeometry();
|
|
136
|
+
}
|
|
137
|
+
#syncHitArea() {
|
|
138
|
+
const bounds = this.#boxBounds();
|
|
139
|
+
this.hitArea = bounds;
|
|
140
|
+
this.boundsArea = bounds;
|
|
141
|
+
}
|
|
142
|
+
#syncGeometry() {
|
|
143
|
+
this.#syncPositions();
|
|
144
|
+
this.#syncUvs();
|
|
145
|
+
this.geometry.positions = this.geometry.positions;
|
|
146
|
+
this.geometry.uvs = this.geometry.uvs;
|
|
147
|
+
}
|
|
148
|
+
#syncPositions() {
|
|
149
|
+
const positions = this.geometry.positions;
|
|
150
|
+
const draw = this.#drawRect();
|
|
151
|
+
positions[0] = draw.x;
|
|
152
|
+
positions[1] = draw.y;
|
|
153
|
+
positions[2] = draw.x + draw.width;
|
|
154
|
+
positions[3] = draw.y;
|
|
155
|
+
positions[4] = draw.x + draw.width;
|
|
156
|
+
positions[5] = draw.y + draw.height;
|
|
157
|
+
positions[6] = draw.x;
|
|
158
|
+
positions[7] = draw.y + draw.height;
|
|
159
|
+
}
|
|
160
|
+
#syncUvs() {
|
|
161
|
+
const uvs = this.geometry.uvs;
|
|
162
|
+
const crop = this.#uvCrop();
|
|
163
|
+
uvs[0] = crop.u0;
|
|
164
|
+
uvs[1] = crop.v0;
|
|
165
|
+
uvs[2] = crop.u1;
|
|
166
|
+
uvs[3] = crop.v0;
|
|
167
|
+
uvs[4] = crop.u1;
|
|
168
|
+
uvs[5] = crop.v1;
|
|
169
|
+
uvs[6] = crop.u0;
|
|
170
|
+
uvs[7] = crop.v1;
|
|
171
|
+
}
|
|
172
|
+
#drawRect() {
|
|
173
|
+
const box = this.#boxBounds();
|
|
174
|
+
if (this.#fit === 'contain') {
|
|
175
|
+
const size = containSize(this.texture.width, this.texture.height, this.#width, this.#height);
|
|
176
|
+
return centeredRect(size.width, size.height, box.x, box.y, box.width, box.height);
|
|
177
|
+
}
|
|
178
|
+
if (this.#fit === 'none') {
|
|
179
|
+
return new Rectangle(box.x, box.y, this.texture.width, this.texture.height);
|
|
180
|
+
}
|
|
181
|
+
return box;
|
|
182
|
+
}
|
|
183
|
+
#uvCrop() {
|
|
184
|
+
if (this.#fit !== 'cover') {
|
|
185
|
+
return { u0: 0, v0: 0, u1: 1, v1: 1 };
|
|
186
|
+
}
|
|
187
|
+
return coverUvCrop(this.texture.width, this.texture.height, this.#width, this.#height);
|
|
188
|
+
}
|
|
189
|
+
#boxBounds() {
|
|
190
|
+
return new Rectangle(-this.#anchor.x * this.#width, -this.#anchor.y * this.#height, this.#width, this.#height);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
function containSize(textureWidth, textureHeight, boxWidth, boxHeight) {
|
|
194
|
+
if (textureWidth <= 0 || textureHeight <= 0 || boxWidth <= 0 || boxHeight <= 0) {
|
|
195
|
+
return { width: 0, height: 0 };
|
|
196
|
+
}
|
|
197
|
+
const scale = Math.min(boxWidth / textureWidth, boxHeight / textureHeight);
|
|
198
|
+
return {
|
|
199
|
+
width: textureWidth * scale,
|
|
200
|
+
height: textureHeight * scale,
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
function coverUvCrop(textureWidth, textureHeight, boxWidth, boxHeight) {
|
|
204
|
+
if (textureWidth <= 0 || textureHeight <= 0 || boxWidth <= 0 || boxHeight <= 0) {
|
|
205
|
+
return { u0: 0, v0: 0, u1: 1, v1: 1 };
|
|
206
|
+
}
|
|
207
|
+
const textureRatio = textureWidth / textureHeight;
|
|
208
|
+
const boxRatio = boxWidth / boxHeight;
|
|
209
|
+
if (textureRatio > boxRatio) {
|
|
210
|
+
const visibleWidth = boxRatio / textureRatio;
|
|
211
|
+
const inset = (1 - visibleWidth) / 2;
|
|
212
|
+
return { u0: inset, v0: 0, u1: 1 - inset, v1: 1 };
|
|
213
|
+
}
|
|
214
|
+
const visibleHeight = textureRatio / boxRatio;
|
|
215
|
+
const inset = (1 - visibleHeight) / 2;
|
|
216
|
+
return { u0: 0, v0: inset, u1: 1, v1: 1 - inset };
|
|
217
|
+
}
|
|
218
|
+
function centeredRect(width, height, boxX, boxY, boxWidth, boxHeight) {
|
|
219
|
+
return new Rectangle(boxX + (boxWidth - width) / 2, boxY + (boxHeight - height) / 2, width, height);
|
|
220
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { NineSliceSprite, Texture, type NineSliceSpriteOptions } from 'pixi.js';
|
|
2
|
+
export type NineImageOptions = Omit<NineSliceSpriteOptions, 'texture' | 'anchor'> & {
|
|
3
|
+
texture?: Texture;
|
|
4
|
+
anchorX?: number;
|
|
5
|
+
anchorY?: number;
|
|
6
|
+
};
|
|
7
|
+
export declare class NineImage extends NineSliceSprite {
|
|
8
|
+
#private;
|
|
9
|
+
constructor(options?: NineImageOptions);
|
|
10
|
+
get left(): number | undefined;
|
|
11
|
+
set left(value: number | undefined);
|
|
12
|
+
get right(): number | undefined;
|
|
13
|
+
set right(value: number | undefined);
|
|
14
|
+
get top(): number | undefined;
|
|
15
|
+
set top(value: number | undefined);
|
|
16
|
+
get bottom(): number | undefined;
|
|
17
|
+
set bottom(value: number | undefined);
|
|
18
|
+
get horizontal(): number | undefined;
|
|
19
|
+
set horizontal(value: number | undefined);
|
|
20
|
+
get vertical(): number | undefined;
|
|
21
|
+
set vertical(value: number | undefined);
|
|
22
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { NineSliceSprite, Texture } from 'pixi.js';
|
|
2
|
+
import { frameLayoutProp, setFrameLayoutProp } from './frameLayoutAccessors.js';
|
|
3
|
+
export class NineImage extends NineSliceSprite {
|
|
4
|
+
constructor(options = {}) {
|
|
5
|
+
const { texture, anchorX, anchorY, ...spriteOptions } = options;
|
|
6
|
+
super({
|
|
7
|
+
texture: texture ?? Texture.EMPTY,
|
|
8
|
+
...spriteOptions,
|
|
9
|
+
});
|
|
10
|
+
this.anchor.set(anchorX ?? 0, anchorY ?? 0);
|
|
11
|
+
}
|
|
12
|
+
get left() {
|
|
13
|
+
return this.#layoutProp('left');
|
|
14
|
+
}
|
|
15
|
+
set left(value) {
|
|
16
|
+
this.#setLayoutProp('left', value);
|
|
17
|
+
}
|
|
18
|
+
get right() {
|
|
19
|
+
return this.#layoutProp('right');
|
|
20
|
+
}
|
|
21
|
+
set right(value) {
|
|
22
|
+
this.#setLayoutProp('right', value);
|
|
23
|
+
}
|
|
24
|
+
get top() {
|
|
25
|
+
return this.#layoutProp('top');
|
|
26
|
+
}
|
|
27
|
+
set top(value) {
|
|
28
|
+
this.#setLayoutProp('top', value);
|
|
29
|
+
}
|
|
30
|
+
get bottom() {
|
|
31
|
+
return this.#layoutProp('bottom');
|
|
32
|
+
}
|
|
33
|
+
set bottom(value) {
|
|
34
|
+
this.#setLayoutProp('bottom', value);
|
|
35
|
+
}
|
|
36
|
+
get horizontal() {
|
|
37
|
+
return this.#layoutProp('horizontal');
|
|
38
|
+
}
|
|
39
|
+
set horizontal(value) {
|
|
40
|
+
this.#setLayoutProp('horizontal', value);
|
|
41
|
+
}
|
|
42
|
+
get vertical() {
|
|
43
|
+
return this.#layoutProp('vertical');
|
|
44
|
+
}
|
|
45
|
+
set vertical(value) {
|
|
46
|
+
this.#setLayoutProp('vertical', value);
|
|
47
|
+
}
|
|
48
|
+
#layoutProp(prop) {
|
|
49
|
+
return frameLayoutProp(this, prop);
|
|
50
|
+
}
|
|
51
|
+
#setLayoutProp(prop, value) {
|
|
52
|
+
setFrameLayoutProp(this, prop, value);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Graphics, type GraphicsOptions, type Size } from 'pixi.js';
|
|
2
|
+
export type RectOptions = GraphicsOptions & {
|
|
3
|
+
width?: number;
|
|
4
|
+
height?: number;
|
|
5
|
+
fillColor?: number;
|
|
6
|
+
fillAlpha?: number;
|
|
7
|
+
strokeColor?: number;
|
|
8
|
+
strokeAlpha?: number;
|
|
9
|
+
strokeWidth?: number;
|
|
10
|
+
radius?: number;
|
|
11
|
+
};
|
|
12
|
+
export declare class Rect extends Graphics {
|
|
13
|
+
#private;
|
|
14
|
+
constructor(options?: RectOptions);
|
|
15
|
+
get width(): number;
|
|
16
|
+
set width(value: number);
|
|
17
|
+
get height(): number;
|
|
18
|
+
set height(value: number);
|
|
19
|
+
getSize(out?: Size): Size;
|
|
20
|
+
setSize(value: number | {
|
|
21
|
+
width: number;
|
|
22
|
+
height?: number;
|
|
23
|
+
}, height?: number): void;
|
|
24
|
+
get fillColor(): number;
|
|
25
|
+
set fillColor(value: number);
|
|
26
|
+
get fillAlpha(): number;
|
|
27
|
+
set fillAlpha(value: number);
|
|
28
|
+
get strokeColor(): number;
|
|
29
|
+
set strokeColor(value: number);
|
|
30
|
+
get strokeAlpha(): number;
|
|
31
|
+
set strokeAlpha(value: number);
|
|
32
|
+
get strokeWidth(): number;
|
|
33
|
+
set strokeWidth(value: number);
|
|
34
|
+
get radius(): number;
|
|
35
|
+
set radius(value: number);
|
|
36
|
+
get left(): number | undefined;
|
|
37
|
+
set left(value: number | undefined);
|
|
38
|
+
get right(): number | undefined;
|
|
39
|
+
set right(value: number | undefined);
|
|
40
|
+
get top(): number | undefined;
|
|
41
|
+
set top(value: number | undefined);
|
|
42
|
+
get bottom(): number | undefined;
|
|
43
|
+
set bottom(value: number | undefined);
|
|
44
|
+
get horizontal(): number | undefined;
|
|
45
|
+
set horizontal(value: number | undefined);
|
|
46
|
+
get vertical(): number | undefined;
|
|
47
|
+
set vertical(value: number | undefined);
|
|
48
|
+
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { Graphics, Rectangle } from 'pixi.js';
|
|
2
|
+
import { getFrameLayout, setFrameLayout, } from './frameLayout.js';
|
|
3
|
+
export class Rect extends Graphics {
|
|
4
|
+
#width = 100;
|
|
5
|
+
#height = 60;
|
|
6
|
+
#fillColor = 0xffffff;
|
|
7
|
+
#fillAlpha = 1;
|
|
8
|
+
#strokeColor = 0x000000;
|
|
9
|
+
#strokeAlpha = 1;
|
|
10
|
+
#strokeWidth = 0;
|
|
11
|
+
#radius = 0;
|
|
12
|
+
constructor(options = {}) {
|
|
13
|
+
const { width, height, fillColor, fillAlpha, strokeColor, strokeAlpha, strokeWidth, radius, ...graphicsOptions } = options;
|
|
14
|
+
super(graphicsOptions);
|
|
15
|
+
this.#width = width ?? this.#width;
|
|
16
|
+
this.#height = height ?? this.#height;
|
|
17
|
+
this.#fillColor = fillColor ?? this.#fillColor;
|
|
18
|
+
this.#fillAlpha = fillAlpha ?? this.#fillAlpha;
|
|
19
|
+
this.#strokeColor = strokeColor ?? this.#strokeColor;
|
|
20
|
+
this.#strokeAlpha = strokeAlpha ?? this.#strokeAlpha;
|
|
21
|
+
this.#strokeWidth = strokeWidth ?? this.#strokeWidth;
|
|
22
|
+
this.#radius = radius ?? this.#radius;
|
|
23
|
+
this.#syncHitArea();
|
|
24
|
+
this.#redraw();
|
|
25
|
+
}
|
|
26
|
+
get width() {
|
|
27
|
+
return this.#width;
|
|
28
|
+
}
|
|
29
|
+
set width(value) {
|
|
30
|
+
this.#setBoxSize(value, this.#height);
|
|
31
|
+
}
|
|
32
|
+
get height() {
|
|
33
|
+
return this.#height;
|
|
34
|
+
}
|
|
35
|
+
set height(value) {
|
|
36
|
+
this.#setBoxSize(this.#width, value);
|
|
37
|
+
}
|
|
38
|
+
getSize(out = { width: 0, height: 0 }) {
|
|
39
|
+
out.width = this.#width;
|
|
40
|
+
out.height = this.#height;
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
43
|
+
setSize(value, height) {
|
|
44
|
+
if (typeof value === 'number') {
|
|
45
|
+
this.#setBoxSize(value, height ?? value);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
this.#setBoxSize(value.width, value.height ?? value.width);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
get fillColor() {
|
|
52
|
+
return this.#fillColor;
|
|
53
|
+
}
|
|
54
|
+
set fillColor(value) {
|
|
55
|
+
this.#fillColor = value;
|
|
56
|
+
this.#redraw();
|
|
57
|
+
}
|
|
58
|
+
get fillAlpha() {
|
|
59
|
+
return this.#fillAlpha;
|
|
60
|
+
}
|
|
61
|
+
set fillAlpha(value) {
|
|
62
|
+
this.#fillAlpha = value;
|
|
63
|
+
this.#redraw();
|
|
64
|
+
}
|
|
65
|
+
get strokeColor() {
|
|
66
|
+
return this.#strokeColor;
|
|
67
|
+
}
|
|
68
|
+
set strokeColor(value) {
|
|
69
|
+
this.#strokeColor = value;
|
|
70
|
+
this.#redraw();
|
|
71
|
+
}
|
|
72
|
+
get strokeAlpha() {
|
|
73
|
+
return this.#strokeAlpha;
|
|
74
|
+
}
|
|
75
|
+
set strokeAlpha(value) {
|
|
76
|
+
this.#strokeAlpha = value;
|
|
77
|
+
this.#redraw();
|
|
78
|
+
}
|
|
79
|
+
get strokeWidth() {
|
|
80
|
+
return this.#strokeWidth;
|
|
81
|
+
}
|
|
82
|
+
set strokeWidth(value) {
|
|
83
|
+
this.#strokeWidth = value;
|
|
84
|
+
this.#redraw();
|
|
85
|
+
}
|
|
86
|
+
get radius() {
|
|
87
|
+
return this.#radius;
|
|
88
|
+
}
|
|
89
|
+
set radius(value) {
|
|
90
|
+
this.#radius = value;
|
|
91
|
+
this.#redraw();
|
|
92
|
+
}
|
|
93
|
+
get left() {
|
|
94
|
+
return this.#layoutProp('left');
|
|
95
|
+
}
|
|
96
|
+
set left(value) {
|
|
97
|
+
this.#setLayoutProp('left', value);
|
|
98
|
+
}
|
|
99
|
+
get right() {
|
|
100
|
+
return this.#layoutProp('right');
|
|
101
|
+
}
|
|
102
|
+
set right(value) {
|
|
103
|
+
this.#setLayoutProp('right', value);
|
|
104
|
+
}
|
|
105
|
+
get top() {
|
|
106
|
+
return this.#layoutProp('top');
|
|
107
|
+
}
|
|
108
|
+
set top(value) {
|
|
109
|
+
this.#setLayoutProp('top', value);
|
|
110
|
+
}
|
|
111
|
+
get bottom() {
|
|
112
|
+
return this.#layoutProp('bottom');
|
|
113
|
+
}
|
|
114
|
+
set bottom(value) {
|
|
115
|
+
this.#setLayoutProp('bottom', value);
|
|
116
|
+
}
|
|
117
|
+
get horizontal() {
|
|
118
|
+
return this.#layoutProp('horizontal');
|
|
119
|
+
}
|
|
120
|
+
set horizontal(value) {
|
|
121
|
+
this.#setLayoutProp('horizontal', value);
|
|
122
|
+
}
|
|
123
|
+
get vertical() {
|
|
124
|
+
return this.#layoutProp('vertical');
|
|
125
|
+
}
|
|
126
|
+
set vertical(value) {
|
|
127
|
+
this.#setLayoutProp('vertical', value);
|
|
128
|
+
}
|
|
129
|
+
#layoutProp(prop) {
|
|
130
|
+
return getFrameLayout(this)[prop];
|
|
131
|
+
}
|
|
132
|
+
#setLayoutProp(prop, value) {
|
|
133
|
+
setFrameLayout(this, { [prop]: value });
|
|
134
|
+
}
|
|
135
|
+
#setBoxSize(width, height) {
|
|
136
|
+
this.#width = width;
|
|
137
|
+
this.#height = height;
|
|
138
|
+
this.#syncHitArea();
|
|
139
|
+
this.#redraw();
|
|
140
|
+
}
|
|
141
|
+
#syncHitArea() {
|
|
142
|
+
const bounds = new Rectangle(0, 0, this.#width, this.#height);
|
|
143
|
+
this.hitArea = bounds;
|
|
144
|
+
this.boundsArea = bounds;
|
|
145
|
+
}
|
|
146
|
+
#redraw() {
|
|
147
|
+
this.clear();
|
|
148
|
+
const radius = Math.max(0, Math.min(this.#radius, this.#width / 2, this.#height / 2));
|
|
149
|
+
const shape = radius > 0
|
|
150
|
+
? this.roundRect(0, 0, this.#width, this.#height, radius)
|
|
151
|
+
: this.rect(0, 0, this.#width, this.#height);
|
|
152
|
+
shape.fill({ color: this.#fillColor, alpha: this.#fillAlpha });
|
|
153
|
+
if (this.#strokeWidth > 0) {
|
|
154
|
+
shape.stroke({
|
|
155
|
+
width: this.#strokeWidth,
|
|
156
|
+
color: this.#strokeColor,
|
|
157
|
+
alpha: this.#strokeAlpha,
|
|
158
|
+
alignment: 1,
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Container, type ContainerChild, type DestroyOptions } from 'pixi.js';
|
|
2
|
+
import { Control } from './Control.js';
|
|
3
|
+
import type { GroupOptions } from './Group.js';
|
|
4
|
+
export type ScrollDirection = 'vertical' | 'horizontal' | 'both';
|
|
5
|
+
export type ScrollContainerOptions = GroupOptions & {
|
|
6
|
+
direction?: ScrollDirection;
|
|
7
|
+
scrollX?: number;
|
|
8
|
+
scrollY?: number;
|
|
9
|
+
};
|
|
10
|
+
export declare class ScrollContainer extends Control {
|
|
11
|
+
#private;
|
|
12
|
+
readonly contentLayer: Container<ContainerChild>;
|
|
13
|
+
constructor(options?: ScrollContainerOptions);
|
|
14
|
+
get direction(): ScrollDirection;
|
|
15
|
+
set direction(value: ScrollDirection);
|
|
16
|
+
get scrollX(): number;
|
|
17
|
+
set scrollX(value: number);
|
|
18
|
+
get scrollY(): number;
|
|
19
|
+
set scrollY(value: number);
|
|
20
|
+
addChild<U extends ContainerChild[]>(...children: U): U[0];
|
|
21
|
+
addChildAt<U extends ContainerChild>(child: U, index: number): U;
|
|
22
|
+
removeChild<U extends ContainerChild[]>(...children: U): U[0];
|
|
23
|
+
setChildIndex(child: ContainerChild, index: number): void;
|
|
24
|
+
getChildIndex(child: ContainerChild): number;
|
|
25
|
+
swapChildren(child: ContainerChild, child2: ContainerChild): void;
|
|
26
|
+
layout(): void;
|
|
27
|
+
destroy(options?: DestroyOptions): void;
|
|
28
|
+
}
|