Interface IInputProcessor
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
Name
Display name for debugging.
string Name { get; }
Property Value
Priority
Priority for checking this processor. Higher = checked first.
int Priority { get; }
Property Value
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
targetTypeHitTargetType
Returns
HandlePointerMoved(InputStateContext, GraphHitTestResult, PointerEventArgs)
Handles pointer moved. Called during idle state for hover effects.
InputProcessorResult HandlePointerMoved(InputStateContext context, GraphHitTestResult hit, PointerEventArgs e)
Parameters
contextInputStateContexthitGraphHitTestResultePointerEventArgs
Returns
HandlePointerPressed(InputStateContext, GraphHitTestResult, PointerPressedEventArgs)
Handles pointer pressed on an element this processor is responsible for.
InputProcessorResult HandlePointerPressed(InputStateContext context, GraphHitTestResult hit, PointerPressedEventArgs e)
Parameters
contextInputStateContextThe input state context.
hitGraphHitTestResultThe hit test result (guaranteed to be a type from HandledTypes).
ePointerPressedEventArgsThe 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
contextInputStateContexthitGraphHitTestResultePointerReleasedEventArgs