835f16c0bf
Paint the landed orthogonal EdgeRoutes on a caller-sized canvas: one polyline per route, a filled arrow at the target port in the route's real arrival direction, clipping, and value-based repaint. The layer is pointer transparent so node widgets below it keep their gestures. Includes focused geometry, painter and hit-test regressions, an isolated web probe with rendered evidence, and a note recording the slice and its limits.
42 lines
1.3 KiB
Dart
42 lines
1.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:pipelines_app/features/graph/routing/route_models.dart';
|
|
|
|
/// Shared hand-built routes for the edge-layer painting tests.
|
|
|
|
EdgeRoute edgeRoute({
|
|
required List<RoutePoint> points,
|
|
RouteKind kind = RouteKind.forward,
|
|
RoutePortSide targetSide = RoutePortSide.left,
|
|
double portX = 0,
|
|
double portY = 0,
|
|
}) {
|
|
final start = points.isEmpty ? RoutePoint(portX, portY) : points.first;
|
|
final end = points.isEmpty ? RoutePoint(portX, portY) : points.last;
|
|
return EdgeRoute(
|
|
id: 1,
|
|
source: 'a',
|
|
outcome: 'success',
|
|
target: 'b',
|
|
label: 'success',
|
|
fallback: false,
|
|
kind: kind,
|
|
straight: false,
|
|
sourcePort: RoutePort(side: RoutePortSide.right, point: start),
|
|
targetPort: RoutePort(side: targetSide, point: end),
|
|
points: points,
|
|
);
|
|
}
|
|
|
|
Offset routeOffset(RoutePoint point) => Offset(point.x, point.y);
|
|
|
|
/// The direction of the route's last non-degenerate segment.
|
|
Offset arrival(EdgeRoute route) {
|
|
final points = route.points;
|
|
final end = points.last;
|
|
for (var index = points.length - 2; index >= 0; index -= 1) {
|
|
final delta = Offset(end.x - points[index].x, end.y - points[index].y);
|
|
if (delta != Offset.zero) return delta / delta.distance;
|
|
}
|
|
return Offset.zero;
|
|
}
|