pub struct Timeline { /* private fields */ }Expand description
Things along time, on named tracks, under a ruler with markers and a playhead.
It holds nothing: the app gives it what is there and where the playhead is, and gets back what people do. Blocks are buttons, so they work with the keyboard. Dragging the ruler moves the playhead, dragging a movable block moves it, and the ends of a trimmable one change its length.
use ravenrs_widgets::{Timeline, TimelineItem, TimelineTrack, Tone};
let timeline = Timeline::new(vec![
TimelineTrack::new("Notes", 34.0, vec![TimelineItem::new(1, 2_000, 3_000, "Callout").movable()]),
TimelineTrack::new("Film", 56.0, vec![TimelineItem::new(2, 0, 10_000, "Take 1").tone(Tone::Accent)]),
])
.position_ms(4_000)
.on_seek(|ms| println!("{ms}"));Implementations§
Source§impl Timeline
impl Timeline
Sourcepub fn new(tracks: Vec<TimelineTrack>) -> Timeline
pub fn new(tracks: Vec<TimelineTrack>) -> Timeline
A timeline of these tracks, top to bottom.
Sourcepub fn markers(self, markers: Vec<TimelineMarker>) -> Timeline
pub fn markers(self, markers: Vec<TimelineMarker>) -> Timeline
The named moments on its ruler.
Sourcepub fn position_ms(self, ms: u64) -> Timeline
pub fn position_ms(self, ms: u64) -> Timeline
Where the playhead is.
Sourcepub fn pixels_per_second(self, pixels: f32) -> Timeline
pub fn pixels_per_second(self, pixels: f32) -> Timeline
How wide a second is, in logical pixels (28 by default).
Sourcepub fn heads_width(self, width: f32) -> Timeline
pub fn heads_width(self, width: f32) -> Timeline
The width of the column of track names (112 by default).
Sourcepub fn on_seek(self, handler: impl Fn(u64) + 'static) -> Timeline
pub fn on_seek(self, handler: impl Fn(u64) + 'static) -> Timeline
Runs when someone moves the playhead.
Sourcepub fn on_select(self, handler: impl Fn(u64) + 'static) -> Timeline
pub fn on_select(self, handler: impl Fn(u64) + 'static) -> Timeline
Runs when someone selects a block.
Sourcepub fn on_edit(self, handler: impl Fn(TimelineEdit) + 'static) -> Timeline
pub fn on_edit(self, handler: impl Fn(TimelineEdit) + 'static) -> Timeline
Runs when someone moves or trims a block.
Sourcepub fn total_height(&self) -> f32
pub fn total_height(&self) -> f32
The whole height: the ruler and every track.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Timeline
impl !Send for Timeline
impl !Sync for Timeline
impl !UnwindSafe for Timeline
impl Freeze for Timeline
impl Unpin for Timeline
impl UnsafeUnpin for Timeline
Blanket Implementations§
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
fn to_sample_(self) -> U
Source§impl<V> ViewExt for Vwhere
V: View,
impl<V> ViewExt for Vwhere
V: View,
Source§fn padding(self, padding: impl Into<Insets>) -> Styled<Self>
fn padding(self, padding: impl Into<Insets>) -> Styled<Self>
Adds padding inside the box, in logical pixels.
Source§fn background(self, fill: impl Into<Fill>) -> Styled<Self>
fn background(self, fill: impl Into<Fill>) -> Styled<Self>
Paints a background behind the content.
Source§fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
Fixes the width and/or height in logical pixels;
None keeps the content size.