Skip to content

Commit a1b91ee

Browse files
committed
feat: 按树形格式化快捷键后添加一个提示特效。
1 parent 9a59dd3 commit a1b91ee

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

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

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ import { ConnectableEntity } from "@/core/stage/stageObject/abstract/Connectable
33
import { CollisionBox } from "@/core/stage/stageObject/collisionBox/collisionBox";
44
import { TextNode } from "@/core/stage/stageObject/entity/TextNode";
55
import { Direction } from "@/types/directions";
6-
import { Vector } from "@graphif/data-structures";
6+
import { ProgressNumber, Vector } from "@graphif/data-structures";
77
import { Rectangle } from "@graphif/shapes";
88
import { v4 } from "uuid";
99
import { Settings } from "../../Settings";
1010
import { LineEffect } from "../../feedbackService/effectEngine/concrete/LineEffect";
11+
import { RectangleRenderEffect } from "../../feedbackService/effectEngine/concrete/RectangleRenderEffect";
1112

1213
/**
1314
* 专用于Xmind式的树形结构的键盘操作引擎
@@ -340,9 +341,32 @@ export class KeyboardOnlyTreeEngine {
340341
*/
341342
adjustTreeNode(entity: ConnectableEntity) {
342343
const rootNodeParents = this.project.graphMethods.getRoots(entity);
343-
this.project.autoAlign.autoLayoutSelectedFastTreeMode(rootNodeParents[0]);
344+
const rootNode = rootNodeParents[0];
345+
this.project.autoAlign.autoLayoutSelectedFastTreeMode(rootNode);
346+
347+
// 添加闪烁特效:树形结构的外接矩形和根节点
348+
const allNodes = this.project.graphMethods.getSuccessorSet(rootNode, true);
349+
const treeBoundingRect = Rectangle.getBoundingRectangle(
350+
allNodes.map((node) => node.collisionBox.getRectangle()),
351+
10, // 添加一些 padding
352+
);
353+
const rootNodeRect = rootNode.collisionBox.getRectangle();
354+
355+
// 使用成功阴影颜色作为闪烁特效颜色
356+
const flashColor = this.project.stageStyleManager.currentStyle.effects.successShadow;
357+
358+
// 为树的外接矩形添加闪烁特效
359+
this.project.effects.addEffect(
360+
new RectangleRenderEffect(new ProgressNumber(0, 60), treeBoundingRect, flashColor.toTransparent(), flashColor, 3),
361+
);
362+
363+
// 为根节点添加闪烁特效
364+
this.project.effects.addEffect(
365+
new RectangleRenderEffect(new ProgressNumber(0, 60), rootNodeRect, flashColor.toTransparent(), flashColor, 4),
366+
);
367+
344368
// 恢复选择状态
345-
rootNodeParents[0].isSelected = false;
369+
rootNode.isSelected = false;
346370
entity.isSelected = true;
347371
}
348372

0 commit comments

Comments
 (0)