pixifact 0.1.3 → 0.1.4
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/README.md +3 -3
- package/dist/builtin-scenes/CenterContainer.d.ts +13 -0
- package/dist/builtin-scenes/CenterContainer.js +71 -0
- package/dist/builtin-scenes/CenterContainer.scene +3 -0
- package/dist/builtin-scenes/CenterContainer.ts +77 -0
- package/dist/builtin-scenes/Control.d.ts +44 -0
- package/dist/builtin-scenes/Control.js +206 -0
- package/dist/builtin-scenes/Control.scene +3 -0
- package/dist/builtin-scenes/Control.ts +233 -0
- package/dist/builtin-scenes/FlexItem.d.ts +45 -0
- package/dist/builtin-scenes/FlexItem.js +164 -0
- package/dist/builtin-scenes/FlexItem.scene +3 -0
- package/dist/builtin-scenes/FlexItem.ts +180 -0
- package/dist/builtin-scenes/FlexLayout.d.ts +29 -0
- package/dist/builtin-scenes/FlexLayout.js +358 -0
- package/dist/builtin-scenes/FlexLayout.scene +3 -0
- package/dist/builtin-scenes/FlexLayout.ts +409 -0
- package/dist/builtin-scenes/HBoxContainer.d.ts +15 -0
- package/dist/builtin-scenes/HBoxContainer.js +70 -0
- package/dist/builtin-scenes/HBoxContainer.scene +3 -0
- package/dist/builtin-scenes/HBoxContainer.ts +75 -0
- package/dist/builtin-scenes/MarginContainer.d.ts +23 -0
- package/dist/builtin-scenes/MarginContainer.js +131 -0
- package/dist/builtin-scenes/MarginContainer.scene +3 -0
- package/dist/builtin-scenes/MarginContainer.ts +139 -0
- package/dist/builtin-scenes/VBoxContainer.d.ts +15 -0
- package/dist/builtin-scenes/VBoxContainer.js +70 -0
- package/dist/builtin-scenes/VBoxContainer.scene +3 -0
- package/dist/builtin-scenes/VBoxContainer.ts +75 -0
- package/dist/builtin-scenes/controlLayout.d.ts +57 -0
- package/dist/builtin-scenes/controlLayout.js +202 -0
- package/dist/builtin-scenes/controlLayout.ts +270 -0
- package/dist/compiler/builtinScenes.d.ts +14 -0
- package/dist/compiler/builtinScenes.js +62 -0
- package/dist/compiler/compileScenes.js +126 -19
- package/dist/compiler/decorators.js +3 -0
- package/dist/compiler/index.d.ts +1 -0
- package/dist/compiler/index.js +1 -0
- package/dist/compiler/sceneAssetPair.js +19 -0
- package/dist/compiler/sceneRuntime.d.ts +5 -4
- package/dist/compiler/scriptInterfaceExtractor.d.ts +5 -0
- package/dist/compiler/scriptInterfaceExtractor.js +214 -8
- package/dist/compiler/spec.d.ts +2 -0
- package/dist/compiler/templateParser.js +4 -3
- package/dist/compiler/templateSerializer.js +2 -1
- package/dist/compiler/typescriptCompiler.js +87 -13
- package/dist/compiler-node/builtinSceneAssets.d.ts +8 -0
- package/dist/compiler-node/builtinSceneAssets.js +57 -0
- package/dist/compiler-node/index.d.ts +1 -0
- package/dist/compiler-node/index.js +1 -0
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +24 -0
- package/dist/index.d.ts +2 -5
- package/dist/index.js +2 -5
- package/dist/{authoring/ProjectConfig.d.ts → project/index.d.ts} +7 -0
- package/dist/{authoring/ProjectConfig.js → project/index.js} +22 -0
- package/dist/runtime/Group.d.ts +18 -0
- package/dist/runtime/Group.js +45 -0
- package/dist/runtime/index.d.ts +1 -9
- package/dist/runtime/index.js +1 -9
- package/package.json +4 -26
- package/dist/authoring/ActionRegistry.d.ts +0 -10
- package/dist/authoring/ActionRegistry.js +0 -26
- package/dist/authoring/ComponentPalette.d.ts +0 -16
- package/dist/authoring/ComponentPalette.js +0 -50
- package/dist/authoring/DesignToken.d.ts +0 -16
- package/dist/authoring/DesignToken.js +0 -33
- package/dist/authoring/DiffModel.d.ts +0 -10
- package/dist/authoring/DiffModel.js +0 -104
- package/dist/authoring/InspectorModel.d.ts +0 -27
- package/dist/authoring/InspectorModel.js +0 -139
- package/dist/authoring/LogicGraph.d.ts +0 -66
- package/dist/authoring/LogicGraph.js +0 -184
- package/dist/authoring/OverrideJournal.d.ts +0 -18
- package/dist/authoring/OverrideJournal.js +0 -23
- package/dist/authoring/PreferenceMemory.d.ts +0 -21
- package/dist/authoring/PreferenceMemory.js +0 -39
- package/dist/authoring/RuntimePreview.d.ts +0 -11
- package/dist/authoring/RuntimePreview.js +0 -25
- package/dist/authoring/SceneDocument.d.ts +0 -74
- package/dist/authoring/SceneDocument.js +0 -332
- package/dist/authoring/SceneProjectState.d.ts +0 -20
- package/dist/authoring/SceneProjectState.js +0 -8
- package/dist/authoring/SceneSelection.d.ts +0 -11
- package/dist/authoring/SceneSelection.js +0 -1
- package/dist/authoring/index.d.ts +0 -13
- package/dist/authoring/index.js +0 -13
- package/dist/commands/Command.d.ts +0 -63
- package/dist/commands/Command.js +0 -1
- package/dist/commands/CommandStack.d.ts +0 -14
- package/dist/commands/CommandStack.js +0 -45
- package/dist/commands/applyCommand.d.ts +0 -23
- package/dist/commands/applyCommand.js +0 -316
- package/dist/commands/index.d.ts +0 -4
- package/dist/commands/index.js +0 -4
- package/dist/commands/utils.d.ts +0 -17
- package/dist/commands/utils.js +0 -77
- package/dist/commands/validateCommand.d.ts +0 -12
- package/dist/commands/validateCommand.js +0 -285
- package/dist/nodes/Input.d.ts +0 -91
- package/dist/nodes/Input.js +0 -352
- package/dist/nodes/Textarea.d.ts +0 -10
- package/dist/nodes/Textarea.js +0 -38
- package/dist/nodes/components/Button.d.ts +0 -8
- package/dist/nodes/components/Button.js +0 -45
- package/dist/nodes/components/InputField.d.ts +0 -12
- package/dist/nodes/components/InputField.js +0 -53
- package/dist/nodes/components/ProgressBar.d.ts +0 -14
- package/dist/nodes/components/ProgressBar.js +0 -66
- package/dist/nodes/components/ScrollRect.d.ts +0 -23
- package/dist/nodes/components/ScrollRect.js +0 -108
- package/dist/nodes/components/Selectable.d.ts +0 -32
- package/dist/nodes/components/Selectable.js +0 -153
- package/dist/nodes/components/index.d.ts +0 -5
- package/dist/nodes/components/index.js +0 -5
- package/dist/nodes/graphics/Graphic.d.ts +0 -14
- package/dist/nodes/graphics/Graphic.js +0 -47
- package/dist/nodes/graphics/ImageGraphic.d.ts +0 -9
- package/dist/nodes/graphics/ImageGraphic.js +0 -42
- package/dist/nodes/graphics/RoundedRectGraphic.d.ts +0 -13
- package/dist/nodes/graphics/RoundedRectGraphic.js +0 -65
- package/dist/nodes/graphics/TextGraphic.d.ts +0 -13
- package/dist/nodes/graphics/TextGraphic.js +0 -70
- package/dist/nodes/graphics/index.d.ts +0 -4
- package/dist/nodes/graphics/index.js +0 -4
- package/dist/nodes/index.d.ts +0 -3
- package/dist/nodes/index.js +0 -3
- package/dist/runtime/Application.d.ts +0 -15
- package/dist/runtime/Application.js +0 -67
- package/dist/runtime/GameObject.d.ts +0 -100
- package/dist/runtime/GameObject.js +0 -297
- package/dist/runtime/GameObjectEvent.d.ts +0 -52
- package/dist/runtime/GameObjectEvent.js +0 -38
- package/dist/runtime/Transform.d.ts +0 -32
- package/dist/runtime/Transform.js +0 -157
- package/dist/runtime/component/Component.d.ts +0 -13
- package/dist/runtime/component/Component.js +0 -13
- package/dist/runtime/component/ComponentRegistry.d.ts +0 -49
- package/dist/runtime/component/ComponentRegistry.js +0 -25
- package/dist/runtime/component/Flex.d.ts +0 -6
- package/dist/runtime/component/Flex.js +0 -15
- package/dist/runtime/component/FlexGroup.d.ts +0 -26
- package/dist/runtime/component/FlexGroup.js +0 -136
- package/dist/runtime/component/GridLayout.d.ts +0 -47
- package/dist/runtime/component/GridLayout.js +0 -129
- package/dist/runtime/component/Layout.d.ts +0 -104
- package/dist/runtime/component/Layout.js +0 -248
- package/dist/runtime/component/decorators.d.ts +0 -4
- package/dist/runtime/component/decorators.js +0 -52
- package/dist/runtime/component/index.d.ts +0 -7
- package/dist/runtime/component/index.js +0 -7
- package/dist/runtime/graphics/index.d.ts +0 -11
- package/dist/runtime/graphics/index.js +0 -29
- package/dist/runtime/group/index.d.ts +0 -39
- package/dist/runtime/group/index.js +0 -102
- package/dist/runtime/image/Image.d.ts +0 -19
- package/dist/runtime/image/Image.js +0 -60
- package/dist/runtime/image/NineSliceImage.d.ts +0 -23
- package/dist/runtime/image/NineSliceImage.js +0 -64
- package/dist/runtime/image/index.d.ts +0 -2
- package/dist/runtime/image/index.js +0 -2
- package/dist/runtime/label/Label.d.ts +0 -11
- package/dist/runtime/label/Label.js +0 -26
- package/dist/runtime/label/LabelStyle.d.ts +0 -3
- package/dist/runtime/label/LabelStyle.js +0 -3
- package/dist/runtime/label/index.d.ts +0 -2
- package/dist/runtime/label/index.js +0 -2
- package/dist/runtime/utils/index.d.ts +0 -1
- package/dist/runtime/utils/index.js +0 -1
- package/dist/runtime/utils/onlyOnceQueueMicrotask.d.ts +0 -1
- package/dist/runtime/utils/onlyOnceQueueMicrotask.js +0 -12
- package/dist/runtime/utils/setProps.d.ts +0 -10
- package/dist/runtime/utils/setProps.js +0 -17
- package/dist/scene/dsl.d.ts +0 -25
- package/dist/scene/dsl.js +0 -112
- package/dist/scene/index.d.ts +0 -5
- package/dist/scene/index.js +0 -5
- package/dist/scene/instantiate.d.ts +0 -8
- package/dist/scene/instantiate.js +0 -208
- package/dist/scene/nodesDsl.d.ts +0 -42
- package/dist/scene/nodesDsl.js +0 -169
- package/dist/scene/spec.d.ts +0 -100
- package/dist/scene/spec.js +0 -1
- package/dist/scene/templates.d.ts +0 -21
- package/dist/scene/templates.js +0 -239
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { prop, scene, slot } from 'pixifact/compiler';
|
|
8
|
+
import { Control } from './Control.js';
|
|
9
|
+
import { alignOffset, controlChildProps, controlMinSize, fillOrExpand, finiteNumber, parseAlign, setControlChildBox, } from './controlLayout.js';
|
|
10
|
+
let MarginContainer = class MarginContainer extends Control {
|
|
11
|
+
#margin = 0;
|
|
12
|
+
#marginLeft;
|
|
13
|
+
#marginRight;
|
|
14
|
+
#marginTop;
|
|
15
|
+
#marginBottom;
|
|
16
|
+
#alignX = 'start';
|
|
17
|
+
#alignY = 'start';
|
|
18
|
+
#baseSizes = new WeakMap();
|
|
19
|
+
get margin() {
|
|
20
|
+
return this.#margin;
|
|
21
|
+
}
|
|
22
|
+
set margin(value) {
|
|
23
|
+
this.#margin = Math.max(0, finiteNumber(value, 0));
|
|
24
|
+
this.refreshControlLayout();
|
|
25
|
+
}
|
|
26
|
+
get marginLeft() {
|
|
27
|
+
return this.#marginLeft ?? this.#margin;
|
|
28
|
+
}
|
|
29
|
+
set marginLeft(value) {
|
|
30
|
+
this.#marginLeft = Math.max(0, finiteNumber(value, 0));
|
|
31
|
+
this.refreshControlLayout();
|
|
32
|
+
}
|
|
33
|
+
get marginRight() {
|
|
34
|
+
return this.#marginRight ?? this.#margin;
|
|
35
|
+
}
|
|
36
|
+
set marginRight(value) {
|
|
37
|
+
this.#marginRight = Math.max(0, finiteNumber(value, 0));
|
|
38
|
+
this.refreshControlLayout();
|
|
39
|
+
}
|
|
40
|
+
get marginTop() {
|
|
41
|
+
return this.#marginTop ?? this.#margin;
|
|
42
|
+
}
|
|
43
|
+
set marginTop(value) {
|
|
44
|
+
this.#marginTop = Math.max(0, finiteNumber(value, 0));
|
|
45
|
+
this.refreshControlLayout();
|
|
46
|
+
}
|
|
47
|
+
get marginBottom() {
|
|
48
|
+
return this.#marginBottom ?? this.#margin;
|
|
49
|
+
}
|
|
50
|
+
set marginBottom(value) {
|
|
51
|
+
this.#marginBottom = Math.max(0, finiteNumber(value, 0));
|
|
52
|
+
this.refreshControlLayout();
|
|
53
|
+
}
|
|
54
|
+
get alignX() {
|
|
55
|
+
return this.#alignX;
|
|
56
|
+
}
|
|
57
|
+
set alignX(value) {
|
|
58
|
+
this.#alignX = parseAlign(value);
|
|
59
|
+
this.layout();
|
|
60
|
+
}
|
|
61
|
+
get alignY() {
|
|
62
|
+
return this.#alignY;
|
|
63
|
+
}
|
|
64
|
+
set alignY(value) {
|
|
65
|
+
this.#alignY = parseAlign(value);
|
|
66
|
+
this.layout();
|
|
67
|
+
}
|
|
68
|
+
layout() {
|
|
69
|
+
const size = this.syncControlBoxSize();
|
|
70
|
+
const children = this.default?.children;
|
|
71
|
+
if (!children || children.length === 0) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const innerWidth = Math.max(0, size.width - this.marginLeft - this.marginRight);
|
|
75
|
+
const innerHeight = Math.max(0, size.height - this.marginTop - this.marginBottom);
|
|
76
|
+
for (const child of children) {
|
|
77
|
+
const props = controlChildProps(child);
|
|
78
|
+
const childSize = controlMinSize(child, this.#baseSizes);
|
|
79
|
+
const childWidth = fillOrExpand(props.hSize) ? innerWidth : childSize.width;
|
|
80
|
+
const childHeight = fillOrExpand(props.vSize) ? innerHeight : childSize.height;
|
|
81
|
+
setControlChildBox(child, {
|
|
82
|
+
x: this.marginLeft + alignOffset(this.#alignX, Math.max(0, innerWidth - childWidth)),
|
|
83
|
+
y: this.marginTop + alignOffset(this.#alignY, Math.max(0, innerHeight - childHeight)),
|
|
84
|
+
width: childWidth,
|
|
85
|
+
height: childHeight,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
measureControlNaturalSize() {
|
|
90
|
+
const children = this.default?.children;
|
|
91
|
+
if (!children || children.length === 0) {
|
|
92
|
+
return {
|
|
93
|
+
width: this.marginLeft + this.marginRight,
|
|
94
|
+
height: this.marginTop + this.marginBottom,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
const sizes = children.map((child) => controlMinSize(child, this.#baseSizes));
|
|
98
|
+
return {
|
|
99
|
+
width: this.marginLeft + this.marginRight + sizes.reduce((max, size) => Math.max(max, size.width), 0),
|
|
100
|
+
height: this.marginTop + this.marginBottom + sizes.reduce((max, size) => Math.max(max, size.height), 0),
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
__decorate([
|
|
105
|
+
slot()
|
|
106
|
+
], MarginContainer.prototype, "default", void 0);
|
|
107
|
+
__decorate([
|
|
108
|
+
prop({ type: Number, default: 0 })
|
|
109
|
+
], MarginContainer.prototype, "margin", null);
|
|
110
|
+
__decorate([
|
|
111
|
+
prop({ type: Number })
|
|
112
|
+
], MarginContainer.prototype, "marginLeft", null);
|
|
113
|
+
__decorate([
|
|
114
|
+
prop({ type: Number })
|
|
115
|
+
], MarginContainer.prototype, "marginRight", null);
|
|
116
|
+
__decorate([
|
|
117
|
+
prop({ type: Number })
|
|
118
|
+
], MarginContainer.prototype, "marginTop", null);
|
|
119
|
+
__decorate([
|
|
120
|
+
prop({ type: Number })
|
|
121
|
+
], MarginContainer.prototype, "marginBottom", null);
|
|
122
|
+
__decorate([
|
|
123
|
+
prop({ type: String, default: 'start' })
|
|
124
|
+
], MarginContainer.prototype, "alignX", null);
|
|
125
|
+
__decorate([
|
|
126
|
+
prop({ type: String, default: 'start' })
|
|
127
|
+
], MarginContainer.prototype, "alignY", null);
|
|
128
|
+
MarginContainer = __decorate([
|
|
129
|
+
scene()
|
|
130
|
+
], MarginContainer);
|
|
131
|
+
export { MarginContainer };
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { Container } from 'pixi.js';
|
|
2
|
+
import { prop, scene, slot } from 'pixifact/compiler';
|
|
3
|
+
import { Control } from './Control';
|
|
4
|
+
import {
|
|
5
|
+
alignOffset,
|
|
6
|
+
controlChildProps,
|
|
7
|
+
controlMinSize,
|
|
8
|
+
fillOrExpand,
|
|
9
|
+
finiteNumber,
|
|
10
|
+
parseAlign,
|
|
11
|
+
setControlChildBox,
|
|
12
|
+
type ControlAlign,
|
|
13
|
+
type ControlLayoutChild,
|
|
14
|
+
type Size,
|
|
15
|
+
} from './controlLayout';
|
|
16
|
+
|
|
17
|
+
@scene()
|
|
18
|
+
export class MarginContainer extends Control {
|
|
19
|
+
@slot()
|
|
20
|
+
declare readonly default: Container;
|
|
21
|
+
|
|
22
|
+
#margin = 0;
|
|
23
|
+
#marginLeft: number | undefined;
|
|
24
|
+
#marginRight: number | undefined;
|
|
25
|
+
#marginTop: number | undefined;
|
|
26
|
+
#marginBottom: number | undefined;
|
|
27
|
+
#alignX: ControlAlign = 'start';
|
|
28
|
+
#alignY: ControlAlign = 'start';
|
|
29
|
+
#baseSizes = new WeakMap<object, Size>();
|
|
30
|
+
|
|
31
|
+
get margin() {
|
|
32
|
+
return this.#margin;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@prop({ type: Number, default: 0 })
|
|
36
|
+
set margin(value: number) {
|
|
37
|
+
this.#margin = Math.max(0, finiteNumber(value, 0));
|
|
38
|
+
this.refreshControlLayout();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
get marginLeft() {
|
|
42
|
+
return this.#marginLeft ?? this.#margin;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@prop({ type: Number })
|
|
46
|
+
set marginLeft(value: number) {
|
|
47
|
+
this.#marginLeft = Math.max(0, finiteNumber(value, 0));
|
|
48
|
+
this.refreshControlLayout();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
get marginRight() {
|
|
52
|
+
return this.#marginRight ?? this.#margin;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@prop({ type: Number })
|
|
56
|
+
set marginRight(value: number) {
|
|
57
|
+
this.#marginRight = Math.max(0, finiteNumber(value, 0));
|
|
58
|
+
this.refreshControlLayout();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
get marginTop() {
|
|
62
|
+
return this.#marginTop ?? this.#margin;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@prop({ type: Number })
|
|
66
|
+
set marginTop(value: number) {
|
|
67
|
+
this.#marginTop = Math.max(0, finiteNumber(value, 0));
|
|
68
|
+
this.refreshControlLayout();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
get marginBottom() {
|
|
72
|
+
return this.#marginBottom ?? this.#margin;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@prop({ type: Number })
|
|
76
|
+
set marginBottom(value: number) {
|
|
77
|
+
this.#marginBottom = Math.max(0, finiteNumber(value, 0));
|
|
78
|
+
this.refreshControlLayout();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
get alignX() {
|
|
82
|
+
return this.#alignX;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@prop({ type: String, default: 'start' })
|
|
86
|
+
set alignX(value: string) {
|
|
87
|
+
this.#alignX = parseAlign(value);
|
|
88
|
+
this.layout();
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
get alignY() {
|
|
92
|
+
return this.#alignY;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
@prop({ type: String, default: 'start' })
|
|
96
|
+
set alignY(value: string) {
|
|
97
|
+
this.#alignY = parseAlign(value);
|
|
98
|
+
this.layout();
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
override layout() {
|
|
102
|
+
const size = this.syncControlBoxSize();
|
|
103
|
+
const children = this.default?.children as ControlLayoutChild[] | undefined;
|
|
104
|
+
if (!children || children.length === 0) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const innerWidth = Math.max(0, size.width - this.marginLeft - this.marginRight);
|
|
109
|
+
const innerHeight = Math.max(0, size.height - this.marginTop - this.marginBottom);
|
|
110
|
+
|
|
111
|
+
for (const child of children) {
|
|
112
|
+
const props = controlChildProps(child);
|
|
113
|
+
const childSize = controlMinSize(child, this.#baseSizes);
|
|
114
|
+
const childWidth = fillOrExpand(props.hSize) ? innerWidth : childSize.width;
|
|
115
|
+
const childHeight = fillOrExpand(props.vSize) ? innerHeight : childSize.height;
|
|
116
|
+
setControlChildBox(child, {
|
|
117
|
+
x: this.marginLeft + alignOffset(this.#alignX, Math.max(0, innerWidth - childWidth)),
|
|
118
|
+
y: this.marginTop + alignOffset(this.#alignY, Math.max(0, innerHeight - childHeight)),
|
|
119
|
+
width: childWidth,
|
|
120
|
+
height: childHeight,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
override measureControlNaturalSize(): Size {
|
|
126
|
+
const children = this.default?.children as ControlLayoutChild[] | undefined;
|
|
127
|
+
if (!children || children.length === 0) {
|
|
128
|
+
return {
|
|
129
|
+
width: this.marginLeft + this.marginRight,
|
|
130
|
+
height: this.marginTop + this.marginBottom,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
const sizes = children.map((child) => controlMinSize(child, this.#baseSizes));
|
|
134
|
+
return {
|
|
135
|
+
width: this.marginLeft + this.marginRight + sizes.reduce((max, size) => Math.max(max, size.width), 0),
|
|
136
|
+
height: this.marginTop + this.marginBottom + sizes.reduce((max, size) => Math.max(max, size.height), 0),
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Container } from 'pixi.js';
|
|
2
|
+
import { Control } from './Control.js';
|
|
3
|
+
import { type Size } from './controlLayout.js';
|
|
4
|
+
export declare class VBoxContainer extends Control {
|
|
5
|
+
#private;
|
|
6
|
+
readonly default: Container;
|
|
7
|
+
get gap(): number;
|
|
8
|
+
set gap(value: number);
|
|
9
|
+
get alignX(): string;
|
|
10
|
+
set alignX(value: string);
|
|
11
|
+
get justify(): string;
|
|
12
|
+
set justify(value: string);
|
|
13
|
+
layout(): void;
|
|
14
|
+
measureControlNaturalSize(): Size;
|
|
15
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { prop, scene, slot } from 'pixifact/compiler';
|
|
8
|
+
import { Control } from './Control.js';
|
|
9
|
+
import { finiteNumber, layoutStack, measureStackNaturalSize, parseAlign, parseJustify, } from './controlLayout.js';
|
|
10
|
+
let VBoxContainer = class VBoxContainer extends Control {
|
|
11
|
+
#gap = 0;
|
|
12
|
+
#alignX = 'start';
|
|
13
|
+
#justify = 'start';
|
|
14
|
+
#baseSizes = new WeakMap();
|
|
15
|
+
get gap() {
|
|
16
|
+
return this.#gap;
|
|
17
|
+
}
|
|
18
|
+
set gap(value) {
|
|
19
|
+
this.#gap = Math.max(0, finiteNumber(value, 0));
|
|
20
|
+
this.refreshControlLayout();
|
|
21
|
+
}
|
|
22
|
+
get alignX() {
|
|
23
|
+
return this.#alignX;
|
|
24
|
+
}
|
|
25
|
+
set alignX(value) {
|
|
26
|
+
this.#alignX = parseAlign(value);
|
|
27
|
+
this.layout();
|
|
28
|
+
}
|
|
29
|
+
get justify() {
|
|
30
|
+
return this.#justify;
|
|
31
|
+
}
|
|
32
|
+
set justify(value) {
|
|
33
|
+
this.#justify = parseJustify(value);
|
|
34
|
+
this.layout();
|
|
35
|
+
}
|
|
36
|
+
layout() {
|
|
37
|
+
this.syncControlBoxSize();
|
|
38
|
+
const assigned = this.getAssignedControlBoxSize();
|
|
39
|
+
layoutStack({
|
|
40
|
+
axis: 'vertical',
|
|
41
|
+
children: this.default?.children,
|
|
42
|
+
gap: this.#gap,
|
|
43
|
+
alignCross: this.#alignX,
|
|
44
|
+
justify: this.#justify,
|
|
45
|
+
baseSizes: this.#baseSizes,
|
|
46
|
+
width: assigned.width,
|
|
47
|
+
height: assigned.height,
|
|
48
|
+
naturalSize: () => this.measureControlNaturalSize(),
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
measureControlNaturalSize() {
|
|
52
|
+
return measureStackNaturalSize('vertical', this.default?.children, this.#gap, this.#baseSizes);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
__decorate([
|
|
56
|
+
slot()
|
|
57
|
+
], VBoxContainer.prototype, "default", void 0);
|
|
58
|
+
__decorate([
|
|
59
|
+
prop({ type: Number, default: 0 })
|
|
60
|
+
], VBoxContainer.prototype, "gap", null);
|
|
61
|
+
__decorate([
|
|
62
|
+
prop({ type: String, default: 'start' })
|
|
63
|
+
], VBoxContainer.prototype, "alignX", null);
|
|
64
|
+
__decorate([
|
|
65
|
+
prop({ type: String, default: 'start' })
|
|
66
|
+
], VBoxContainer.prototype, "justify", null);
|
|
67
|
+
VBoxContainer = __decorate([
|
|
68
|
+
scene()
|
|
69
|
+
], VBoxContainer);
|
|
70
|
+
export { VBoxContainer };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Container } from 'pixi.js';
|
|
2
|
+
import { prop, scene, slot } from 'pixifact/compiler';
|
|
3
|
+
import { Control } from './Control';
|
|
4
|
+
import {
|
|
5
|
+
finiteNumber,
|
|
6
|
+
layoutStack,
|
|
7
|
+
measureStackNaturalSize,
|
|
8
|
+
parseAlign,
|
|
9
|
+
parseJustify,
|
|
10
|
+
type ControlAlign,
|
|
11
|
+
type ControlJustify,
|
|
12
|
+
type ControlLayoutChild,
|
|
13
|
+
type Size,
|
|
14
|
+
} from './controlLayout';
|
|
15
|
+
|
|
16
|
+
@scene()
|
|
17
|
+
export class VBoxContainer extends Control {
|
|
18
|
+
@slot()
|
|
19
|
+
declare readonly default: Container;
|
|
20
|
+
|
|
21
|
+
#gap = 0;
|
|
22
|
+
#alignX: ControlAlign = 'start';
|
|
23
|
+
#justify: ControlJustify = 'start';
|
|
24
|
+
#baseSizes = new WeakMap<object, Size>();
|
|
25
|
+
|
|
26
|
+
get gap() {
|
|
27
|
+
return this.#gap;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@prop({ type: Number, default: 0 })
|
|
31
|
+
set gap(value: number) {
|
|
32
|
+
this.#gap = Math.max(0, finiteNumber(value, 0));
|
|
33
|
+
this.refreshControlLayout();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
get alignX() {
|
|
37
|
+
return this.#alignX;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@prop({ type: String, default: 'start' })
|
|
41
|
+
set alignX(value: string) {
|
|
42
|
+
this.#alignX = parseAlign(value);
|
|
43
|
+
this.layout();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
get justify() {
|
|
47
|
+
return this.#justify;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@prop({ type: String, default: 'start' })
|
|
51
|
+
set justify(value: string) {
|
|
52
|
+
this.#justify = parseJustify(value);
|
|
53
|
+
this.layout();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
override layout() {
|
|
57
|
+
this.syncControlBoxSize();
|
|
58
|
+
const assigned = this.getAssignedControlBoxSize();
|
|
59
|
+
layoutStack({
|
|
60
|
+
axis: 'vertical',
|
|
61
|
+
children: this.default?.children as ControlLayoutChild[] | undefined,
|
|
62
|
+
gap: this.#gap,
|
|
63
|
+
alignCross: this.#alignX,
|
|
64
|
+
justify: this.#justify,
|
|
65
|
+
baseSizes: this.#baseSizes,
|
|
66
|
+
width: assigned.width,
|
|
67
|
+
height: assigned.height,
|
|
68
|
+
naturalSize: () => this.measureControlNaturalSize(),
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
override measureControlNaturalSize(): Size {
|
|
73
|
+
return measureStackNaturalSize('vertical', this.default?.children as ControlLayoutChild[] | undefined, this.#gap, this.#baseSizes);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Container, type ContainerChild } from 'pixi.js';
|
|
2
|
+
export type ControlSizeMode = 'content' | 'fill' | 'expand';
|
|
3
|
+
export type ControlAlign = 'start' | 'center' | 'end';
|
|
4
|
+
export type ControlJustify = 'start' | 'center' | 'end' | 'space-between';
|
|
5
|
+
export type ControlAxis = 'horizontal' | 'vertical';
|
|
6
|
+
export interface Size {
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
}
|
|
10
|
+
export interface Rect extends Size {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
}
|
|
14
|
+
export interface ControlLayoutProps {
|
|
15
|
+
minWidth: number;
|
|
16
|
+
minHeight: number;
|
|
17
|
+
hSize: ControlSizeMode;
|
|
18
|
+
vSize: ControlSizeMode;
|
|
19
|
+
stretch: number;
|
|
20
|
+
}
|
|
21
|
+
export type ControlLayoutChild = ContainerChild & {
|
|
22
|
+
getControlLayoutProps?: () => ControlLayoutProps;
|
|
23
|
+
measureControlNaturalSize?: () => Size;
|
|
24
|
+
setControlLayoutBox?: (x: number, y: number, width: number, height: number) => void;
|
|
25
|
+
};
|
|
26
|
+
export declare const defaultControlLayoutProps: ControlLayoutProps;
|
|
27
|
+
export declare function measureChildren(container: Container): Size;
|
|
28
|
+
export declare function measureChildrenBounds(container: Container): Rect;
|
|
29
|
+
export declare function measureControlChild(child: ControlLayoutChild, baseSizes: WeakMap<object, Size>): Size;
|
|
30
|
+
export declare function controlChildProps(child: ControlLayoutChild): ControlLayoutProps;
|
|
31
|
+
export declare function controlMinSize(child: ControlLayoutChild, baseSizes: WeakMap<object, Size>): Size;
|
|
32
|
+
export declare function setControlChildBox(child: ControlLayoutChild, rect: Rect): void;
|
|
33
|
+
export interface StackLayoutOptions {
|
|
34
|
+
axis: ControlAxis;
|
|
35
|
+
children: ControlLayoutChild[] | undefined;
|
|
36
|
+
gap: number;
|
|
37
|
+
alignCross: ControlAlign;
|
|
38
|
+
justify: ControlJustify;
|
|
39
|
+
baseSizes: WeakMap<object, Size>;
|
|
40
|
+
width: number | undefined;
|
|
41
|
+
height: number | undefined;
|
|
42
|
+
naturalSize: () => Size;
|
|
43
|
+
}
|
|
44
|
+
export declare function layoutStack(options: StackLayoutOptions): void;
|
|
45
|
+
export declare function measureStackNaturalSize(axis: ControlAxis, children: ControlLayoutChild[] | undefined, gap: number, baseSizes: WeakMap<object, Size>): Size;
|
|
46
|
+
export declare function fillOrExpand(mode: ControlSizeMode): mode is "fill" | "expand";
|
|
47
|
+
export declare function crossAxis(axis: ControlAxis): ControlAxis;
|
|
48
|
+
export declare function alignOffset(align: ControlAlign, available: number): number;
|
|
49
|
+
export declare function justifyOffset(justify: ControlJustify, available: number): number;
|
|
50
|
+
export declare function parseSizeMode(value: string): ControlSizeMode;
|
|
51
|
+
export declare function parseAlign(value: string): ControlAlign;
|
|
52
|
+
export declare function parseJustify(value: string): ControlJustify;
|
|
53
|
+
export declare function finiteNumber(value: number, fallback: number): number;
|
|
54
|
+
export declare function boxSize(value: number | {
|
|
55
|
+
width: number;
|
|
56
|
+
height?: number;
|
|
57
|
+
}, height?: number): Size;
|