|
@@ -59,9 +59,13 @@ export class SelectCtrl extends ModuleControl<EditorModule> {
|
|
|
_downClientY = 0;
|
|
|
//groupCtrl = new GroupActionCtrl(this.module);
|
|
|
bus = new Event();
|
|
|
- viewport?:HTMLElement;
|
|
|
+ viewport?: HTMLElement;
|
|
|
|
|
|
- initEvents(pageEl: HTMLElement, selCanvas: HTMLCanvasElement, viewport:HTMLElement) {
|
|
|
+ initEvents(
|
|
|
+ pageEl: HTMLElement,
|
|
|
+ selCanvas: HTMLCanvasElement,
|
|
|
+ viewport: HTMLElement
|
|
|
+ ) {
|
|
|
this.viewport = viewport;
|
|
|
this.pageEl = pageEl;
|
|
|
this.selCanvas = selCanvas;
|
|
@@ -74,7 +78,7 @@ export class SelectCtrl extends ModuleControl<EditorModule> {
|
|
|
this._selCanvaseSize.w = selCanvas.width * 2;
|
|
|
this._selCanvaseSize.h = selCanvas.height * 2;
|
|
|
|
|
|
- document.addEventListener("mousedown", this.onDocMouseDown.bind(this));
|
|
|
+ document.addEventListener("mousedown", this.onDocMouseDown.bind(this), {capture: true});
|
|
|
document.addEventListener("mousemove", this.onDocMouseMove.bind(this));
|
|
|
document.addEventListener("mouseup", this.onDocMouseUp.bind(this));
|
|
|
|
|
@@ -85,6 +89,9 @@ export class SelectCtrl extends ModuleControl<EditorModule> {
|
|
|
onDocMouseDown(e: MouseEvent) {
|
|
|
if (!this.pageEl || !this.selCanvas) return;
|
|
|
|
|
|
+ if (this.store.textEditingState) {
|
|
|
+ return
|
|
|
+ }
|
|
|
let box = this.pageEl.getBoundingClientRect();
|
|
|
const pageX = e.clientX - box?.left;
|
|
|
const pageY = e.clientY - box?.top;
|
|
@@ -122,13 +129,17 @@ export class SelectCtrl extends ModuleControl<EditorModule> {
|
|
|
//判断是否有点击到card stream
|
|
|
const comps = this.compClickTest(e);
|
|
|
this.mouseDownSelects = comps;
|
|
|
- console.log("comps=>", comps);
|
|
|
+ console.log("comps=>", comps);
|
|
|
if (comps.length < 1) {
|
|
|
- const view = this.viewport?.getBoundingClientRect() as any;
|
|
|
- const isOut = (e.clientX < view.left || e.clientX > (view.right) || e.clientY < view.top || e.clientY > view.bottom)
|
|
|
- if (!isOut) {
|
|
|
- this._state = MODE_SEL_RECT;
|
|
|
- }
|
|
|
+ const view = this.viewport?.getBoundingClientRect() as any;
|
|
|
+ const isOut =
|
|
|
+ e.clientX < view.left ||
|
|
|
+ e.clientX > view.right ||
|
|
|
+ e.clientY < view.top ||
|
|
|
+ e.clientY > view.bottom;
|
|
|
+ if (!isOut) {
|
|
|
+ this._state = MODE_SEL_RECT;
|
|
|
+ }
|
|
|
} else {
|
|
|
this._state = MODE_MOVING;
|
|
|
const obj = this.compMap[comps[0].id];
|
|
@@ -247,7 +258,7 @@ export class SelectCtrl extends ModuleControl<EditorModule> {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- translate(xOffset:number, yOffset:number) {
|
|
|
+ translate(xOffset: number, yOffset: number) {
|
|
|
const objContainer = this.objContainer as ObjsContainer;
|
|
|
objContainer.translate(xOffset, yOffset);
|
|
|
this.upgateGizmoStyle();
|
|
@@ -301,7 +312,7 @@ export class SelectCtrl extends ModuleControl<EditorModule> {
|
|
|
let isClick = false;
|
|
|
const dx = Math.abs(e.clientX - this._downClientX);
|
|
|
const dy = Math.abs(e.clientY - this._downClientY);
|
|
|
- if (dx < 2 && dy < 2) {
|
|
|
+ if (dx < 2 && dy < 2 && !this.store.textEditingState ) {
|
|
|
isClick = true;
|
|
|
}
|
|
|
if (isClick) {
|
|
@@ -385,7 +396,6 @@ export class SelectCtrl extends ModuleControl<EditorModule> {
|
|
|
|
|
|
let tmp = new Matrix();
|
|
|
tmp.copyFrom(obj.worldTransform);
|
|
|
- // tmp.scale(0.5 , 0.5);
|
|
|
|
|
|
let matrix = `matrix(${tmp.a},${tmp.b},${tmp.c},${tmp.d},${tmp.tx},${tmp.ty})`;
|
|
|
tmp.invert();
|
|
@@ -469,7 +479,7 @@ export class SelectCtrl extends ModuleControl<EditorModule> {
|
|
|
return;
|
|
|
|
|
|
if (objs.length == 1) {
|
|
|
- this.actions.pickComp(objs[0].comp.id);
|
|
|
+ this.actions.pickComp(objs[0].comp.id);
|
|
|
}
|
|
|
|
|
|
// objs = this.getSceneObjOrderArr(objs);
|
|
@@ -656,6 +666,8 @@ export class SelectCtrl extends ModuleControl<EditorModule> {
|
|
|
scaleCmd = false;
|
|
|
lastScale = { x: 1, y: 1 };
|
|
|
|
|
|
+ initScaleWith = {w: 0, h:0};
|
|
|
+
|
|
|
scaleMousemove(event: MouseEvent) {
|
|
|
let dirIndexs = [
|
|
|
"scaleBottomright",
|
|
@@ -687,6 +699,8 @@ export class SelectCtrl extends ModuleControl<EditorModule> {
|
|
|
this.mainAxisVector = { x: StartX - pivot.x, y: StartY - pivot.y };
|
|
|
let scale = objContainer.parent.scale;
|
|
|
this.initScale = { x: scale.x, y: scale.y };
|
|
|
+ this.initScaleWith = {w: objContainer.width, h: objContainer.height}
|
|
|
+
|
|
|
this.mainAxisVectorLenth = VectorLenth(
|
|
|
this.mainAxisVector.x,
|
|
|
this.mainAxisVector.y
|
|
@@ -712,7 +726,10 @@ export class SelectCtrl extends ModuleControl<EditorModule> {
|
|
|
let dtaY = Project(vec, this.yAxisVector) / this.yAxisVectorLength;
|
|
|
this.lastScale.x = dtaX * this.initScale.x;
|
|
|
this.lastScale.y = dtaY * this.initScale.y;
|
|
|
- objContainer.scale(this.lastScale.x, this.lastScale.y);
|
|
|
+ // objContainer.scale(this.lastScale.x, this.lastScale.y);
|
|
|
+ const currW = this.initScaleWith.w * this.lastScale.x;
|
|
|
+ objContainer.scaleSize(currW, this.lastScale.y * this.initScaleWith.h);
|
|
|
+
|
|
|
} else {
|
|
|
let mainVec = this.mainAxisVector;
|
|
|
let dtaScale = Project(vec, mainVec) / this.mainAxisVectorLenth;
|
|
@@ -721,13 +738,22 @@ export class SelectCtrl extends ModuleControl<EditorModule> {
|
|
|
if (i == -1) {
|
|
|
this.lastScale.x = dtaScale * this.initScale.x;
|
|
|
this.lastScale.y = dtaScale * this.initScale.y;
|
|
|
- objContainer.scale(this.lastScale.x, this.lastScale.y);
|
|
|
+ // objContainer.scale(this.lastScale.x, this.lastScale.y);
|
|
|
+ const currW = this.initScaleWith.w * this.lastScale.x;
|
|
|
+ objContainer.scaleSize(currW, this.initScaleWith.h *this.lastScale.y);
|
|
|
+ // objContainer.scaleHeight(, dtaScale);
|
|
|
+
|
|
|
} else if (i == 0 || i == 1) {
|
|
|
this.lastScale.x = dtaScale * this.initScale.x;
|
|
|
- objContainer.scaleX(this.lastScale.x);
|
|
|
+ // objContainer.scaleX(this.lastScale.x);
|
|
|
+ const currW = this.initScaleWith.w * this.lastScale.x;
|
|
|
+ objContainer.scaleWidth(currW);
|
|
|
+
|
|
|
} else if (i == 2 || i == 3) {
|
|
|
this.lastScale.y = dtaScale * this.initScale.y;
|
|
|
- objContainer.scaleY(this.lastScale.y);
|
|
|
+
|
|
|
+ // objContainer.scaleY(this.lastScale.y);
|
|
|
+ objContainer.scaleHeight(this.lastScale.y * this.initScaleWith.h);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -740,8 +766,8 @@ export class SelectCtrl extends ModuleControl<EditorModule> {
|
|
|
let preScale = { x: this.initScale.x, y: this.initScale.y };
|
|
|
let scaleIndex = this.scaleIndex;
|
|
|
let lastScale = { x: this.lastScale.x, y: this.lastScale.y };
|
|
|
- this.objContainer?.applyScaleToChildSize();
|
|
|
- this.upgateGizmoStyle();
|
|
|
+ // this.objContainer?.applyScaleToChildSize();
|
|
|
+ // this.upgateGizmoStyle();
|
|
|
// this.editor.history.record({
|
|
|
// undo:()=>{
|
|
|
// this.objContainer.setPivot( scaleIndex );
|