Selaa lähdekoodia

增加undo支持。

sybotan 5 vuotta sitten
vanhempi
commit
b01444b272

+ 1 - 1
saga-web-base/package.json

@@ -1,6 +1,6 @@
 {
     "name": "@saga-web/base",
-    "version": "2.1.9",
+    "version": "2.1.12",
     "description": "上格云Web基础库。",
     "main": "lib/index.js",
     "types": "lib/index.d.js",

+ 4 - 2
saga-web-base/src/undo/SUndoStack.ts

@@ -67,7 +67,8 @@ export class SUndoStack extends SObject {
      * 清空堆栈
      */
     clear(): void {
-        // this.cmdStack
+        this.cmdStack.length = 0;
+        this._index = -1;
     } // Function clear()
 
     /**
@@ -87,7 +88,7 @@ export class SUndoStack extends SObject {
     /**
      * 统计命令栈中命令的数量
      */
-    cout(): number {
+    count(): number {
         return this.cmdStack.length;
     } // Function cout()
 
@@ -97,6 +98,7 @@ export class SUndoStack extends SObject {
      * @param   cmd     被添加的命令
      */
     push(cmd: SUndoCommand): void {
+        this.cmdStack.length = this._index + 1;
         this.cmdStack.push(cmd);
         this._index = this.cmdStack.length - 1;
     } // Function push()

+ 2 - 2
saga-web-draw/package.json

@@ -1,6 +1,6 @@
 {
     "name": "@saga-web/draw",
-    "version": "2.1.81",
+    "version": "2.1.83",
     "description": "上格云绘制引擎。",
     "main": "lib/index.js",
     "types": "lib/index.d.js",
@@ -33,7 +33,7 @@
         "typescript": "^3.5.3"
     },
     "dependencies": {
-        "@saga-web/base": "^2.1.9"
+        "@saga-web/base": "^2.1.12"
     },
     "jest": {
         "setupFiles": [

+ 2 - 2
saga-web-graphy/package.json

@@ -1,6 +1,6 @@
 {
     "name": "@saga-web/graphy",
-    "version": "2.1.53",
+    "version": "2.1.54",
     "description": "上格云二维图形引擎。",
     "main": "lib/index.js",
     "types": "lib/index.d.js",
@@ -41,6 +41,6 @@
         "typescript": "^3.5.3"
     },
     "dependencies": {
-        "@saga-web/draw": "2.1.81"
+        "@saga-web/draw": "2.1.83"
     }
 }

+ 10 - 0
saga-web-graphy/src/SGraphyItem.ts

@@ -72,16 +72,26 @@ export class SGraphyItem extends SObject {
         return this.pos.x;
     } // Get x
     set x(v: number) {
+        if (this.pos.x == v) {
+            return;
+        }
+        let old = this.pos.x;
         this.pos.x = v;
         this.update();
+        this.$emit("onMove", new SPoint(old, this.pos.y), this.pos);
     } // Set x
     /** Y轴坐标 */
     get y(): number {
         return this.pos.y;
     } // Get y
     set y(v: number) {
+        if (this.pos.y == v) {
+            return;
+        }
+        let old = this.pos.y;
         this.pos.y = v;
         this.update();
+        this.$emit("onMove", new SPoint(this.pos.x, old), this.pos);
     } // Set y
     /** 缩放比例 */
     scale: number = 1;

+ 1 - 1
saga-web-graphy/src/SGraphyView.ts

@@ -7,7 +7,7 @@ import {
     SSvgPaintEngine
 } from "@saga-web/draw/lib";
 import { SGraphyScene } from "./SGraphyScene";
-import { SGraphyItem } from "../lib";
+import { SGraphyItem } from "./SGraphyItem";
 
 /**
  * Graphy图形引擎视图类