Table of Contents

Interface ISnapProvider

Namespace
FlowGraph.Avalonia.Input
Assembly
FlowGraph.Avalonia.dll

Interface for providing snap offsets during node drag operations. External systems (like helper lines, guides, magnetic snapping) can implement this interface to influence node positions during drag without directly modifying node positions themselves.

public interface ISnapProvider

Remarks

This follows the "single authority" pattern where the drag system remains the sole authority for setting node positions. Snap providers suggest offsets, and the drag system decides whether and how to apply them.

Methods

GetSnapOffset(IReadOnlyList<Node>, Point)

Calculate a snap offset for nodes being dragged.

Point? GetSnapOffset(IReadOnlyList<Node> nodes, Point proposedPosition)

Parameters

nodes IReadOnlyList<Node>

The nodes currently being dragged.

proposedPosition Point

The position the drag system is proposing for the primary node (after applying delta from drag start and any grid snapping).

Returns

Point?

A snap offset to apply to all dragged nodes, or null if no snapping should occur. The offset is relative to the proposed position (e.g., return (5, 0) to shift 5 pixels right).

OnDragEnd(IReadOnlyList<Node>, bool)

Called when a drag operation ends.

void OnDragEnd(IReadOnlyList<Node> nodes, bool cancelled)

Parameters

nodes IReadOnlyList<Node>

The nodes that were dragged.

cancelled bool

Whether the drag was cancelled.

OnDragStart(IReadOnlyList<Node>, Point)

Called when a drag operation starts.

void OnDragStart(IReadOnlyList<Node> nodes, Point startPosition)

Parameters

nodes IReadOnlyList<Node>

The nodes being dragged.

startPosition Point

The starting canvas position of the drag.