|
@@ -1,4 +1,4 @@
|
|
|
-import { ModuleControl } from "queenjs";
|
|
|
+import { Effect, ModuleControl } from "queenjs";
|
|
|
import { reactive } from "vue";
|
|
|
import { EditorModule } from "../../module";
|
|
|
import { ObjsContainer } from "./ObjsContainer";
|
|
@@ -81,11 +81,35 @@ export class SelectCtrl extends ModuleControl<EditorModule> {
|
|
|
capture: true,
|
|
|
});
|
|
|
window.addEventListener("resize", this.onResize.bind(this));
|
|
|
+
|
|
|
+ this.initEffects();
|
|
|
+ }
|
|
|
+
|
|
|
+ initEffects() {
|
|
|
+ //相应相应的事件
|
|
|
+ Effect.array(()=>this.store.selected).list({
|
|
|
+ remove:()=>{
|
|
|
+ console.log("xxx")
|
|
|
+ },
|
|
|
+ change:(added:string[], removed:string[])=>{
|
|
|
+ console.log("changeMap=>", added, removed)
|
|
|
+ this._updateSelects();
|
|
|
+ },
|
|
|
+ }).run();
|
|
|
}
|
|
|
|
|
|
_mouseDownFlag = "";
|
|
|
_mouseDownTimestamp = 0;
|
|
|
|
|
|
+ _updateSelects() {
|
|
|
+ const selecteds = this.store.selected;
|
|
|
+ let objs = [];
|
|
|
+ for (let item of selecteds) {
|
|
|
+ objs.push( new CompObject(this.compMap[item]) )
|
|
|
+ }
|
|
|
+ this.selecteObjs(objs);
|
|
|
+ }
|
|
|
+
|
|
|
onDocMouseDown(e: MouseEvent) {
|
|
|
this._mouseDownTimestamp = Date.now();
|
|
|
|
|
@@ -134,7 +158,6 @@ export class SelectCtrl extends ModuleControl<EditorModule> {
|
|
|
this._state = MODE_MOVING;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
if (!isClickSelRect) {
|
|
|
//判断是否有点击到card stream
|
|
|
const comps = this.compClickTest(e);
|
|
@@ -336,17 +359,12 @@ export class SelectCtrl extends ModuleControl<EditorModule> {
|
|
|
const comps = this.compClickTest(e);
|
|
|
if (comps.length < 1) {
|
|
|
setTimeout(() => {
|
|
|
- if (this.historySelected ) {
|
|
|
- this.histroySelectObjs([])
|
|
|
- } else {
|
|
|
- this.selecteObjs([]);
|
|
|
- }
|
|
|
+ this.actions.selectObjs([]) //清空选择
|
|
|
}, 0);
|
|
|
}
|
|
|
} else {
|
|
|
e.stopPropagation();
|
|
|
}
|
|
|
- console.log("up");
|
|
|
|
|
|
if (this._state == MODE_SEL_RECT && !isClick) {
|
|
|
//选择空间转 streamCard空间
|
|
@@ -421,15 +439,12 @@ export class SelectCtrl extends ModuleControl<EditorModule> {
|
|
|
const o = new CompObject(this.compMap[childs[n]]);
|
|
|
if (o.testRect({ x, y, w: width, h: height }, true)) {
|
|
|
//相交
|
|
|
- outs.push(o);
|
|
|
+ outs.push(o.comp.id);
|
|
|
}
|
|
|
}
|
|
|
- console.log(outs);
|
|
|
-
|
|
|
- this.histroySelectObjs(outs)
|
|
|
- // this.selecteObjs(outs);
|
|
|
+ this.actions.selectObjs(outs);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
upgateGizmoStyle() {
|
|
|
this.helper.extendStreamCard(this.store.currStreamCardId);
|
|
|
this.transferStyle.mode = this._state;
|
|
@@ -535,53 +550,6 @@ export class SelectCtrl extends ModuleControl<EditorModule> {
|
|
|
}
|
|
|
objContainer?: ObjsContainer;
|
|
|
|
|
|
- historySelected = false;
|
|
|
- histroySelectObjs(objs: any[]) {
|
|
|
-
|
|
|
- const preObjContainer = this.objContainer;
|
|
|
- const history = this.controls.historyCtrl.history;
|
|
|
- const pre = this.selected;
|
|
|
- this.selecteObjs(objs);
|
|
|
- const lastContainer = this.objContainer;
|
|
|
- const lastObjs = objs;
|
|
|
- this.historySelected = true;
|
|
|
-
|
|
|
- history.record({
|
|
|
- undo: () => {
|
|
|
- this.selected = pre;
|
|
|
- if (preObjContainer) {
|
|
|
- let parent = preObjContainer.parent;
|
|
|
- pre.forEach((obj) => {
|
|
|
- parent.addChildWorldNoChange(obj);
|
|
|
- });
|
|
|
- parent.updateTransform();
|
|
|
- this.objContainer = preObjContainer;
|
|
|
- } else {
|
|
|
- this.objContainer = undefined;
|
|
|
- }
|
|
|
- this.upgateGizmoStyle();
|
|
|
- },
|
|
|
- redo: () => {
|
|
|
- this.selected = lastObjs;
|
|
|
- if (preObjContainer) {
|
|
|
- preObjContainer.destroy();
|
|
|
- }
|
|
|
- if (lastContainer) {
|
|
|
- let parent = lastContainer.parent;
|
|
|
- objs.forEach((obj) => {
|
|
|
- parent.addChildWorldNoChange(obj);
|
|
|
- });
|
|
|
- parent.updateTransform();
|
|
|
- this.objContainer = lastContainer;
|
|
|
- } else {
|
|
|
- this.objContainer = undefined;
|
|
|
- }
|
|
|
- this.upgateGizmoStyle();
|
|
|
- },
|
|
|
- } as any);
|
|
|
- history.submit();
|
|
|
- }
|
|
|
-
|
|
|
selecteObjs(objs: any[], ContainerBox?: ObjsContainer) {
|
|
|
if (this.selected.length == 0 && objs.length == 0) return;
|
|
|
|
|
@@ -592,11 +560,6 @@ export class SelectCtrl extends ModuleControl<EditorModule> {
|
|
|
)
|
|
|
return;
|
|
|
|
|
|
- // objs = this.getSceneObjOrderArr(objs);
|
|
|
- this.historySelected = false;
|
|
|
-
|
|
|
- const preObjContainer = this.objContainer;
|
|
|
-
|
|
|
if (this.objContainer) {
|
|
|
this.objContainer.destroy();
|
|
|
this.objContainer = undefined;
|
|
@@ -615,51 +578,10 @@ export class SelectCtrl extends ModuleControl<EditorModule> {
|
|
|
}
|
|
|
}
|
|
|
this.objContainer = newObjContainer;
|
|
|
-
|
|
|
- const pre = this.selected.slice(0);
|
|
|
this.selected = objs;
|
|
|
|
|
|
- // if (history) {
|
|
|
- // this.editor.history.record({
|
|
|
- // undo: () => {
|
|
|
-
|
|
|
- // this.selected = pre;
|
|
|
-
|
|
|
- // if (preObjContainer) {
|
|
|
- // let parent = preObjContainer.parent;
|
|
|
- // pre.forEach(obj => {
|
|
|
- // parent.addChildWorldNoChange(obj);
|
|
|
- // });
|
|
|
- // parent.updateTransform();
|
|
|
- // this.objContainer = preObjContainer;
|
|
|
- // } else {
|
|
|
- // this.objContainer = null;
|
|
|
- // }
|
|
|
-
|
|
|
- // this.emitChange();
|
|
|
-
|
|
|
- // }, redo: () => {
|
|
|
- // this.selected = objs;
|
|
|
-
|
|
|
- // if (preObjContainer) {
|
|
|
- // preObjContainer.destroy();
|
|
|
- // }
|
|
|
-
|
|
|
- // if (newObjContainer) {
|
|
|
- // let parent = newObjContainer.parent;
|
|
|
- // objs.forEach(obj => {
|
|
|
- // parent.addChildWorldNoChange(obj);
|
|
|
- // });
|
|
|
- // parent.updateTransform();
|
|
|
- // this.objContainer = newObjContainer;
|
|
|
- // } else {
|
|
|
- // this.objContainer = null;
|
|
|
- // }
|
|
|
- // this.emitChange();
|
|
|
- // }
|
|
|
- // })
|
|
|
- // }
|
|
|
this.emitChange();
|
|
|
+
|
|
|
this.upgateGizmoStyle();
|
|
|
|
|
|
return this.selected;
|