From b49435632674b1e74b67a4d2c4c9dcf49c78d204 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=86=E5=A4=B4=E9=B9=85?= Date: Fri, 18 Sep 2026 18:04:35 +0800 Subject: [PATCH] =?UTF-8?q?fix(ui):=20=E5=90=8C=E6=B3=B3=E9=81=93=E4=BE=9D?= =?UTF-8?q?=E8=B5=96=E6=94=B9=E6=B0=B4=E5=B9=B3=E8=BF=9E=E7=BA=BF=EF=BC=9B?= =?UTF-8?q?=E5=9C=86=E5=91=A8=E4=BE=9D=E8=B5=96=E6=A0=87=E7=AD=BE=E6=B2=BF?= =?UTF-8?q?=E5=BC=A7=E6=98=BE=E7=A4=BA=EF=BC=9B=E5=AF=BC=E5=87=BA=E6=94=B9?= =?UTF-8?q?=E7=8B=AC=E7=AB=8B=E6=8C=89=E9=92=AE=EF=BC=9B=E6=8D=A2=E9=81=93?= =?UTF-8?q?=E9=AB=98=E4=BA=AE=E7=9B=AE=E6=A0=87=E6=B3=B3=E9=81=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 同泳道依赖:源/目标同 y 时水平直线连接,标签置于线上方,不再压住箭头/色块 - 圆周依赖标签改用沿弧文字(与动作名一致),不再显示为竖直矩形 - 紧凑工具栏导出恢复为「导出 SVG / 导出 PNG」两个独立按钮 - 上下换泳道时高亮目标泳道(可放置=强调色,重叠=警示色) - 重新构建 dist --- lib/render/bar_painter.dart | 50 +++++++++++++++++++++++++++++--- lib/render/circular_painter.dart | 36 +++++------------------ lib/ui/app_shell.dart | 29 ++++-------------- lib/ui/canvas_view.dart | 14 ++++++++- 4 files changed, 71 insertions(+), 58 deletions(-) diff --git a/lib/render/bar_painter.dart b/lib/render/bar_painter.dart index 2d07ea5..dd4ff25 100644 --- a/lib/render/bar_painter.dart +++ b/lib/render/bar_painter.dart @@ -46,6 +46,8 @@ class BarPainter extends CustomPainter { required this.criticalDeps, required this.selectedIds, this.guideAngle, + this.dropLane, + this.dropValid = true, }); /// 待绘制的工程数据源。 @@ -62,6 +64,12 @@ class BarPainter extends CustomPainter { /// 拖拽相位分区边界时的参考角(度);非空时绘制一条竖直虚线参考。 final double? guideAngle; + /// 上下拖拽换泳道时,光标所在的目标泳道号;非空时高亮该泳道。 + final int? dropLane; + + /// 目标泳道是否可放置(时间不重叠);false 时用警示色高亮。 + final bool dropValid; + /// 标尺横线所在的 y 坐标(画布坐标)。 static const double axisTop = 138; /// 相位色带的顶部 y 坐标。 @@ -79,6 +87,28 @@ class BarPainter extends CustomPainter { final double cycle = project.cycle.durationMs; if (project.viewState.showPhaseBands) _phaseBands(canvas, layout); + // 换泳道拖拽:高亮目标泳道(可放置=强调色,重叠=警示色)。 + if (dropLane != null && layout.lanes.contains(dropLane)) { + final double y = layout.yForLane(dropLane!); + final Color c = dropValid ? tokens.accent : tokens.danger; + canvas.drawRRect( + RRect.fromRectAndRadius( + Rect.fromLTWH(20, y - 8, layout.plotRight - 20, BarLayout.rowVisual), + const Radius.circular(10), + ), + Paint()..color = c.withValues(alpha: 0.12), + ); + canvas.drawRRect( + RRect.fromRectAndRadius( + Rect.fromLTWH(20, y - 8, layout.plotRight - 20, BarLayout.rowVisual), + const Radius.circular(10), + ), + Paint() + ..style = PaintingStyle.stroke + ..strokeWidth = 1.4 + ..color = c.withValues(alpha: 0.8), + ); + } if (project.viewState.showRuler) _ruler(canvas, layout, u, cycle); _boundaries(canvas, layout); _rows(canvas, layout, u, cycle); @@ -399,9 +429,16 @@ class BarPainter extends CustomPainter { final Path p = Path(); double chipX; - final double chipY = gapY; - // 相邻行:短折线,直接从源端折向目标条块上方。 - if ((ib - ia).abs() <= 1) { + double chipY; + // 同一泳道内的依赖(源/目标同 y):水平直线连接,标签置于线上方。 + final bool sameLane = (ty - sy).abs() < 1; + if (sameLane) { + p.moveTo(ex, sy); + p.lineTo(tx, sy); + chipX = (ex + tx) / 2; + chipY = sy - 14; + } else if ((ib - ia).abs() <= 1) { + chipY = gapY; p.moveTo(ex, sy + dir * 13); p.lineTo(ex, gapY); p.lineTo(tx, gapY); @@ -432,6 +469,7 @@ class BarPainter extends CustomPainter { p.lineTo(tx, gapY); p.lineTo(tx, tipY - dir * 12); chipX = (lane + tx) / 2; + chipY = gapY; } // 关键路径依赖:先铺一层加粗低透明度光晕,再画主线。 if (crit) { @@ -452,7 +490,11 @@ class BarPainter extends CustomPainter { ..strokeCap = StrokeCap.round ..color = col.withValues(alpha: 0.95), ); - _arrow(canvas, Offset(tx, tipY), Offset(0, dir), col); + if (sameLane) { + _arrow(canvas, Offset(tx, sy), const Offset(1, 0), col); + } else { + _arrow(canvas, Offset(tx, tipY), Offset(0, dir), col); + } final String label = d.type == DepType.fs ? 'FS 顺序' : 'SS +${d.offsetAngle.toStringAsFixed(0)}°'; // 标签上移,避免压住箭头(箭头在更靠近目标条块的一侧)。 _chip(canvas, Offset(chipX, chipY - 11), label, col, crit); diff --git a/lib/render/circular_painter.dart b/lib/render/circular_painter.dart index d702907..90c09e0 100644 --- a/lib/render/circular_painter.dart +++ b/lib/render/circular_painter.dart @@ -464,37 +464,15 @@ 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'; - _arcChip(canvas, c, chipR, chipDeg, '${A.id}→${B.id} $label', col, crit); - } - - /// 沿圆弧切向绘制依赖标签胶囊,使其贴合环间空隙、不压住动作弧。 - void _arcChip(Canvas canvas, Offset c, double r, double midDeg, String label, Color col, bool crit) { - final TextPainter tp = _tp(label, 10, col, FontWeight.w600); - final double w = tp.width + 16 + (crit ? 18 : 0); - const double h = 17; - final Offset pos = polar(c, r, midDeg); - final double rad = midDeg * math.pi / 180; - final bool flip = midDeg > 90 && midDeg < 270; - canvas.save(); - canvas.translate(pos.dx, pos.dy); - canvas.rotate(flip ? rad + math.pi : rad); - final Rect rect = Rect.fromCenter(center: Offset.zero, width: w, height: h); - canvas.drawRRect(RRect.fromRectAndRadius(rect, const Radius.circular(6)), Paint()..color = tokens.chip); - canvas.drawRRect( - RRect.fromRectAndRadius(rect, const Radius.circular(6)), - Paint() - ..style = PaintingStyle.stroke - ..strokeWidth = 1 - ..color = col, - ); - double tx = rect.left + 8; + // 依赖标签沿圆弧切向排布(与动作名一致),呈现“圆弧效果”。 + 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) { - canvas.drawCircle(Offset(rect.left + 8, 0), 6.5, Paint()..color = tokens.crit); - _text(canvas, '★', Offset(rect.left + 8, 0), color: tokens.onAccent, size: 10, align: TextAlign.center); - tx = rect.left + 18; + 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); } - tp.paint(canvas, Offset(tx, -tp.height / 2)); - canvas.restore(); } /// 在 [tip] 处绘制指向 [dir] 方向的实心三角箭头。 diff --git a/lib/ui/app_shell.dart b/lib/ui/app_shell.dart index 1e0b969..d9cf54f 100644 --- a/lib/ui/app_shell.dart +++ b/lib/ui/app_shell.dart @@ -423,7 +423,11 @@ class _AppShellState extends State { _segmented(t, compact: true), ]; right = [ - _exportMenuBtn(t), + // 导出保持两个独立按钮(不用合并菜单,便于一眼识别)。 + _ghost(t, '导出 SVG', _exportSvg), + const SizedBox(width: 4), + _ghost(t, '导出 PNG', _exportPng), + const SizedBox(width: 4), _zoomBox(t), _iconBtn(t, Icons.crop_free, c.fitView, tooltip: '适应视图'), _unitDropdown(t), @@ -709,29 +713,6 @@ class _AppShellState extends State { ); } - /// 导出菜单按钮:一个图标弹出「导出 SVG / PNG」,节省工具栏宽度。 - Widget _exportMenuBtn(Tokens t) { - return PopupMenuButton( - tooltip: '导出 SVG / PNG', - color: t.dialog, - onSelected: (String v) { - if (v == 'svg') { - _exportSvg(); - } else { - _exportPng(); - } - }, - itemBuilder: (BuildContext ctx) => const >[ - PopupMenuItem(value: 'svg', child: Text('导出 SVG')), - PopupMenuItem(value: 'png', child: Text('导出 PNG')), - ], - child: Padding( - padding: const EdgeInsets.all(7), - child: Icon(Icons.download, size: 18, color: t.accent2), - ), - ); - } - // ===================== 侧栏停靠状态机(钉住 / 悬浮 / 轨道) ===================== /// 侧栏标题栏控制按钮:切换钉住状态与隐藏侧栏。 diff --git a/lib/ui/canvas_view.dart b/lib/ui/canvas_view.dart index 0458235..0ab7680 100644 --- a/lib/ui/canvas_view.dart +++ b/lib/ui/canvas_view.dart @@ -70,6 +70,12 @@ class _CanvasViewState extends State { /// 当前鼠标指针样式(靠近可拖拽端点时显示左右箭头)。 MouseCursor _cursor = SystemMouseCursors.basic; + /// 上下拖拽换泳道时的目标泳道号;非空时在画布上高亮。 + int? _dropLane; + + /// 目标泳道是否可放置(时间不重叠)。 + bool _dropValid = true; + /// 控制器快捷访问器。 AppController get c => widget.controller; @@ -377,7 +383,10 @@ class _CanvasViewState extends State { ); } else if (dy.abs() > dx.abs() + 6 && dy.abs() > 12) { // 以垂直为主:上下拖拽换泳道(同泳道可放多个不重叠动作)。 - c.moveActionLane(_dragAction!.id, layout.laneAt(p.dy)); + final int target = layout.laneAt(p.dy); + _dropLane = target; + _dropValid = c.canPlaceInLane(_dragAction!.id, target); + c.moveActionLane(_dragAction!.id, target); } else { c.setActionStart(_dragAction!.id, _startAngle + dx / layout.span * 360); } @@ -419,6 +428,7 @@ class _CanvasViewState extends State { _dragAction = null; _zoneIndex = -1; _zoneGuideAngle = null; + _dropLane = null; } /// 滚轮:按住 Ctrl 时以指针方向缩放,否则按滚轮增量平移画布。 @@ -573,6 +583,8 @@ class _CanvasViewState extends State { criticalDeps: c.criticalDeps, selectedIds: c.selectedIds.toSet(), guideAngle: _zoneGuideAngle, + dropLane: _dropLane, + dropValid: _dropValid, ) : CircularPainter( project: c.project,