|
@@ -68,8 +68,18 @@ export class SGraphSelectContainer extends SGraphItem {
|
|
|
this._height = v;
|
|
|
this.update();
|
|
|
}
|
|
|
+
|
|
|
private oldWidth: number = 0;
|
|
|
+
|
|
|
private oldHeight: number = 0;
|
|
|
+
|
|
|
+ minWidth: number = 0;
|
|
|
+
|
|
|
+ maxWidth: number = Number.MAX_SAFE_INTEGER;
|
|
|
+
|
|
|
+ minHeight: number = 0;
|
|
|
+
|
|
|
+ maxHeight: number = Number.MAX_SAFE_INTEGER;
|
|
|
|
|
|
|
|
|
get count(): number {
|
|
@@ -99,6 +109,19 @@ export class SGraphSelectContainer extends SGraphItem {
|
|
|
}
|
|
|
|
|
|
private curPoint: SPoint | undefined;
|
|
|
+
|
|
|
+ static cursorList: string[] = [
|
|
|
+ "nw-resize",
|
|
|
+ "n-resize",
|
|
|
+ "ne-resize",
|
|
|
+ "e-resize",
|
|
|
+ "se-resize",
|
|
|
+ "s-resize",
|
|
|
+ "sw-resize",
|
|
|
+ "w-resize",
|
|
|
+ "move",
|
|
|
+ "default"
|
|
|
+ ];
|
|
|
|
|
|
|
|
|
* 构造体
|
|
@@ -123,7 +146,7 @@ export class SGraphSelectContainer extends SGraphItem {
|
|
|
}
|
|
|
item.selected = true;
|
|
|
this.itemList.push(item);
|
|
|
- this.throttle(this.selectChange, 200);
|
|
|
+ this.throttle(this.selectChange, 100);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -754,12 +777,16 @@ export class SGraphSelectContainer extends SGraphItem {
|
|
|
* @return 对象边界区域
|
|
|
*/
|
|
|
boundingRect(): SRect {
|
|
|
- return new SRect(
|
|
|
- -this.sceneDis,
|
|
|
- -this.sceneDis,
|
|
|
- this.width + this.sceneDis + this.sceneDis,
|
|
|
- this.height + this.sceneDis + this.sceneDis
|
|
|
- );
|
|
|
+ if (this.visible) {
|
|
|
+ return new SRect(
|
|
|
+ -this.sceneDis,
|
|
|
+ -this.sceneDis,
|
|
|
+ this.width + this.sceneDis + this.sceneDis,
|
|
|
+ this.height + this.sceneDis + this.sceneDis
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ return new SRect();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
@@ -810,46 +837,86 @@ export class SGraphSelectContainer extends SGraphItem {
|
|
|
* @return boolean
|
|
|
*/
|
|
|
onMouseMove(event: SMouseEvent): boolean {
|
|
|
+ this.setCursor(9);
|
|
|
if (this.curIndex > -1 && this.count == 1) {
|
|
|
+ this.setCursor(this.curIndex);
|
|
|
|
|
|
const difX = event.x - this.curPoint.x;
|
|
|
|
|
|
const difY = event.y - this.curPoint.y;
|
|
|
const mp = this.toParentChange(difX, difY);
|
|
|
const oldSize = new SSize(this.width, this.height);
|
|
|
+ let resultX, resultY;
|
|
|
switch (this.curIndex) {
|
|
|
case 0:
|
|
|
- this.moveTo(this.pos.x + mp.x, this.pos.y + mp.y);
|
|
|
- this.width = this.width - difX;
|
|
|
- this.height = this.height - difY;
|
|
|
+ resultX = this.width - difX;
|
|
|
+ resultY = this.height - difY;
|
|
|
+ if (resultX > this.minWidth && resultX < this.maxWidth) {
|
|
|
+ this.width = resultX;
|
|
|
+ this.x = this.x + mp.x;
|
|
|
+ }
|
|
|
+ if (resultY > this.minHeight && resultY < this.maxHeight) {
|
|
|
+ this.height = resultY;
|
|
|
+ this.y = this.y + mp.y;
|
|
|
+ }
|
|
|
break;
|
|
|
case 1:
|
|
|
- this.height = this.height - difY;
|
|
|
- this.moveTo(this.pos.x, this.pos.y + mp.y);
|
|
|
+ resultY = this.height - difY;
|
|
|
+ if (resultY > this.minHeight && resultY < this.maxHeight) {
|
|
|
+ this.height = resultY;
|
|
|
+ this.y = this.y + mp.y;
|
|
|
+ }
|
|
|
break;
|
|
|
case 2:
|
|
|
- this.moveTo(this.pos.x, this.pos.y + mp.y);
|
|
|
- this.width = this.oldWidth + difX;
|
|
|
- this.height = this.height - difY;
|
|
|
+ resultX = this.oldWidth + difX;
|
|
|
+ resultY = this.height - difY;
|
|
|
+ if (resultX > this.minWidth && resultX < this.maxWidth) {
|
|
|
+ this.width = resultX;
|
|
|
+ }
|
|
|
+ if (resultY > this.minHeight && resultY < this.maxHeight) {
|
|
|
+ this.height = resultY;
|
|
|
+ this.y = this.y + mp.y;
|
|
|
+ }
|
|
|
break;
|
|
|
case 3:
|
|
|
- this.width = this.oldWidth + difX;
|
|
|
+ resultX = this.oldWidth + difX;
|
|
|
+ if (resultX > this.minWidth && resultX < this.maxWidth) {
|
|
|
+ this.width = resultX;
|
|
|
+ }
|
|
|
break;
|
|
|
case 4:
|
|
|
- this.width = this.oldWidth + difX;
|
|
|
- this.height = this.oldHeight + difY;
|
|
|
+ resultX = this.oldWidth + difX;
|
|
|
+ resultY = this.oldHeight + difY;
|
|
|
+ if (resultX > this.minWidth && resultX < this.maxWidth) {
|
|
|
+ this.width = resultX;
|
|
|
+ }
|
|
|
+ if (resultY > this.minHeight && resultY < this.maxHeight) {
|
|
|
+ this.height = resultY;
|
|
|
+ }
|
|
|
break;
|
|
|
case 5:
|
|
|
- this.height = this.oldHeight + difY;
|
|
|
+ resultY = this.oldHeight + difY;
|
|
|
+ if (resultY > this.minHeight && resultY < this.maxHeight) {
|
|
|
+ this.height = resultY;
|
|
|
+ }
|
|
|
break;
|
|
|
case 6:
|
|
|
- this.moveTo(this.pos.x + mp.x, this.pos.y);
|
|
|
- this.width = this.width - difX;
|
|
|
- this.height = this.oldHeight + difY;
|
|
|
+ resultX = this.width - difX;
|
|
|
+ resultY = this.oldHeight + difY;
|
|
|
+ if (resultX > this.minWidth && resultX < this.maxWidth) {
|
|
|
+ this.width = resultX;
|
|
|
+ this.x = this.x + mp.x;
|
|
|
+ }
|
|
|
+ if (resultY > this.minHeight && resultY < this.maxHeight) {
|
|
|
+ this.height = resultY;
|
|
|
+ }
|
|
|
break;
|
|
|
case 7:
|
|
|
- this.moveTo(this.pos.x + mp.x, this.pos.y);
|
|
|
- this.width = this.width - difX;
|
|
|
+ resultX = this.width - difX;
|
|
|
+ if (resultX > this.minWidth && resultX < this.maxWidth) {
|
|
|
+ this.width = resultX;
|
|
|
+ this.x = this.x + mp.x;
|
|
|
+ }
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
@@ -866,6 +933,7 @@ export class SGraphSelectContainer extends SGraphItem {
|
|
|
}
|
|
|
if (flag) {
|
|
|
super.onMouseMove(event);
|
|
|
+ this.setCursor(8);
|
|
|
if (this._isMoving) {
|
|
|
const mp = this.toParentChange(
|
|
|
event.x - this._mouseDownPos.x,
|
|
@@ -881,6 +949,18 @@ export class SGraphSelectContainer extends SGraphItem {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ * 设置鼠标样式
|
|
|
+ *
|
|
|
+ * @param n 样式的索引
|
|
|
+ * */
|
|
|
+ private setCursor(n: number): void {
|
|
|
+ this.cursor = SGraphSelectContainer.cursorList[n] || "default";
|
|
|
+ if (this.scene && this.scene.view) {
|
|
|
+ this.scene.view.cursor = this.cursor;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
* 鼠标按下事件
|
|
|
*
|
|
|
* @param event 保存事件参数
|