fix(交互/渲染): 手写笔拖拽、换泳道与依赖标签排版

- 触屏单指拖拽改走原始指针事件(绕开手势竞技场),手写笔拖拽端点更稳
- 端点把手优先命中:精确点在把手上也能选中并拖拽
- 换泳道不再因目标泳道时间重叠而拒绝(消除“磁吸回弹”),斜向拖拽也能换道
- 依赖标签:FS/SS 缩短、字号收小、去掉五角星;条形图上下/左右自动避让,
  圆周图沿半径自动避让,避免标签互相压盖
- 条形动作条 22→18px、泳道间距上限 52→58;圆周环宽略收窄、环间距上限提高
- 图例:关键路径改为「线条加粗光晕」示例
This commit is contained in:
2026-10-08 14:34:04 +08:00
parent 76d1ce0d9a
commit 5e30ab17a2
6 changed files with 292 additions and 82 deletions
+50 -11
View File
@@ -131,11 +131,14 @@ class CircularPainter extends CustomPainter {
// 依赖连线先于动作弧绘制,使其位于弧之下、不被遮挡。
if (project.viewState.showDeps) {
final List<_ArcChip> chips = <_ArcChip>[];
for (final Action to in project.actions) {
for (final Dependency d in to.deps) {
_dep(canvas, layout, d);
final _ArcChip? chip = _dep(canvas, layout, d);
if (chip != null) chips.add(chip);
}
}
_placeArcChips(canvas, layout, chips);
}
// 逐个绘制动作弧。
@@ -381,10 +384,10 @@ class CircularPainter extends CustomPainter {
/// - 相邻层取两层半径均值作为 [rC];层差大于 1 时改用最外圈 `rMax+24` 绕行。
/// - [large]/[cw] 决定圆弧走大弧还是小弧、顺时针还是逆时针。
/// - 关键依赖先画低透明度粗描边,再画主线,最后放置 `A→B 类型` 胶囊。
void _dep(Canvas canvas, CircularLayout layout, Dependency d) {
_ArcChip? _dep(Canvas canvas, CircularLayout layout, Dependency d) {
final Action? A = project.actionById(d.fromId);
final Action? B = project.actionById(d.toId);
if (A == null || B == null) return;
if (A == null || B == null) return null;
final Offset c = layout.center;
final double rA = layout.radiusFor(A.layer);
final double rB = layout.radiusFor(B.layer);
@@ -455,14 +458,34 @@ class CircularPainter extends CustomPainter {
String label = d.type == DepType.fs ? 'FS' : 'SS+${d.offsetAngle.toStringAsFixed(0)}°';
if (d.type == DepType.ff) label = 'FF';
if (d.type == DepType.sf) label = 'SF';
// 依赖标签沿圆弧切向排布(与动作名一致),呈现“圆弧效果”。
final double arcLen = 2 * math.pi * chipR * 0.9;
_arcLabel(canvas, c, chipR, chipDeg, '${A.id}→${B.id} $label', col, 10,
math.max(math.min(arcLen, 200), 40));
if (crit) {
final Offset sp = polar(c, chipR, chipDeg);
canvas.drawCircle(sp.translate(-46, 0), 7, Paint()..color = tokens.crit);
_text(canvas, '★', sp.translate(-46, 0), color: tokens.onAccent, size: 9, align: TextAlign.center, weight: FontWeight.w700);
// 标签不在此处直接绘制:收集后统一避让放置(见 [_placeArcChips]),
// 字号收小、取消五角星,避免多个依赖(尤其 FS 与 SS 并存)互相压盖。
return _ArcChip(chipR, chipDeg, '${A.id}→${B.id} $label', col);
}
/// 统一绘制圆周视图的依赖标签:沿半径方向逐级外移 / 内移避让,避免相互重叠。
///
/// 估算每个标签的占位矩形(文本长度 × 字号),若与已放置标签相交则按
/// +14 / −14 / +28 / −28 … 的步长沿半径方向挪动,直到找到空位。
void _placeArcChips(Canvas canvas, CircularLayout layout, List<_ArcChip> chips) {
final Offset c = layout.center;
final List<Rect> placed = <Rect>[];
const double size = 8.5;
for (final _ArcChip chip in chips) {
final double w = chip.text.runes.length * size * 0.62 + 8;
final double h = size * 1.7;
double r = chip.r;
Rect rect = Rect.fromCenter(center: polar(c, r, chip.deg), width: w, height: h);
for (int i = 1; i <= 10; i++) {
if (!placed.any((Rect o) => o.inflate(1.5).overlaps(rect))) break;
final double step = 14.0 * ((i + 1) ~/ 2);
r = chip.r + (i.isOdd ? step : -step);
rect = Rect.fromCenter(center: polar(c, r, chip.deg), width: w, height: h);
}
placed.add(rect);
final double arcLen = 2 * math.pi * r * 0.9;
_arcLabel(canvas, c, r, chip.deg, chip.text, chip.color, size,
math.max(math.min(arcLen, 200), 40));
}
}
@@ -626,3 +649,19 @@ class CircularPainter extends CustomPainter {
@override
bool shouldRepaint(covariant CircularPainter old) => true;
}
/// 圆周视图依赖标签的待放置描述:半径、角度、文本与颜色。
///
/// 先在依赖遍历中收集,再由 [CircularPainter] 统一做径向避让绘制。
class _ArcChip {
const _ArcChip(this.r, this.deg, this.text, this.color);
/// 期望的标签半径(像素)。
final double r;
/// 期望的标签角度(度,0° = 12 点钟、顺时针)。
final double deg;
/// 标签文本(如 `A1→A2 SS+30°`)。
final String text;
/// 文本颜色(按依赖类型区分)。
final Color color;
}