Class PreviewGestureController
Tracks one in-progress move, scale, deform or rotate gesture on the preview: what started it, and the Undo group it should collapse into on release.
Inherited Members
Namespace: Serenity.Ui.Infrastructure.Editor.Preview
Assembly: Serenity.UnityUi.Infrastructure.Editor.dll
Syntax
public sealed class PreviewGestureController
Remarks
Deliberately holds only primitive gesture-start state, not object references — a domain reload survives a
[Serializable] field on the window, but the preview rig and its element handles do not, so the
window is the one that decides whether a stale gesture can still be applied and cancels it otherwise.
Every value here is captured once, at Begin(int, PreviewGestureKind, PreviewHandle, HudOffset, float, float, Vector2, Vector2, Vector2, Vector2, Vector2, Vector2), and never updated mid-gesture. The pure placement solvers compute the whole gesture from this fixed starting point every frame, so nothing here ever needs to track a running total — that is what keeps a long drag from drifting off from float error.
Constructors
PreviewGestureController()
Declaration
public PreviewGestureController()
Properties
ElementIndex
Index of the element being transformed.
Declaration
public int ElementIndex { get; }
Property Value
| Type | Description |
|---|---|
| int |
FixedPointLocal
The point that must not move, in the element's own local reference units.
Declaration
public Vector2 FixedPointLocal { get; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
Handle
The handle that started the gesture.
Declaration
public PreviewHandle Handle { get; }
Property Value
| Type | Description |
|---|---|
| PreviewHandle |
IsGesturing
Whether a gesture is currently in progress.
Declaration
public bool IsGesturing { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Kind
What the current gesture is doing.
Declaration
public PreviewGestureKind Kind { get; }
Property Value
| Type | Description |
|---|---|
| PreviewGestureKind |
PointerStart
Where the pointer was, in frame space, when the gesture began.
Declaration
public Vector2 PointerStart { get; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
PointerVectorOrigin
Frame-space projection of FixedPointLocal, captured once at gesture start.
Declaration
public Vector2 PointerVectorOrigin { get; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
StartAxisX
The element's local +X axis, in frame-space screen pixels, frozen at gesture start.
Declaration
public Vector2 StartAxisX { get; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
Remarks
Frozen rather than re-read every frame: a live edge lags behind the 30Hz render throttle, and a deform gesture's axes must stay put for its whole duration the same way FixedPointLocal already does.
StartAxisY
The element's local +Y axis, in frame-space screen pixels, frozen at gesture start.
Declaration
public Vector2 StartAxisY { get; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
StartOffset
The element's authored (pre-mirror) offset when the gesture began.
Declaration
public HudOffset StartOffset { get; }
Property Value
| Type | Description |
|---|---|
| HudOffset |
StartRotationDegrees
The element's authored (pre-mirror) rotation when the gesture began, in degrees.
Declaration
public float StartRotationDegrees { get; }
Property Value
| Type | Description |
|---|---|
| float |
StartScale
The element's scale when the gesture began.
Declaration
public float StartScale { get; }
Property Value
| Type | Description |
|---|---|
| float |
StartStretch
The element's stretch when the gesture began.
Declaration
public Vector2 StartStretch { get; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
UndoGroupIndex
The Undo group captured at Begin(int, PreviewGestureKind, PreviewHandle, HudOffset, float, float, Vector2, Vector2, Vector2, Vector2, Vector2, Vector2). A cancelled gesture reverts to this group via UnityEditor.Undo.RevertAllDownToGroup(System.Int32) instead of writing a manual restore — on a persistent asset and on the wizard's non-persistent scratch alike, since a UnityEditor.SerializedObject apply records Undo either way.
Declaration
public int UndoGroupIndex { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
Begin(int, PreviewGestureKind, PreviewHandle, HudOffset, float, float, Vector2, Vector2, Vector2, Vector2, Vector2, Vector2)
Starts tracking a gesture.
Declaration
public void Begin(int elementIndex, PreviewGestureKind kind, PreviewHandle handle, HudOffset startOffset, float startScale, float startRotationDegrees, Vector2 startStretch, Vector2 pointerStart, Vector2 fixedPointLocal, Vector2 pointerVectorOrigin, Vector2 startAxisX, Vector2 startAxisY)
Parameters
| Type | Name | Description |
|---|---|---|
| int | elementIndex | Index of the element being transformed. |
| PreviewGestureKind | kind | What the gesture will do. |
| PreviewHandle | handle | The handle that started it. |
| HudOffset | startOffset | The element's authored offset right now. |
| float | startScale | The element's scale right now. |
| float | startRotationDegrees | The element's authored rotation right now, in degrees. |
| Vector2 | startStretch | The element's stretch right now. |
| Vector2 | pointerStart | Where the pointer is, in frame space. |
| Vector2 | fixedPointLocal | The point that must not move, in local reference units. |
| Vector2 | pointerVectorOrigin | Frame-space projection of |
| Vector2 | startAxisX | The element's local +X axis, in frame-space screen pixels, right now. |
| Vector2 | startAxisY | The element's local +Y axis, in frame-space screen pixels, right now. |
Cancel()
Drops the gesture without collapsing Undo — the caller is responsible for restoring the element.
Declaration
public void Cancel()
End(string)
Ends the gesture, collapsing every per-frame write it made into one Undo step.
Declaration
public void End(string undoLabel)
Parameters
| Type | Name | Description |
|---|---|---|
| string | undoLabel | The label the collapsed Undo step should carry. |