pub struct TimelineState {
pub scale: TimeScale,
pub view: TimeView,
pub bounds: Option<TimeRange>,
pub playhead: f64,
pub range: Option<TimeRange>,
pub looping: bool,
pub markers: Vec<Marker>,
pub selected: Option<u64>,
pub tracks: Vec<Track>,
pub selected_clips: Vec<u64>,
pub play: PlayState,
pub speed: f64,
}Expand description
Fields§
§scale: TimeScale§view: TimeView§bounds: Option<TimeRange>The document’s span: the playhead stays inside, the view near it.
playhead: f64§range: Option<TimeRange>§looping: boolPlayback goes round the range.
markers: Vec<Marker>§selected: Option<u64>The marker the keys act on.
tracks: Vec<Track>Rows of clips under the ruler, from the top.
selected_clips: Vec<u64>The clips selected, the one selected last at the end (the keys act on it).
play: PlayState§speed: f64Asked speed, negative backwards (J), 1 by default.
Implementations§
Source§impl TimelineState
impl TimelineState
Sourcepub fn new(scale: TimeScale, length: f64) -> Self
pub fn new(scale: TimeScale, length: f64) -> Self
A timeline on scale over 0..length seconds, all of it in view.
pub fn is_playing(&self) -> bool
Sourcepub fn doc(&self) -> TimelineDoc
pub fn doc(&self) -> TimelineDoc
The document’s part.
Sourcepub fn set_doc(&mut self, doc: TimelineDoc)
pub fn set_doc(&mut self, doc: TimelineDoc)
Replaces the document’s part (an undo, a load).
Sourcepub fn clamp(&self, time: f64) -> f64
pub fn clamp(&self, time: f64) -> f64
time kept inside the bounds and on the scale (whole frames).
Sourcepub fn set_playhead(&mut self, time: f64) -> bool
pub fn set_playhead(&mut self, time: f64) -> bool
Moves the playhead (kept inside the bounds): whether it moved.
Sourcepub fn shuttle(&mut self, forward: bool)
pub fn shuttle(&mut self, forward: bool)
J (forward false) or L: plays that way at 1, or twice as fast when
it already does, up to MAX_SPEED.
Sourcepub fn step_by(&mut self, by: f64) -> bool
pub fn step_by(&mut self, by: f64) -> bool
Moves the playhead by by seconds, pausing: whether it moved.
Sourcepub fn advance(&mut self, dt: f64) -> bool
pub fn advance(&mut self, dt: f64) -> bool
Moves the playhead as playing does for dt seconds of the clock:
round the range when looping, else stopping at the bounds. Whether
it moved.
pub fn marker(&self, id: u64) -> Option<&Marker>
Sourcepub fn add_marker(&mut self, marker: Marker) -> u64
pub fn add_marker(&mut self, marker: Marker) -> u64
Adds a marker (its id taken if free, else the next one), in time order; returns the id.
Sourcepub fn move_marker(&mut self, id: u64, time: f64) -> Option<f64>
pub fn move_marker(&mut self, id: u64, time: f64) -> Option<f64>
Moves a marker: its old time, None when there is no such marker.
pub fn remove_marker(&mut self, id: u64) -> Option<Marker>
Sourcepub fn neighbour_marker(&self, forward: bool) -> Option<u64>
pub fn neighbour_marker(&self, forward: bool) -> Option<u64>
The marker after the selected one (else after the playhead), or
before it (forward false).
Sourcepub fn in_at(&self, time: f64) -> TimeRange
pub fn in_at(&self, time: f64) -> TimeRange
The in point at time: the range starts there (ends at its end, else
the bounds’ end, else time).
Sourcepub fn end(&self) -> f64
pub fn end(&self) -> f64
Where End goes: the bounds’ end, else the last marker or the range’s end, whichever is later.
Sourcepub fn zoom_limits(&self) -> (f64, f64)
pub fn zoom_limits(&self) -> (f64, f64)
The shortest and longest the view may be.
Source§impl TimelineState
impl TimelineState
pub fn track(&self, id: u64) -> Option<&Track>
pub fn track_mut(&mut self, id: u64) -> Option<&mut Track>
Sourcepub fn add_track(&mut self, track: Track) -> u64
pub fn add_track(&mut self, track: Track) -> u64
Adds a track below the others (its id taken if free, else the next one); returns the id.
pub fn clip(&self, id: u64) -> Option<&Clip>
Sourcepub fn clip_track(&self, id: u64) -> Option<&Track>
pub fn clip_track(&self, id: u64) -> Option<&Track>
The track clip id is on.
Sourcepub fn clips(&self) -> impl Iterator<Item = (&Track, &Clip)>
pub fn clips(&self) -> impl Iterator<Item = (&Track, &Clip)>
Every clip with its track, track by track.
Sourcepub fn next_clip_id(&self) -> u64
pub fn next_clip_id(&self) -> u64
The id the next clip takes.
Sourcepub fn min_clip_length(&self) -> f64
pub fn min_clip_length(&self) -> f64
The shortest a clip can be: a frame, else the ruler’s finest step.
Sourcepub fn add_clip(&mut self, track: u64, clip: Clip) -> Result<u64, ClipError>
pub fn add_clip(&mut self, track: u64, clip: Clip) -> Result<u64, ClipError>
Adds clip to track track (its id taken if free, else the next
one), on the scale’s units: refused where it would overlap a clip or
leave the bounds. Returns the id.
Sourcepub fn move_clips(&mut self, moves: &[ClipMove]) -> Result<Vec<Edit>, ClipError>
pub fn move_clips(&mut self, moves: &[ClipMove]) -> Result<Vec<Edit>, ClipError>
Moves clips at once, each to its track and start (on the scale’s units): refused, nothing moved, where one would overlap a clip or leave the bounds. The edits, one per clip that moved.
Sourcepub fn trim_clip(
&mut self,
id: u64,
edge: ClipEdge,
time: f64,
) -> Result<ClipSpan, ClipError>
pub fn trim_clip( &mut self, id: u64, edge: ClipEdge, time: f64, ) -> Result<ClipSpan, ClipError>
Moves clip id’s edge to time, kept on its source (never before
its start nor past its end), off its neighbours, inside the bounds,
and at least min_clip_length long. Its
span before.
Sourcepub fn split_clip(&mut self, id: u64, time: f64) -> Result<u64, ClipError>
pub fn split_clip(&mut self, id: u64, time: f64) -> Result<u64, ClipError>
Splits clip id at time (on the scale’s units) into two clips
touching there: the clip keeps its id and ends at time, the new
one (the next id) starts there, reading its source on from where
the first stops. Refused unless both parts are at least
min_clip_length long. The new clip’s id.
Sourcepub fn ripple_remove_clips(
&mut self,
ids: &[u64],
) -> (Vec<(u64, Clip)>, Vec<Edit>)
pub fn ripple_remove_clips( &mut self, ids: &[u64], ) -> (Vec<(u64, Clip)>, Vec<Edit>)
Removes clips and closes the gaps they leave: on each track, the clips after a removed one move back by its length. The clips removed (each with its track’s id), and an edit per clip moved.
Sourcepub fn remove_clips(&mut self, ids: &[u64]) -> Vec<(u64, Clip)>
pub fn remove_clips(&mut self, ids: &[u64]) -> Vec<(u64, Clip)>
Removes clips: those removed, each with its track’s id.
Sourcepub fn neighbour_clip(&self, forward: bool) -> Option<u64>
pub fn neighbour_clip(&self, forward: bool) -> Option<u64>
The clip after (forward) or before the one selected last, on its
track; with none selected, the first after the playhead (or the last
before it) on the first track holding clips.
Sourcepub fn clip_across(&self, up: bool) -> Option<u64>
pub fn clip_across(&self, up: bool) -> Option<u64>
The clip under the playhead (else the nearest to it) on the next
track holding clips above (up) or below the selected clip’s track
(with none selected, from the last or the first track).
Trait Implementations§
Source§impl Clone for TimelineState
impl Clone for TimelineState
Source§fn clone(&self) -> TimelineState
fn clone(&self) -> TimelineState
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TimelineState
impl Debug for TimelineState
Source§impl Default for TimelineState
impl Default for TimelineState
Source§impl<'de> Deserialize<'de> for TimelineStatewhere
TimelineState: Default,
impl<'de> Deserialize<'de> for TimelineStatewhere
TimelineState: Default,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for TimelineState
impl PartialEq for TimelineState
Source§impl Serialize for TimelineState
impl Serialize for TimelineState
impl StructuralPartialEq for TimelineState
Auto Trait Implementations§
impl Freeze for TimelineState
impl RefUnwindSafe for TimelineState
impl Send for TimelineState
impl Sync for TimelineState
impl Unpin for TimelineState
impl UnsafeUnpin for TimelineState
impl UnwindSafe for TimelineState
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more