Skip to content

Commit 01e520a

Browse files
committed
🐛 完善工具栏变动检测情况
1 parent 4ab8f45 commit 01e520a

File tree

3 files changed

+31
-9
lines changed

3 files changed

+31
-9
lines changed

app/src/core/service/controlService/controller/concrete/ControllerEntityCreate.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Renderer } from "../../../../render/canvas2d/renderer";
33
import { LeftMouseModeEnum, Stage } from "../../../../stage/Stage";
44
import { SectionMethods } from "../../../../stage/stageManager/basicMethods/SectionMethods";
55
import { StageNodeAdder } from "../../../../stage/stageManager/concreteMethods/stageNodeAdder";
6+
import { StageObjectSelectCounter } from "../../../../stage/stageManager/concreteMethods/StageObjectSelectCounter";
67
import { StageManager } from "../../../../stage/stageManager/StageManager";
78
import { Section } from "../../../../stage/stageObject/entity/Section";
89
import { Controller } from "../Controller";
@@ -42,6 +43,8 @@ ControllerEntityCreate.mouseDoubleClick = (event: MouseEvent) => {
4243
// 双击创建节点
4344
addTextNodeByLocation(pressLocation, true);
4445
}
46+
// 更新选中内容的数量
47+
StageObjectSelectCounter.update();
4548
};
4649

4750
function createConnectPoint(pressLocation: Vector, addToSections: Section[]) {

app/src/core/service/controlService/controller/concrete/utilsControl.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { Camera } from "../../../../stage/Camera";
88
import { Stage } from "../../../../stage/Stage";
99
import { SectionMethods } from "../../../../stage/stageManager/basicMethods/SectionMethods";
1010
import { StageNodeAdder } from "../../../../stage/stageManager/concreteMethods/stageNodeAdder";
11+
import { StageObjectSelectCounter } from "../../../../stage/stageManager/concreteMethods/StageObjectSelectCounter";
1112
import { StageHistoryManager } from "../../../../stage/stageManager/StageHistoryManager";
1213
import { StageManager } from "../../../../stage/stageManager/StageManager";
1314
import { Entity } from "../../../../stage/stageObject/abstract/StageEntity";
@@ -83,6 +84,8 @@ export function editTextNode(clickedNode: TextNode, selectAll = true) {
8384
clickedNode!.isEditing = false;
8485
Controller.isCameraLocked = false;
8586
StageHistoryManager.recordStep();
87+
// 更新选中内容的数量
88+
StageObjectSelectCounter.update();
8689
});
8790
}
8891

app/src/core/service/controlService/keyboardOnlyEngine/selectChangeEngine.tsx

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Line } from "../../../dataStruct/shape/Line";
33
import { Vector } from "../../../dataStruct/Vector";
44
import { Camera } from "../../../stage/Camera";
55
import { Stage } from "../../../stage/Stage";
6+
import { StageObjectSelectCounter } from "../../../stage/stageManager/concreteMethods/StageObjectSelectCounter";
67
import { StageManager } from "../../../stage/stageManager/StageManager";
78
import { ConnectableEntity } from "../../../stage/stageObject/abstract/ConnectableEntity";
89
import { LineCuttingEffect } from "../../feedbackService/effectEngine/concrete/LineCuttingEffect";
@@ -35,25 +36,37 @@ export namespace SelectChangeEngine {
3536
}
3637
return;
3738
}
38-
let newSelectedNode: ConnectableEntity | null = null;
39+
let newSelectedConnectableEntity: ConnectableEntity | null = null;
3940
const selectedNodeRect = selectedNode.collisionBox.getRectangle();
4041
if (key === "arrowup") {
4142
// 在节点上方查找所有节点,并选中距离上方最近的一个
42-
newSelectedNode = getMostNearNode(collectTopNodes(selectedNode), selectedNodeRect.center);
43+
newSelectedConnectableEntity = getMostNearConnectableEntity(
44+
collectTopNodes(selectedNode),
45+
selectedNodeRect.center,
46+
);
4347
} else if (key === "arrowdown") {
4448
// 在节点下方查找所有节点,并选中距离下方最近的一个
45-
newSelectedNode = getMostNearNode(collectBottomNodes(selectedNode), selectedNodeRect.center);
49+
newSelectedConnectableEntity = getMostNearConnectableEntity(
50+
collectBottomNodes(selectedNode),
51+
selectedNodeRect.center,
52+
);
4653
} else if (key === "arrowleft") {
4754
// 在节点左侧查找所有节点,并选中距离左侧最近的一个
48-
newSelectedNode = getMostNearNode(collectLeftNodes(selectedNode), selectedNodeRect.center);
55+
newSelectedConnectableEntity = getMostNearConnectableEntity(
56+
collectLeftNodes(selectedNode),
57+
selectedNodeRect.center,
58+
);
4959
} else if (key === "arrowright") {
5060
// 在节点右侧查找所有节点,并选中距离右侧最近的一个
51-
newSelectedNode = getMostNearNode(collectRightNodes(selectedNode), selectedNodeRect.center);
61+
newSelectedConnectableEntity = getMostNearConnectableEntity(
62+
collectRightNodes(selectedNode),
63+
selectedNodeRect.center,
64+
);
5265
}
53-
if (newSelectedNode) {
66+
if (newSelectedConnectableEntity) {
5467
selectedNode.isSelected = false;
55-
newSelectedNode.isSelected = true;
56-
const newSelectNodeRect = newSelectedNode.collisionBox.getRectangle();
68+
newSelectedConnectableEntity.isSelected = true;
69+
const newSelectNodeRect = newSelectedConnectableEntity.collisionBox.getRectangle();
5770
const color = StageStyleManager.currentStyle.effects.successShadow;
5871

5972
if (Camera.cameraFollowsSelectedNodeOnArrowKeys) {
@@ -97,10 +110,13 @@ export namespace SelectChangeEngine {
97110
color,
98111
),
99112
]);
113+
114+
// 更新选中内容的数量
115+
StageObjectSelectCounter.update();
100116
}
101117
}
102118

103-
function getMostNearNode(nodes: ConnectableEntity[], location: Vector): ConnectableEntity | null {
119+
function getMostNearConnectableEntity(nodes: ConnectableEntity[], location: Vector): ConnectableEntity | null {
104120
if (nodes.length === 0) return null;
105121
let currentMinDistance = Infinity;
106122
let currentNearestNode: ConnectableEntity | null = null;

0 commit comments

Comments
 (0)