Table of Contents

Class SKGestureTracker

Namespace
SkiaSharp.Extended
Assembly
SkiaSharp.Extended.dll

A high-level gesture handler that tracks touch input and maintains an absolute transform (scale, rotation, and offset) by consuming events from an internal SKGestureDetector.

public sealed class SKGestureTracker : IDisposable
Inheritance
SKGestureTracker
Implements
Inherited Members

Remarks

The tracker is the primary public API for gesture handling. It accepts raw touch input via ProcessTouchDown(long, SKPoint, bool), ProcessTouchMove(long, SKPoint, bool), ProcessTouchUp(long, SKPoint, bool), and ProcessMouseWheel(SKPoint, float, float), detects gestures internally, and translates them into transform state changes and higher-level events such as drag lifecycle and fling animation.

Use the Matrix property to apply the current transform when painting. The matrix uses (0,0) as its origin — no view size configuration is required.

All coordinates are in view (screen) space. The tracker converts screen-space deltas to content-space deltas internally when updating Offset.

Basic usage with an SkiaSharp canvas:

var tracker = new SKGestureTracker();

// Forward touch events from your platform: tracker.ProcessTouchDown(id, new SKPoint(x, y)); tracker.ProcessTouchMove(id, new SKPoint(x, y)); tracker.ProcessTouchUp(id, new SKPoint(x, y));

// In your paint handler: canvas.Save(); canvas.Concat(tracker.Matrix); // Draw your content... canvas.Restore();

// Listen for transform changes to trigger redraws: tracker.TransformChanged += (s, e) => canvasView.InvalidateSurface();

SKGestureDetector SKGestureTrackerOptions

Constructors

SKGestureTracker()

Initializes a new instance of the SKGestureTracker class with default options.

SKGestureTracker(SKGestureTrackerOptions)

Initializes a new instance of the SKGestureTracker class with the specified options.

Properties

IsDoubleTapEnabled

Gets or sets a value indicating whether double-tap detection is enabled.

IsDoubleTapZoomEnabled

Gets or sets a value indicating whether double-tap triggers an animated zoom.

IsEnabled

Gets or sets a value indicating whether gesture detection is enabled.

IsFlingEnabled

Gets or sets a value indicating whether fling (inertia) animation is enabled after a pan gesture.

IsFlinging

Gets a value indicating whether a fling (inertia) animation is in progress.

IsGestureActive

Gets a value indicating whether any gesture is currently active (touch contact in progress).

IsHoverEnabled

Gets or sets a value indicating whether hover (mouse move without contact) detection is enabled.

IsLongPressEnabled

Gets or sets a value indicating whether long press detection is enabled.

IsPanEnabled

Gets or sets a value indicating whether pan gestures update the Offset.

IsPinchEnabled

Gets or sets a value indicating whether pinch-to-zoom gestures update the Scale.

IsRotateEnabled

Gets or sets a value indicating whether rotation gestures update the Rotation.

IsScrollZoomEnabled

Gets or sets a value indicating whether scroll-wheel events trigger zoom.

IsTapEnabled

Gets or sets a value indicating whether tap detection is enabled.

IsZoomAnimating

Gets a value indicating whether an animated zoom (from double-tap or ZoomTo(float, SKPoint)) is in progress.

Matrix

Gets the composite transform matrix that combines scale, rotation, and offset, using (0,0) as the transform origin.

Offset

Gets the current pan offset in content coordinates.

Options

Gets the configuration options for this tracker.

Rotation

Gets the current rotation angle in degrees.

Scale

Gets the current zoom scale factor.

TimeProvider

Gets or sets the time provider function used to obtain the current time in ticks.

Methods

Dispose()

Releases all resources used by this SKGestureTracker instance, including stopping all animations and disposing the internal SKGestureDetector.

ProcessMouseWheel(SKPoint, float, float)

Processes a mouse wheel (scroll) event and forwards it to the internal gesture detector.

ProcessTouchCancel(long)

Processes a touch cancel event and forwards it to the internal gesture detector.

ProcessTouchDown(long, SKPoint, bool)

Processes a touch down event and forwards it to the internal gesture detector.

ProcessTouchMove(long, SKPoint, bool)

Processes a touch move event and forwards it to the internal gesture detector.

ProcessTouchUp(long, SKPoint, bool)

Processes a touch up event and forwards it to the internal gesture detector.

Reset()

Resets the tracker to an identity transform (scale 1, rotation 0, offset zero), stops all animations, and raises TransformChanged.

SetOffset(SKPoint)

Sets the pan offset and raises TransformChanged.

SetRotation(float, SKPoint?)

Sets the rotation angle and raises TransformChanged.

SetScale(float, SKPoint?)

Sets the zoom scale, clamping to MinScale/MaxScale, and raises TransformChanged.

SetTransform(float, float, SKPoint)

Sets the transform to the specified values, clamping scale to MinScale/MaxScale.

StopFling()

Stops any active fling animation and raises FlingCompleted.

StopZoomAnimation()

Stops any active zoom animation immediately.

ZoomTo(float, SKPoint)

Starts an animated zoom by the given multiplicative factor around a focal point.

Events

DoubleTapDetected

Occurs when a double tap is detected. Forwarded from the internal SKGestureDetector.

DragEnded

Occurs when a drag operation ends (all touches released).

DragStarted

Occurs when a drag operation starts (first pan movement after touch down).

DragUpdated

Occurs on each movement during a drag operation.

FlingCompleted

Occurs when a fling animation completes (velocity drops below FlingMinVelocity).

FlingDetected

Occurs when a fling gesture is detected (once, with initial velocity). Forwarded from the internal SKGestureDetector.

FlingUpdated

Occurs each animation frame during a fling deceleration.

GestureEnded

Occurs when a gesture interaction ends (last touch released). Forwarded from the internal SKGestureDetector.

GestureStarted

Occurs when a gesture interaction begins (first touch contact). Forwarded from the internal SKGestureDetector.

HoverDetected

Occurs when a hover is detected. Forwarded from the internal SKGestureDetector.

LongPressDetected

Occurs when a long press is detected. Forwarded from the internal SKGestureDetector.

PanDetected

Occurs when a pan gesture is detected. Forwarded from the internal SKGestureDetector.

PinchDetected

Occurs when a pinch (scale) gesture is detected. Forwarded from the internal SKGestureDetector.

RotateDetected

Occurs when a rotation gesture is detected. Forwarded from the internal SKGestureDetector.

ScrollDetected

Occurs when a scroll (mouse wheel) event is detected. Forwarded from the internal SKGestureDetector.

TapDetected

Occurs when a single tap is detected. Forwarded from the internal SKGestureDetector.

TransformChanged

Occurs when the transform state (Scale, Rotation, Offset, or Matrix) changes.