Vixen
02b45cc4
csharp
public sealed class Timeline

Tracks against time: keys, a playhead, a zoom and a snap.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

Three parts, and only one of them is elements. The headers down the left are controls, because a track name is text and a mute button is a button. Everything to the right of them is drawn, because it is eight thousand diamonds whose positions are two multiplications each. That split is the same one TreeView makes between its rows and its scroll range, one level coarser.

⚠ Time and pixels are related by one number. PixelsPerSecond is the zoom and TimeStart is the pan, and everything — the ruler's tick spacing, a key's x, the playhead, the hit radius — goes through the two. A timeline that kept a separate visible range would have three numbers that could disagree.

⚠ Snapping is to frames, not to a grid. An animation is played back at a frame rate and a key between two frames is a key that plays on one of them anyway — so the snap that matters is FrameRate, and a pixel grid would put keys where no frame is.

⚠ A track holds instants or intervals, never both, and the two are drawn and hit tested differently — see TimelineTrackKind. A span is a bar with its ramps drawn on it rather than a pair of keys, because a pair of keys loses the association between the two the moment either is dragged, and because the shape of a fade is the thing an author is trying to see.

Fields and properties (41)

  • protected override string TagName

    The element name this type answers to when a caller does not choose one.

  • protected override bool AcceptsFocus

    Whether the focus can rest on this kind of control at all.

  • public TimelineRuler Ruler

    The strip of times along the top.

  • public UiElement Headers

    The column of names down the left.

  • public TimelineLanes Lanes

    Everything to the right of the names.

  • public IReadOnlyList<TimelineTrack> Tracks

    The tracks, top to bottom.

  • public IReadOnlyList<TimelineHeader> HeaderRows

    The header elements that exist, including the parked ones.

  • public IReadOnlyCollection<TimelineKey> Selection

    Which keys are selected.

  • public IReadOnlyCollection<TimelineSpan> SpanSelection

    Which spans are selected.

  • public float Time
  • public float Duration
  • public float TimeStart
  • public float PixelsPerSecond
  • public float FrameRate
  • public bool SnapToFrames
  • public float ScrollTop
  • public float TrackHeight

    How tall a track is, from --track-height.

  • public float KeySize
  • public float GripSize
  • public int FirstVisibleTrack

    The first track with any of it on screen.

  • public Rectangle? Marquee

    The rubber band, if one is being dragged.

  • public float TickStep

    How far apart the ruler's ticks are, in seconds.

  • public Color4 GridColor

    The tick and grid colour.

  • public Color4 StripeColor

    The colour of every other lane.

  • public Color4 KeyColor

    A keyframe's colour.

  • public Color4 KeyActiveColor

    A selected keyframe's colour.

  • public Color4 PlayheadColor

    The playhead's colour.

  • public Color4 MarqueeColor

    The rubber band's colour.

  • public Color4 CurveColor

    The colour of the trace behind a track's keys.

  • public Color4 SpanColor

    A span's colour.

  • public Color4 SpanActiveColor

    A selected span's colour.

  • public Color4 SpanGripColor

    The colour of the handles at a span's ends.

  • public static readonly UiPropertyKey TimeProperty

    Identity for Time.

  • public static readonly UiPropertyKey DurationProperty

    Identity for Duration.

  • public static readonly UiPropertyKey TimeStartProperty

    Identity for TimeStart.

  • public static readonly UiPropertyKey PixelsPerSecondProperty

    Identity for PixelsPerSecond.

  • public static readonly UiPropertyKey FrameRateProperty

    Identity for FrameRate.

  • public static readonly UiPropertyKey SnapToFramesProperty

    Identity for SnapToFrames.

  • public static readonly UiPropertyKey ScrollTopProperty

    Identity for ScrollTop.

  • public static readonly UiPropertyKey KeySizeProperty

    Identity for KeySize.

  • public static readonly UiPropertyKey GripSizeProperty

    Identity for GripSize.

Events (6)

  • public Action<Timeline, float>? TimeChanged

    Raised when the playhead moves.

  • public Action<Timeline>? SelectionChanged

    Raised when the selection changes.

  • public Action<Timeline>? KeysMoved

    Raised after a drag has moved some keys.

  • public Action<Timeline, TimelineSpan>? SpanMoved

    Raised after a drag has moved a span's ends.

  • public Action<Timeline, TimelineTrack, TimelineSpan>? SpanRemoved

    Raised after a double-tap has taken a span off its track.

  • public Action<Timeline, TimelineTrack, float>? SpanRequested

    Raised when a double-tap asks for a span on an empty stretch of a span track.

Methods (25)

  • protected override void OnCreated()

    Builds whatever this element is made of, once, as it joins a document.

  • public TimelineTrack AddTrack(string name, TimelineTrackKind kind = Keys)

    Adds a track at the bottom.

  • public bool Remove(TimelineTrack track)

    Removes a track, and takes its keys and spans out of the selection.

  • public void Refresh()

    Brings the headers back into agreement with the tracks.

  • public void ZoomToFit()

    Zooms and pans until the whole duration fits.

  • public float ToScreen(float time)

    Where a time is, in document space.

  • public float ToTime(float x)

    Which time a document-space x is.

  • public int TrackAt(float y)

    Which track a document-space y is over, or -1.

  • public TimelineKey? KeyAt(float x, float y)

    The key nearest a document-space point, if one is within reach.

  • public TimelineSpan? SpanAt(float x, float y, out SpanGrip grip)

    The span under a document-space point, and which part of it.

  • public float Snap(float time)

    Brings a time onto a frame, if snapping is on.

  • public void Select(TimelineKey? key, ModifierKeys modifiers = None)

    Selects a key, or adds it to or removes it from the selection.

  • public void SelectNone()

    Selects nothing at all, keys and spans alike.

  • public void Select(TimelineSpan? span, ModifierKeys modifiers = None)

    Selects a span, or adds it to or removes it from the selection.

  • public void SelectAll()

    Selects every key and every span on every track.

  • public void DeleteSelection()

    Removes every selected key and span.

  • public void ClearTime()

    Unsets Time, so it takes its default or its ancestor's value again.

  • public void ClearDuration()

    Unsets Duration, so it takes its default or its ancestor's value again.

  • public void ClearTimeStart()

    Unsets TimeStart, so it takes its default or its ancestor's value again.

  • public void ClearPixelsPerSecond()

    Unsets PixelsPerSecond, so it takes its default or its ancestor's value again.

  • public void ClearFrameRate()

    Unsets FrameRate, so it takes its default or its ancestor's value again.

  • public void ClearSnapToFrames()

    Unsets SnapToFrames, so it takes its default or its ancestor's value again.

  • public void ClearScrollTop()

    Unsets ScrollTop, so it takes its default or its ancestor's value again.

  • public void ClearKeySize()

    Unsets KeySize, so it takes its default or its ancestor's value again.

  • public void ClearGripSize()

    Unsets GripSize, so it takes its default or its ancestor's value again.

Used by (7)

  • TimelineLanesVixen.Ui.Controls.Advanced
  • TimelineRulerVixen.Ui.Controls.Advanced
  • TimelineSpanTestsVixen.Ui.Controls.Advanced.Tests
  • TimelineTestsVixen.Ui.Controls.Advanced.Tests
  • AnimationClipViewVixen.Editor.AssetEditors
  • MilestoneE5TestsVixen.Editor.App.Tests
  • SequenceViewVixen.Editor.AssetEditors