Skip to main content

TimelineState

Struct TimelineState 

Source
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

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).

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: bool

Playback 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: f64

Asked speed, negative backwards (J), 1 by default.

Implementations§

Source§

impl TimelineState

Source

pub fn new(scale: TimeScale, length: f64) -> Self

A timeline on scale over 0..length seconds, all of it in view.

Source

pub fn is_playing(&self) -> bool

Source

pub fn doc(&self) -> TimelineDoc

The document’s part.

Source

pub fn set_doc(&mut self, doc: TimelineDoc)

Replaces the document’s part (an undo, a load).

Source

pub fn clamp(&self, time: f64) -> f64

time kept inside the bounds and on the scale (whole frames).

Source

pub fn set_playhead(&mut self, time: f64) -> bool

Moves the playhead (kept inside the bounds): whether it moved.

Source

pub fn play_at(&mut self, speed: f64)

Plays at speed (negative: backwards).

Source

pub fn pause(&mut self)

Pauses, the speed back to 1.

Source

pub fn toggle(&mut self)

Space: plays forward at 1, or pauses.

Source

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.

Source

pub fn step_by(&mut self, by: f64) -> bool

Moves the playhead by by seconds, pausing: whether it moved.

Source

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.

Source

pub fn marker(&self, id: u64) -> Option<&Marker>

Source

pub fn next_id(&self) -> u64

The id the next marker takes.

Source

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.

Source

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.

Source

pub fn remove_marker(&mut self, id: u64) -> Option<Marker>

Source

pub fn neighbour_marker(&self, forward: bool) -> Option<u64>

The marker after the selected one (else after the playhead), or before it (forward false).

Source

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).

Source

pub fn out_at(&self, time: f64) -> TimeRange

The out point at time.

Source

pub fn home(&self) -> f64

Where Home goes: the bounds’ start, else 0.

Source

pub fn end(&self) -> f64

Where End goes: the bounds’ end, else the last marker or the range’s end, whichever is later.

Source

pub fn zoom_limits(&self) -> (f64, f64)

The shortest and longest the view may be.

Source

pub fn fit_view(&self, view: TimeView) -> TimeView

view within the zoom limits and near the bounds.

Source§

impl TimelineState

Source

pub fn track(&self, id: u64) -> Option<&Track>

Source

pub fn track_mut(&mut self, id: u64) -> Option<&mut Track>

Source

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.

Source

pub fn clip(&self, id: u64) -> Option<&Clip>

Source

pub fn clip_track(&self, id: u64) -> Option<&Track>

The track clip id is on.

Source

pub fn clips(&self) -> impl Iterator<Item = (&Track, &Clip)>

Every clip with its track, track by track.

Source

pub fn next_clip_id(&self) -> u64

The id the next clip takes.

Source

pub fn min_clip_length(&self) -> f64

The shortest a clip can be: a frame, else the ruler’s finest step.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn remove_clips(&mut self, ids: &[u64]) -> Vec<(u64, Clip)>

Removes clips: those removed, each with its track’s id.

Source

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.

Source

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

Source§

fn clone(&self) -> TimelineState

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TimelineState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for TimelineState

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for TimelineState

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for TimelineState

Source§

fn eq(&self, other: &TimelineState) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for TimelineState

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for TimelineState

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> NoneValue for T
where T: Default,

§

type NoneType = T

§

fn null_value() -> T

The none-equivalent value.
§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

impl<T> SerializableAny for T
where T: 'static + Any + Clone + for<'a> Send + Sync,

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,