diff --git a/src/oakui/real.rs b/src/oakui/real.rs index 494a41b41..891a0a3e5 100644 --- a/src/oakui/real.rs +++ b/src/oakui/real.rs @@ -2951,17 +2951,41 @@ impl AppEngine for RealEngine { match self.tracks.iter().position(|t| t.kind == footage_kind) { Some(index) => index, None => { - println!( - "[real engine] drop footage: no {:?} track for {:?} media \"{}\"", - footage_kind, track_kind, filename - ); - // SAFETY: `footage_node` is a box from - // `oakengine_project_footage_at`. - unsafe { oakengine_node_free(footage_node) }; - return; + // No track of the media's kind: create one (the NLE + // convention — Premiere auto-creates on drop). + self.add_track(footage_kind, cx); + match self.tracks.iter().position(|t| t.kind == footage_kind) { + Some(index) => index, + None => { + println!( + "[real engine] drop footage: could not add a {:?} track for \"{}\"", + footage_kind, filename + ); + // SAFETY: `footage_node` is a box from + // `oakengine_project_footage_at`. + unsafe { oakengine_node_free(footage_node) }; + return; + } + } } } } + } else if self.tracks.is_empty() { + // An empty timeline (a fresh sequence has no tracks yet): create + // the media's track and drop onto it. + self.add_track(footage_kind, cx); + match self.tracks.iter().position(|t| t.kind == footage_kind) { + Some(index) => index, + None => { + println!( + "[real engine] drop footage: could not add a {:?} track", + footage_kind + ); + // SAFETY: `footage_node` is a box from `oakengine_project_footage_at`. + unsafe { oakengine_node_free(footage_node) }; + return; + } + } } else { println!("[real engine] drop footage: display track {track_index} does not exist"); // SAFETY: `footage_node` is a box from `oakengine_project_footage_at`. diff --git a/src/panels/timeline.rs b/src/panels/timeline.rs index 36da0237f..2398d90ca 100644 --- a/src/panels/timeline.rs +++ b/src/panels/timeline.rs @@ -424,6 +424,9 @@ impl Render for TimelinePanel { }, )) .on_drop(cx.listener(|this, drag: &FootageDrag, _window, cx| { + if std::env::var("OAK_DEBUG_DRAG").is_ok() { + eprintln!("[drag] timeline drop: {drag:?}"); + } this.finish_footage_drop(drag, cx); })) .child(self.timeline.clone()),