public sealed class CurveEditorEditing a value over time: keys, tangent handles, and a pannable graph.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
Entirely drawn. A curve is a polyline, a key is a five-pixel diamond and a handle is a line with a dot on the end — none of them is a box, and as elements they would be a style node and a layout box each for something whose position is a matrix multiply. This is the case OnDraw exists for, and the theme still owns every colour through custom properties.
⚠ The curve is sampled per pixel column, not per key. A cubic drawn as one segment per key is faceted wherever the keys are far apart, and one sampled finely everywhere is work that scales with the curve rather than with the window. A column is the finest thing anybody can see.
⚠ Handles are drawn at a fixed pixel length rather than at a third of the interval. The slope is what is being edited, and a handle whose length depended on the neighbouring key's time would change length when a key nowhere near it moved — which makes it look like the tangent changed when it did not.
Fields and properties (14)
protected override string TagNameThe element name this type answers to when a caller does not choose one.
protected override bool AcceptsFocusWhether the focus can rest on this kind of control at all.
public AnimationCurve CurveThe curve being edited.
public Rectangle ViewWhat the graph is showing: time across, value up.
public IReadOnlyCollection<CurveKey> SelectionWhich keys are selected.
public CurveKey? ActiveThe key whose handles are shown, if any.
public bool SnapToGridpublic float TimeSteppublic float ValueSteppublic float HandleLengthpublic static readonly UiPropertyKey SnapToGridPropertyIdentity for SnapToGrid.
public static readonly UiPropertyKey TimeStepPropertyIdentity for TimeStep.
public static readonly UiPropertyKey ValueStepPropertyIdentity for ValueStep.
public static readonly UiPropertyKey HandleLengthPropertyIdentity for HandleLength.
Events (2)
public Action<CurveEditor>? CurveChangedRaised after a key is added, moved or removed.
public Action<CurveEditor>? SelectionChangedRaised when the selection changes.
Methods (13)
protected override void OnCreated()Builds whatever this element is made of, once, as it joins a document.
public Vector2 ToScreen(float time, float value)Where a point of the graph is, in document space.
public Vector2 ToCurve(float x, float y)Where a document-space point is on the graph.
public void Frame()Pans and zooms until every key fits, with a little room round it.
public void Apply(AnimationCurve preset)Replaces the curve with a preset, keeping the object the caller is holding.
public void SetTangentMode(TangentMode mode)Sets the tangent mode of every selected key.
public CurveKey? KeyAt(float x, float y, float radius = 9)The key nearest a document-space point, if one is within reach.
protected override void OnDraw(DrawContext context)Draws whatever this element is, beyond what a stylesheet can describe.
public Vector2 HandlePoint(CurveKey key, bool outgoing)Where a key's handle dot is, in document space.
public void ClearSnapToGrid()Unsets SnapToGrid, so it takes its default or its ancestor's value again.
public void ClearTimeStep()Unsets TimeStep, so it takes its default or its ancestor's value again.
public void ClearValueStep()Unsets ValueStep, so it takes its default or its ancestor's value again.
public void ClearHandleLength()Unsets HandleLength, so it takes its default or its ancestor's value again.
Used by (3)
- CurveEditorTestsVixen.Ui.Controls.Advanced.Tests
- AnimationClipViewVixen.Editor.AssetEditors
- CurveDrawerVixen.Editor.Inspector