reparentTarget method

ResolvedShape? reparentTarget(
  1. DiagramRect bounds, {
  2. Set<String> excluding = const {},
})

Finds the frontmost expanded frame intersecting a dragged object's bounds. Exclude the complete moving subtree to prevent ownership cycles.

Implementation

ResolvedShape? reparentTarget(
  DiagramRect bounds, {
  Set<String> excluding = const {},
}) {
  final scene = store.scene;
  final candidates = scene.spatialIndex.query(bounds).toList(growable: false);
  for (final candidate in candidates.reversed) {
    if (candidate is ResolvedShape &&
        !excluding.contains(candidate.id) &&
        scene.isVisible(candidate.id) &&
        !candidate.isLocked &&
        !candidate.source.isCollapsed &&
        candidate.container != null &&
        !candidate.container!.resizesChildren &&
        diagramSelectionBounds(candidate).intersects(bounds)) {
      return candidate;
    }
  }
  return null;
}