fix(交互/渲染): 手写笔拖拽、换泳道与依赖标签排版
- 触屏单指拖拽改走原始指针事件(绕开手势竞技场),手写笔拖拽端点更稳 - 端点把手优先命中:精确点在把手上也能选中并拖拽 - 换泳道不再因目标泳道时间重叠而拒绝(消除“磁吸回弹”),斜向拖拽也能换道 - 依赖标签:FS/SS 缩短、字号收小、去掉五角星;条形图上下/左右自动避让, 圆周图沿半径自动避让,避免标签互相压盖 - 条形动作条 22→18px、泳道间距上限 52→58;圆周环宽略收窄、环间距上限提高 - 图例:关键路径改为「线条加粗光晕」示例
This commit is contained in:
+22
-19
@@ -355,16 +355,16 @@ class _DepTypeLegend extends StatelessWidget {
|
||||
const SizedBox(height: 10),
|
||||
row(_SampleLine(color: t.fs, dash: false, arrow: true), 'FS 严格顺序(完成后启动)'),
|
||||
row(_SampleLine(color: t.ss, dash: true, arrow: true), 'SS 并行重叠(可提前启动)'),
|
||||
row(_SampleLine(color: t.fs, dash: false, arrow: false, star: true), '关键路径(累计最长链)'),
|
||||
row(_SampleLine(color: t.fs, dash: false, arrow: false, glow: true), '关键路径(线条加粗光晕)'),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 图例中的示例线段:可组合实线/虚线、箭头与关键路径星标。
|
||||
/// 图例中的示例线段:可组合实线/虚线、箭头与关键路径光晕。
|
||||
class _SampleLine extends StatelessWidget {
|
||||
const _SampleLine({required this.color, required this.dash, required this.arrow, this.star = false});
|
||||
const _SampleLine({required this.color, required this.dash, required this.arrow, this.glow = false});
|
||||
|
||||
/// 线条颜色。
|
||||
final Color color;
|
||||
@@ -372,22 +372,22 @@ class _SampleLine extends StatelessWidget {
|
||||
final bool dash;
|
||||
/// 是否绘制箭头。
|
||||
final bool arrow;
|
||||
/// 是否绘制关键路径星标。
|
||||
final bool star;
|
||||
/// 是否为关键路径样式(线条加粗光晕)。
|
||||
final bool glow;
|
||||
|
||||
/// 用 [_SamplePainter] 绘制示例线段。
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
height: 16,
|
||||
child: CustomPaint(painter: _SamplePainter(color, dash, arrow, star)),
|
||||
child: CustomPaint(painter: _SamplePainter(color, dash, arrow, glow)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 示例线段绘制器:按参数绘制实/虚线、箭头与星标。
|
||||
/// 示例线段绘制器:按参数绘制实/虚线、箭头与关键路径光晕。
|
||||
class _SamplePainter extends CustomPainter {
|
||||
_SamplePainter(this.color, this.dash, this.arrow, this.star);
|
||||
_SamplePainter(this.color, this.dash, this.arrow, this.glow);
|
||||
|
||||
/// 线条颜色。
|
||||
final Color color;
|
||||
@@ -395,10 +395,10 @@ class _SamplePainter extends CustomPainter {
|
||||
final bool dash;
|
||||
/// 是否绘制箭头。
|
||||
final bool arrow;
|
||||
/// 是否绘制关键路径星标。
|
||||
final bool star;
|
||||
/// 是否为关键路径样式(线条加粗光晕)。
|
||||
final bool glow;
|
||||
|
||||
/// 绘制示例线段本体、箭头及可选星标。
|
||||
/// 绘制示例线段本体、箭头及可选光晕。
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
final Paint p = Paint()
|
||||
@@ -406,6 +406,17 @@ class _SamplePainter extends CustomPainter {
|
||||
..strokeWidth = 2.4
|
||||
..strokeCap = StrokeCap.round;
|
||||
final double y = size.height / 2;
|
||||
// 关键路径:先铺一层加粗低透明度光晕,再画主线(与画布绘制一致)。
|
||||
if (glow) {
|
||||
canvas.drawLine(
|
||||
Offset(0, y),
|
||||
Offset(size.width - 10, y),
|
||||
Paint()
|
||||
..color = color.withValues(alpha: 0.2)
|
||||
..strokeWidth = 7
|
||||
..strokeCap = StrokeCap.round,
|
||||
);
|
||||
}
|
||||
if (dash) {
|
||||
for (double x = 0; x < size.width - 10; x += 8) {
|
||||
canvas.drawLine(Offset(x, y), Offset(math.min(x + 4, size.width - 10), y), p);
|
||||
@@ -421,14 +432,6 @@ class _SamplePainter extends CustomPainter {
|
||||
..close();
|
||||
canvas.drawPath(a, Paint()..color = color);
|
||||
}
|
||||
if (star) {
|
||||
canvas.drawCircle(Offset(size.width - 8, y), 7.5, Paint()..color = const Color(0xFF4CC9F0));
|
||||
final TextPainter tp = TextPainter(
|
||||
text: const TextSpan(text: '★', style: TextStyle(color: Colors.black, fontSize: 10, fontWeight: FontWeight.w700)),
|
||||
textDirection: TextDirection.ltr,
|
||||
)..layout();
|
||||
tp.paint(canvas, Offset(size.width - 8 - tp.width / 2, y - tp.height / 2));
|
||||
}
|
||||
}
|
||||
|
||||
/// 示例线段始终重绘(开销极小)。
|
||||
|
||||
Reference in New Issue
Block a user