@gedit/editor-2d 0.2.45 → 0.2.47
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/lib/browser/model/editor2d-document.d.ts +11 -2
- package/lib/browser/model/editor2d-document.d.ts.map +1 -1
- package/lib/browser/model/editor2d-document.js +44 -8
- package/lib/browser/model/editor2d-document.js.map +1 -1
- package/lib/browser/model/editor2d-model-container.d.ts.map +1 -1
- package/lib/browser/model/editor2d-model-container.js +1 -1
- package/lib/browser/model/editor2d-model-container.js.map +1 -1
- package/lib/browser/model/editor2d-model.d.ts +2 -0
- package/lib/browser/model/editor2d-model.d.ts.map +1 -1
- package/lib/browser/model/editor2d-model.js +5 -0
- package/lib/browser/model/editor2d-model.js.map +1 -1
- package/lib/browser/model/editor2d.d.ts +2 -0
- package/lib/browser/model/editor2d.d.ts.map +1 -1
- package/lib/browser/model/editor2d.js +4 -2
- package/lib/browser/model/editor2d.js.map +1 -1
- package/lib/browser/playground/canvas-draw.d.ts.map +1 -1
- package/lib/browser/playground/canvas-draw.js +30 -27
- package/lib/browser/playground/canvas-draw.js.map +1 -1
- package/lib/browser/playground/canvas-layer.d.ts +14 -2
- package/lib/browser/playground/canvas-layer.d.ts.map +1 -1
- package/lib/browser/playground/canvas-layer.js +96 -50
- package/lib/browser/playground/canvas-layer.js.map +1 -1
- package/lib/browser/playground/index.d.ts +2 -0
- package/lib/browser/playground/index.d.ts.map +1 -1
- package/lib/browser/playground/index.js +2 -0
- package/lib/browser/playground/index.js.map +1 -1
- package/lib/browser/playground/path-edit/index.d.ts +4 -0
- package/lib/browser/playground/path-edit/index.d.ts.map +1 -0
- package/lib/browser/playground/path-edit/index.js +20 -0
- package/lib/browser/playground/path-edit/index.js.map +1 -0
- package/lib/browser/playground/path-edit/path-edit-layer-move-point.d.ts +18 -0
- package/lib/browser/playground/path-edit/path-edit-layer-move-point.d.ts.map +1 -0
- package/lib/browser/playground/path-edit/path-edit-layer-move-point.js +52 -0
- package/lib/browser/playground/path-edit/path-edit-layer-move-point.js.map +1 -0
- package/lib/browser/playground/path-edit/path-edit-layer-svg-path.d.ts +21 -0
- package/lib/browser/playground/path-edit/path-edit-layer-svg-path.d.ts.map +1 -0
- package/lib/browser/playground/path-edit/path-edit-layer-svg-path.js +158 -0
- package/lib/browser/playground/path-edit/path-edit-layer-svg-path.js.map +1 -0
- package/lib/browser/playground/path-edit/utils.d.ts +37 -0
- package/lib/browser/playground/path-edit/utils.d.ts.map +1 -0
- package/lib/browser/playground/path-edit/utils.js +236 -0
- package/lib/browser/playground/path-edit/utils.js.map +1 -0
- package/lib/browser/playground/path-edit-layer.d.ts +32 -12
- package/lib/browser/playground/path-edit-layer.d.ts.map +1 -1
- package/lib/browser/playground/path-edit-layer.js +460 -146
- package/lib/browser/playground/path-edit-layer.js.map +1 -1
- package/lib/browser/playground/playground-context.d.ts +5 -2
- package/lib/browser/playground/playground-context.d.ts.map +1 -1
- package/lib/browser/playground/playground-context.js +13 -2
- package/lib/browser/playground/playground-context.js.map +1 -1
- package/lib/browser/playground/playground-contribution.d.ts +2 -1
- package/lib/browser/playground/playground-contribution.d.ts.map +1 -1
- package/lib/browser/playground/playground-contribution.js +4 -21
- package/lib/browser/playground/playground-contribution.js.map +1 -1
- package/lib/browser/playground/selection-entity-manager.d.ts.map +1 -1
- package/lib/browser/playground/selection-entity-manager.js +24 -8
- package/lib/browser/playground/selection-entity-manager.js.map +1 -1
- package/lib/browser/playground/selector-extend-renderer.d.ts +2 -1
- package/lib/browser/playground/selector-extend-renderer.d.ts.map +1 -1
- package/lib/browser/playground/selector-extend-renderer.js +50 -21
- package/lib/browser/playground/selector-extend-renderer.js.map +1 -1
- package/lib/browser/utils/snapshot.d.ts +1 -0
- package/lib/browser/utils/snapshot.d.ts.map +1 -1
- package/lib/browser/utils/snapshot.js +11 -0
- package/lib/browser/utils/snapshot.js.map +1 -1
- package/package.json +9 -7
- package/src/browser/model/editor2d-document.ts +44 -6
- package/src/browser/model/editor2d-model-container.ts +2 -0
- package/src/browser/model/editor2d-model.ts +2 -0
- package/src/browser/model/editor2d.ts +4 -1
- package/src/browser/playground/canvas-draw.ts +30 -25
- package/src/browser/playground/canvas-layer.ts +97 -52
- package/src/browser/playground/index.ts +2 -0
- package/src/browser/playground/path-edit/index.ts +3 -0
- package/src/browser/playground/path-edit/path-edit-layer-move-point.tsx +108 -0
- package/src/browser/playground/path-edit/path-edit-layer-svg-path.tsx +283 -0
- package/src/browser/playground/path-edit/utils.tsx +285 -0
- package/src/browser/playground/path-edit-layer.tsx +563 -216
- package/src/browser/playground/playground-context.ts +7 -1
- package/src/browser/playground/playground-contribution.ts +2 -21
- package/src/browser/playground/selection-entity-manager.tsx +34 -6
- package/src/browser/playground/selector-extend-renderer.tsx +69 -37
- package/src/browser/style/path-edit-layer.less +17 -30
- package/src/browser/svg/pen_close.svg +24 -0
- package/src/browser/utils/snapshot.ts +11 -0
- package/lib/browser/playground/path-edit-layer-move-point.d.ts +0 -15
- package/lib/browser/playground/path-edit-layer-move-point.d.ts.map +0 -1
- package/lib/browser/playground/path-edit-layer-move-point.js +0 -47
- package/lib/browser/playground/path-edit-layer-move-point.js.map +0 -1
- package/lib/browser/playground/path-edit-layer-svg-path.d.ts +0 -11
- package/lib/browser/playground/path-edit-layer-svg-path.d.ts.map +0 -1
- package/lib/browser/playground/path-edit-layer-svg-path.js +0 -21
- package/lib/browser/playground/path-edit-layer-svg-path.js.map +0 -1
- package/src/browser/playground/path-edit-layer-move-point.tsx +0 -71
- package/src/browser/playground/path-edit-layer-svg-path.tsx +0 -50
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../../../src/browser/utils/snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,
|
|
1
|
+
{"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../../../src/browser/utils/snap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AAU,CAAC;IAC7B,SAAS,CAAC,UAAU,CAAC,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC;IAC7C,SAAS,CAAC,MAAM,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CAAA;KAAE,CAAM;IACnD,SAAS,CAAC,cAAc,EAAE,aAAa,EAAE,CAAM;IAC/C,SAAS,CAAC,eAAe,gBAAuB;IAChD,QAAQ,CAAC,QAAQ,qCAA8B;IAC/C,SAAS,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC;gBAEb,IAAI,EAAE,YAAY;IAmBvC;;OAEG;IACH,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,IAAI;IAO7C,kBAAkB,IAAI,QAAQ,EAAE;IAGhC,iBAAiB,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI;IAGvC,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS;IAGxC,IAAI,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAUxD,SAAS,CAAC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IA2ClC,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,YAAY,GAAG,YAAY;IAQlD,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,IAAI,GAAG,IAAI;IA0BrC;;;;;;OAMG;IACH,kBAAkB,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,EAAE,OAAO,SAAM,EAAE,KAAK,SAAO,GAAG,UAAU;CAgBnH"}
|
|
@@ -117,6 +117,15 @@ class SnapshotCreator extends utils_1.DisposableImpl {
|
|
|
117
117
|
this.next(() => dispose.dispose());
|
|
118
118
|
return deferred.promise;
|
|
119
119
|
}
|
|
120
|
+
setParent(n) {
|
|
121
|
+
if (!n.children)
|
|
122
|
+
return n;
|
|
123
|
+
n.children.forEach((c) => {
|
|
124
|
+
c.parent = n;
|
|
125
|
+
this.setParent(c);
|
|
126
|
+
});
|
|
127
|
+
return n;
|
|
128
|
+
}
|
|
120
129
|
next(end) {
|
|
121
130
|
var _a, _b;
|
|
122
131
|
const next = this.processingData.shift();
|
|
@@ -131,6 +140,8 @@ class SnapshotCreator extends utils_1.DisposableImpl {
|
|
|
131
140
|
const attrs = this.opts.renderEngine.getDisplayDefaultData(this.opts.engineName, content.displayType);
|
|
132
141
|
Object.assign(content, Object.assign({}, attrs));
|
|
133
142
|
}
|
|
143
|
+
// 设置 parent, 保持 id 一致; mask 里用的是 path id;
|
|
144
|
+
content = this.setParent((0, utils_1.deepClone)(content));
|
|
134
145
|
this.drawer.update({
|
|
135
146
|
visible: true,
|
|
136
147
|
uri: next.uri,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../../../src/browser/utils/snapshot.ts"],"names":[],"mappings":";;;AAAA,2DAAuE;AACvE,
|
|
1
|
+
{"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../../../src/browser/utils/snapshot.ts"],"names":[],"mappings":";;;AAAA,2DAAuE;AACvE,wCAUsB;AAEtB,oCAAwC;AAW3B,QAAA,mBAAmB,GAAG;IACjC,OAAO,EAAE,GAAG;IACZ,SAAS,EAAE,YAAY;CACxB,CAAC;AAgBF,SAAS,cAAc,CAAC,MAAkB,EAAE,SAAqB;IAC/D,iDAAiD;IACjD,0BAA0B;IAC1B,MAAM,WAAW,GAAG,MAAM,CAAC,YAAY,EAAE,CAAC;IAC1C,MAAM,KAAK,GAAG,kBAAU,CAAC,OAAO,CAAC,WAAY,EAAE;QAC7C,KAAK,EAAE,SAAS,CAAC,KAAK;QACtB,MAAM,EAAE,SAAS,CAAC,MAAM;KACzB,CAAC,CAAC;IACH,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AACpC,CAAC;AAEM,KAAK,UAAU,eAAe,CAAC,IAAkB,EAA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AAc,EAAE,EAAE;wBAC1E,IAAI,MAAM,EAAE;4BACV,EAAE,CAAC,MAAM,CAAC,CAAC;yBACZ;oBACH,CAAC,CAAC,CAAC;iBACJ;aACF;QACH,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;IACb,CAAC;CACF;AA7JD,0CA6JC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gedit/editor-2d",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.47",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/browser/index",
|
|
6
6
|
"typings": "lib/browser/index.d.ts",
|
|
@@ -9,11 +9,13 @@
|
|
|
9
9
|
"src"
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@gedit/app-config": "^0.2.
|
|
13
|
-
"@gedit/
|
|
14
|
-
"@gedit/
|
|
15
|
-
"@gedit/
|
|
16
|
-
"@gedit/
|
|
12
|
+
"@gedit/app-config": "^0.2.40",
|
|
13
|
+
"@gedit/canvas-draw": "^0.2.32",
|
|
14
|
+
"@gedit/editor": "^0.2.13",
|
|
15
|
+
"@gedit/playground": "^0.2.18",
|
|
16
|
+
"@gedit/render-engine-ide": "^0.2.38",
|
|
17
|
+
"@gedit/theme": "^0.2.10",
|
|
18
|
+
"@gedit/workspace-2d": "^0.2.18",
|
|
17
19
|
"bezier-js": "^4.0.3",
|
|
18
20
|
"clsx": "^1.1.1",
|
|
19
21
|
"json-stringify-pretty-compact": "^2.0.0",
|
|
@@ -37,5 +39,5 @@
|
|
|
37
39
|
"nyc": {
|
|
38
40
|
"extends": "../../configs/nyc.json"
|
|
39
41
|
},
|
|
40
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "3556856ee2671257bd0c588bdfdc18ac0d57dab4"
|
|
41
43
|
}
|
|
@@ -30,6 +30,8 @@ import { WorkspaceResourceService } from '@gedit/workspace-2d';
|
|
|
30
30
|
import { ResourceProvider, ResourceRefError } from '@gedit/resource';
|
|
31
31
|
import { AppConfigService } from '@gedit/app-config';
|
|
32
32
|
import { Editor2dIterator } from './editor2d-iterator';
|
|
33
|
+
import { ThemeService } from '@gedit/theme';
|
|
34
|
+
import { followKeyType, getFollowValue } from '@gedit/render-engine-pixi';
|
|
33
35
|
// import { getAnimationKeys, getChangeAnimationData } from './utils';
|
|
34
36
|
|
|
35
37
|
export const maskShowArray: GameObjectType[] = [
|
|
@@ -41,7 +43,8 @@ export const maskShowArray: GameObjectType[] = [
|
|
|
41
43
|
GameObjectBaseType.TEXT,
|
|
42
44
|
GameObjectBaseType.TRIANGLE,
|
|
43
45
|
GameObjectBaseType.COMPONENT,
|
|
44
|
-
GameObjectBaseType.ANIM_FRAMES
|
|
46
|
+
GameObjectBaseType.ANIM_FRAMES,
|
|
47
|
+
GameObjectBaseType.STAR,
|
|
45
48
|
];
|
|
46
49
|
export const maskEnabledArray: GameObjectType[] = [
|
|
47
50
|
GameObjectBaseType.GROUP,
|
|
@@ -91,7 +94,7 @@ export class Editor2dDocument extends TreeImpl<Editor2dNode, Editor2dContainerNo
|
|
|
91
94
|
}
|
|
92
95
|
|
|
93
96
|
constructor(
|
|
94
|
-
@inject(MessageService)
|
|
97
|
+
@inject(MessageService) readonly message: MessageService,
|
|
95
98
|
@inject(Editor2dModelOptions) protected readonly options: Editor2dModelOptions,
|
|
96
99
|
@inject(ResourceProvider) protected readonly resourceProvider: ResourceProvider,
|
|
97
100
|
@inject(ResourceAutoSaveService) protected readonly resourceAutoSaveService: ResourceAutoSaveService,
|
|
@@ -99,6 +102,7 @@ export class Editor2dDocument extends TreeImpl<Editor2dNode, Editor2dContainerNo
|
|
|
99
102
|
@inject(RenderEngineIDEService) readonly engineService: RenderEngineIDEService,
|
|
100
103
|
@inject(AppConfigService) readonly appConfig: AppConfigService,
|
|
101
104
|
@inject(Editor2dComponentProvider) @optional() readonly componentProvider?: Editor2dComponentProvider,
|
|
105
|
+
@inject(ThemeService) @optional() readonly themeService?: ThemeService,
|
|
102
106
|
) {
|
|
103
107
|
super();
|
|
104
108
|
this.toDispose.push(this.onContentChangedEmitter);
|
|
@@ -886,8 +890,11 @@ export class Editor2dDocument extends TreeImpl<Editor2dNode, Editor2dContainerNo
|
|
|
886
890
|
if (!checkSuccess) return false;
|
|
887
891
|
const siblings = (targetNode as Editor2dContainerNode).children || [];
|
|
888
892
|
if (childDeco.single) {
|
|
889
|
-
const
|
|
890
|
-
if (
|
|
893
|
+
const single = typeof childDeco.single === 'function' ? childDeco.single(this.themeService?.mode) : childDeco.single;
|
|
894
|
+
if (single) {
|
|
895
|
+
const addedNodes = siblings.filter(s => s.displayType === childDisplayType);
|
|
896
|
+
if (addedNodes.length > 0) return false;
|
|
897
|
+
}
|
|
891
898
|
}
|
|
892
899
|
if (childDeco.canbeAddedAsChild !== undefined) {
|
|
893
900
|
return childDeco.canbeAddedAsChild(targetNode, siblings);
|
|
@@ -1110,9 +1117,24 @@ export class Editor2dDocument extends TreeImpl<Editor2dNode, Editor2dContainerNo
|
|
|
1110
1117
|
x: moveType === 'x' ? position.x + moveDelta : position.x,
|
|
1111
1118
|
y: moveType === 'y' ? position.y + moveDelta : position.y,
|
|
1112
1119
|
};
|
|
1113
|
-
|
|
1120
|
+
// 锁定跟随图层
|
|
1121
|
+
if (node.follow) {
|
|
1122
|
+
const { open, target, type } = node.follow;
|
|
1123
|
+
if (open && target && node.position) {
|
|
1124
|
+
this.message.warn(
|
|
1125
|
+
`元素开启了跟随,${type
|
|
1126
|
+
?.map(c => followKeyType[c])
|
|
1127
|
+
.join(',')} 被锁定`,
|
|
1128
|
+
{timeout: 2000 }
|
|
1129
|
+
);
|
|
1130
|
+
const p = this.getFollowPosition(node);
|
|
1131
|
+
p.forEach(c => {
|
|
1132
|
+
newPosition[c.type] = c.value;
|
|
1133
|
+
});
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
this.updateNode(node, { position: newPosition }, true, true, true);
|
|
1114
1137
|
});
|
|
1115
|
-
this.clearSelectNodeFollow();
|
|
1116
1138
|
this.fireContentChanged(nodes, 'update');
|
|
1117
1139
|
}
|
|
1118
1140
|
|
|
@@ -1139,6 +1161,22 @@ export class Editor2dDocument extends TreeImpl<Editor2dNode, Editor2dContainerNo
|
|
|
1139
1161
|
return 0;
|
|
1140
1162
|
}
|
|
1141
1163
|
|
|
1164
|
+
/**
|
|
1165
|
+
* 锁定节点的 follow
|
|
1166
|
+
*/
|
|
1167
|
+
getFollowPosition(node: Editor2dNode): { value: number; type: 'x' | 'y' }[] {
|
|
1168
|
+
if (node.follow) {
|
|
1169
|
+
const { open, target } = node.follow;
|
|
1170
|
+
if (open && target && node.position) {
|
|
1171
|
+
const targetNode = this.getNodeById(target);
|
|
1172
|
+
if (targetNode && targetNode.position) {
|
|
1173
|
+
const t = getFollowValue(node.follow, targetNode);
|
|
1174
|
+
return t;
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
return [];
|
|
1179
|
+
}
|
|
1142
1180
|
/**
|
|
1143
1181
|
* 清除节点的 follow
|
|
1144
1182
|
*/
|
|
@@ -2,6 +2,7 @@ import { Container, interfaces } from 'inversify';
|
|
|
2
2
|
import {
|
|
3
3
|
Editor2dDocument,
|
|
4
4
|
Editor2dDocumentContextMenuPath,
|
|
5
|
+
Editor2dDocumentContextMenuPathEditPath,
|
|
5
6
|
Editor2dModel,
|
|
6
7
|
Editor2dModelOptions,
|
|
7
8
|
Editor2dSelection,
|
|
@@ -39,6 +40,7 @@ export function createEditor2dModelContainer(parent: interfaces.Container, opts:
|
|
|
39
40
|
...createDefaultPlaygroundConfig(),
|
|
40
41
|
autoFocus: false,
|
|
41
42
|
contextMenuPath: Editor2dDocumentContextMenuPath,
|
|
43
|
+
contextMenuPathEditPath: Editor2dDocumentContextMenuPathEditPath,
|
|
42
44
|
...opts.playgroundConfig,
|
|
43
45
|
});
|
|
44
46
|
c.bind(PlaygroundContribution).toService(PlaygroundContribution2d);
|
|
@@ -6,6 +6,7 @@ import { Editor2dModelOptions } from './editor2d';
|
|
|
6
6
|
import { Editor2dSelection } from './editor2d-selection';
|
|
7
7
|
import { Editor2dWidget } from './editor2d-widget';
|
|
8
8
|
import type { Editor2dPlayGround } from '../playground/playground-context';
|
|
9
|
+
import { PathPointSelectionService } from '@gedit/playground';
|
|
9
10
|
|
|
10
11
|
export const Editor2dModelFactory = Symbol('Editor2dModelFactory');
|
|
11
12
|
export type Editor2dModelFactory = (options: Editor2dModelOptions) => Editor2dModel;
|
|
@@ -26,6 +27,7 @@ export class Editor2dModel implements Editor {
|
|
|
26
27
|
@inject(Editor2dModelOptions) protected readonly options: Editor2dModelOptions;
|
|
27
28
|
@inject(Editor2dDocument) readonly document: Editor2dDocument;
|
|
28
29
|
@inject(Editor2dSelection) readonly selection: Editor2dSelection;
|
|
30
|
+
@inject(PathPointSelectionService) readonly pathPointSelection: PathPointSelectionService;
|
|
29
31
|
node: HTMLElement;
|
|
30
32
|
|
|
31
33
|
@postConstruct()
|
|
@@ -29,7 +29,9 @@ export interface Editor2dContent {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
// 文档内容菜单
|
|
32
|
-
export const Editor2dDocumentContextMenuPath = ['editor2d-
|
|
32
|
+
export const Editor2dDocumentContextMenuPath = ['editor2d-document-menu'];
|
|
33
|
+
// 路径编辑态的菜单
|
|
34
|
+
export const Editor2dDocumentContextMenuPathEditPath = ['editor2d-document-path-menu'];
|
|
33
35
|
|
|
34
36
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
35
37
|
function omitNode(node?: Editor2dNode | Editor2dContainerNode, omitKeys: string[] = [], assign?: (n: Editor2dNode) => Editor2dNode): any {
|
|
@@ -91,6 +93,7 @@ export interface Editor2dNode extends TreeNode, EditorDocumentNode, Lockable, Se
|
|
|
91
93
|
*/
|
|
92
94
|
export interface Editor2dPathNode extends Editor2dNode {
|
|
93
95
|
[GameObjectBaseType.PATH]: {
|
|
96
|
+
closed?: boolean;
|
|
94
97
|
paths: PathChild[]
|
|
95
98
|
}
|
|
96
99
|
}
|
|
@@ -272,47 +272,52 @@ export class CanvasDraw extends DisposableImpl {
|
|
|
272
272
|
return depth;
|
|
273
273
|
}
|
|
274
274
|
gameObjectCache.set(nodePath, gameObject);
|
|
275
|
+
const updateParent = (node?: Editor2dNode, obj?: GameObject, type: GameObjectEventType = GameObjectEventType.UPDATE) => {
|
|
276
|
+
// 如果父级是组件或分组更新中心点;
|
|
277
|
+
if (
|
|
278
|
+
node &&
|
|
279
|
+
obj &&
|
|
280
|
+
!Editor2dNode.isRootNode(node)
|
|
281
|
+
) {
|
|
282
|
+
this.onGameObjectChangeEmitter.fire({
|
|
283
|
+
type,
|
|
284
|
+
gameObject: obj!,
|
|
285
|
+
node: node!,
|
|
286
|
+
});
|
|
287
|
+
if (node.parent && obj.parent) {
|
|
288
|
+
updateParent(node.parent, obj.parent, type);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
};
|
|
275
292
|
scene.onGameObjectDispose(gameObject, () => {
|
|
276
|
-
const parentObject = parentId ? this.gameObjectCache.get(parentId) : undefined;
|
|
277
|
-
const parentNode = parentId ? this.nodeCache.get(parentId) : undefined;
|
|
278
293
|
const node = this.nodeCache.get(nodePath)!;
|
|
279
|
-
this.gameObjectCache.delete(nodePath);
|
|
280
|
-
this.nodeVersionCache.delete(nodePath);
|
|
281
|
-
this.nodeCache.delete(nodePath);
|
|
282
|
-
this.maskCache.delete(nodePath);
|
|
283
294
|
this.onGameObjectChangeEmitter.fire({
|
|
284
295
|
type: GameObjectEventType.DESTROY,
|
|
285
296
|
gameObject: gameObject!,
|
|
286
|
-
parentObject,
|
|
287
|
-
parentNode,
|
|
288
297
|
node,
|
|
289
298
|
});
|
|
299
|
+
updateParent(node, gameObject);
|
|
300
|
+
this.gameObjectCache.delete(nodePath);
|
|
301
|
+
this.nodeVersionCache.delete(nodePath);
|
|
302
|
+
this.nodeCache.delete(nodePath);
|
|
303
|
+
this.maskCache.delete(nodePath);
|
|
290
304
|
});
|
|
291
305
|
scene.onGameObjectUpdate(gameObject, () => {
|
|
292
|
-
const
|
|
293
|
-
|
|
294
|
-
this.onGameObjectChangeEmitter.fire({
|
|
306
|
+
const node = this.nodeCache.get(nodePath);
|
|
307
|
+
/* this.onGameObjectChangeEmitter.fire({
|
|
295
308
|
type: GameObjectEventType.UPDATE,
|
|
296
309
|
gameObject: gameObject!,
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
310
|
+
node: node!,
|
|
311
|
+
}); */
|
|
312
|
+
// 更新父级
|
|
313
|
+
updateParent(node, gameObject);
|
|
301
314
|
});
|
|
302
315
|
scene.onGameObjectCreate(gameObject, () => {
|
|
303
316
|
this.nodeVersionCache.set(nodePath, newVersion);
|
|
304
317
|
this.maskCache.set(nodePath, { mask: node.mask, isMask: node.isMask, ignoreMask: node.ignoreMask });
|
|
305
|
-
const parentObject = parentId ? this.gameObjectCache.get(parentId) : undefined;
|
|
306
|
-
const parentNode = parentId ? this.nodeCache.get(parentId) : undefined;
|
|
307
|
-
this.onGameObjectChangeEmitter.fire({
|
|
308
|
-
type: GameObjectEventType.CREATE_READY,
|
|
309
|
-
gameObject: gameObject!,
|
|
310
|
-
node: this.nodeCache.get(nodePath)!,
|
|
311
|
-
parentObject,
|
|
312
|
-
parentNode
|
|
313
|
-
});
|
|
314
318
|
// 根节点创建完成则代表加载完成
|
|
315
319
|
this.fireLoading(Editor2dNode.isRootNode(this.nodeCache.get(nodePath)!));
|
|
320
|
+
updateParent(this.nodeCache.get(nodePath), gameObject);
|
|
316
321
|
});
|
|
317
322
|
scene.onGameObjectError(gameObject, error => {
|
|
318
323
|
this.onGameObjectChangeEmitter.fire({
|
|
@@ -360,7 +365,7 @@ export class CanvasDraw extends DisposableImpl {
|
|
|
360
365
|
this.maskCache.set(nodePath, { mask: node.mask, isMask: node.isMask, ignoreMask: node.ignoreMask });
|
|
361
366
|
}
|
|
362
367
|
};
|
|
363
|
-
if (!firstCreate && gameObject
|
|
368
|
+
if (!firstCreate && gameObject?.created) {
|
|
364
369
|
try {
|
|
365
370
|
update();
|
|
366
371
|
} catch (e) {
|
|
@@ -2,19 +2,83 @@ import { entity, Layer, PipelineDimension } from '@gedit/playground';
|
|
|
2
2
|
import { DocumentEntity, Editor2dEntity } from './entities';
|
|
3
3
|
import { domUtils } from '@gedit/utils/lib/browser';
|
|
4
4
|
import { PlaygroundContext2d } from './playground-context';
|
|
5
|
-
import { Editor2dDocument } from '../model';
|
|
5
|
+
import { Editor2dDocument, Editor2dNode } from '../model';
|
|
6
6
|
import { Rectangle } from '@gedit/math';
|
|
7
7
|
import { SelectionEntityManager } from './selection-entity-manager';
|
|
8
8
|
import { CanvasDraw, CanvasDrawLoadingState, GameObjectChangeEvent, GameObjectEventType } from './canvas-draw';
|
|
9
9
|
import { debounce, OriginSchema } from '@gedit/utils';
|
|
10
|
-
import { GameObjectBaseType, GameWidgetIDE } from '@gedit/render-engine-ide';
|
|
10
|
+
import { GameObject, GameObjectBaseType, GameWidgetIDE } from '@gedit/render-engine-ide';
|
|
11
|
+
import { toFixedValue as toFixedValueFunc } from '@gedit/canvas-draw';
|
|
12
|
+
/**
|
|
13
|
+
* 四舍五入并保留小数点
|
|
14
|
+
* @param value
|
|
15
|
+
* @param fixed 需要保留的小数位,默认两位
|
|
16
|
+
*/
|
|
17
|
+
export const toFixedValue = toFixedValueFunc;
|
|
11
18
|
|
|
19
|
+
const childrenMap = (list: GameObject[], c: GameObject) => {
|
|
20
|
+
if (c.disposed) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (!list.includes(c)) {
|
|
24
|
+
list.push(c);
|
|
25
|
+
}
|
|
26
|
+
if (c.children) {
|
|
27
|
+
c.children.forEach(d => {
|
|
28
|
+
childrenMap(list, d);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const parentMap = (list: GameObject[], p: GameObject) => {
|
|
33
|
+
if (p.disposed) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (!list.includes(p)) {
|
|
37
|
+
list.push(p);
|
|
38
|
+
}
|
|
39
|
+
if (p.parent) {
|
|
40
|
+
parentMap(list , p.parent);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const getListData = (list: GameObject[]) => {
|
|
45
|
+
let updateList: GameObject[] = [];
|
|
46
|
+
|
|
47
|
+
// 遍历更新节点;
|
|
48
|
+
list.forEach(item => {
|
|
49
|
+
if (item.disposed) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (!updateList.includes(item)) {
|
|
53
|
+
updateList.push(item);
|
|
54
|
+
}
|
|
55
|
+
// 子级遍历
|
|
56
|
+
if (item.children) {
|
|
57
|
+
item.children.forEach(c => {
|
|
58
|
+
childrenMap(updateList, c);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
// 父级遍历
|
|
62
|
+
if (item.parent) {
|
|
63
|
+
childrenMap(updateList, item.parent);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
updateList = updateList.filter(c => !c.disposed).sort((a, b) => {
|
|
67
|
+
const aa = a.getDepth?.() || 0;
|
|
68
|
+
const bb = b.getDepth?.() || 0;
|
|
69
|
+
return aa - bb;
|
|
70
|
+
});
|
|
71
|
+
return updateList;
|
|
72
|
+
};
|
|
12
73
|
export class CanvasLayer extends Layer<PlaygroundContext2d> {
|
|
13
74
|
@entity(DocumentEntity) documentEntity: DocumentEntity;
|
|
14
75
|
node = domUtils.createDivWithClass('gedit-canvas-layer');
|
|
15
76
|
protected scene?: HTMLElement;
|
|
16
77
|
protected selectionEntityManager: SelectionEntityManager;
|
|
17
78
|
protected canvasDrawer?: CanvasDraw;
|
|
79
|
+
protected updateList: GameObject[] = [];
|
|
80
|
+
protected nodeCache: Map<string, Editor2dNode> = new Map();
|
|
81
|
+
protected updateTimeout: NodeJS.Timeout;
|
|
18
82
|
onReady(): void {
|
|
19
83
|
this.selectionEntityManager = new SelectionEntityManager(
|
|
20
84
|
this.entityManager,
|
|
@@ -50,19 +114,19 @@ export class CanvasLayer extends Layer<PlaygroundContext2d> {
|
|
|
50
114
|
if (config.appConfig?.engine !== 'pixi' || !entity) {
|
|
51
115
|
return;
|
|
52
116
|
}
|
|
53
|
-
const
|
|
117
|
+
const node = this.nodeCache.get(entity.id);
|
|
54
118
|
const type = node?.displayType;
|
|
55
119
|
// 分组与组件创建完后初始化中心点;
|
|
56
120
|
if (
|
|
57
|
-
node && (type === GameObjectBaseType.
|
|
58
|
-
type === GameObjectBaseType.COMPONENT)
|
|
121
|
+
node && (type === GameObjectBaseType.COMPONENT)
|
|
59
122
|
) {
|
|
60
123
|
const { transform } = entity;
|
|
61
124
|
const { origin: org, localBounds } = transform;
|
|
62
|
-
|
|
125
|
+
// console.log(localBounds, entity.gameObject.rendererObject._localBoundsRect);
|
|
126
|
+
const { x: minX, y: minY, width, height } = localBounds; // entity.gameObject.rendererObject._localBoundsRect;
|
|
63
127
|
// 算出组件与组的 0 点位置;
|
|
64
|
-
const x = (-minX / width) || 0;
|
|
65
|
-
const y = (-minY / height) || 0;
|
|
128
|
+
const x = toFixedValue((-minX / width) || 0, 6);
|
|
129
|
+
const y = toFixedValue((-minY / height) || 0, 6);
|
|
66
130
|
const initOrigin = { x, y };
|
|
67
131
|
const o: OriginSchema = update ? org : initOrigin;
|
|
68
132
|
if (update || typeof o.initX === 'undefined') {
|
|
@@ -74,69 +138,50 @@ export class CanvasLayer extends Layer<PlaygroundContext2d> {
|
|
|
74
138
|
initY: initOrigin.y || 0
|
|
75
139
|
};
|
|
76
140
|
// group origin 始终为 0;
|
|
77
|
-
if (type === GameObjectBaseType.GROUP) {
|
|
78
|
-
origin.x = initOrigin.x || 0;
|
|
79
|
-
origin.y = initOrigin.y || 0;
|
|
80
|
-
}
|
|
81
141
|
// transform.update({ origin });
|
|
82
142
|
this.document?.updateNode(node, {
|
|
83
143
|
origin,
|
|
84
144
|
});
|
|
145
|
+
// console.log('--------------origin--------------', origin);
|
|
146
|
+
// obj.data.origin = origin;
|
|
85
147
|
// this.selectionEntityManager.updateEntity(obj.id, obj);
|
|
86
148
|
}
|
|
87
149
|
}
|
|
88
150
|
};
|
|
151
|
+
onUpdateEntity(update: boolean): void {
|
|
152
|
+
clearTimeout(this.updateTimeout);
|
|
153
|
+
this.updateTimeout = setTimeout(() => {
|
|
154
|
+
const updateList = getListData(this.updateList);
|
|
155
|
+
updateList.forEach(item => {
|
|
156
|
+
if (item.disposed) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
// console.log('------------------updateddddddddddddddd-----------', item.name);
|
|
160
|
+
this.selectionEntityManager.updateEntity(item.id, item);
|
|
161
|
+
const entity = this.selectionEntityManager.nodeEntitiesCache.get(item.id);
|
|
162
|
+
this.onContainerInitOrigin(entity, update);
|
|
163
|
+
});
|
|
164
|
+
this.updateList = [];
|
|
165
|
+
}, 150);
|
|
166
|
+
}
|
|
89
167
|
onGameObjectChange(e: GameObjectChangeEvent): void {
|
|
90
|
-
const { gameObject,
|
|
168
|
+
const { gameObject, state } = e;
|
|
91
169
|
switch (e.type) {
|
|
92
170
|
case GameObjectEventType.CREATE:
|
|
93
171
|
this.document?.updateNode(e.node, { error: undefined });
|
|
94
172
|
this.selectionEntityManager.createEntity(gameObject.id, e.node, gameObject!, !!state?.selectable, !!state?.adsorbable);
|
|
95
173
|
break;
|
|
96
|
-
case GameObjectEventType.CREATE_READY:
|
|
97
|
-
// 避免元素创后的回调;必须在元素创建完实例后执行;
|
|
98
|
-
setTimeout(() => {
|
|
99
|
-
const entity = this.selectionEntityManager.nodeEntitiesCache.get(gameObject.id);
|
|
100
|
-
// 旧的没有中心点
|
|
101
|
-
if (typeof entity?.transform.origin.initX === 'undefined') {
|
|
102
|
-
this.selectionEntityManager.updateEntity(gameObject.id, gameObject!);
|
|
103
|
-
this.onContainerInitOrigin(entity);
|
|
104
|
-
}
|
|
105
|
-
if (
|
|
106
|
-
parentObject &&
|
|
107
|
-
parentNode &&
|
|
108
|
-
(parentObject.type === GameObjectBaseType.GROUP ||
|
|
109
|
-
parentObject.type === GameObjectBaseType.COMPONENT)
|
|
110
|
-
) {
|
|
111
|
-
this.document?.updateNode(parentNode, undefined, true);
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
break;
|
|
115
174
|
case GameObjectEventType.DESTROY:
|
|
116
175
|
this.selectionEntityManager.removeEntity(gameObject.id);
|
|
117
|
-
|
|
118
|
-
if (parentNode) {
|
|
119
|
-
this.document?.updateNode(parentNode, undefined, true);
|
|
120
|
-
}
|
|
176
|
+
this.nodeCache.delete(gameObject.id);
|
|
121
177
|
break;
|
|
122
178
|
case GameObjectEventType.UPDATE:
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
this.
|
|
127
|
-
});
|
|
128
|
-
if (
|
|
129
|
-
parentObject &&
|
|
130
|
-
parentObject.parent &&
|
|
131
|
-
(parentObject.type === GameObjectBaseType.GROUP ||
|
|
132
|
-
parentObject.type === GameObjectBaseType.COMPONENT)
|
|
133
|
-
) {
|
|
134
|
-
// 需要等 parent 数据没有更后再执行;
|
|
135
|
-
setTimeout(() => {
|
|
136
|
-
const entity = this.selectionEntityManager.nodeEntitiesCache.get(parentObject.id);
|
|
137
|
-
this.onContainerInitOrigin(entity, true);
|
|
138
|
-
});
|
|
179
|
+
// console.log('------------------update-----------', gameObject.name);
|
|
180
|
+
if (!this.updateList.includes(gameObject)) {
|
|
181
|
+
this.updateList.push(gameObject);
|
|
182
|
+
this.nodeCache.set(gameObject.id, e.node);
|
|
139
183
|
}
|
|
184
|
+
this.onUpdateEntity(true);
|
|
140
185
|
break;
|
|
141
186
|
case GameObjectEventType.ERROR:
|
|
142
187
|
this.document?.updateNode(e.node, {error: e.error});
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { PathChild, PATH_FUNC_TYPE, getPointsToPath } from '@gedit/canvas-draw';
|
|
3
|
+
import { PositionSchema } from '@gedit/playground';
|
|
4
|
+
import { PathEditLayerEventContext } from '../path-edit-layer';
|
|
5
|
+
import clsx from 'clsx';
|
|
6
|
+
|
|
7
|
+
export interface PointSchema extends PositionSchema {
|
|
8
|
+
id?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface PointDefaultProps {
|
|
12
|
+
getPosFromMouseEvent: (
|
|
13
|
+
event: {
|
|
14
|
+
clientX: number;
|
|
15
|
+
clientY: number;
|
|
16
|
+
},
|
|
17
|
+
addScale?: boolean
|
|
18
|
+
) => PositionSchema;
|
|
19
|
+
paths: PathChild[];
|
|
20
|
+
scale: number;
|
|
21
|
+
closePath: boolean; // 显示闭合路径图标
|
|
22
|
+
currentPointId?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const PointMoveDefault = ({
|
|
26
|
+
getPosFromMouseEvent,
|
|
27
|
+
paths,
|
|
28
|
+
scale,
|
|
29
|
+
closePath,
|
|
30
|
+
currentPointId,
|
|
31
|
+
}: PointDefaultProps) => {
|
|
32
|
+
const [movePoint, setMovePoint] = React.useState<PathChild>();
|
|
33
|
+
const { onSceneAddEvent } = React.useContext(PathEditLayerEventContext);
|
|
34
|
+
const endPoint = paths[paths.length - 1];
|
|
35
|
+
const startPoint = paths[0];
|
|
36
|
+
/**
|
|
37
|
+
* 选中起始点的情况,显示移动点,绘制起点到移动点的路径,反转点的 x1=x2, y1=y2;
|
|
38
|
+
* @param lineStartPoint 选中的起始点
|
|
39
|
+
* @param lineEndPoint 选中的结束点
|
|
40
|
+
* @param reverse 是否反转
|
|
41
|
+
*/
|
|
42
|
+
let lineStartPoint = paths.find(c => c.id === currentPointId);
|
|
43
|
+
let lineEndPoint = lineStartPoint === startPoint ? endPoint : startPoint;
|
|
44
|
+
const reverse = lineStartPoint === startPoint && lineStartPoint !== endPoint;
|
|
45
|
+
if (reverse && lineStartPoint) {
|
|
46
|
+
const { x1, x2, y1, y2 } = lineStartPoint;
|
|
47
|
+
lineStartPoint = {
|
|
48
|
+
...lineStartPoint,
|
|
49
|
+
x1: x2,
|
|
50
|
+
x2: x1,
|
|
51
|
+
y1: y2,
|
|
52
|
+
y2: y1,
|
|
53
|
+
};
|
|
54
|
+
const { x1: e1, x2: e2, y1: r1, y2: r2 } = lineEndPoint;
|
|
55
|
+
lineEndPoint = {
|
|
56
|
+
...lineEndPoint,
|
|
57
|
+
x1: e2,
|
|
58
|
+
x2: e1,
|
|
59
|
+
y1: r2,
|
|
60
|
+
y2: r1,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
const onMove = (e: MouseEvent) => {
|
|
64
|
+
const pos = getPosFromMouseEvent(e);
|
|
65
|
+
setMovePoint({
|
|
66
|
+
...pos,
|
|
67
|
+
type: PATH_FUNC_TYPE.STRAIGHT,
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
React.useEffect(() => {
|
|
71
|
+
const event = onSceneAddEvent('mousemove', onMove);
|
|
72
|
+
const event2 = onSceneAddEvent('mouseleave', () => {
|
|
73
|
+
setMovePoint(undefined);
|
|
74
|
+
});
|
|
75
|
+
return () => {
|
|
76
|
+
event.dispose();
|
|
77
|
+
event2.dispose();
|
|
78
|
+
};
|
|
79
|
+
}, []);
|
|
80
|
+
if (!movePoint) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
const line =
|
|
84
|
+
lineStartPoint &&
|
|
85
|
+
getPointsToPath([lineStartPoint, closePath ? lineEndPoint : movePoint]);
|
|
86
|
+
return (
|
|
87
|
+
<>
|
|
88
|
+
{line && (
|
|
89
|
+
<path
|
|
90
|
+
className="gedit-path-edit-layer-line"
|
|
91
|
+
d={line}
|
|
92
|
+
strokeLinecap="round"
|
|
93
|
+
strokeWidth={1.5 / scale}
|
|
94
|
+
/>
|
|
95
|
+
)}
|
|
96
|
+
<circle
|
|
97
|
+
className={clsx(
|
|
98
|
+
'gedit-path-edit-layer-point',
|
|
99
|
+
'gedit-path-edit-layer-point-move',
|
|
100
|
+
'gedit-path-edit-layer-pen'
|
|
101
|
+
)}
|
|
102
|
+
cx={closePath ? startPoint.x : movePoint.x}
|
|
103
|
+
cy={closePath ? startPoint.y : movePoint.y}
|
|
104
|
+
r={4 / scale}
|
|
105
|
+
/>
|
|
106
|
+
</>
|
|
107
|
+
);
|
|
108
|
+
};
|