Skip to main content

Module timeline

Module timeline 

Source
Expand description

Timeline: the Timeline widget, a ruler of time with a playhead, a range, markers and the transport keys, over a TimeScale (seconds, frames and timecode, bars and beats).

Experimental: may change in any release (docs/stability.md).
use egui_pop_views::timeline::{Marker, TimeScale, Timeline, TimelineState};

fn ui(ui: &mut egui::Ui, song: &mut TimelineState, dt: f64) {
    // The application moves the time; the widget asks for it.
    song.advance(dt);
    let out = Timeline::new(song).id("song").show(ui);
    if out.response.has_focus() && song.is_playing() {
        ui.ctx().request_repaint();
    }
}

let mut song = TimelineState::new(TimeScale::beats(128.0), 240.0);
song.add_marker(Marker::new(0, 30.0, "Drop"));
  • Time is an f64 in seconds everywhere; a TimeScale only reads and writes it in its units, spaces the ruler and gives the grid.
  • State: the application keeps a TimelineState (serializable): the view, the playhead, the range and its loop, the markers, and the play state and speed the user asked for. Playing is the application’s job: it moves the playhead (TimelineState::advance does it the usual way) and repaints while it plays.
  • Pointer: a press on the ruler or the lanes moves the playhead and a drag scrubs; Shift+drag selects a range; Ctrl+drag or the middle button pans; the wheel pans, Ctrl+wheel and a pinch zoom around the pointer. A marker is clicked to select it, dragged to move it; a double click on the markers’ lane adds one. Snapping goes to the grid (the ruler’s small ticks), the markers, the playhead and the range’s ends; Alt turns it off while held (Snap chooses the targets).
  • Keys, while it has the focus (a Tab stop): Space plays or pauses; J, K, L shuttle (J or L again doubles the speed, K pauses, K held with J or L steps one unit); Left and Right step one unit, Shift for a bigger one (TimeScale::step); Home and End; I and O set the range’s in and out points, Shift+I and Shift+O go to them, Alt+X clears the range, Ctrl+L loops it; M adds a marker at the playhead; Up and Down select the previous and next marker; Ctrl+Left and Ctrl+Right move the selected one; Delete removes it, Escape lets it go; + and - zoom. A key an application binds on the timeline’s surface (SURFACE) runs its command instead.
  • Tracks and clips: TimelineState::tracks are rows under the ruler holding Clips (a start, a length, an offset into a source), never overlapping on a track. A ClipPainter the application gives (Timeline::clips) draws their content; a click selects a clip, a drag moves the selection along a track or across tracks, a clip’s edges trim it. Page Up and Page Down walk a track’s clips, Shift+Up and Shift+Down reach the next track’s, Ctrl+arrows move the selection, [ and ] trim it to the playhead, Ctrl+K splits clips at the playhead, Shift+Delete removes the selection and closes its gaps.
  • History: with Timeline::history, each change of the document (adding, moving, removing a marker, setting or clearing the range, looping, adding, moving, trimming, removing clips) is one step of egui-pop’s history, undone with Ctrl+Z; the playhead, the view, playing and selecting are not. Without it, the output lists the changes (TimelineOutput::edits) for the application’s own.
  • Accessibility: the timeline is a slider whose value is the playhead’s text; Up and Down reach the markers, each named.
  • Agents: a timeline given an id is listed by the timeline collector and driven by the timeline.* commands (TimelinePlugin).
  • Look: the theme’s tokens only, timeline.* with fallbacks (TimelineTokens).

Re-exports§

pub use ruler::Snapped;
pub use ruler::Ticks;

Modules§

ruler
The ruler’s arithmetic, without egui: which steps its ticks and labels take at a zoom, where they go, and what snapping lands on.

Structs§

Clip
A piece of a source placed on a track: from start, length long, the source read from offset (all in seconds). A video’s shot, a sample, a span of recorded data.
ClipMove
A clip to move: to track, starting at start.
ClipPaint
What a ClipPainter draws a clip with: the clip, its track, where it is on screen, and the mapping of time.
ClipPlace
Where a clip is: its track and its start.
ClipSpan
What a trim changes: a clip’s start, length and offset.
FrameRate
A frame rate, num / den frames per second: 25 / 1, 30000 / 1001 (29.97).
Lanes
The lanes under the ruler, for what an application draws there (rows of data, clips): where a time is across them.
Marker
A named point in time.
PlainClips
The plain painter: each clip’s label, nothing else.
Snap
What a timeline snaps to; Alt held snaps to nothing.
Tempo
A tempo and a time signature, for a timeline counted in bars and beats.
TimeRange
A span of time, start before end (seconds).
TimeView
The part of time in view: from start, duration long (seconds).
Timeline
A timeline drawn over a TimelineState the application keeps.
TimelineDoc
The document’s part of a timeline: what its history keeps, one step per change (the markers, the range, the loop, the tracks and their clips).
TimelineOutput
What a timeline did this pass.
TimelinePlugin
Declares the timeline.* commands and the timeline collector. Connect it when an application’s timelines should be read and driven by agents; the widgets work without it.
TimelineState
Everything a timeline shows: its scale, view, playhead, range, markers, tracks and clips, and the play state and speed it asks for. The application keeps it, draws it with Timeline and moves the playhead while it plays (advance).
TimelineTokens
A timeline’s colours and sizes, from the theme installed.
Timelines
The timelines drawn in a context, by id: what the timeline.* commands and the timeline collector reach.
Track
A row of clips under the ruler.
Transport
A row of transport buttons over a timeline’s state, the playhead’s text beside them.
TransportOutput
What a transport did this pass.

Enums§

ClipEdge
Which end of a clip a trim moves.
ClipError
Why a change of the clips was refused.
Edit
A change of a timeline’s document, as its output reports it.
Follow
How the view follows the playhead (Timeline::follow_mode).
MarkerKind
A marker, or a cue point (a DJ’s hot cue, drawn as a pin).
PlayState
Whether the timeline asks to play.
TimeScale
How a timeline counts time: its ruler, its text, its steps and its grid.
TransportButton
A transport button.

Constants§

CMD_ADD_CLIP
CMD_ADD_MARKER
CMD_GO_TO_END
CMD_GO_TO_START
CMD_MOVE_CLIP
CMD_PAUSE
CMD_PLAY
CMD_REMOVE_CLIP
CMD_REMOVE_MARKER
CMD_RIPPLE_DELETE
CMD_SELECT_CLIPS
CMD_SET_RANGE
CMD_SET_TIME
CMD_SHUTTLE_BACKWARD
CMD_SHUTTLE_FORWARD
CMD_SPLIT_CLIP
CMD_STEP_BACKWARD
CMD_STEP_FORWARD
CMD_TOGGLE_LOOP
CMD_TOGGLE_PLAY
CMD_TRIM_CLIP
MAX_SPEED
The fastest J or L shuttles, in either direction.
NUDGE_GAIN
How much of a drag’s own speed a nudge adds to playing (Timeline::nudge_on_drag).
PLUGIN
The plugin’s id.
SNAP_REACH
How near, in points, a time is pulled to a marker, the playhead or a range’s end.
SURFACE
The surface a timeline opens, for key bindings (timelineFocus).

Traits§

ClipPainter
How an application draws its clips’ content: a video’s thumbnails, an audio waveform, a data plot. The timeline draws a clip’s box, its selection and its trimming handles; the painter what is inside, clipped to the clip.

Functions§

describe
A timeline as agents read it.