diff --git a/MCP.md b/MCP.md index b8c7266..db84a85 100644 --- a/MCP.md +++ b/MCP.md @@ -159,7 +159,7 @@ in the GUI. Ops take `scope: "group" | "clip"` where it matters. | `lift`, `fade`, `dissolve`, `transition`, `crossfade`, `gain`, `color`, `transform`, `fit`, `eq`, `sub_trim`, `sub_delete`, `cue_text` | clip | act on the one clip named | | `split` | all lanes (or `lanes`) | a cut, not a ripple: nothing moves. `lanes` limits which lanes are cut; a linked partner follows its clip | | `regroup` | all lanes | `regroup {at}` rejoins the clips that meet at `at` and groups them again: the inverse of `split`, metadata only | -| `copy_paste` | the copied clips | `copy_paste {clips:[addr…], at, lane?}`: one clip pastes as the GUI paste does (splits and ripples the room open); several, or any with `lane`, land as one set and are refused whole if they would overlap. Each copy gets a new link, so group the halves of a copied take after | +| `copy_paste` | the copied clips | `copy_paste {clips:[addr…], at, lane?}`: one clip pastes as the GUI paste does (splits and ripples the room open); several, or any with `lane`, land as one set and are refused whole if they would overlap. Copies that were one take (a picture and its sound) come back as one new take; a copy whose partner was not copied comes back unlinked. A `lane` override keeps a take only where its members land on different lanes | | `close_gap` | the gap's take | `close_gap {lane, at}` closes the one gap on `lane` that `at` stands in (the GUI's Close gap); a linked take's other lane closes with it. Captions use `close_gaps` | | `solo` | — | `solo {lane, on}` for an audio lane: monitoring only, not project state, not saved, never exported, no undo step | | `close_gaps` | one lane | closes the gaps on that lane only | diff --git a/crates/engine/src/project.rs b/crates/engine/src/project.rs index 684480a..4421cd4 100644 --- a/crates/engine/src/project.rs +++ b/crates/engine/src/project.rs @@ -9809,6 +9809,11 @@ impl Project { /// clipboard to bed unchanged, rather than collapsing onto `V1`/`A1` the /// way a lone clip's copy does. /// + /// The links come back among the copies: clips that shared a link id in + /// the set share one fresh id between them, distinct from every link in + /// the project, so a picture and its sound pasted together stay linked. A + /// clip whose link partner was not in the set comes back unlinked. + /// /// All-or-nothing, and **refused** rather than opening room or splitting /// a neighbour the way [`paste`](Project::paste) does for one clip: /// a set-paste never ripples the bed, so a landing that overlaps so much @@ -9855,9 +9860,38 @@ impl Project { } landings.push((li, Clip { start, ..clip })); } + // The links the copies carry among themselves. A clipboard link names + // the take it was copied from: members that were copied together and + // land on distinct lanes get one fresh id between them, so the take + // stays a take. A member whose partner was not copied, or two members + // forced onto one lane (a `lane` override), gets none, because a link + // may never name two clips of one lane. + let members: Vec<(usize, u32)> = landings + .iter() + .filter_map(|(li, c)| c.link.map(|id| (*li, id))) + .collect(); + let keeps = |old: u32| { + let lanes: Vec = members + .iter() + .filter(|m| m.1 == old) + .map(|m| m.0) + .collect(); + lanes.len() >= 2 && lanes.iter().enumerate().all(|(i, l)| !lanes[..i].contains(l)) + }; self.snapshot(); + let mut fresh: Vec<(u32, u32)> = Vec::new(); for (li, mut clip) in landings { - clip.link = Some(self.new_link()); + clip.link = match clip.link { + Some(old) if keeps(old) => match fresh.iter().find(|(o, _)| *o == old) { + Some(&(_, id)) => Some(id), + None => { + let id = self.new_link(); + fresh.push((old, id)); + Some(id) + } + }, + _ => None, + }; clip.fade_in = 0; clip.fade_out = 0; clip.transition_out = 0; @@ -15002,6 +15036,21 @@ mod tests { assert_eq!(p.map_timeline(8), Some((4, 6))); } + /// A set pasted from a take keeps the take: the picture and the sound copied + /// together come back on one fresh link, and not the one they came from. + #[test] + fn paste_set_relinks_the_copied_take() { + let mut p = Project::single(FILE, 40); + let video = p.lane(Lane::V1)[0].clone(); + let sound = p.lane(Lane::A1)[0].clone(); + assert_eq!(video.link, sound.link, "the take starts linked"); + assert!(p.paste_set(50, &[(Lane::V1, video.clone()), (Lane::A1, sound.clone())])); + let (v, a) = (p.lane(Lane::V1)[1].link, p.lane(Lane::A1)[1].link); + assert!(v.is_some() && v == a, "the pasted pair is one take again"); + assert_ne!(v, video.link, "on a link of its own, not the source's"); + assert!(links_are_consistent(&p.lanes).is_ok()); + } + #[test] fn paste_at_boundary_zero_and_end() { let mut p = three(); diff --git a/crates/mcp/src/tools/edit.rs b/crates/mcp/src/tools/edit.rs index 61fda90..31b5e1b 100644 --- a/crates/mcp/src/tools/edit.rs +++ b/crates/mcp/src/tools/edit.rs @@ -98,7 +98,7 @@ TIME speed {clip, x, ripple?, lanes?} — rate 0.25..4. [group] Its length changes, so a neighbour in its way refuses; ripple:true moves the later items in the RIPPLE RULE scope (titles too) by the length change: slower pushes them later, faster closes the gap. A clip on another lane that spans the change is never cut: outside the scope it is left in place and the reply names it; a scope lane (named in lanes) that holds one refuses, naming it. One undo step. speed_ramp {clip, keys:[{at, speed}...], ripple?, lanes?} [group] — a speed that changes over the clip: each key sets a speed 0.25–4 at a clip-relative time `at` ("0s", "2s", "end" or frames), linear between keys and held before the first and after the last. Keys must be in increasing `at`, at most 8, and keys:[] clears the ramp back to the clip's constant speed. The clip's length follows the ramp, and ripple:true moves the later items as speed does. preset:"speed_up"|"slow_down"|"fast_middle"|"slow_middle" lays one of the speed card's shapes across the clip's length instead of keys (speed_up: 1x to 2x; slow_down: 2x to 1x; fast_middle: slow–fast–slow; slow_middle: fast–slow–fast); not with keys. regroup {at} — rejoins the clips that meet at `at` in every lane and puts them back in one group: the inverse of split (metadata only, one undo step; refused when no cut sits there). -copy_paste {clips:[addr,...], at, lane?} — pastes copies of the named clips at `at`, with their effects, keys and volume, keeping their spacing. One clip splits and ripples the room open as the GUI's paste does; several (or any with `lane`) land as one set on their own lanes, refused whole when a landing would overlap. `lane` puts every copy on that lane (the same kind, V or A, as each copy). Each copy gets a new link, as the GUI's paste gives it: the halves of a copied take come back unlinked to each other, so group them after with group {clips}. +copy_paste {clips:[addr,...], at, lane?} — pastes copies of the named clips at `at`, with their effects, keys and volume, keeping their spacing. One clip splits and ripples the room open as the GUI's paste does; several (or any with `lane`) land as one set on their own lanes, refused whole when a landing would overlap. `lane` puts every copy on that lane (the same kind, V or A, as each copy). Links come back among the copies: copied clips that were one take (a picture and its sound, say) land as one new take, while a clip whose partner was not copied comes back unlinked. A set with a `lane` override keeps a take only where its members land on different lanes. close_gap {lane, at} — closes the one gap on `lane` that `at` stands in (the GUI's Close gap): a gap that borders a linked take closes with the take's other lane too; nothing else moves. Refused for a clip at `at`, the time past the lane's last clip, and the empty lead-in before its first clip. Captions use close_gaps. solo {lane, on} — solos an audio lane for listening: while any is soloed, the other audio lanes are silent in this session's playback. It is monitoring only: not project state, not saved, never exported, and it leaves no undo step. reverse {clip, on?} — the clip plays backward, picture and sound: on true/false, or omit `on` to toggle. [group] Its length and place do not change, so nothing ripples, and it composes with speed and a speed ramp. Fades stay on the timeline's ends and gain and transform keys keep their time on the timeline. A trim, split or join follows the footage (a reversed clip's start edge trims its source's end). A still refuses. One undo step. clip_info and timeline say "reversed". Limits: a reversed clip decodes at 8 bits (a 10-bit source loses its low 2 bits on a 10-bit export; banding is possible on HDR), hardware decode is off for it, a dissolve's B side plays forward, and waveforms and thumbnails draw forward.