Files
pipelines/app/lib/features/graph/painting/edge_highlight_layer.dart
T
alan 7872e57d40 Run card mini-map and stage strip; graph edge hover highlight
The show_run card carries the run's graph and per-stage progress (bounded by
the graph, not the run length) and draws a still mini-map with the run graph
plus a stage strip with status, visits and time. Hovering or tapping an edge
in the pipeline and run graphs highlights it, its label and endpoints, with a
tooltip naming from -> to, the outcome and, for runs, how often it was taken.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 12:56:51 +00:00

92 lines
2.6 KiB
Dart

import 'package:flutter/material.dart';
import '../layout/layout_models.dart';
import '../routing/route_models.dart';
import 'graph_edge_layer.dart';
/// Paints one highlighted edge over the other routes and behind the nodes: a
/// soft glow under the two endpoint stages, then the route in [color] at a
/// heavier stroke with its arrow, on a translucent halo.
///
/// Passive like the other edge layers: it never takes a hit.
class EdgeHighlightPainter extends CustomPainter {
EdgeHighlightPainter({
required this.route,
required this.endpoints,
required this.color,
required this.strokeWidth,
});
final EdgeRoute route;
/// The source and target node boxes (one for a self loop).
final List<GraphNodeBox> endpoints;
final Color color;
/// The highlighted stroke; the halo is wider.
final double strokeWidth;
@override
void paint(Canvas canvas, Size size) {
final glow = Paint()..color = color.withValues(alpha: 0.18);
for (final box in endpoints) {
final rect = Rect.fromLTWH(box.x, box.y, box.width, box.height);
canvas.drawRRect(
RRect.fromRectAndRadius(rect.inflate(5), const Radius.circular(14)),
glow,
);
}
if (route.points.length < 2) return;
final geometry = GraphEdgePainter(
routes: [route],
color: color,
strokeWidth: strokeWidth,
);
final line = geometry.linePath(route);
canvas.drawPath(
line,
Paint()
..color = color.withValues(alpha: 0.22)
..strokeWidth = strokeWidth * 3
..style = PaintingStyle.stroke
..strokeJoin = StrokeJoin.round
..strokeCap = StrokeCap.round,
);
canvas.drawPath(
line,
Paint()
..color = color
..strokeWidth = strokeWidth
..style = PaintingStyle.stroke
..strokeJoin = StrokeJoin.round,
);
canvas.drawPath(
GraphEdgePainter(
routes: [route],
color: color,
// The arrow scales with the stroke; keep it near the plain arrow.
strokeWidth: strokeWidth / 1.5,
).arrowPath(route),
Paint()..color = color,
);
}
@override
bool hitTest(Offset position) => false;
@override
bool shouldRepaint(EdgeHighlightPainter oldDelegate) =>
oldDelegate.route != route ||
oldDelegate.color != color ||
oldDelegate.strokeWidth != strokeWidth ||
oldDelegate.endpoints.length != endpoints.length ||
!_sameBoxes(oldDelegate.endpoints, endpoints);
static bool _sameBoxes(List<GraphNodeBox> a, List<GraphNodeBox> b) {
for (var index = 0; index < a.length; index += 1) {
if (a[index] != b[index]) return false;
}
return true;
}
}