Skip to main content

Module timeline

Module timeline 

Source
Available on crate feature timeline only.
Expand description

A timeline across a sequence of steps, such as the actions of a recorded session or the frames of a run: a tick per step coloured by its tone, a playhead on the current step, and optional lanes below the track that show spans over ranges of steps, such as tasks that ran across several.

The app owns the current step. Pressing or dragging along the track, or a shortcut from default_keymap, picks another one, and Timeline::on_hover reports the step under the pointer so the app can preview it. Shortcuts act only while the timeline has keyboard focus (Tab reaches it) or was the last thing pressed, so several on one screen never fight over keys.

Steps sit evenly by default. Give each one a time with Timeline::times to place them by when they happened, add a labelled ruler, and shorten long idle stretches with Timeline::compress_gaps.

Under the icedwright feature it reports itself as a slider named by its label. The value is always the current step’s index, from 0 to one less than the number of steps, however the steps are placed, with a step of 1. The slider runs from the first tick to the last. icedwright 0.0.7 and later reach a value with the arrow keys, one step per press, so it lands on the right step even when steps are placed by time; a test can also press a tick at its place in Timing::positions.

Re-exports§

pub use crate::theme::Tone;

Structs§

Break
A stretch of the track where an idle gap is drawn shorter than it lasted, from start to end along the track (0 to 1), and how much time it leaves out.
Lane
A labelled row of spans below the track.
Mark
A ruler mark: a time and where it falls along the track (0 to 1).
Span
A run of steps in a lane, from start to end inclusive.
Style
Colours of a timeline in one status.
Timeline
A timeline builder. Convert it into an Element to render.
Timing
Where timed steps sit along a track, from 0 at its start to 1 at its end.

Enums§

Action
What a timeline shortcut does.
Status
How the pointer is interacting with a timeline.

Constants§

LABEL_WIDTH
Width of the lane labels when the timeline has lanes.
LANE_HEIGHT
Height of one lane row.
MARK_SPACING
The least room, in pixels, each ruler label is given along the track.
PAGE
Steps that a page action moves.
PLAYHEAD_RADIUS
Radius of the playhead.
RULER_HEIGHT
Height of the time ruler below the track and lanes.
TRACK_HEIGHT
Height of the track row.

Functions§

default_keymap
The default timeline shortcuts:
height
The height of a timeline with lanes lanes.
index_at
The step under x, for a track width wide holding count steps placed evenly from its left edge to its right edge.
lane
Creates a lane named label holding spans.
position_of
Where step index sits along a track width wide.
span_extent
The left and right edges of a span along a track width wide: half a step either side of its first and last steps, kept on the track.
style
Resolves the colours of a timeline for a status.
time_label
The default ruler label for time, with marks interval apart on a track that ends at end: milliseconds under a second, seconds under a minute, and minutes and seconds (or hours, minutes and seconds) beyond.
timeline
Creates a timeline over steps, one tone per step, with current selected. The current step is clamped to the steps.
track_bounds
The part of bounds a step maps onto: right of the labels, and inset by the playhead radius so the playhead never leaves the widget.