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
f64in seconds everywhere; aTimeScaleonly 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::advancedoes 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 (
Snapchooses 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::tracksare rows under the ruler holdingClips (a start, a length, an offset into a source), never overlapping on a track. AClipPainterthe 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
idis listed by thetimelinecollector and driven by thetimeline.*commands (TimelinePlugin). - Look: the theme’s tokens only,
timeline.*with fallbacks (TimelineTokens).
Re-exports§
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,lengthlong, the source read fromoffset(all in seconds). A video’s shot, a sample, a span of recorded data. - Clip
Move - A clip to move: to
track, starting atstart. - Clip
Paint - What a
ClipPainterdraws a clip with: the clip, its track, where it is on screen, and the mapping of time. - Clip
Place - Where a clip is: its track and its start.
- Clip
Span - What a trim changes: a clip’s start, length and offset.
- Frame
Rate - A frame rate,
num / denframes 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.
- Plain
Clips - 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.
- Time
Range - A span of time,
startbeforeend(seconds). - Time
View - The part of time in view: from
start,durationlong (seconds). - Timeline
- A timeline drawn over a
TimelineStatethe application keeps. - Timeline
Doc - 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).
- Timeline
Output - What a timeline did this pass.
- Timeline
Plugin - Declares the
timeline.*commands and thetimelinecollector. Connect it when an application’s timelines should be read and driven by agents; the widgets work without it. - Timeline
State - 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
Timelineand moves the playhead while it plays (advance). - Timeline
Tokens - A timeline’s colours and sizes, from the theme installed.
- Timelines
- The timelines drawn in a context, by id: what the
timeline.*commands and thetimelinecollector 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.
- Transport
Output - What a transport did this pass.
Enums§
- Clip
Edge - Which end of a clip a trim moves.
- Clip
Error - 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). - Marker
Kind - A marker, or a cue point (a DJ’s hot cue, drawn as a pin).
- Play
State - Whether the timeline asks to play.
- Time
Scale - How a timeline counts time: its ruler, its text, its steps and its grid.
- Transport
Button - 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§
- Clip
Painter - 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.