Skip to content

Commit 98d97ec

Browse files
committed
feat: 增加广度树形生长方向的节点提示(在节点旁预测反斜杠键生长节点的位置并提示)并增加渲染的开关设置项:“显示树形生长方向提示”
1 parent 944f737 commit 98d97ec

9 files changed

Lines changed: 51 additions & 2 deletions

File tree

app/src/core/render/canvas2d/entityRenderer/textNode/TextNodeRenderer.tsx

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export class TextNodeRenderer {
8080
);
8181
}
8282
// 渲染键盘树形模式方向提示(仅在键盘操作模式下且非编辑状态时显示)
83-
if (this.project.keyboardOnlyEngine.isOpenning() && !node.isEditing) {
83+
if (this.project.keyboardOnlyEngine.isOpenning() && !node.isEditing && Settings.showTreeDirectionHint) {
8484
this.renderKeyboardTreeHint(node);
8585
}
8686
}
@@ -171,6 +171,30 @@ export class TextNodeRenderer {
171171
this.project.textRenderer.renderTextFromCenter(key, viewPos, 13 * this.project.camera.currentScale, hintColor);
172172
}
173173
}
174+
175+
// 反斜杠(\)广度生长:在父节点方向确定的新兄弟节点预测位置画一个虚框
176+
// onBroadGenerateNode 创建的是父节点的新子节点(当前选中节点的兄弟)
177+
// 父节点方向 left/right → 新兄弟在当前节点下方
178+
// 父节点方向 up/down → 新兄弟在当前节点右侧
179+
const parents = this.project.graphMethods.nodeParentArray(node);
180+
if (parents.length === 1) {
181+
const parentNode = parents[0];
182+
const parentDirection = this.project.keyboardOnlyTreeEngine.getNodePreDirection(parentNode);
183+
const SIBLING_GAP = 10;
184+
let previewLocation: Vector;
185+
if (parentDirection === "right" || parentDirection === "left") {
186+
previewLocation = rect.leftBottom.add(new Vector(0, SIBLING_GAP));
187+
} else {
188+
previewLocation = rect.rightTop.add(new Vector(SIBLING_GAP, 0));
189+
}
190+
const previewCenter = previewLocation.add(new Vector(rect.width / 2, rect.height / 2));
191+
this.project.textRenderer.renderTextFromCenter(
192+
"backslash \\",
193+
this.project.renderer.transformWorld2View(previewCenter),
194+
10 * this.project.camera.currentScale,
195+
hintColor,
196+
);
197+
}
174198
}
175199

176200
/**

app/src/core/service/Settings.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export const settingsSchema = z.object({
1919
showBackgroundCartesian: z.boolean().default(true),
2020
enableTagTextNodesBigDisplay: z.boolean().default(true),
2121
showTextNodeBorder: z.boolean().default(true),
22+
showTreeDirectionHint: z.boolean().default(true),
2223
lineStyle: z.union([z.literal("straight"), z.literal("bezier"), z.literal("vertical")]).default("straight"),
2324
sectionBitTitleRenderType: z.union([z.literal("none"), z.literal("top"), z.literal("cover")]).default("cover"),
2425
nodeDetailsPanel: z.union([z.literal("small"), z.literal("vditor")]).default("vditor"),

app/src/core/service/SettingsIcons.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ export const settingsIcons = {
157157
showBackgroundCartesian: Move3d,
158158
enableTagTextNodesBigDisplay: Tag,
159159
showTextNodeBorder: Square,
160+
showTreeDirectionHint: ListTree,
160161
lineStyle: Spline,
161162
sectionBitTitleRenderType: SquareM,
162163
sectionBigTitleThresholdRatio: Ratio,

app/src/locales/en.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,11 @@ settings:
782782
showTextNodeBorder:
783783
title: Show Text Node Border
784784
description: "Controls whether to show the text node border or not.\n"
785+
showTreeDirectionHint:
786+
title: Show Tree Growth Direction Hints
787+
description: |
788+
When a text node is selected, display keyboard hints (tab/W W/S S/A A/D D) around the node indicating tree growth directions.
789+
When disabled, these hint labels will not be rendered.
785790
autoLayoutWhenTreeGenerate:
786791
title: Automatically update layout when growing nodes
787792
description: "After it is turned on, the layout will be automatically updated

app/src/locales/id.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,11 @@ settings:
269269
title: Tampilkan Batas Node Teks
270270
description: |
271271
Mengontrol apakah menampilkan batas node teks
272+
showTreeDirectionHint:
273+
title: Tampilkan Petunjuk Arah Pertumbuhan Pohon
274+
description: |
275+
Saat node teks dipilih, tampilkan petunjuk keyboard (tab/W W/S S/A A/D D) di sekitar node yang menunjukkan arah pertumbuhan pohon.
276+
Saat dinonaktifkan, label petunjuk ini tidak akan dirender.
272277
sectionBitTitleRenderType:
273278
title: Jenis Render Judul Besar Ringkasan Kotak
274279
options:

app/src/locales/zh_CN.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,11 @@ settings:
278278
title: 显示文本节点边框
279279
description: |
280280
控制是否显示文本节点的边框
281+
showTreeDirectionHint:
282+
title: 显示树形生长方向提示
283+
description: |
284+
选中文本节点时,在节点四周显示 tab/W W/S S/A A/D D 等键盘树形生长方向提示。
285+
关闭后不再渲染这些提示文字。
281286
sectionBitTitleRenderType:
282287
title: 框的缩略大标题渲染类型
283288
options:

app/src/locales/zh_TW.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,11 @@ settings:
278278
title: 顯示文本節點邊框
279279
description: |
280280
控制是否顯示文本節點的邊框
281+
showTreeDirectionHint:
282+
title: 顯示樹形生長方向提示
283+
description: |
284+
選中文本節點時,在節點四周顯示 tab/W W/S S/A A/D D 等鍵盤樹形生長方向提示。
285+
關閉後不再渲染這些提示文字。
281286
sectionBitTitleRenderType:
282287
title: 框的縮略大標題渲染類型
283288
options:

app/src/locales/zh_TWC.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,9 @@ settings:
322322
showTextNodeBorder:
323323
title: 顯示文字節點邊框
324324
description: 控制是否顯示文字節點的邊框
325+
showTreeDirectionHint:
326+
title: 顯示樹形生長方向提示
327+
description: 選中文字節點時,在節點四周顯示 tab/W W/S S/A A/D D 等鍵盤樹形生長方向提示。關閉後不再渲染這些提示文字。
325328
sectionBitTitleRenderType:
326329
title: 框的縮略大標題渲染類型
327330
options:

app/src/sub/SettingsWindow/settings.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ const categories = {
217217
"stealthModeReverseMask",
218218
"stealthModeMaskShape",
219219
],
220-
node: ["enableTagTextNodesBigDisplay", "showTextNodeBorder"],
220+
node: ["enableTagTextNodesBigDisplay", "showTextNodeBorder", "showTreeDirectionHint"],
221221
edge: ["lineStyle"],
222222
section: [
223223
"sectionBitTitleRenderType",

0 commit comments

Comments
 (0)