Table of Contents

Interface IInputProcessor

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

Processes input for a specific element type or interaction pattern.

public interface IInputProcessor

Remarks

InputProcessors replace the pattern-matching approach in IdleState with a more maintainable, extensible architecture. Each processor handles input for one or more HitTargetTypes.

Priority Order (higher = checked first):

  • 100: Resize handles (small targets, always on top)
  • 90: Ports (small targets need priority)
  • 80: Nodes
  • 70: Edges
  • 60: Shapes (sticky notes, etc.)
  • 50: Groups
  • 0: Canvas (fallback)

Performance Note (Gemini Optimization): HandledTypes is a bitmask enum, enabling O(1) type checking via bitwise AND instead of O(N) list iteration. Critical for high-frequency events like PointerMoved.

Design Rationale:

  • Eliminates fragile pattern matching on Tag objects
  • Each element type's logic is self-contained
  • New element types = new processor, not touching IdleState
  • Testable in isolation

Properties

HandledTypes

The hit target types this processor handles (bitmask). Use bitwise OR to handle multiple types: HitTargetType.Node | HitTargetType.Group

HitTargetType HandledTypes { get; }

Property Value

HitTargetType

Name

Display name for debugging.

string Name { get; }

Property Value

string

Priority

Priority for checking this processor. Higher = checked first.

int Priority { get; }

Property Value

int

Methods

CanHandle(HitTargetType)

Checks if this processor handles the given target type. Default implementation uses bitwise AND for O(1) checking.

bool CanHandle(HitTargetType targetType)

Parameters

targetType HitTargetType

Returns

bool

HandlePointerMoved(InputStateContext, GraphHitTestResult, PointerEventArgs)

Handles pointer moved. Called during idle state for hover effects.

InputProcessorResult HandlePointerMoved(InputStateContext context, GraphHitTestResult hit, PointerEventArgs e)

Parameters

context InputStateContext
hit GraphHitTestResult
e PointerEventArgs

Returns

InputProcessorResult

HandlePointerPressed(InputStateContext, GraphHitTestResult, PointerPressedEventArgs)

Handles pointer pressed on an element this processor is responsible for.

InputProcessorResult HandlePointerPressed(InputStateContext context, GraphHitTestResult hit, PointerPressedEventArgs e)

Parameters

context InputStateContext

The input state context.

hit GraphHitTestResult

The hit test result (guaranteed to be a type from HandledTypes).

e PointerPressedEventArgs

The Avalonia pointer event.

Returns

InputProcessorResult

Result indicating whether handled and any state transition.

HandlePointerReleased(InputStateContext, GraphHitTestResult, PointerReleasedEventArgs)

Handles pointer released. Rarely needed at processor level.

InputProcessorResult HandlePointerReleased(InputStateContext context, GraphHitTestResult hit, PointerReleasedEventArgs e)

Parameters

context InputStateContext
hit GraphHitTestResult
e PointerReleasedEventArgs

Returns

InputProcessorResult