Skip to main content

Timeline

Struct Timeline 

Source
pub struct Timeline {
Show 15 fields pub tracks: Vec<Track>, pub timebase: Rational, pub frame_rate: Rational, pub duration: i64, pub playhead: i64, pub selection: ClipSelection, pub transitions: TransitionManager, pub markers: MarkerManager, pub regions: RegionManager, pub in_out: InOutPoints, pub groups: GroupManager, pub links: LinkManager, pub next_clip_id: u64, pub clip_map: HashMap<ClipId, (usize, usize)>, pub snap_engine: Option<MagneticSnapEngine>,
}
Expand description

A multi-track timeline.

Fields§

§tracks: Vec<Track>

Timeline tracks.

§timebase: Rational

Timeline timebase (e.g., 1/1000 for milliseconds).

§frame_rate: Rational

Timeline frame rate (for video).

§duration: i64

Timeline duration (in timebase units).

§playhead: i64

Current playhead position.

§selection: ClipSelection

Clip selection.

§transitions: TransitionManager

Transition manager.

§markers: MarkerManager

Marker manager.

§regions: RegionManager

Region manager.

§in_out: InOutPoints

In/Out points.

§groups: GroupManager

Group manager.

§links: LinkManager

Link manager.

§next_clip_id: u64

Next clip ID.

§clip_map: HashMap<ClipId, (usize, usize)>

Clip lookup by ID.

§snap_engine: Option<MagneticSnapEngine>

Optional magnetic snap engine.

Implementations§

Source§

impl Timeline

Source

pub fn new(timebase: Rational, frame_rate: Rational) -> Self

Create a new timeline.

Source

pub fn with_magnetic_snap(self, config: MagneticSnapConfig) -> Self

Enable magnetic snapping with the given configuration.

Source

pub fn default_settings() -> Self

Create a timeline with default settings (1ms timebase, 30fps).

Source

pub fn add_track(&mut self, track_type: TrackType) -> usize

Add a new track.

Source

pub fn remove_track(&mut self, index: usize) -> EditResult<Track>

Remove a track by index.

Source

pub fn get_track(&self, index: usize) -> Option<&Track>

Get a track by index.

Source

pub fn get_track_mut(&mut self, index: usize) -> Option<&mut Track>

Get a mutable track by index.

Source

pub fn add_clip(&mut self, track_index: usize, clip: Clip) -> EditResult<ClipId>

Add a clip to a track.

Returns EditError::TrackTypeMismatch when the clip’s type does not match the track type (e.g., adding an audio clip to a video track).

Source

pub fn remove_clip(&mut self, clip_id: ClipId) -> EditResult<Clip>

Remove a clip by ID.

Link policy: linked clips are preserved on delete; only the link association is removed. The linked clip remains in its track at its current position.

Source

pub fn get_clip(&self, clip_id: ClipId) -> Option<&Clip>

Get a clip by ID.

Source

pub fn get_clip_mut(&mut self, clip_id: ClipId) -> Option<&mut Clip>

Get a mutable clip by ID.

Source

pub fn move_clip( &mut self, clip_id: ClipId, requested_start: i64, ) -> EditResult<()>

Move a clip to a new position on the timeline.

If magnetic snapping is enabled, the requested position is adjusted to the nearest snap target before the move is applied.

All clips linked to clip_id are moved by the same delta (cascade).

The operation is atomic: if any clip in the cascade would overlap an existing clip, the entire batch is rolled back and an error is returned.

Source

pub fn move_clip_to_track( &mut self, clip_id: ClipId, target_track: usize, ) -> EditResult<()>

Move a clip to a different track.

Source

pub fn get_clips_at(&self, position: i64) -> Vec<(usize, &Clip)>

Get all clips at a specific timeline position.

Source

pub fn get_clips_in_range(&self, start: i64, end: i64) -> Vec<(usize, &Clip)>

Get all clips in a time range.

Source

pub fn rebuild_clip_map(&mut self)

Rebuild the clip map from scratch.

Source

pub fn set_playhead(&mut self, position: i64)

Set playhead position.

Source

pub fn move_playhead(&mut self, delta: i64)

Move playhead forward by delta.

Source

pub fn seek_to_start(&mut self)

Seek to start of timeline.

Source

pub fn seek_to_end(&mut self)

Seek to end of timeline.

Source

pub fn duration_seconds(&self) -> f64

Get timeline duration in seconds.

Source

pub fn video_tracks(&self) -> Vec<&Track>

Get video tracks.

Source

pub fn audio_tracks(&self) -> Vec<&Track>

Get audio tracks.

Source

pub fn subtitle_tracks(&self) -> Vec<&Track>

Get subtitle tracks.

Source

pub fn clip_count(&self) -> usize

Get total number of clips.

Source

pub fn clear(&mut self)

Clear all tracks and clips.

Trait Implementations§

Source§

impl Debug for Timeline

Source§

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

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

impl Default for Timeline

Source§

fn default() -> Self

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

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

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.
Source§

impl<T> Upcast<T> for T

Source§

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

Source§

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

Source§

impl<T> WasmNotSendSync for T

Source§

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