FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust
Merge origin/main into #1240 (the marquee release keeps Alt's linked:false in main's restructured drag end)
Brandon Thomas676ce6e8ff7d
diff --cc crates/ui-egui/src/panels/timeline.rsindex 65fe15166,88ee963fd..9c9711b97--- a/crates/ui-egui/src/panels/timeline.rs+++ b/crates/ui-egui/src/panels/timeline.rs@@@ -2481,51 -2564,55 +2567,55 @@@ fn interact(app: &mut FilmcraftApp, ui}// ---- release: commit exactly one command- if resp.drag_stopped()- && let Some(d) = app.tl.drag.take()- {- let r = match d {- Drag::Move { clips, offset, track_delta, new_track, copy, .. } if offset != Tick::ZERO || track_delta != 0 || new_track.is_some() => {- // #1104: dropped past the last track, the clips go onto a new one- let to = |tid| new_track.map_or_else(|| json!(shift_track(seq, tid, track_delta).unwrap_or(tid).0), |_| json!("new"));- let moves: Vec<Value> = clips- .iter()- .filter_map(|c| seq.find_item(*c).map(|(tid, it)| json!({"clip": c.0, "track": to(tid), "time": (it.start + offset).max(Tick::ZERO).0})))- .collect();- // Option held while dropping copies (Premiere: Option-drag duplicates)- Some(app.session.execute("timeline.move", json!({"moves": moves, "insert": mods.command, "linked": false, "copy": copy || mods.alt})))- }- Drag::Trim { clip, edge, mode, delta, .. } if delta != Tick::ZERO => Some(app.session.execute(- "timeline.trim",- json!({"clip": clip.0, "edge": if edge == filmcraft_edit::Edge::In {"in"} else {"out"}, "mode": if mode == filmcraft_edit::TrimMode::Ripple {"ripple"} else {"regular"}, "delta": delta.0}),- )),- Drag::Stretch { clip, edge, delta, .. } if delta != Tick::ZERO => Some(app.session.execute("timeline.rateStretch", json!({"clip": clip.0, "edge": if edge == filmcraft_edit::Edge::In {"in"} else {"out"}, "delta": delta.0}))),- Drag::Remix { clip, delta, .. } if delta != Tick::ZERO => {- let d = seq.find_item(clip).map(|(_, it)| it.duration + delta).unwrap_or(Tick::ZERO);- Some(app.session.execute("clip.remix", json!({"clip": clip.0, "duration": d.0})))- }- Drag::Roll { left, right, delta, .. } if delta != Tick::ZERO => Some(app.session.execute("timeline.roll", json!({"left": left.0, "right": right.0, "delta": delta.0}))),- Drag::Slip { clip, delta } if delta != Tick::ZERO => Some(app.session.execute("timeline.slip", json!({"clip": clip.0, "delta": delta.0}))),- Drag::Slide { clip, delta } if delta != Tick::ZERO => Some(app.session.execute("timeline.slide", json!({"clip": clip.0, "delta": delta.0}))),- Drag::Transition { id, start, duration, .. } => {- let moved = seq.all_tracks().find_map(|tr| tr.transitions.iter().find(|x| x.id == id)).is_some_and(|x| (x.start, x.duration) != (start, duration));- moved.then(|| app.session.execute("sequence.setTransition", json!({"transition": id.0, "start": start.0, "duration": duration.0})))- }- Drag::Marquee { start, before, add, individual } => {- app.session.state.selection = before;- // egui ends a drag on Escape: that cancels the box, as in the Project panel- match resp.interact_pointer_pos() {- Some(end) if !ctx.input(|i| i.key_pressed(egui::Key::Escape)) => {- let ids: Vec<u64> = marquee_clips(seq, layout, Rect::from_two_pos(start, end)).iter().map(|c| c.0).collect();- Some(app.session.execute("timeline.select", json!({"clips": ids, "add": add, "linked": !individual})))+ if resp.drag_stopped() {+ // a drag Escape cancelled (#580) commits nothing+ let cancelled = std::mem::take(&mut app.tl.cancelled);+ if !cancelled && let Some(d) = app.tl.drag.take() {+ let r = match d {+ Drag::Move { clips, offset, track_delta, new_track, copy, .. } if offset != Tick::ZERO || track_delta != 0 || new_track.is_some() => {+ // #1104: dropped past the last track, the clips go onto a new one+ let to = |tid| new_track.map_or_else(|| json!(shift_track(seq, tid, track_delta).unwrap_or(tid).0), |_| json!("new"));+ let moves: Vec<Value> = clips+ .iter()+ .filter_map(|c| seq.find_item(*c).map(|(tid, it)| json!({"clip": c.0, "track": to(tid), "time": (it.start + offset).max(Tick::ZERO).0})))+ .collect();+ // Option held while dropping copies (Premiere: Option-drag duplicates)+ Some(app.session.execute("timeline.move", json!({"moves": moves, "insert": mods.command, "linked": false, "copy": copy || mods.alt})))+ }+ Drag::Trim { clip, edge, mode, delta, .. } if delta != Tick::ZERO => Some(app.session.execute(+ "timeline.trim",+ json!({"clip": clip.0, "edge": if edge == filmcraft_edit::Edge::In {"in"} else {"out"}, "mode": if mode == filmcraft_edit::TrimMode::Ripple {"ripple"} else {"regular"}, "delta": delta.0}),+ )),+ Drag::Stretch { clip, edge, delta, .. } if delta != Tick::ZERO => Some(app.session.execute("timeline.rateStretch", json!({"clip": clip.0, "edge": if edge == filmcraft_edit::Edge::In {"in"} else {"out"}, "delta": delta.0}))),+ Drag::Remix { clip, delta, .. } if delta != Tick::ZERO => {+ let d = seq.find_item(clip).map(|(_, it)| it.duration + delta).unwrap_or(Tick::ZERO);+ Some(app.session.execute("clip.remix", json!({"clip": clip.0, "duration": d.0})))+ }+ Drag::Roll { left, right, delta, .. } if delta != Tick::ZERO => Some(app.session.execute("timeline.roll", json!({"left": left.0, "right": right.0, "delta": delta.0}))),+ Drag::Slip { clip, delta } if delta != Tick::ZERO => Some(app.session.execute("timeline.slip", json!({"clip": clip.0, "delta": delta.0}))),+ Drag::Slide { clip, delta } if delta != Tick::ZERO => Some(app.session.execute("timeline.slide", json!({"clip": clip.0, "delta": delta.0}))),+ Drag::Transition { id, start, duration, .. } => {+ let moved = seq.all_tracks().find_map(|tr| tr.transitions.iter().find(|x| x.id == id)).is_some_and(|x| (x.start, x.duration) != (start, duration));+ moved.then(|| app.session.execute("sequence.setTransition", json!({"transition": id.0, "start": start.0, "duration": duration.0})))+ }- Drag::Marquee { start, before, add } => {++ Drag::Marquee { start, before, add, individual } => {+ app.session.state.selection = before;+ // egui ends a drag on Escape: that cancels the box, as in the Project panel+ match resp.interact_pointer_pos() {+ Some(end) if !ctx.input(|i| i.key_pressed(egui::Key::Escape)) => {+ let ids: Vec<u64> = marquee_clips(seq, layout, Rect::from_two_pos(start, end)).iter().map(|c| c.0).collect();- Some(app.session.execute("timeline.select", json!({"clips": ids, "add": add})))++ Some(app.session.execute("timeline.select", json!({"clips": ids, "add": add, "linked": !individual})))+ }+ _ => None,}- _ => None,}+ _ => None,+ };+ if let Some(Err(e)) = r {+ app.ui.status = e.to_string();}- _ => None,- };- if let Some(Err(e)) = r {- app.ui.status = e.to_string();+ } else {+ app.tl.drag = None;}}diff --cc crates/ui-egui/tests/timeline_marquee_ui.rsindex dc57ca6af,962eefbac..301fd0edc--- a/crates/ui-egui/tests/timeline_marquee_ui.rs+++ b/crates/ui-egui/tests/timeline_marquee_ui.rs@@@ -121,34 -121,6 +121,33 @@@ fn the_selection_follows_the_box_while_assert!(d.selected(b) && !d.selected(a), "the release keeps what the box showed");}-+#[test]+fn alt_box_selects_only_video_and_delete_keeps_linked_audio() {+ let mut d = Driver::demo();+ let (_, video, _, rv, start) = d.setup();+ let audio = {+ let seq = d.harness.state().session.active_sequence().unwrap();+ let link = seq.find_item(ClipId(video)).unwrap().1.link;+ seq.audio_tracks.iter().flat_map(|tr| &tr.items).find(|clip| clip.link == link).unwrap().id.0+ };+ d.exec("timeline.select", json!({"clips": []}));+ d.modifiers = egui::Modifiers::ALT;+ d.send(egui::Event::PointerMoved(start));+ d.button(start, true);+ let over = egui::pos2(rv.center().x, start.y + 2.0);+ d.move_to(start, over);+ assert!(d.selected(video));+ assert!(!d.selected(audio), "Alt excludes the linked audio during the drag");+ d.button(over, false);+ d.modifiers = egui::Modifiers::NONE;+ d.frames(2);+ assert!(d.selected(video) && !d.selected(audio), "release preserves the individual selection");+ d.exec("edit.clear", json!({}));+ let seq = d.harness.state().session.active_sequence().unwrap();+ assert!(seq.find_item(ClipId(video)).is_none());+ assert!(seq.find_item(ClipId(audio)).is_some(), "Delete leaves the unselected linked audio");+}+#[test]fn shift_adds_to_the_selection_the_drag_began_with() {let mut d = Driver::demo();