forge
Explore
Log in

Don't you dare go Hollow

Ctrl-click multi-selection, manual groups, ctrl+a

Browse files at this commit

66d5395c3e2281d3ff1b86f69384d287c2264a32Ahmet Kaan GümüşParent: 48cacb6
  • feat
    • ctrl-click multi-selection, manual groups, ctrl+a
Show full message
✨ feat(timeline): ctrl-click multi-selection, manual groups, ctrl+a

The app half of manual clip grouping: the timeline's selection becomes
a list of picks (Selection, click order kept, anchor = last), ctrl+click
toggles a pick on every clip box, caption box and edge strip, and a
right-click on a picked placement keeps the selection so the menu's
Group row acts on all of it — one pick keeps the span-partner flow.

SelectAll takes ctrl+a (every clip and caption, one selection) and
RemoveAudioLane moves to ctrl+q beside its own letter. The oracle
unhides Group and Detach over captions, words the one-clip-per-lane
refusal, and the caption menu grows the group rows. marked() lights
every pick and its link-mates — captions included — captions wear the
grouped border, trims preview each member by the drag's delta clamped
to its own room, deletes route a grouped caption through the group
door, and a drag's snap excludes the group it carries. The save-format
tests and every affected app suite updated with the new shapes.
crates/app/src/interact.rsmodified+7 -2
@@ -96,12 +96,17 @@ pub(crate) struct Trim {
96 pub(crate) lane: Lane,96 pub(crate) lane: Lane,
97 pub(crate) idx: usize,97 pub(crate) idx: usize,
98 pub(crate) edge: Edge,98 pub(crate) edge: Edge,
99+ /// Where the edge stood at the press: with `to`, the delta the whole group
100+ /// follows by -- each member's own edge moves this far, clamped to its own
101+ /// room, which is exactly what the engine commits at the release.
102+ pub(crate) from: u32,
99 /// Already clamped by `PlaybackSession::trim_room`, so the width drawn from103 /// Already clamped by `PlaybackSession::trim_room`, so the width drawn from
100 /// it is the width the release commits -- an edge stops under the pointer104 /// it is the width the release commits -- an edge stops under the pointer
101 /// rather than snapping back after the fact.105 /// rather than snapping back after the fact.
102 pub(crate) to: u32,106 pub(crate) to: u32,
103- /// The dragged clip's group, so its other halves' boxes follow the edge on107+ /// The dragged placement's group, so the boxes of everything it names --
104- /// screen exactly as the engine will move them.108+ /// clips and captions alike -- follow the edge on screen exactly as the
109+ /// engine will move them.
105 pub(crate) link: Option<u32>,110 pub(crate) link: Option<u32>,
106 }111 }
107 112
crates/app/src/keymap.rsmodified+25 -7
@@ -86,6 +86,10 @@ actions! {
86 Select,86 Select,
87 SelectNext,87 SelectNext,
88 SelectPrev,88 SelectPrev,
89+ /// Every placement on every lane in one selection -- the companion of the
90+ /// ctrl-click that builds a selection by hand, for the times everything
91+ /// wants selecting at once.
92+ SelectAll,
89 Delete,93 Delete,
90 Lift,94 Lift,
91 Color,95 Color,
@@ -159,11 +163,12 @@ impl ActionId {
159 // Neither half's action: it takes the *pair* apart, and the menu163 // Neither half's action: it takes the *pair* apart, and the menu
160 // that offers it hangs on whichever half was right-clicked -- worded164 // that offers it hangs on whichever half was right-clicked -- worded
161 // from the picture's side it read as a video item on an audio clip.165 // from the picture's side it read as a video item on an audio clip.
162- ActionId::Detach => "Ungroup the picture and the sound",166+ ActionId::Detach => "Ungroup the selection (clips and captions)",
163- ActionId::Group => "Group with the clip on another track",167+ ActionId::Group => "Group the selection (ctrl-click the clips first)",
164 ActionId::Select => "Select the clip under the playhead (again for the next lane)",168 ActionId::Select => "Select the clip under the playhead (again for the next lane)",
165 ActionId::SelectNext => "Select the next clip in the lane",169 ActionId::SelectNext => "Select the next clip in the lane",
166 ActionId::SelectPrev => "Select the previous clip in the lane",170 ActionId::SelectPrev => "Select the previous clip in the lane",
171+ ActionId::SelectAll => "Select everything (every clip and caption)",
167 ActionId::Delete => "Delete",172 ActionId::Delete => "Delete",
168 ActionId::Lift => "Lift (leave a gap)",173 ActionId::Lift => "Lift (leave a gap)",
169 ActionId::Color => "Colour…",174 ActionId::Color => "Colour…",
@@ -221,6 +226,7 @@ impl ActionId {
221 ActionId::Select => "select",226 ActionId::Select => "select",
222 ActionId::SelectNext => "select-next",227 ActionId::SelectNext => "select-next",
223 ActionId::SelectPrev => "select-prev",228 ActionId::SelectPrev => "select-prev",
229+ ActionId::SelectAll => "select-all",
224 ActionId::Delete => "delete",230 ActionId::Delete => "delete",
225 ActionId::Lift => "lift",231 ActionId::Lift => "lift",
226 ActionId::Color => "color",232 ActionId::Color => "color",
@@ -277,6 +283,7 @@ impl ActionId {
277 | ActionId::Select283 | ActionId::Select
278 | ActionId::SelectNext284 | ActionId::SelectNext
279 | ActionId::SelectPrev285 | ActionId::SelectPrev
286+ | ActionId::SelectAll
280 | ActionId::Delete287 | ActionId::Delete
281 | ActionId::Lift288 | ActionId::Lift
282 | ActionId::Color289 | ActionId::Color
@@ -776,6 +783,11 @@ impl Keymap {
776 b(ActionId::Select, "tab", false),783 b(ActionId::Select, "tab", false),
777 b(ActionId::SelectNext, "]", false),784 b(ActionId::SelectNext, "]", false),
778 b(ActionId::SelectPrev, "[", false),785 b(ActionId::SelectPrev, "[", false),
786+ // Select-all, on the chord every editor and every text field
787+ // already means it by -- which is why the audio-lane removal
788+ // below had to move off ctrl+a: a stroke that universal was
789+ // never really the removal's to keep.
790+ b(ActionId::SelectAll, "a", true),
779 b(ActionId::Delete, "x", false),791 b(ActionId::Delete, "x", false),
780 b(ActionId::Delete, "delete", false),792 b(ActionId::Delete, "delete", false),
781 b(ActionId::Lift, "l", false),793 b(ActionId::Lift, "l", false),
@@ -811,7 +823,10 @@ impl Keymap {
811 // matching initial and is the paste, so the video one takes the823 // matching initial and is the paste, so the video one takes the
812 // key beside it.824 // key beside it.
813 b(ActionId::RemoveVideoLane, "b", true),825 b(ActionId::RemoveVideoLane, "b", true),
814- b(ActionId::RemoveAudioLane, "a", true),826+ // Ctrl+a is the select-all above now, so the audio removal
827+ // takes the free key beside its own letter: "a" neighbours
828+ // "q" on the row, and ctrl+q was taken by nothing.
829+ b(ActionId::RemoveAudioLane, "q", true),
815 // The subtitle pair reads the same way: the unshifted initial830 // The subtitle pair reads the same way: the unshifted initial
816 // adds one -- "s" is free, the save is the *ctrl* chord -- and a831 // adds one -- "s" is free, the save is the *ctrl* chord -- and a
817 // ctrl chord takes it back. Ctrl+s is that save, so the removal832 // ctrl chord takes it back. Ctrl+s is that save, so the removal
@@ -862,7 +877,7 @@ impl Keymap {
862 // Making them takes the key next to it, ctrl+o: the pair is one877 // Making them takes the key next to it, ctrl+o: the pair is one
863 // subject and the two chords are under the same finger, and878 // subject and the two chords are under the same finger, and
864 // every letter of the word itself is spoken for ("a" adds an879 // every letter of the word itself is spoken for ("a" adds an
865- // audio lane, ctrl+a removes one).880+ // audio lane, ctrl+a selects everything).
866 b(ActionId::ToggleAutoProxies, "o", true),881 b(ActionId::ToggleAutoProxies, "o", true),
867 // The theme takes ctrl+h -- the h of the word, since "t" is the882 // The theme takes ctrl+h -- the h of the word, since "t" is the
868 // subtitles and ctrl+t takes one off -- and a ctrl chord because883 // subtitles and ctrl+t takes one off -- and a ctrl chord because
@@ -1143,7 +1158,7 @@ mod tests {
1143 #[test]1158 #[test]
1144 fn every_default_stroke_reaches_its_action() {1159 fn every_default_stroke_reaches_its_action() {
1145 let k = Keymap::defaults();1160 let k = Keymap::defaults();
1146- assert_eq!(k.entries().len(), 52);1161+ assert_eq!(k.entries().len(), 53);
1147 assert_eq!(k.lookup("p", true), Some(ActionId::ToggleProxies));1162 assert_eq!(k.lookup("p", true), Some(ActionId::ToggleProxies));
1148 assert_eq!(k.lookup("o", true), Some(ActionId::ToggleAutoProxies));1163 assert_eq!(k.lookup("o", true), Some(ActionId::ToggleAutoProxies));
1149 assert_eq!(k.lookup("f1", false), Some(ActionId::ShowActions));1164 assert_eq!(k.lookup("f1", false), Some(ActionId::ShowActions));
@@ -1189,9 +1204,12 @@ mod tests {
1189 assert_eq!(k.lookup("v", false), Some(ActionId::AddVideoLane));1204 assert_eq!(k.lookup("v", false), Some(ActionId::AddVideoLane));
1190 assert_eq!(k.lookup("a", false), Some(ActionId::AddAudioLane));1205 assert_eq!(k.lookup("a", false), Some(ActionId::AddAudioLane));
1191 // ...and the ctrl ones take a track away, out of the way of a stray1206 // ...and the ctrl ones take a track away, out of the way of a stray
1192- // press. Ctrl+v is the paste, so the video one sits beside it.1207+ // press. Ctrl+v is the paste, so the video one sits beside it; ctrl+a
1208+ // is the select-all every editor shares, so the audio one sits beside
1209+ // its own letter instead.
1193 assert_eq!(k.lookup("b", true), Some(ActionId::RemoveVideoLane));1210 assert_eq!(k.lookup("b", true), Some(ActionId::RemoveVideoLane));
1194- assert_eq!(k.lookup("a", true), Some(ActionId::RemoveAudioLane));1211+ assert_eq!(k.lookup("q", true), Some(ActionId::RemoveAudioLane));
1212+ assert_eq!(k.lookup("a", true), Some(ActionId::SelectAll));
1195 // The subtitle pair, the third kind of track: the initial adds and the1213 // The subtitle pair, the third kind of track: the initial adds and the
1196 // subtitle letter's chord takes it back.1214 // subtitle letter's chord takes it back.
1197 assert_eq!(k.lookup("s", false), Some(ActionId::AddSubtitleLane));1215 assert_eq!(k.lookup("s", false), Some(ActionId::AddSubtitleLane));
crates/app/src/main.rsmodified+8 -6
@@ -116,11 +116,13 @@ struct Player {
116 /// the head is on screen again, and by every transport ask (a seek, a116 /// the head is on screen again, and by every transport ask (a seek, a
117 /// play/pause) outright -- those are a person saying where to look.117 /// play/pause) outright -- those are a person saying where to look.
118 panned: bool,118 panned: bool,
119- /// Which clip the edit keys act on: the lane it is in and its index there.119+ /// Which placements the edit keys act on: the lane each is in and its
120- /// The *clicked* half, not the group -- a group is what gets marked on120+ /// index there, every ctrl-click in the order it was made. The *clicked*
121- /// screen, but Lift has to know which half it was aimed at. Indices move121+ /// half and not the group -- a group is what gets marked on screen, but
122- /// under every edit, so this is cleared by all of them.122+ /// Lift has to know which half it was aimed at -- and the last pick is the
123- selected: Option<(Lane, usize)>,123+ /// [`anchor`](Selection::anchor) every single-thing action uses. Indices
124+ /// move under every edit, so this is cleared by all of them.
125+ selected: Selection,
124 /// The clip menu a right-click opened, if one is up. Holds an index like126 /// The clip menu a right-click opened, if one is up. Holds an index like
125 /// `selected` does, so it is closed by anything that can move indices --127 /// `selected` does, so it is closed by anything that can move indices --
126 /// every stroke, and every item of its own.128 /// every stroke, and every item of its own.
@@ -660,7 +662,7 @@ fn main() {
660 // Nobody has scrolled anything yet, so the follow has the662 // Nobody has scrolled anything yet, so the follow has the
661 // view: the first frame is drawn where the head is.663 // view: the first frame is drawn where the head is.
662 panned: false,664 panned: false,
663- selected: None,665+ selected: Selection::new(),
664 context_menu: None,666 context_menu: None,
665 picker: None,667 picker: None,
666 library_menu: None,668 library_menu: None,
crates/app/src/oracle.rsmodified+43 -17
@@ -74,6 +74,14 @@ pub(crate) struct Ctx {
74 /// about a clip.74 /// about a clip.
75 pub(crate) playable: bool,75 pub(crate) playable: bool,
76 pub(crate) exporting: bool,76 pub(crate) exporting: bool,
77+ /// How many placements the selection holds, and on how many distinct
78+ /// lanes -- the manual group's two questions in one reading. Picks that
79+ /// name nothing (a stroke moved the indices under them) count as none.
80+ pub(crate) picks: usize,
81+ pub(crate) pick_lanes: usize,
82+ /// The group id of the marked caption, when what is marked is one: the
83+ /// detach question, asked over a box the clip index space cannot name.
84+ pub(crate) caption_link: Option<u32>,
77 }85 }
78 86
79 /// Whether `action` can be asked for, on `ctx`. One arm per action and nothing87 /// Whether `action` can be asked for, on `ctx`. One arm per action and nothing
@@ -137,7 +145,10 @@ pub(crate) fn enable(action: ActionId, ctx: Ctx) -> Enable {
137 // nothing else* have nothing to act on over a placed subtitle, so they are145 // nothing else* have nothing to act on over a placed subtitle, so they are
138 // refusals of kind -- not rows at all, rather than rows saying "click a clip146 // refusals of kind -- not rows at all, rather than rows saying "click a clip
139 // first" over a clicked caption. Delete is the one that means something: it147 // first" over a clicked caption. Delete is the one that means something: it
140- // routes to [`Player::lift_sub`] when what is marked is a caption.148+ // routes to [`Player::lift_sub`] when what is marked is a caption, and so
149+ // are Group and Detach now that a caption may be grouped by hand -- the one
150+ // over the selection the menu was opened on, the other over the group the
151+ // marked caption is in.
141 //152 //
142 // And it is *only* those. The playhead actions are about the timeline rather153 // And it is *only* those. The playhead actions are about the timeline rather
143 // than about what is marked -- the split and the regroup act at the line154 // than about what is marked -- the split and the regroup act at the line
@@ -150,12 +161,7 @@ pub(crate) fn enable(action: ActionId, ctx: Ctx) -> Enable {
150 if ctx.caption161 if ctx.caption
151 && matches!(162 && matches!(
152 action,163 action,
153- ActionId::Copy164+ ActionId::Copy | ActionId::Delete | ActionId::Lift | ActionId::Equalizer
154- | ActionId::Delete
155- | ActionId::Lift
156- | ActionId::Detach
157- | ActionId::Group
158- | ActionId::Equalizer
159 )165 )
160 {166 {
161 return match action {167 return match action {
@@ -216,11 +222,25 @@ pub(crate) fn enable(action: ActionId, ctx: Ctx) -> Enable {
216 }222 }
217 _ => Enable::Yes,223 _ => Enable::Yes,
218 },224 },
219- // Nothing to take apart in a clip that names no group at all. Whether225+ // Nothing to take apart in a placement that names no group at all --
220- // the group it names still has another half is the engine's question,226+ // a clip by its own field, a caption by the one the mark carries.
221- // like the regroup above.227+ // Whether the group it names still has another half is the engine's
222- ActionId::Detach => match ctx.clip {228+ // question, like the regroup above.
223- Some((clip, _)) if clip.link.is_none() => Enable::No("this clip is not grouped"),229+ ActionId::Detach => match (ctx.clip, ctx.caption) {
230+ (Some((clip, _)), _) if clip.link.is_none() => Enable::No("this clip is not grouped"),
231+ (None, true) if ctx.caption_link.is_none() => {
232+ Enable::No("this caption is not grouped")
233+ }
234+ _ => Enable::Yes,
235+ },
236+ // The manual group: a *selection* of placements, at most one per lane.
237+ // Two picks or more, all on their own lanes, is a group waiting to be
238+ // made; a lane picked twice is the one thing a group may never hold;
239+ // and a single pick is the partner hunt it always was, which the engine
240+ // words itself.
241+ ActionId::Group => match ctx.picks {
242+ 2.. if ctx.pick_lanes == ctx.picks => Enable::Yes,
243+ 2.. => Enable::No("a group is one clip per lane: keep one pick per track"),
224 _ => Enable::Yes,244 _ => Enable::Yes,
225 },245 },
226 // The three that act on the marked clip and on nothing else: with none246 // The three that act on the marked clip and on nothing else: with none
@@ -266,10 +286,12 @@ pub(crate) fn enable(action: ActionId, ctx: Ctx) -> Enable {
266 /// caption -- [`enable`] says so, and the strokes and the toolbar read that --286 /// caption -- [`enable`] says so, and the strokes and the toolbar read that --
267 /// but a split, a rate, a grade or a fit listed under a right-clicked caption287 /// but a split, a rate, a grade or a fit listed under a right-clicked caption
268 /// reads as something the caption is about to get, when what they reach is the288 /// reads as something the caption is about to get, when what they reach is the
269-/// video clip the playhead is standing in. So a caption's menu carries the one289+/// video clip the playhead is standing in. So a caption's menu carries the rows
270-/// row that is the caption's ([`Player::lift_sub`], reached through Delete) and290+/// that are the caption's -- its removal ([`Player::lift_sub`], reached through
271-/// the rows the card already prints "(global)" beside, which say for themselves291+/// Delete) and, since a caption may be grouped by hand, the group pair over the
272-/// that they are not about what was clicked.292+/// selection and its own group -- and the rows the card already prints
293+/// "(global)" beside, which say for themselves that they are not about what was
294+/// clicked.
273 pub(crate) fn menu_items(ctx: Ctx) -> Vec<ActionId> {295 pub(crate) fn menu_items(ctx: Ctx) -> Vec<ActionId> {
274 MENU_ITEMS296 MENU_ITEMS
275 .into_iter()297 .into_iter()
@@ -278,7 +300,11 @@ pub(crate) fn menu_items(ctx: Ctx) -> Vec<ActionId> {
278 !ctx.caption300 !ctx.caption
279 || matches!(301 || matches!(
280 action,302 action,
281- ActionId::Delete | ActionId::Paste | ActionId::ToggleMute303+ ActionId::Delete
304+ | ActionId::Paste
305+ | ActionId::ToggleMute
306+ | ActionId::Group
307+ | ActionId::Detach
282 )308 )
283 })309 })
284 .collect()310 .collect()
crates/app/src/player/actions.rsmodified+22 -5
@@ -54,6 +54,7 @@ impl Player {
54 ActionId::Select => self.select_under_playhead(cx),54 ActionId::Select => self.select_under_playhead(cx),
55 ActionId::SelectNext => self.select_step(true, cx),55 ActionId::SelectNext => self.select_step(true, cx),
56 ActionId::SelectPrev => self.select_step(false, cx),56 ActionId::SelectPrev => self.select_step(false, cx),
57+ ActionId::SelectAll => self.select_all(cx),
57 ActionId::Delete => self.delete_selected(cx),58 ActionId::Delete => self.delete_selected(cx),
58 ActionId::Lift => self.lift_selected(cx),59 ActionId::Lift => self.lift_selected(cx),
59 ActionId::Color => self.open_color(cx),60 ActionId::Color => self.open_color(cx),
@@ -213,16 +214,30 @@ impl Player {
213 let Some(session) = &self.session else {214 let Some(session) = &self.session else {
214 return Ctx::default();215 return Ctx::default();
215 };216 };
216- let on = on.or(self.selected);217+ let on = on.or(self.selected.anchor());
217 let clip = on218 let clip = on
218 .and_then(|(lane, idx)| session.lane_clips(lane).get(idx).map(|clip| (*clip, lane)));219 .and_then(|(lane, idx)| session.lane_clips(lane).get(idx).map(|clip| (*clip, lane)));
220+ let caption = on.is_some_and(|(lane, idx)| {
221+ lane.kind == LaneKind::Subtitle && idx < session.sub_lane(lane).len()
222+ });
223+ // The selection's shape, over the picks that still name something:
224+ // how many placements, and on how many lanes. The lane count is the
225+ // manual group's one-per-lane question -- equal counts say a group, a
226+ // short one says a lane is picked twice.
227+ let (picks, _) = self.marks();
228+ let mut lanes = Vec::new();
229+ for &(lane, _) in &picks {
230+ if !lanes.contains(&lane) {
231+ lanes.push(lane);
232+ }
233+ }
234+ let pick_lanes = lanes.len();
219 Ctx {235 Ctx {
220 clip,236 clip,
221 // The same pair read in the other index space: a subtitle lane's237 // The same pair read in the other index space: a subtitle lane's
222 // own, where the box that was clicked is a caption.238 // own, where the box that was clicked is a caption.
223- caption: on.is_some_and(|(lane, idx)| {239+ caption,
224- lane.kind == LaneKind::Subtitle && idx < session.sub_lane(lane).len()240+ caption_link: caption.then(|| on.and_then(|(lane, idx)| session.sub_lane(lane).get(idx)).and_then(|s| s.link)).flatten(),
225- }),
226 image: clip.is_some_and(|(clip, _)| {241 image: clip.is_some_and(|(clip, _)| {
227 session242 session
228 .sources()243 .sources()
@@ -235,6 +250,8 @@ impl Player {
235 subtitles: !session.subtitles().is_empty(),250 subtitles: !session.subtitles().is_empty(),
236 playable: !nothing_to_play(Some(session)),251 playable: !nothing_to_play(Some(session)),
237 exporting: self.exporting().is_some(),252 exporting: self.exporting().is_some(),
253+ picks: picks.len(),
254+ pick_lanes,
238 }255 }
239 }256 }
240 257
@@ -347,7 +364,7 @@ impl Player {
347 if self.session.as_mut().is_some_and(PlaybackSession::undo) {364 if self.session.as_mut().is_some_and(PlaybackSession::undo) {
348 self.reset_after_reseek();365 self.reset_after_reseek();
349 }366 }
350- self.selected = None;367+ self.selected.clear();
351 cx.notify();368 cx.notify();
352 }369 }
353 370
crates/app/src/player/cards.rsmodified+7 -4
@@ -178,6 +178,7 @@ impl Player {
178 };178 };
179 let target = self179 let target = self
180 .selected180 .selected
181+ .anchor()
181 .filter(|(lane, _)| lane.kind == LaneKind::Video)182 .filter(|(lane, _)| lane.kind == LaneKind::Video)
182 .or_else(|| session.video_clip_at(session.now()));183 .or_else(|| session.video_clip_at(session.now()));
183 match target {184 match target {
@@ -310,6 +311,7 @@ impl Player {
310 };311 };
311 match self312 match self
312 .selected313 .selected
314+ .anchor()
313 .or_else(|| session.video_clip_at(session.now()))315 .or_else(|| session.video_clip_at(session.now()))
314 {316 {
315 Some(clip) => {317 Some(clip) => {
@@ -452,6 +454,7 @@ impl Player {
452 };454 };
453 match self455 match self
454 .selected456 .selected
457+ .anchor()
455 .or_else(|| session.video_clip_at(session.now()))458 .or_else(|| session.video_clip_at(session.now()))
456 .map(|clip| audio_half(session, clip))459 .map(|clip| audio_half(session, clip))
457 {460 {
@@ -842,7 +845,7 @@ impl Player {
842 // selection now names a different clip than the one that is845 // selection now names a different clip than the one that is
843 // highlighted -- dropped here as after every other edit that846 // highlighted -- dropped here as after every other edit that
844 // moves indexes (a delete, a paste, an undo).847 // moves indexes (a delete, a paste, an undo).
845- self.selected = None;848+ self.selected.clear();
846 self.reset_after_reseek();849 self.reset_after_reseek();
847 self.notify_user(850 self.notify_user(
848 format!(851 format!(
@@ -881,7 +884,7 @@ impl Player {
881 // Splitting each silence out and closing the room it no longer884 // Splitting each silence out and closing the room it no longer
882 // needs moves indexes exactly as the cut does: the selection885 // needs moves indexes exactly as the cut does: the selection
883 // goes with them.886 // goes with them.
884- self.selected = None;887+ self.selected.clear();
885 self.reset_after_reseek();888 self.reset_after_reseek();
886 self.notify_user(889 self.notify_user(
887 format!(890 format!(
@@ -958,7 +961,7 @@ impl Player {
958 if self.exporting().is_some() {961 if self.exporting().is_some() {
959 return;962 return;
960 }963 }
961- let refusal = match (self.selected, &self.session) {964+ let refusal = match (self.selected.anchor(), &self.session) {
962 (_, None) => Some("NO TIMELINE — open a file first".to_string()),965 (_, None) => Some("NO TIMELINE — open a file first".to_string()),
963 (None, _) => Some(format!(966 (None, _) => Some(format!(
964 "NOTHING SELECTED — click an audio clip or press {}, then ask again",967 "NOTHING SELECTED — click an audio clip or press {}, then ask again",
@@ -974,7 +977,7 @@ impl Player {
974 cx.notify();977 cx.notify();
975 return;978 return;
976 }979 }
977- let (lane, idx) = self.selected.expect("checked above");980+ let (lane, idx) = self.selected.anchor().expect("checked above");
978 let session = self.session.as_ref().expect("checked above");981 let session = self.session.as_ref().expect("checked above");
979 // What the clip already plays through, or the flat default -- so the982 // What the clip already plays through, or the flat default -- so the
980 // card opens on the curve that is in force and a reopen shows the last983 // card opens on the curve that is in force and a reopen shows the last
crates/app/src/player/library.rsmodified+5 -5
@@ -51,7 +51,7 @@ impl Player {
51 };51 };
52 match placed {52 match placed {
53 Ok(true) => {53 Ok(true) => {
54- self.selected = None;54+ self.selected.clear();
55 self.reset_after_reseek();55 self.reset_after_reseek();
56 }56 }
57 // The engine's own words: a stream that cannot join this timeline57 // The engine's own words: a stream that cannot join this timeline
@@ -145,7 +145,7 @@ impl Player {
145 // The drawn cue with it, and its tile for the same reason as above.145 // The drawn cue with it, and its tile for the same reason as above.
146 self.sub_image = None;146 self.sub_image = None;
147 self.clipboard = None;147 self.clipboard = None;
148- self.selected = None;148+ self.selected.clear();
149 self.selected_asset = None;149 self.selected_asset = None;
150 // The subtitle rows go with the timeline they were on, and so does the150 // The subtitle rows go with the timeline they were on, and so does the
151 // lane that was shown: S1 of one project is not S1 of the next.151 // lane that was shown: S1 of one project is not S1 of the next.
@@ -1154,7 +1154,7 @@ impl Player {
1154 // A copied clip names its source by index, which means a1154 // A copied clip names its source by index, which means a
1155 // different file -- or none -- in another project.1155 // different file -- or none -- in another project.
1156 self.clipboard = None;1156 self.clipboard = None;
1157- self.selected = None;1157+ self.selected.clear();
1158 // A menu can be up while a project is dropped on the window --1158 // A menu can be up while a project is dropped on the window --
1159 // the scrim swallows clicks, never a drop -- and its index1159 // the scrim swallows clicks, never a drop -- and its index
1160 // would name some other timeline's clip. The two clip cards1160 // would name some other timeline's clip. The two clip cards
@@ -1256,7 +1256,7 @@ impl Player {
1256 .map(|session| session.remove_lane(lane));1256 .map(|session| session.remove_lane(lane));
1257 let text = match removed {1257 let text = match removed {
1258 Some(Ok(())) => {1258 Some(Ok(())) => {
1259- self.selected = None;1259+ self.selected.clear();
1260 self.context_menu = None;1260 self.context_menu = None;
1261 self.eq_open = None;1261 self.eq_open = None;
1262 self.color_open = None;1262 self.color_open = None;
@@ -1313,7 +1313,7 @@ impl Player {
1313 return;1313 return;
1314 };1314 };
1315 if moved != lane {1315 if moved != lane {
1316- self.selected = None;1316+ self.selected.clear();
1317 self.context_menu = None;1317 self.context_menu = None;
1318 self.eq_open = None;1318 self.eq_open = None;
1319 self.color_open = None;1319 self.color_open = None;
crates/app/src/player/timeline_edit.rsmodified+225 -61
@@ -27,7 +27,7 @@ impl Player {
27 if let Some(session) = &mut self.session {27 if let Some(session) = &mut self.session {
28 session.cut_at(f64::from(at) / self.fps);28 session.cut_at(f64::from(at) / self.fps);
29 }29 }
30- self.selected = None;30+ self.selected.clear();
31 cx.notify();31 cx.notify();
32 }32 }
33 33
@@ -42,7 +42,7 @@ impl Player {
42 }42 }
43 if let Some(session) = &mut self.session {43 if let Some(session) = &mut self.session {
44 if session.regroup_at(session.now()) {44 if session.regroup_at(session.now()) {
45- self.selected = None;45+ self.selected.clear();
46 } else {46 } else {
47 self.notify_user(47 self.notify_user(
48 "NOTHING TO REGROUP — put the playhead where two clips meet, on frames that were cut apart"48 "NOTHING TO REGROUP — put the playhead where two clips meet, on frames that were cut apart"
@@ -61,7 +61,7 @@ impl Player {
61 if self.exporting().is_some() {61 if self.exporting().is_some() {
62 return;62 return;
63 }63 }
64- match (&mut self.session, self.selected) {64+ match (&mut self.session, self.selected.anchor()) {
65 (Some(session), Some((lane, idx))) => {65 (Some(session), Some((lane, idx))) => {
66 if !session.ungroup(lane, idx) {66 if !session.ungroup(lane, idx) {
67 self.notify_user(67 self.notify_user(
@@ -77,35 +77,55 @@ impl Player {
77 cx.notify();77 cx.notify();
78 }78 }
79 79
80- /// Puts the selected clip back in a group with the clip covering exactly the80+ /// Puts the selection into one group. Two paths, by how much of a
81- /// same frames on another track -- the way back from [`Player::detach`], and81+ /// selection there is:
82- /// the way to group a picture with sound it was never opened with. The82+ ///
83- /// partner is not clicked because there is nothing to choose: a group id83+ /// * **One pick** -- the way back from [`Player::detach`], and the way to
84- /// names one span, so only a clip covering these very frames could join it,84+ /// group a picture with sound it was never opened with. The partner is
85- /// and the engine words what to do when none does.85+ /// not clicked because there is nothing to choose: the clip covering
86+ /// exactly the same frames on another track, and the engine words what to
87+ /// do when none does.
88+ ///
89+ /// * **A ctrl-click selection** -- the group a hand builds: every pick it
90+ /// names, clips and captions alike, into one id, whatever frames each of
91+ /// them covers. The members keep their own offsets, which is the point:
92+ /// from here they move, trim and delete together.
86 pub(crate) fn group(&mut self, cx: &mut Context<Self>) {93 pub(crate) fn group(&mut self, cx: &mut Context<Self>) {
87 if self.exporting().is_some() {94 if self.exporting().is_some() {
88 return;95 return;
89 }96 }
90- let partner = match (&self.session, self.selected) {97+ // The picks the selection holds that still name something: a stale
91- (Some(session), Some((lane, idx))) => span_partner(session, lane, idx),98+ // index (a stroke nobody saw) is not a thing to group.
92- _ => None,99+ let picks = self.marks().0;
93- };100+ match (&mut self.session, self.selected.anchor(), picks.len()) {
94- match (&mut self.session, self.selected, partner) {101+ (_, None, _) => {
95- (Some(session), Some((lane, idx)), Some((other, o_idx))) => {102+ self.notify_user("NOTHING GROUPED — click one of the halves first".into())
96- if let Err(e) = session.group(lane, idx, other, o_idx) {103+ }
104+ // The hand's group: every pick, one id.
105+ (Some(session), _, 2..) => {
106+ if let Err(e) = session.group_all(&picks) {
97 self.notify_user(format!("NOT GROUPED — {e}").into());107 self.notify_user(format!("NOT GROUPED — {e}").into());
98 }108 }
99 }109 }
100- (Some(_), Some(_), None) => {110+ // One pick that no longer names anything.
101- self.notify_user(111+ (Some(_), Some(_), 0) => {
102- "NOTHING TO GROUP WITH — no clip on another track covers exactly these frames"112+ self.notify_user("NOTHING GROUPED — that clip is no longer there".into())
103- .into(),
104- )
105- }
106- (Some(_), None, _) => {
107- self.notify_user("NOTHING GROUPED — click one of the halves first".into())
108 }113 }
114+ // One pick: the partner flow it always was.
115+ (Some(session), Some((lane, idx)), _) => match span_partner(session, lane, idx) {
116+ Some((other, o_idx)) => {
117+ if let Err(e) = session.group(lane, idx, other, o_idx) {
118+ self.notify_user(format!("NOT GROUPED — {e}").into());
119+ }
120+ }
121+ None => {
122+ self.notify_user(
123+ "NOTHING TO GROUP WITH — no clip on another track covers exactly these \
124+ frames; ctrl-click the clips to group instead"
125+ .into(),
126+ )
127+ }
128+ },
109 (None, ..) => {}129 (None, ..) => {}
110 }130 }
111 cx.notify();131 cx.notify();
@@ -120,20 +140,43 @@ impl Player {
120 if self.exporting().is_some() {140 if self.exporting().is_some() {
121 return;141 return;
122 }142 }
123- let selected = self.selected.take();143+ let selected = self.selected.anchor();
144+ self.selected.clear();
124 // A caption is marked in its own lane's index space -- that lane holds145 // A caption is marked in its own lane's index space -- that lane holds
125 // no `Clip` -- so the same key reaches it through the one removal a146 // no `Clip` -- so the same key reaches it through the one removal a
126- // placed subtitle has ([`Player::lift_sub`], one undo step). Parity: the147+ // placed subtitle has ([`Player::lift_sub`], one undo step), unless a
127- // box on a subtitle lane goes by the stroke every other box goes by.148+ // hand put it in a group: then it goes the way its group goes.
149+ // Parity: the box on a subtitle lane goes by the stroke every other box
150+ // goes by.
128 if let Some((lane, idx)) = selected.filter(|(lane, _)| lane.kind == LaneKind::Subtitle) {151 if let Some((lane, idx)) = selected.filter(|(lane, _)| lane.kind == LaneKind::Subtitle) {
129- self.lift_sub(lane, idx, cx);152+ // A caption carrying a group id is a member, and a member goes the
153+ // way its group goes -- the engine's own door decides how much of
154+ // that is media (and so a reseek) and how much is a lift.
155+ let grouped = self
156+ .session
157+ .as_ref()
158+ .is_some_and(|session| session.sub_lane(lane).get(idx).is_some_and(|s| s.link.is_some()));
159+ match grouped {
160+ true => {
161+ if self
162+ .session
163+ .as_mut()
164+ .is_some_and(|session| session.delete_sub(lane, idx))
165+ {
166+ self.reset_after_reseek();
167+ }
168+ }
169+ false => self.lift_sub(lane, idx, cx),
170+ }
171+ cx.notify();
130 return;172 return;
131 }173 }
132 // Whichever lane it was clicked in: the index is that lane's own, and174 // Whichever lane it was clicked in: the index is that lane's own, and
133- // the ripple cuts the clip's span out of every lane -- a group covers175+ // the engine cuts what the clip covers out of the lanes it covers -- a
134- // one span, so deleting a take by its audio half is the same edit as by176+ // lone clip's span out of every lane, a grouped member's own span out
135- // its picture. What is not a whole take is lifted instead, which is what177+ // of its own lane and its caption members off their lanes. What is not
136- // reaches a clip on an added track ([`whole_take`]).178+ // a whole take is lifted instead, which is what reaches a clip on an
179+ // added track ([`whole_take`]).
137 let deleted = match (&mut self.session, selected) {180 let deleted = match (&mut self.session, selected) {
138 (Some(session), Some((lane, idx))) => match whole_take(session, lane, idx) {181 (Some(session), Some((lane, idx))) => match whole_take(session, lane, idx) {
139 true => session.delete_clip(lane, idx),182 true => session.delete_clip(lane, idx),
@@ -157,7 +200,9 @@ impl Player {
157 if self.exporting().is_some() {200 if self.exporting().is_some() {
158 return;201 return;
159 }202 }
160- match (&mut self.session, self.selected.take()) {203+ let selected = self.selected.anchor();
204+ self.selected.clear();
205+ match (&mut self.session, selected) {
161 (Some(session), Some((lane, idx))) => {206 (Some(session), Some((lane, idx))) => {
162 if session.lift_clip(lane, idx) {207 if session.lift_clip(lane, idx) {
163 self.reset_after_reseek();208 self.reset_after_reseek();
@@ -181,16 +226,34 @@ impl Player {
181 // frames is a paste of the wrong thing.226 // frames is a paste of the wrong thing.
182 if let Some(clip) = self227 if let Some(clip) = self
183 .selected228 .selected
229+ .anchor()
184 .and_then(|(lane, idx)| session?.lane_clips(lane).get(idx).copied())230 .and_then(|(lane, idx)| session?.lane_clips(lane).get(idx).copied())
185 {231 {
186 self.clipboard = Some(clip);232 self.clipboard = Some(clip);
187 }233 }
188 }234 }
189 235
190- /// The group id of the clicked clip, which is what marks the other half.236+ /// The picks and their group ids, in click order: the two halves of what
191- pub(crate) fn selected_link(&self) -> Option<u32> {237+ /// [`marked`] asks about every box on the bed -- which picks there are, and
192- let (lane, idx) = self.selected?;238+ /// which groups they carry (a caption's included, which is what marks the
193- self.session.as_ref()?.lane_clips(lane).get(idx)?.link239+ /// clip it was pinned to). Picks an edit has left stale name nothing and
240+ /// contribute no id.
241+ pub(crate) fn marks(&self) -> (Vec<(Lane, usize)>, Vec<Option<u32>>) {
242+ let Some(session) = &self.session else {
243+ return (Vec::new(), Vec::new());
244+ };
245+ let (mut picks, mut links) = (Vec::new(), Vec::new());
246+ for &(lane, idx) in self.selected.picks() {
247+ let link = match lane.kind {
248+ LaneKind::Subtitle => session.sub_lane(lane).get(idx).map(|s| s.link),
249+ _ => session.lane_clips(lane).get(idx).map(|c| c.link),
250+ };
251+ if let Some(link) = link {
252+ picks.push((lane, idx));
253+ links.push(link);
254+ }
255+ }
256+ (picks, links)
194 }257 }
195 258
196 /// Drops the copied clip in at the playhead. The engine reseeks itself, so259 /// Drops the copied clip in at the playhead. The engine reseeks itself, so
@@ -202,7 +265,7 @@ impl Player {
202 _ => false,265 _ => false,
203 };266 };
204 if pasted {267 if pasted {
205- self.selected = None;268+ self.selected.clear();
206 self.reset_after_reseek();269 self.reset_after_reseek();
207 }270 }
208 cx.notify();271 cx.notify();
@@ -240,7 +303,7 @@ impl Player {
240 };303 };
241 match moved {304 match moved {
242 true => {305 true => {
243- self.selected = None;306+ self.selected.clear();
244 self.reset_after_reseek();307 self.reset_after_reseek();
245 }308 }
246 // The three ways a drag is refused, told apart by what the309 // The three ways a drag is refused, told apart by what the
@@ -289,6 +352,9 @@ impl Player {
289 track,352 track,
290 in_us: 0,353 in_us: 0,
291 out_us,354 out_us,
355+ // A palette row arrives in no group: pinning its words to a clip is
356+ // a hand's decision, made with the Group row afterwards.
357+ link: None,
292 })358 })
293 }359 }
294 360
@@ -308,6 +374,7 @@ impl Player {
308 // frame is its name on its lane ([`sub_mark`]).374 // frame is its name on its lane ([`sub_mark`]).
309 let marked = self375 let marked = self
310 .selected376 .selected
377+ .anchor()
311 .filter(|&(lane, _)| lane == to)378 .filter(|&(lane, _)| lane == to)
312 .and_then(|(lane, idx)| Some(self.session.as_ref()?.sub_lane(lane).get(idx)?.start));379 .and_then(|(lane, idx)| Some(self.session.as_ref()?.sub_lane(lane).get(idx)?.start));
313 let text = match (self.sub_of_track(track), &mut self.session) {380 let text = match (self.sub_of_track(track), &mut self.session) {
@@ -331,11 +398,19 @@ impl Player {
331 // names its new neighbour -- the caption the next Delete would take.398 // names its new neighbour -- the caption the next Delete would take.
332 // The mark goes back on the caption it was on.399 // The mark goes back on the caption it was on.
333 (None, Some(start)) => {400 (None, Some(start)) => {
334- self.selected = self401+ let mark = self
335 .session402 .session
336 .as_ref()403 .as_ref()
337 .and_then(|session| sub_mark(session.sub_lane(to), start))404 .and_then(|session| sub_mark(session.sub_lane(to), start))
338 .map(|i| (to, i));405 .map(|i| (to, i));
406+ self.selected = match mark {
407+ Some(mark) => {
408+ let mut sel = Selection::new();
409+ sel.set_one(mark);
410+ sel
411+ }
412+ None => Selection::new(),
413+ };
339 }414 }
340 (None, None) => {}415 (None, None) => {}
341 }416 }
@@ -385,11 +460,19 @@ impl Player {
385 // landed rather than left on the index it had, which after the move460 // landed rather than left on the index it had, which after the move
386 // is a neighbour's.461 // is a neighbour's.
387 Some(Ok(())) => {462 Some(Ok(())) => {
388- self.selected = self463+ let mark = self
389 .session464 .session
390 .as_ref()465 .as_ref()
391 .and_then(|session| sub_mark(session.sub_lane(to), start))466 .and_then(|session| sub_mark(session.sub_lane(to), start))
392 .map(|i| (to, i));467 .map(|i| (to, i));
468+ self.selected = match mark {
469+ Some(mark) => {
470+ let mut sel = Selection::new();
471+ sel.set_one(mark);
472+ sel
473+ }
474+ None => Selection::new(),
475+ };
393 }476 }
394 None => {}477 None => {}
395 }478 }
@@ -425,8 +508,12 @@ impl Player {
425 // so a mark or an open menu left at or past it names a *different*508 // so a mark or an open menu left at or past it names a *different*
426 // caption now -- and the next Delete would take that one. Both go509 // caption now -- and the next Delete would take that one. Both go
427 // with the caption they were on.510 // with the caption they were on.
428- if self.selected.is_some_and(|(l, i)| l == lane && i >= idx) {511+ if self
429- self.selected = None;512+ .selected
513+ .anchor()
514+ .is_some_and(|(l, i)| l == lane && i >= idx)
515+ {
516+ self.selected.clear();
430 }517 }
431 self.context_menu = None;518 self.context_menu = None;
432 }519 }
@@ -714,8 +801,19 @@ impl Player {
714 };801 };
715 let lanes = session.lanes();802 let lanes = session.lanes();
716 let clips: Vec<&[Clip]> = lanes.iter().map(|&lane| session.lane_clips(lane)).collect();803 let clips: Vec<&[Clip]> = lanes.iter().map(|&lane| session.lane_clips(lane)).collect();
804+ // The dragged placement's group, whatever kind it is: the clips of the
805+ // group travel with a clip's drag, and a caption's drag -- which has no
806+ // clip of its own to skip by -- must not snap onto the very clips it is
807+ // carrying.
808+ let skip_link = skip.and_then(|(lane, idx)| {
809+ match lane.kind {
810+ LaneKind::Subtitle => session.sub_lane(lane).get(idx).map(|s| s.link),
811+ _ => session.lane_clips(lane).get(idx).map(|c| c.link),
812+ }
813+ .flatten()
814+ });
717 let skip = skip.and_then(|(lane, idx)| Some((lanes.iter().position(|&l| l == lane)?, idx)));815 let skip = skip.and_then(|(lane, idx)| Some((lanes.iter().position(|&l| l == lane)?, idx)));
718- snap_marks(&clips, skip, frame_at(session.now(), self.fps))816+ snap_marks(&clips, skip, skip_link, frame_at(session.now(), self.fps))
719 }817 }
720 818
721 /// Where a gesture at `raw` lands and the mark that pulled it there, with819 /// Where a gesture at `raw` lands and the mark that pulled it there, with
@@ -854,12 +952,17 @@ impl Player {
854 /// Opens the clip menu on the box under the pointer, from the right button952 /// Opens the clip menu on the box under the pointer, from the right button
855 /// wherever it was pressed on that box -- its middle or one of its edge953 /// wherever it was pressed on that box -- its middle or one of its edge
856 /// strips, which cover the middle's own listener. Selecting first is part of954 /// strips, which cover the middle's own listener. Selecting first is part of
857- /// it: every item acts on the clip the menu names.955+ /// it: every item acts on the clip the menu names -- and a right-click on
956+ /// one of the clips a ctrl-click selection already holds keeps that
957+ /// selection, so the menu's Group is about the whole of it. A right-click
958+ /// anywhere else is the single mark, exactly as a left press is.
858 pub(crate) fn open_menu(&mut self, lane: Lane, idx: usize, at: Point<Pixels>, cx: &mut Context<Self>) {959 pub(crate) fn open_menu(&mut self, lane: Lane, idx: usize, at: Point<Pixels>, cx: &mut Context<Self>) {
859 if self.modal() {960 if self.modal() {
860 return;961 return;
861 }962 }
862- self.select((lane, idx), cx);963+ if !self.selected.contains((lane, idx)) {
964+ self.select((lane, idx), cx);
965+ }
863 self.context_menu = Some(ContextMenu {966 self.context_menu = Some(ContextMenu {
864 lane,967 lane,
865 idx,968 idx,
@@ -869,11 +972,19 @@ impl Player {
869 cx.notify();972 cx.notify();
870 }973 }
871 974
872- /// A press on a clip's edge: the start of the drag that changes how much of975+ /// A press on an edge: the start of the drag that changes how much of a
873- /// its source it plays. It selects the clip as a press anywhere else on the976+ /// source it plays. It picks the placement as a press anywhere else on the
874 /// box does -- the edge strip covers the box's own listener (`occlude`), so977 /// box does -- the edge strip covers the box's own listener (`occlude`), so
875- /// this is the only one that fires there.978+ /// this is the only one that fires there -- and ctrl makes that pick the
876- pub(crate) fn start_trim(&mut self, lane: Lane, idx: usize, edge: Edge, cx: &mut Context<Self>) {979+ /// toggle it is everywhere else on the bed.
980+ pub(crate) fn start_trim(
981+ &mut self,
982+ lane: Lane,
983+ idx: usize,
984+ edge: Edge,
985+ ctrl: bool,
986+ cx: &mut Context<Self>,
987+ ) {
877 if self.modal() || self.exporting().is_some() {988 if self.modal() || self.exporting().is_some() {
878 return;989 return;
879 }990 }
@@ -881,9 +992,8 @@ impl Player {
881 // gesture, the same `Trim`, and the branch is the lane's kind wherever992 // gesture, the same `Trim`, and the branch is the lane's kind wherever
882 // the drag is asked about ([`Player::trim_to`],993 // the drag is asked about ([`Player::trim_to`],
883 // [`Player::commit_trim`]). A caption *is* markable -- the mark is its994 // [`Player::commit_trim`]). A caption *is* markable -- the mark is its
884- // lane and its index like a clip's ([`Player::select`]) -- but an edge995+ // lane and its index like a clip's ([`Player::pick`]) -- and a caption
885- // drag is a trim and not a pick, so this leaves the mark where the hand996+ // in a group carries its link, so its trim drags the group with it.
886- // left it. No group either: a caption has no half on another lane.
887 if lane.kind == LaneKind::Subtitle {997 if lane.kind == LaneKind::Subtitle {
888 let Some(sub) = self998 let Some(sub) = self
889 .session999 .session
@@ -892,15 +1002,22 @@ impl Player {
892 else {1002 else {
893 return;1003 return;
894 };1004 };
1005+ self.pick((lane, idx), ctrl, cx);
895 self.trim = Some(Trim {1006 self.trim = Some(Trim {
896 lane,1007 lane,
897 idx,1008 idx,
898 edge,1009 edge,
1010+ // Where the edge already is: a press that never moves is not an
1011+ // edit, and the engine refuses exactly that.
1012+ from: match edge {
1013+ Edge::Start => sub.start,
1014+ Edge::End => sub.end(),
1015+ },
899 to: match edge {1016 to: match edge {
900 Edge::Start => sub.start,1017 Edge::Start => sub.start,
901 Edge::End => sub.end(),1018 Edge::End => sub.end(),
902 },1019 },
903- link: None,1020+ link: sub.link,
904 });1021 });
905 cx.notify();1022 cx.notify();
906 return;1023 return;
@@ -912,13 +1029,17 @@ impl Player {
912 else {1029 else {
913 return;1030 return;
914 };1031 };
915- self.select((lane, idx), cx);1032+ self.pick((lane, idx), ctrl, cx);
916 self.trim = Some(Trim {1033 self.trim = Some(Trim {
917 lane,1034 lane,
918 idx,1035 idx,
919 edge,1036 edge,
920 // Where the edge already is: a press that never moves is not an1037 // Where the edge already is: a press that never moves is not an
921 // edit, and `Project::trim` refuses exactly that.1038 // edit, and `Project::trim` refuses exactly that.
1039+ from: match edge {
1040+ Edge::Start => clip.start,
1041+ Edge::End => clip.end(),
1042+ },
922 to: match edge {1043 to: match edge {
923 Edge::Start => clip.start,1044 Edge::Start => clip.start,
924 Edge::End => clip.end(),1045 Edge::End => clip.end(),
@@ -1006,30 +1127,73 @@ impl Player {
1006 }1127 }
1007 1128
1008 /// The clip as the drag is showing it: an edge under the pointer moves its1129 /// The clip as the drag is showing it: an edge under the pointer moves its
1009- /// own box, and the boxes of the halves linked to it, before anything is1130+ /// own box, and the boxes of everything linked to it, before anything is
1010 /// committed. Display only -- the project is not touched until the release.1131 /// committed. Display only -- the project is not touched until the release.
1132+ /// A member of the group follows by the same delta, clamped to its own
1133+ /// room, which is the arithmetic the release commits -- so a box let go of
1134+ /// is the box that lands.
1011 pub(crate) fn trimmed(&self, lane: Lane, idx: usize, clip: Clip) -> Clip {1135 pub(crate) fn trimmed(&self, lane: Lane, idx: usize, clip: Clip) -> Clip {
1012 let Some(trim) = self.trim.filter(|t| {1136 let Some(trim) = self.trim.filter(|t| {
1013 (t.lane, t.idx) == (lane, idx) || (t.link.is_some() && t.link == clip.link)1137 (t.lane, t.idx) == (lane, idx) || (t.link.is_some() && t.link == clip.link)
1014 }) else {1138 }) else {
1015 return clip;1139 return clip;
1016 };1140 };
1141+ let to = self.followed(trim, (lane, idx), match trim.edge {
1142+ Edge::Start => clip.start,
1143+ Edge::End => clip.end(),
1144+ });
1017 let still = self.session.as_ref().is_some_and(|session| {1145 let still = self.session.as_ref().is_some_and(|session| {
1018 session1146 session
1019 .sources()1147 .sources()
1020 .get(clip.source)1148 .get(clip.source)
1021 .is_some_and(|s| engine::is_image(&s.path))1149 .is_some_and(|s| engine::is_image(&s.path))
1022 });1150 });
1023- trimmed_clip(clip, trim.edge, trim.to, still)1151+ trimmed_clip(clip, trim.edge, to, still)
1024 }1152 }
1025 1153
1026 /// The caption as the drag is showing it, [`Player::trimmed`]'s twin:1154 /// The caption as the drag is showing it, [`Player::trimmed`]'s twin:
1027- /// display only, and the engine hears about it once, at the release.1155+ /// display only, and the engine hears about it once, at the release. A
1156+ /// caption in the dragged group follows by the same delta, against its own
1157+ /// walls.
1028 pub(crate) fn trimmed_sub(&self, lane: Lane, idx: usize, sub: SubClip) -> SubClip {1158 pub(crate) fn trimmed_sub(&self, lane: Lane, idx: usize, sub: SubClip) -> SubClip {
1029- match self.trim.filter(|t| (t.lane, t.idx) == (lane, idx)) {1159+ let Some(trim) = self.trim.filter(|t| {
1030- Some(trim) => trimmed_sub(sub, trim.edge, trim.to),1160+ (t.lane, t.idx) == (lane, idx) || (t.link.is_some() && t.link == sub.link)
1031- None => sub,1161+ }) else {
1162+ return sub;
1163+ };
1164+ let to = self.followed(
1165+ trim,
1166+ (lane, idx),
1167+ match trim.edge {
1168+ Edge::Start => sub.start,
1169+ Edge::End => sub.end(),
1170+ },
1171+ );
1172+ trimmed_sub(sub, trim.edge, to)
1173+ }
1174+
1175+ /// The frame a trim is showing for the placement at `here`, whose edge
1176+ /// stands at `at`: the drag's own `to` when `here` is the placement the
1177+ /// press started on, and that `to`'s delta from where the press started,
1178+ /// clamped to this placement's own room, when it is a member following.
1179+ fn followed(&self, trim: Trim, here: (Lane, usize), at: u32) -> u32 {
1180+ if (trim.lane, trim.idx) == here {
1181+ return trim.to;
1032 }1182 }
1183+ let delta = i64::from(trim.to) - i64::from(trim.from);
1184+ let room = match here.0.kind {
1185+ LaneKind::Subtitle => self
1186+ .session
1187+ .as_ref()
1188+ .and_then(|session| session.trim_sub_room(here.0, here.1, trim.edge)),
1189+ _ => self
1190+ .session
1191+ .as_ref()
1192+ .and_then(|session| session.trim_room(here.0, here.1, trim.edge)),
1193+ };
1194+ room.map_or(trim.to, |(lo, hi)| {
1195+ (i64::from(at) + delta).clamp(i64::from(lo), i64::from(hi)) as u32
1196+ })
1033 }1197 }
1034 1198
1035 /// How long the timeline is *drawn* as: its own length, and while a tail is1199 /// How long the timeline is *drawn* as: its own length, and while a tail is
crates/app/src/player/view.rsmodified+49 -7
@@ -4,12 +4,26 @@
4 use crate::*;4 use crate::*;
5 5
6 impl Player {6 impl Player {
7- /// The one place a clip becomes *the* selected one: a click, a right-click7+ /// The one place a clip becomes *the* selected one: a plain click, a
8- /// that opens the menu, and every selection key go through here, so what a8+ /// right-click that opens the menu, and every selection key go through
9- /// keyboard marks and what a pointer marks are the same state marked the9+ /// here, so what a keyboard marks and what a pointer marks are the same
10- /// same way (group and all -- see [`marked`]).10+ /// state marked the same way (group and all -- see [`marked`]). One pick,
11+ /// because one click names one thing; [`Player::pick`] is the ctrl+click
12+ /// that grows the selection instead.
11 pub(crate) fn select(&mut self, target: (Lane, usize), cx: &mut Context<Self>) {13 pub(crate) fn select(&mut self, target: (Lane, usize), cx: &mut Context<Self>) {
12- self.selected = Some(target);14+ self.selected.set_one(target);
15+ cx.notify();
16+ }
17+
18+ /// A press with ctrl held: the pick joins the selection, or leaves it if
19+ /// it was already in -- the toggle that assembles a group by hand. Without
20+ /// ctrl this is exactly [`Player::select`], which is why every box on the
21+ /// bed asks this one and lets the modifier decide.
22+ pub(crate) fn pick(&mut self, target: (Lane, usize), ctrl: bool, cx: &mut Context<Self>) {
23+ match ctrl {
24+ true => self.selected.toggle(target),
25+ false => self.selected.set_one(target),
26+ }
13 cx.notify();27 cx.notify();
14 }28 }
15 29
@@ -27,7 +41,6 @@ impl Player {
27 .filter_map(|lane| Some((lane, session.lane_clip_at(lane, now)?)))41 .filter_map(|lane| Some((lane, session.lane_clip_at(lane, now)?)))
28 .collect()42 .collect()
29 }43 }
30-
31 /// Selects the clip under the playhead, and on a repeat press the next44 /// Selects the clip under the playhead, and on a repeat press the next
32 /// lane's -- so one key reaches every clip the playhead is over, which is45 /// lane's -- so one key reaches every clip the playhead is over, which is
33 /// what makes selection (and everything that acts on a selection: delete,46 /// what makes selection (and everything that acts on a selection: delete,
@@ -43,6 +56,7 @@ impl Player {
43 // means; a selection off the playhead starts the walk over.56 // means; a selection off the playhead starts the walk over.
44 let next = self57 let next = self
45 .selected58 .selected
59+ .anchor()
46 .and_then(|sel| under.iter().position(|&clip| clip == sel))60 .and_then(|sel| under.iter().position(|&clip| clip == sel))
47 .map_or(first, |at| under[(at + 1) % under.len()]);61 .map_or(first, |at| under[(at + 1) % under.len()]);
48 self.select(next, cx);62 self.select(next, cx);
@@ -54,9 +68,10 @@ impl Player {
54 pub(crate) fn select_step(&mut self, forward: bool, cx: &mut Context<Self>) {68 pub(crate) fn select_step(&mut self, forward: bool, cx: &mut Context<Self>) {
55 let clips = self69 let clips = self
56 .selected70 .selected
71+ .anchor()
57 .zip(self.session.as_ref())72 .zip(self.session.as_ref())
58 .map_or(0, |((lane, _), session)| session.lane_clips(lane).len());73 .map_or(0, |((lane, _), session)| session.lane_clips(lane).len());
59- match (self.selected, clips) {74+ match (self.selected.anchor(), clips) {
60 // An empty lane is a selection nothing can be stepped from -- as is75 // An empty lane is a selection nothing can be stepped from -- as is
61 // no selection at all, and the playhead answers both.76 // no selection at all, and the playhead answers both.
62 (Some((lane, idx)), len) if len > 0 => {77 (Some((lane, idx)), len) if len > 0 => {
@@ -71,6 +86,32 @@ impl Player {
71 }86 }
72 }87 }
73 88
89+ /// Every placement on every lane, in the order the lanes are drawn: what
90+ /// Select All marks -- the clips and the captions both, one selection that
91+ /// a Group can take apart lane by lane and a Delete can walk pick by pick.
92+ pub(crate) fn select_all(&mut self, cx: &mut Context<Self>) {
93+ let Some(session) = &self.session else {
94+ return;
95+ };
96+ let mut selected = Selection::new();
97+ for lane in session.lanes() {
98+ let len = match lane.kind {
99+ LaneKind::Subtitle => session.sub_lane(lane).len(),
100+ _ => session.lane_clips(lane).len(),
101+ };
102+ for idx in 0..len {
103+ selected.add((lane, idx));
104+ }
105+ }
106+ self.selected = selected;
107+ if self.selected.is_empty() {
108+ // A key that does nothing looks broken: an empty timeline has
109+ // nothing to select, and that is a thing to say rather than skip.
110+ self.notify_user("NOTHING TO SELECT — the timeline is empty".into());
111+ }
112+ cx.notify();
113+ }
114+
74 /// Cycles the fit policy of the clip the picture is coming from -- the115 /// Cycles the fit policy of the clip the picture is coming from -- the
75 /// clicked one when it is a video clip, else the composite's own, exactly as116 /// clicked one when it is a video clip, else the composite's own, exactly as
76 /// the colour card picks its target. A whole card for one four-valued117 /// the colour card picks its target. A whole card for one four-valued
@@ -91,6 +132,7 @@ impl Player {
91 };132 };
92 let target = self133 let target = self
93 .selected134 .selected
135+ .anchor()
94 .filter(|(lane, _)| lane.kind == LaneKind::Video)136 .filter(|(lane, _)| lane.kind == LaneKind::Video)
95 .or_else(|| session.video_clip_at(session.now()));137 .or_else(|| session.video_clip_at(session.now()));
96 let Some((lane, idx)) = target else {138 let Some((lane, idx)) = target else {
crates/app/src/tests/editing.rsmodified+118 -24
@@ -261,12 +261,14 @@ fn every_audio_stream_of_a_file_is_a_row_usable_or_not() {
261 261
262 /// What the clip menu offers, and where it hangs. The two items that act on262 /// What the clip menu offers, and where it hangs. The two items that act on
263 /// the playhead rather than on the clicked clip are the ones that can be263 /// the playhead rather than on the clicked clip are the ones that can be
264-/// inapplicable, and a menu at the edge of the window has to come back264+/// inapplicable, and a menu at the edge of the window has to come back inside
265-/// inside it or its last item cannot be clicked at all.265+/// it or its last item cannot be clicked at all.
266-/// A caption's own menu, opened on a box that is not a clip: one row that acts266+///
267-/// on it -- Delete, which routes to `Player::lift_sub` -- the timeline's global267+/// A caption's own menu, opened on a box that is not a clip: the rows that act
268-/// item beside it, and nothing else drawn at all. What a placed subtitle used to268+/// on it -- Delete, which routes to `Player::lift_sub`, and the group pair now
269-/// have no menu, and no stroke, to do.269+/// that a caption may be grouped by hand -- the timeline's global items beside
270+/// them, and nothing else drawn at all. What a placed subtitle used to have no
271+/// menu, and no stroke, to do.
270 #[test]272 #[test]
271 fn a_caption_is_deleted_by_the_same_row_and_stroke_every_box_is() {273 fn a_caption_is_deleted_by_the_same_row_and_stroke_every_box_is() {
272 use keymap::ActionId;274 use keymap::ActionId;
@@ -281,26 +283,35 @@ fn a_caption_is_deleted_by_the_same_row_and_stroke_every_box_is() {
281 assert_eq!(283 assert_eq!(
282 enable(ActionId::Delete, cap),284 enable(ActionId::Delete, cap),
283 Enable::Yes,285 Enable::Yes,
284- "the one thing a placed caption can be asked to do",286+ "the one thing a placed caption could always be asked to do",
285- );287+ );
286- // The clip rows are refusals of *kind* on a caption, so the menu leaves them288+ // The clip rows are refusals of *kind* on a caption, so the menu leaves
287- // out rather than drawing "click a clip first" over a clicked box.289+ // them out rather than drawing "click a clip first" over a clicked box.
288- for clip_only in [290+ for clip_only in [ActionId::Copy, ActionId::Lift, ActionId::Equalizer] {
289- ActionId::Copy,
290- ActionId::Lift,
291- ActionId::Detach,
292- ActionId::Group,
293- ActionId::Equalizer,
294- ] {
295 assert_eq!(291 assert_eq!(
296 enable(clip_only, cap),292 enable(clip_only, cap),
297 Enable::Hidden("this is a caption"),293 Enable::Hidden("this is a caption"),
298 "{clip_only:?} is not a row on a caption",294 "{clip_only:?} is not a row on a caption",
299 );295 );
300 }296 }
301- // ...and the playhead's actions are *not* among them: the split and the297+ // The group rows are the caption's now: a caption out of any group says so
302- // regroup act at the line and the cards fall back to the clip under it, so a298+ // in the detach's own words, and Group over one pick is the partner hunt.
303- // caption in hand is no reason for them to go dead -- which, hidden, is299+ assert_eq!(
300+ enable(ActionId::Detach, cap),
301+ Enable::No("this caption is not grouped")
302+ );
303+ assert_eq!(enable(ActionId::Group, cap), Enable::Yes);
304+ // ...and a caption in a group detaches like a clip does.
305+ let grouped = Ctx {
306+ caption: true,
307+ caption_link: Some(3),
308+ timeline: true,
309+ ..Ctx::default()
310+ };
311+ assert_eq!(enable(ActionId::Detach, grouped), Enable::Yes);
312+ // ...and the playhead's actions are *not* refusals: the split and the
313+ // regroup act at the line and the cards fall back to the clip under it, so
314+ // a caption in hand is no reason for them to go dead -- which, hidden, is
304 // exactly what they went: `Player::act` returns without a word on `Hidden`,315 // exactly what they went: `Player::act` returns without a word on `Hidden`,
305 // and no click on the bed clears the mark that put them there.316 // and no click on the bed clears the mark that put them there.
306 for playhead in [317 for playhead in [
@@ -320,11 +331,17 @@ fn a_caption_is_deleted_by_the_same_row_and_stroke_every_box_is() {
320 // ...but live is not *listed*: every one of those rows reaches the clip331 // ...but live is not *listed*: every one of those rows reaches the clip
321 // under the playhead and not the caption, and a menu opened on a caption332 // under the playhead and not the caption, and a menu opened on a caption
322 // that offered a grade would read as the caption's. The caption's menu is333 // that offered a grade would read as the caption's. The caption's menu is
323- // its one row and the global pair the card already names as global.334+ // its own rows and the global pair the card already names as global.
324 assert_eq!(335 assert_eq!(
325 menu_items(cap),336 menu_items(cap),
326- vec![ActionId::Paste, ActionId::Delete, ActionId::ToggleMute],337+ vec![
327- "the caption's menu is its removal and the global rows alone",338+ ActionId::Paste,
339+ ActionId::Delete,
340+ ActionId::Detach,
341+ ActionId::Group,
342+ ActionId::ToggleMute,
343+ ],
344+ "the caption's menu is its removal, its group rows, and the global ones",
328 );345 );
329 // ...and the same reading with a clip under it is the clip menu, untouched:346 // ...and the same reading with a clip under it is the clip menu, untouched:
330 // the flag is off wherever a `Clip` was clicked.347 // the flag is off wherever a `Clip` was clicked.
@@ -353,6 +370,7 @@ fn one_second(start: u32) -> SubClip {
353 track: 0,370 track: 0,
354 in_us: 0,371 in_us: 0,
355 out_us: 1_000_000,372 out_us: 1_000_000,
373+ link: None,
356 }374 }
357 }375 }
358 376
@@ -434,6 +452,82 @@ fn a_caption_placed_before_the_marked_one_leaves_the_mark_on_the_original() {
434 );452 );
435 }453 }
436 454
455+/// A caption a hand grouped with a clip pairs it for the whole-take question:
456+/// deleting the picture takes the group, because the group -- not the lane's
457+/// kind -- is what pairs. The engine door is the one the menu's Group row
458+/// reaches (`group_all`), tested here from the selection's own side of it.
459+#[test]
460+fn a_caption_grouped_with_a_clip_pairs_it_for_the_whole_take_question() {
461+ let (mut session, lane) = with_subtitle_lane();
462+ session
463+ .place_sub(lane, 0, one_second(0))
464+ .expect("the caption goes down");
465+ session
466+ .group_all(&[(Lane::V1, 0), (lane, 0)])
467+ .expect("a clip and a caption are a group");
468+ // Paired through the caption alone: the sound half is gone (the fixture's
469+ // take was split above), and the question is the picture's to answer.
470+ assert!(
471+ whole_take(&session, Lane::V1, 0),
472+ "the caption the clip was grouped with pairs it"
473+ );
474+ // ...and the detach takes the pairing off again.
475+ assert!(session.ungroup(lane, 0));
476+ assert!(
477+ !whole_take(&session, Lane::V1, 0),
478+ "ungrouped, the clip is a half like any other"
479+ );
480+}
481+
482+/// The manual group's oracle question: a selection of placements, one per lane.
483+/// Two picks on two lanes is a group waiting to happen; a lane picked twice is
484+/// the one thing a group may never hold; a single pick is the partner hunt.
485+#[test]
486+fn group_is_live_over_a_multi_selection_and_words_a_repeated_lane() {
487+ use keymap::ActionId;
488+ let distinct = Ctx {
489+ timeline: true,
490+ picks: 2,
491+ pick_lanes: 2,
492+ ..Ctx::default()
493+ };
494+ assert_eq!(enable(ActionId::Group, distinct), Enable::Yes);
495+ let twice = Ctx {
496+ timeline: true,
497+ picks: 2,
498+ pick_lanes: 1,
499+ ..Ctx::default()
500+ };
501+ assert_eq!(
502+ enable(ActionId::Group, twice),
503+ Enable::No("a group is one clip per lane: keep one pick per track")
504+ );
505+ // One pick and none at all: the partner hunt and its own refusal, which
506+ // the player words rather than the oracle.
507+ let one = Ctx {
508+ timeline: true,
509+ picks: 1,
510+ pick_lanes: 1,
511+ ..Ctx::default()
512+ };
513+ assert_eq!(enable(ActionId::Group, one), Enable::Yes);
514+ // Nothing picked at all, on an open timeline: the partner hunt's own
515+ // refusal, worded by the player rather than the oracle.
516+ let none = Ctx {
517+ timeline: true,
518+ ..Ctx::default()
519+ };
520+ assert_eq!(enable(ActionId::Group, none), Enable::Yes);
521+ // Stale picks (an edit moved the indices) count as none.
522+ let stale = Ctx {
523+ timeline: true,
524+ picks: 0,
525+ pick_lanes: 0,
526+ ..Ctx::default()
527+ };
528+ assert_eq!(enable(ActionId::Group, stale), Enable::Yes);
529+}
530+
437 /// The playhead's actions with a caption marked: live, and doing what they say.531 /// The playhead's actions with a caption marked: live, and doing what they say.
438 /// Hidden, they were dead *and* silent -- `Player::act` says nothing on a class532 /// Hidden, they were dead *and* silent -- `Player::act` says nothing on a class
439 /// refusal -- from the first click on a caption until something else was533 /// refusal -- from the first click on a caption until something else was
@@ -1338,7 +1432,7 @@ fn a_row_dropped_on_the_open_bed_lands_under_the_pointer() {
1338 // bed: ten seconds in, five seconds past the end of the timeline, and1432 // bed: ten seconds in, five seconds past the end of the timeline, and
1339 // no mark anywhere near enough to pull it back.1433 // no mark anywhere near enough to pull it back.
1340 let clips = [session.lane_clips(Lane::V1), session.lane_clips(Lane::A1)];1434 let clips = [session.lane_clips(Lane::V1), session.lane_clips(Lane::A1)];
1341- let marks = snap_marks(&clips, None, frame_at(session.now(), fps));1435+ let marks = snap_marks(&clips, None, None, frame_at(session.now(), fps));
1342 let under = frame_at(scale.time_at(px_along(px(212.), bed)), fps);1436 let under = frame_at(scale.time_at(px_along(px(212.), bed)), fps);
1343 let (at, cue) = landing(under, 0, 0, true, scale.snap_frames(fps), &marks);1437 let (at, cue) = landing(under, 0, 0, true, scale.snap_frames(fps), &marks);
1344 assert_eq!((at, cue), (300, None), "the pointer is on frame 300");1438 assert_eq!((at, cue), (300, None), "the pointer is on frame 300");
crates/app/src/tests/layout.rsmodified+64 -8
@@ -266,22 +266,77 @@ fn a_lane_row_is_a_fixed_header_and_a_bed_that_can_be_hit() {
266 assert_eq!(lanes_h(2), 2. * LANE_H + 8.);266 assert_eq!(lanes_h(2), 2. * LANE_H + 8.);
267 }267 }
268 268
269+/// The selection itself: clicks in order, the anchor under the hand, the
270+/// toggle that assembles a group, and the plain click that replaces it all.
271+#[test]
272+fn a_selection_holds_its_picks_in_click_order_and_anchors_the_last() {
273+ use crate::Selection;
274+
275+ let mut sel = Selection::new();
276+ assert!(sel.is_empty());
277+ assert_eq!(sel.anchor(), None);
278+
279+ let (v, a, cap) = (
280+ (Lane::V1, 0),
281+ (Lane::A1, 1),
282+ (Lane::new(LaneKind::Subtitle, 0), 0),
283+ );
284+ sel.set_one(v);
285+ assert_eq!(sel.len(), 1);
286+ assert_eq!(sel.anchor(), Some(v));
287+
288+ // Ctrl-clicks join, in the order they were made.
289+ sel.toggle(a);
290+ sel.toggle(cap);
291+ assert_eq!(sel.picks(), &[v, a, cap]);
292+ assert_eq!(sel.anchor(), Some(cap), "the last pick is the anchor");
293+ assert!(sel.contains(a));
294+
295+ // ...and a ctrl-click on a pick already held takes it back out, leaving
296+ // the others where they were.
297+ sel.toggle(a);
298+ assert_eq!(sel.picks(), &[v, cap]);
299+ assert!(!sel.contains(a));
300+
301+ // A plain click is the whole selection, one pick: whatever was held gives
302+ // way to the thing just named.
303+ sel.set_one(a);
304+ assert_eq!(sel.picks(), &[a]);
305+
306+ // `add` joins without disturbing -- Select All's builder.
307+ let mut all = Selection::new();
308+ all.add(v);
309+ all.add(a);
310+ all.add(v);
311+ assert_eq!(all.picks(), &[v, a], "a pick is never held twice");
312+
313+ sel.clear();
314+ assert!(sel.is_empty());
315+ assert_eq!(sel.anchor(), None);
316+}
317+
269 #[test]318 #[test]
270 fn a_click_marks_the_whole_group_and_nothing_else() {319 fn a_click_marks_the_whole_group_and_nothing_else() {
271 let (v, a) = ((Lane::V1, 0), (Lane::A1, 0));320 let (v, a) = ((Lane::V1, 0), (Lane::A1, 0));
272- // Clicking the video half of group 1 marks the audio half with it.321+ // Clicking the video half of group 1 marks the audio half with it -- the
273- assert!(marked(v, Some(1), Some(v), Some(1)));322+ // pick, and everything sharing its link.
274- assert!(marked(a, Some(1), Some(v), Some(1)));323+ assert!(marked(v, Some(1), &[v], &[Some(1)]));
324+ assert!(marked(a, Some(1), &[v], &[Some(1)]));
275 // Another group's clips stay unmarked, in either lane.325 // Another group's clips stay unmarked, in either lane.
276- assert!(!marked((Lane::V1, 1), Some(2), Some(v), Some(1)));326+ assert!(!marked((Lane::V1, 1), Some(2), &[v], &[Some(1)]));
277- assert!(!marked((Lane::A1, 1), Some(2), Some(v), Some(1)));327+ assert!(!marked((Lane::A1, 1), Some(2), &[v], &[Some(1)]));
278 // A half a lift left behind has no group: it marks itself only, which328 // A half a lift left behind has no group: it marks itself only, which
279 // is what makes it separately deletable. Two ungrouped clips must not329 // is what makes it separately deletable. Two ungrouped clips must not
280 // mark each other by both being ungrouped.330 // mark each other by both being ungrouped.
281- assert!(marked(a, None, Some(a), None));331+ assert!(marked(a, None, &[a], &[None]));
282- assert!(!marked(v, None, Some(a), None));332+ assert!(!marked(v, None, &[a], &[None]));
333+ // A caption ctrl-clicked into the selection marks the clip it was pinned
334+ // to, and the caption is marked by the clip's pick just the same.
335+ let cap = (Lane::new(LaneKind::Subtitle, 0), 0);
336+ assert!(marked(cap, Some(1), &[cap, v], &[None, Some(1)]));
337+ assert!(marked(a, Some(1), &[cap, v], &[None, Some(1)]));
283 // Nothing selected marks nothing.338 // Nothing selected marks nothing.
284- assert!(!marked(v, Some(1), None, None));339+ assert!(!marked(v, Some(1), &[], &[]));
285 }340 }
286 341
287 #[test]342 #[test]
@@ -435,6 +490,7 @@ fn a_caption_trim_preview_lands_where_the_release_commits() {
435 track: 0,490 track: 0,
436 in_us: 0,491 in_us: 0,
437 out_us,492 out_us,
493+ link: None,
438 };494 };
439 session495 session
440 .place_sub(lane, 30, whole)496 .place_sub(lane, 30, whole)
crates/app/src/tests/media.rsmodified+1 -0
@@ -1085,6 +1085,7 @@ fn subtitles_arrive_beside_the_media_and_inside_it() {
1085 track: 0,1085 track: 0,
1086 in_us: 0,1086 in_us: 0,
1087 out_us: 5_000_000,1087 out_us: 5_000_000,
1088+ link: None,
1088 },1089 },
1089 )1090 )
1090 .expect("the palette row goes down on the lane");1091 .expect("the palette row goes down on the lane");
crates/app/src/tests/view.rsmodified+8 -7
@@ -164,20 +164,21 @@ fn the_marks_are_every_lane_the_playhead_and_the_start() {
164 let lanes: [&[Clip]; 2] = [&video, &audio];164 let lanes: [&[Clip]; 2] = [&video, &audio];
165 165
166 // Nothing in the hand: both lanes' edges, the playhead, and 0.166 // Nothing in the hand: both lanes' edges, the playhead, and 0.
167- let mut all = snap_marks(&lanes, None, 300);167+ let mut all = snap_marks(&lanes, None, None, 300);
168 all.sort_unstable();168 all.sort_unstable();
169 assert_eq!(all, [0, 100, 100, 160, 160, 300, 400, 430]);169 assert_eq!(all, [0, 100, 100, 160, 160, 300, 400, 430]);
170 170
171- // The video half in the hand: its own edges are gone, and so are its171+ // The video half in the hand, with its group named as the caller reads it
172- // group's on the other lane -- both boxes travel with the drag. The172+ // off the pick: its own edges are gone, and so are its group's on the
173- // lone audio clip is still a target, which is the whole point: a take173+ // other lane -- both boxes travel with the drag. The lone audio clip is
174- // being carried on V1 lands flush with a sound on A1.174+ // still a target, which is the whole point: a take being carried on V1
175- let mut carried = snap_marks(&lanes, Some((0, 0)), 300);175+ // lands flush with a sound on A1.
176+ let mut carried = snap_marks(&lanes, Some((0, 0)), Some(7), 300);
176 carried.sort_unstable();177 carried.sort_unstable();
177 assert_eq!(carried, [0, 300, 400, 430]);178 assert_eq!(carried, [0, 300, 400, 430]);
178 179
179 // An index that names no clip skips nothing and still answers.180 // An index that names no clip skips nothing and still answers.
180- assert_eq!(snap_marks(&[], Some((3, 9)), 0), [0, 0]);181+ assert_eq!(snap_marks(&[], Some((3, 9)), None, 0), [0, 0]);
181 }182 }
182 183
183 /// The line the bed draws, and the switch that turns the whole thing off.184 /// The line the bed draws, and the switch that turns the whole thing off.
crates/app/src/timeline_math.rsmodified+118 -19
@@ -5,7 +5,8 @@ use crate::*;
5 /// Whether this clip is a whole take, i.e. whether deleting it may close the5 /// Whether this clip is a whole take, i.e. whether deleting it may close the
6 /// hole under it: a take is what the first pair of lanes carries between them,6 /// hole under it: a take is what the first pair of lanes carries between them,
7 /// `V1`'s picture and the sound grouped with it, and dropping one moves the7 /// `V1`'s picture and the sound grouped with it, and dropping one moves the
8-/// frames after it on every lane.8+/// frames after it on every lane. A caption a hand grouped with the clip
9+/// counts as its partner too: the group is what pairs, not the lane's kind.
9 ///10 ///
10 /// Everything else is a half or a layer, and is *lifted* instead: a half whose11 /// Everything else is a half or a layer, and is *lifted* instead: a half whose
11 /// picture was lifted (what a lift leaves behind) has no take to ripple, and a12 /// picture was lifted (what a lift leaves behind) has no take to ripple, and a
@@ -20,8 +21,12 @@ pub(crate) fn whole_take(session: &PlaybackSession, lane: Lane, idx: usize) -> b
20 .lanes()21 .lanes()
21 .into_iter()22 .into_iter()
22 .filter(|&other| other != lane)23 .filter(|&other| other != lane)
23- .flat_map(|other| session.lane_clips(other))24+ .flat_map(|other| {
24- .any(|o| o.link.is_some() && o.link == clip.link)25+ let clips = session.lane_clips(other).iter().map(|c| c.link);
26+ let subs = session.sub_lane(other).iter().map(|s| s.link);
27+ clips.chain(subs)
28+ })
29+ .any(|link| link.is_some() && link == clip.link)
25 };30 };
26 match (lane.kind, lane.ord) {31 match (lane.kind, lane.ord) {
27 (_, 1..) => false,32 (_, 1..) => false,
@@ -69,19 +74,108 @@ pub(crate) fn span_partner(session: &PlaybackSession, lane: Lane, idx: usize) ->
69 opposite.into_iter().chain(same).find_map(matches)74 opposite.into_iter().chain(same).find_map(matches)
70 }75 }
71 76
72-/// Whether a click marks this clip: the clip that was clicked always, and the77+/// What the timeline has picked: every clip and caption a hand ctrl-clicked
73-/// other lane's clip of the same group with it. A clip whose group has no other78+/// into the selection, in click order and with no two the same. The last of
74-/// half -- what a lift leaves behind -- marks only itself, which is what makes a79+/// them is the [`anchor`](Selection::anchor) -- the one every action that is
75-/// detached half separately deletable.80+/// about *one* thing (delete, lift, copy, the equalizer) acts on -- and the
81+/// whole list is what a manual Group names to the engine.
82+///
83+/// Indices move under every edit, exactly as the single mark this replaces
84+/// did, so every edit that renumbers a lane clears the picks it cannot keep
85+/// honest. Pure and engine-free, so a test can build one without a window.
86+#[derive(Clone, Debug, Default, PartialEq)]
87+pub(crate) struct Selection {
88+ /// `(lane, index into that lane's own list)` -- a subtitle lane's index
89+ /// space for a caption, exactly the pair a click was told about.
90+ picks: Vec<(Lane, usize)>,
91+}
92+
93+impl Selection {
94+ /// Nothing picked: what the timeline starts as and what an edit that moved
95+ /// indices leaves behind.
96+ pub(crate) fn new() -> Self {
97+ Self::default()
98+ }
99+
100+ /// The one a plain click and every selection key leave: the whole of the
101+ /// selection, one pick. A click names a thing, and the things it had been
102+ /// naming along with it are no longer named.
103+ pub(crate) fn set_one(&mut self, pick: (Lane, usize)) {
104+ self.picks.clear();
105+ self.picks.push(pick);
106+ }
107+
108+ /// A ctrl-click: the pick joins the selection if it was not in it and
109+ /// leaves if it was -- the toggle that assembles a group by hand. The
110+ /// order is the order they were picked in, and the anchor rides on it.
111+ pub(crate) fn toggle(&mut self, pick: (Lane, usize)) {
112+ match self.picks.iter().position(|&p| p == pick) {
113+ Some(at) => {
114+ self.picks.remove(at);
115+ }
116+ None => self.picks.push(pick),
117+ }
118+ }
119+
120+ /// The last pick: what "the selected clip" is to every action that acts on
121+ /// one thing. The click order puts it under the hand, which is where the
122+ /// eye is.
123+ pub(crate) fn anchor(&self) -> Option<(Lane, usize)> {
124+ self.picks.last().copied()
125+ }
126+
127+ /// Whether `pick` is one of the selection's -- the question a right-click
128+ /// asks before it decides whether the menu is about the selection or
129+ /// about the clip under it.
130+ pub(crate) fn contains(&self, pick: (Lane, usize)) -> bool {
131+ self.picks.contains(&pick)
132+ }
133+
134+ /// Every pick, in click order: what a manual Group names to the engine.
135+ pub(crate) fn picks(&self) -> &[(Lane, usize)] {
136+ &self.picks
137+ }
138+
139+ pub(crate) fn is_empty(&self) -> bool {
140+ self.picks.is_empty()
141+ }
142+
143+ /// A pick that joins without disturbing the rest -- Select All's builder,
144+ /// which names every placement there is and cannot be a `set_one`.
145+ pub(crate) fn add(&mut self, pick: (Lane, usize)) {
146+ if !self.picks.contains(&pick) {
147+ self.picks.push(pick);
148+ }
149+ }
150+
151+ pub(crate) fn len(&self) -> usize {
152+ self.picks.len()
153+ }
154+
155+ pub(crate) fn clear(&mut self) {
156+ self.picks.clear();
157+ }
158+}
159+
160+/// Whether a click marks this box: any pick on it always, and any box sharing
161+/// a group id with a pick -- the clip the anchor was ctrl-clicked beside, and
162+/// the caption a hand pinned to a clip. A group whose only member is picked
163+/// marks that member alone, which is what makes a detached half separately
164+/// deletable.
165+///
166+/// `pick_links` are the group ids of the picks themselves, read by the caller
167+/// off the session in the same order as `picks` -- the one fact this pure
168+/// question cannot know.
76 pub(crate) fn marked(169 pub(crate) fn marked(
77 here: (Lane, usize),170 here: (Lane, usize),
78 link: Option<u32>,171 link: Option<u32>,
79- sel: Option<(Lane, usize)>,172+ picks: &[(Lane, usize)],
80- sel_link: Option<u32>,173+ pick_links: &[Option<u32>],
81 ) -> bool {174 ) -> bool {
82- sel == Some(here) || (link.is_some() && link == sel_link)175+ picks.contains(&here) || (link.is_some() && pick_links.contains(&link))
83 }176 }
84 177
178+
85 /// Whether a clip is wide enough to be worth naming.179 /// Whether a clip is wide enough to be worth naming.
86 pub(crate) fn show_label(w: f32) -> bool {180 pub(crate) fn show_label(w: f32) -> bool {
87 w >= LABEL_MIN_W181 w >= LABEL_MIN_W
@@ -368,18 +462,22 @@ pub(crate) fn snapped(raw: u32, len: u32, tol: u32, marks: &[u32]) -> u32 {
368 462
369 /// The edges worth landing on, off *every* lane: both ends of every clip on the463 /// The edges worth landing on, off *every* lane: both ends of every clip on the
370 /// timeline, less `skip` -- the clip being dragged, which does not snap to where464 /// timeline, less `skip` -- the clip being dragged, which does not snap to where
371-/// it already is -- and less the other halves of its group, which travel with465+/// it already is -- and less `skip_link`, the group id of whatever is being
372-/// it. `skip` is a lane's place in `lanes` and an index into it. The playhead466+/// dragged: its clips travel with it, and so does any caption the id names.
373-/// and the head of the timeline go on the end: a clip meets the cursor and the467+/// `skip` is a lane's place in `lanes` and an index into it; `skip_link` is
374-/// start of the show as readily as it meets another take.468+/// read off a caption by the caller, whose drag has no clip for `skip` to
469+/// name. The playhead and the head of the timeline go on the end: a clip meets
470+/// the cursor and the start of the show as readily as it meets another take.
375 ///471 ///
376 /// All lanes rather than the one being dropped on, because a cut is made across472 /// All lanes rather than the one being dropped on, because a cut is made across
377 /// the timeline: a title on V2 lines up with the shot under it, and a sound473 /// the timeline: a title on V2 lines up with the shot under it, and a sound
378 /// effect lines up with the frame it belongs to.474 /// effect lines up with the frame it belongs to.
379-pub(crate) fn snap_marks(lanes: &[&[Clip]], skip: Option<(usize, usize)>, playhead: u32) -> Vec<u32> {475+pub(crate) fn snap_marks(
380- let link = skip476+ lanes: &[&[Clip]],
381- .and_then(|(lane, idx)| lanes.get(lane)?.get(idx))477+ skip: Option<(usize, usize)>,
382- .and_then(|clip| clip.link);478+ skip_link: Option<u32>,
479+ playhead: u32,
480+) -> Vec<u32> {
383 let mut marks: Vec<u32> = lanes481 let mut marks: Vec<u32> = lanes
384 .iter()482 .iter()
385 .enumerate()483 .enumerate()
@@ -388,7 +486,8 @@ pub(crate) fn snap_marks(lanes: &[&[Clip]], skip: Option<(usize, usize)>, playhe
388 .iter()486 .iter()
389 .enumerate()487 .enumerate()
390 .filter(move |&(idx, clip)| {488 .filter(move |&(idx, clip)| {
391- Some((lane, idx)) != skip && !(link.is_some() && clip.link == link)489+ Some((lane, idx)) != skip
490+ && !(skip_link.is_some() && clip.link == skip_link)
392 })491 })
393 .flat_map(|(_, clip)| [clip.start, clip.end()])492 .flat_map(|(_, clip)| [clip.start, clip.end()])
394 })493 })
crates/app/src/ui/inspector.rsmodified+14 -2
@@ -91,7 +91,7 @@ impl Player {
91 /// with nothing marked the section says how to get one, and each button is91 /// with nothing marked the section says how to get one, and each button is
92 /// dimmed with the oracle's reason rather than missing.92 /// dimmed with the oracle's reason rather than missing.
93 fn selection_section(&self, cx: &mut Context<Self>) -> impl IntoElement {93 fn selection_section(&self, cx: &mut Context<Self>) -> impl IntoElement {
94- let picked = self.selected.and_then(|(lane, idx)| {94+ let picked = self.selected.anchor().and_then(|(lane, idx)| {
95 let session = self.session.as_ref()?;95 let session = self.session.as_ref()?;
96 let clip = session.lane_clips(lane).get(idx).copied()?;96 let clip = session.lane_clips(lane).get(idx).copied()?;
97 let source = session.sources().get(clip.source);97 let source = session.sources().get(clip.source);
@@ -107,15 +107,27 @@ impl Player {
107 // marked caption -- while the bed draws that caption in the selection's107 // marked caption -- while the bed draws that caption in the selection's
108 // own colours and this panel's Delete lifts it. The panel says what is108 // own colours and this panel's Delete lifts it. The panel says what is
109 // marked or it is telling the user the opposite of what they can see.109 // marked or it is telling the user the opposite of what they can see.
110- let caption = self.selected.filter(|_| picked.is_none()).and_then(|(lane, idx)| {110+ let caption = self
111+ .selected
112+ .anchor()
113+ .filter(|_| picked.is_none())
114+ .and_then(|(lane, idx)| {
111 let sub = self.session.as_ref()?.sub_lane(lane).get(idx).copied()?;115 let sub = self.session.as_ref()?.sub_lane(lane).get(idx).copied()?;
112 Some((lane, sub))116 Some((lane, sub))
113 });117 });
118+ // A multi-selection is named for its anchor and counted: what the
119+ // panel shows is the anchor's settings, and the count says there is
120+ // more in hand than the panel is showing.
121+ let more = self.selected.len().saturating_sub(1);
114 let head = match (&picked, &caption) {122 let head = match (&picked, &caption) {
115 (Some((lane, _, name, _)), _) => format!("{} · {}", lane.label(), name),123 (Some((lane, _, name, _)), _) => format!("{} · {}", lane.label(), name),
116 (None, Some((lane, _))) => format!("{} · caption", lane.label()),124 (None, Some((lane, _))) => format!("{} · caption", lane.label()),
117 (None, None) => "Nothing selected".to_string(),125 (None, None) => "Nothing selected".to_string(),
118 };126 };
127+ let head = match more {
128+ 0 => head,
129+ n => format!("{head} · and {n} more picked"),
130+ };
119 let detail = match &picked {131 let detail = match &picked {
120 Some((_, clip, _, _)) => format!(132 Some((_, clip, _, _)) => format!(
121 "{} → {} · {} · {}",133 "{} → {} · {} · {}",
crates/app/src/ui/timeline.rsmodified+43 -14
@@ -596,13 +596,20 @@ impl Player {
596 // The group ids some *other* lane carries: a clip whose id is in here596 // The group ids some *other* lane carries: a clip whose id is in here
597 // has a half elsewhere, and one whose is not is a detached half however597 // has a half elsewhere, and one whose is not is a detached half however
598 // many lanes there are.598 // many lanes there are.
599+ // The group ids some *other* lane carries, on either of its lists: a
600+ // placement whose id is in here has a half elsewhere -- a clip on
601+ // another track, or a caption pinned to this clip -- and one whose is
602+ // not is detached however many lanes there are.
599 let others: Vec<u32> = self.session.as_ref().map_or_else(Vec::new, |session| {603 let others: Vec<u32> = self.session.as_ref().map_or_else(Vec::new, |session| {
600 session604 session
601 .lanes()605 .lanes()
602 .into_iter()606 .into_iter()
603 .filter(|&other| other != lane)607 .filter(|&other| other != lane)
604- .flat_map(|other| session.lane_clips(other))608+ .flat_map(|other| {
605- .filter_map(|clip| clip.link)609+ let clips = session.lane_clips(other).iter().filter_map(|c| c.link);
610+ let subs = session.sub_lane(other).iter().filter_map(|s| s.link);
611+ clips.chain(subs)
612+ })
606 .collect()613 .collect()
607 });614 });
608 let name = lane.label();615 let name = lane.label();
@@ -629,7 +636,7 @@ impl Player {
629 .session636 .session
630 .as_ref()637 .as_ref()
631 .map_or(&[][..], PlaybackSession::sources);638 .map_or(&[][..], PlaybackSession::sources);
632- let (sel, sel_link) = (self.selected, self.selected_link());639+ let (picks, pick_links) = self.marks();
633 let audio = lane.kind == LaneKind::Audio;640 let audio = lane.kind == LaneKind::Audio;
634 // A subtitle lane holds no `Clip` and every other lane holds no641 // A subtitle lane holds no `Clip` and every other lane holds no
635 // `SubClip`, so the two lists below are never both full and the bed642 // `SubClip`, so the two lists below are never both full and the bed
@@ -964,7 +971,7 @@ impl Player {
964 f64::from(clip.start) / self.fps,971 f64::from(clip.start) / self.fps,
965 f64::from(clip.frames()) / self.fps,972 f64::from(clip.frames()) / self.fps,
966 );973 );
967- let on = marked((lane, i), clip.link, sel, sel_link);974+ let on = marked((lane, i), clip.link, &picks, &pick_links);
968 // A group with a half in the other lane wears its tint;975 // A group with a half in the other lane wears its tint;
969 // one without is outlined, so a detached half is visible976 // one without is outlined, so a detached half is visible
970 // as detached before anyone clicks it.977 // as detached before anyone clicks it.
@@ -1074,7 +1081,10 @@ impl Player {
1074 // than jump its head under it.1081 // than jump its head under it.
1075 this.grab =1082 this.grab =
1076 this.frame_under(event.position.x).saturating_sub(head);1083 this.frame_under(event.position.x).saturating_sub(head);
1077- this.select((lane, i), cx);1084+ // Ctrl held, the pick joins the selection
1085+ // instead of replacing it -- the toggle a
1086+ // group is assembled by hand with.
1087+ this.pick((lane, i), event.modifiers.control, cx);
1078 }),1088 }),
1079 )1089 )
1080 // The right button selects exactly as the left one1090 // The right button selects exactly as the left one
@@ -1115,8 +1125,14 @@ impl Player {
1115 .on_mouse_down(1125 .on_mouse_down(
1116 MouseButton::Left,1126 MouseButton::Left,
1117 cx.listener(1127 cx.listener(
1118- move |this, _: &MouseDownEvent, _, cx| {1128+ move |this, event: &MouseDownEvent, _, cx| {
1119- this.start_trim(lane, i, edge, cx);1129+ this.start_trim(
1130+ lane,
1131+ i,
1132+ edge,
1133+ event.modifiers.control,
1134+ cx,
1135+ );
1120 },1136 },
1121 ),1137 ),
1122 )1138 )
@@ -1277,9 +1293,13 @@ impl Player {
1277 let tip = sub_tip.clone();1293 let tip = sub_tip.clone();
1278 let head = shown_sub.start;1294 let head = shown_sub.start;
1279 // Marked the way every other box on this bed is marked,1295 // Marked the way every other box on this bed is marked,
1280- // in this lane's own index space -- a caption has no1296+ // in this lane's own index space -- and a caption in a
1281- // group, so nothing else lights with it.1297+ // group lights with the clips it was pinned to, exactly
1282- let on = sel == Some((lane, i));1298+ // as a clip lights with its halves.
1299+ let on = marked((lane, i), placed.link, &picks, &pick_links);
1300+ // ...and wears the group's border rather than a lone
1301+ // box's, so what travels together reads together.
1302+ let grouped = placed.link.is_some_and(|link| others.contains(&link));
1283 div()1303 div()
1284 .id((row_id.clone(), i))1304 .id((row_id.clone(), i))
1285 .absolute()1305 .absolute()
@@ -1292,6 +1312,8 @@ impl Player {
1292 .border_1()1312 .border_1()
1293 .border_color(rgb(if on {1313 .border_color(rgb(if on {
1294 STROKE_SELECTED()1314 STROKE_SELECTED()
1315+ } else if grouped {
1316+ ACCENT_PRIMARY()
1295 } else {1317 } else {
1296 FG_SECONDARY()1318 FG_SECONDARY()
1297 }))1319 }))
@@ -1325,8 +1347,9 @@ impl Player {
1325 // ...and it marks the caption, exactly as1347 // ...and it marks the caption, exactly as
1326 // the press that may become a clip's drag1348 // the press that may become a clip's drag
1327 // marks the clip: picking a caption up and1349 // marks the clip: picking a caption up and
1328- // putting it back down is a click.1350+ // putting it back down is a click. Ctrl
1329- this.select((lane, i), cx);1351+ // toggles it into the selection like a clip.
1352+ this.pick((lane, i), event.modifiers.control, cx);
1330 }),1353 }),
1331 )1354 )
1332 // The right button marks it and hangs the menu at1355 // The right button marks it and hangs the menu at
@@ -1358,8 +1381,14 @@ impl Player {
1358 .on_mouse_down(1381 .on_mouse_down(
1359 MouseButton::Left,1382 MouseButton::Left,
1360 cx.listener(1383 cx.listener(
1361- move |this, _: &MouseDownEvent, _, cx| {1384+ move |this, event: &MouseDownEvent, _, cx| {
1362- this.start_trim(lane, i, edge, cx);1385+ this.start_trim(
1386+ lane,
1387+ i,
1388+ edge,
1389+ event.modifiers.control,
1390+ cx,
1391+ );
1363 },1392 },
1364 ),1393 ),
1365 )1394 )
crates/engine/tests/export.rsmodified+1 -1
@@ -1010,7 +1010,7 @@ fn a_proxy_is_picture_only_every_frame_a_starting_point_and_cached() {
1010 session.set_proxies(true);1010 session.set_proxies(true);
1011 session.save_project(&project).expect("save");1011 session.save_project(&project).expect("save");
1012 let text = std::fs::read_to_string(&project).expect("read the project back");1012 let text = std::fs::read_to_string(&project).expect("read the project back");
1013- assert!(text.starts_with("edith 15\n"), "{text}");1013+ assert!(text.starts_with("edith 16\n"), "{text}");
1014 assert!(text.contains("\nproxy on\n"), "{text}");1014 assert!(text.contains("\nproxy on\n"), "{text}");
1015 let reopened = PlaybackSession::open_project(&project).expect("load");1015 let reopened = PlaybackSession::open_project(&project).expect("load");
1016 assert!(reopened.proxies(), "the switch came back on");1016 assert!(reopened.proxies(), "the switch came back on");
crates/engine/tests/export_subs.rsmodified+1 -0
@@ -826,6 +826,7 @@ fn on_lanes(tracks: Vec<SubtitleTrack>, placed: &[(usize, u32, u32, i64, i64)])
826 track,826 track,
827 in_us,827 in_us,
828 out_us,828 out_us,
829+ link: None,
829 },830 },
830 )831 )
831 .expect("the lane is empty, so the placement lands");832 .expect("the lane is empty, so the placement lands");
crates/engine/tests/lanes.rsmodified+2 -0
@@ -449,6 +449,7 @@ fn a_subtitle_lane_is_a_peer_and_every_media_path_refuses_it() {
449 track: 0,449 track: 0,
450 in_us: 0,450 in_us: 0,
451 out_us: 2_000_000,451 out_us: 2_000_000,
452+ link: None,
452 };453 };
453 project.place_sub(s1, 0, caption).expect("a caption goes down");454 project.place_sub(s1, 0, caption).expect("a caption goes down");
454 455
@@ -541,6 +542,7 @@ fn a_paste_opens_its_room_under_the_captions_too() {
541 track: 0,542 track: 0,
542 in_us: 0,543 in_us: 0,
543 out_us: 2_000_000,544 out_us: 2_000_000,
545+ link: None,
544 },546 },
545 )547 )
546 .expect("a caption over the first two seconds");548 .expect("a caption over the first two seconds");
crates/engine/tests/pgs_bitmaps.rsmodified+1 -0
@@ -98,6 +98,7 @@ fn the_session_maps_a_pgs_track_onto_the_timeline_and_draws_it() {
98 track: pick,98 track: pick,
99 in_us: cues[0].start_us,99 in_us: cues[0].start_us,
100 out_us: cues[0].end_us,100 out_us: cues[0].end_us,
101+ link: None,
101 },102 },
102 )103 )
103 .expect("the lane is empty, so the placement lands");104 .expect("the lane is empty, so the placement lands");
crates/engine/tests/saveload.rsmodified+6 -6
@@ -291,7 +291,7 @@ fn a_version_1_project_loads_fully_grouped_and_saves_as_version_7() {
291 let v2 = dir.join("new.edith");291 let v2 = dir.join("new.edith");
292 loaded.save_project(&v2).expect("save");292 loaded.save_project(&v2).expect("save");
293 let text = std::fs::read_to_string(&v2).expect("read back");293 let text = std::fs::read_to_string(&v2).expect("read back");
294- assert!(text.starts_with("edith 15\n"), "{text}");294+ assert!(text.starts_with("edith 16\n"), "{text}");
295 assert!(295 assert!(
296 text.contains("\nresolution 1280 720\n"),296 text.contains("\nresolution 1280 720\n"),
297 "a project with no resolution of its own is saved at source 0's: {text}"297 "a project with no resolution of its own is saved at source 0's: {text}"
@@ -379,7 +379,7 @@ fn a_version_4_project_holds_more_than_two_lanes() {
379 loaded.save_project(&again).expect("save");379 loaded.save_project(&again).expect("save");
380 assert_eq!(380 assert_eq!(
381 std::fs::read_to_string(&again).expect("read back"),381 std::fs::read_to_string(&again).expect("read back"),
382- "edith 15\nplayhead 0\nresolution 1280 720\nfps 30.0\nsource 0 test_av.mp4\n\382+ "edith 16\nplayhead 0\nresolution 1280 720\nfps 30.0\nsource 0 test_av.mp4\n\
383 video 1 0 0 30 0 3 - - fit 1000\naudio 1\n\383 video 1 0 0 30 0 3 - - fit 1000\naudio 1\n\
384 video 2 40 0 20 0 - - - fit 1000\naudio 2 0 0 30 0 3 - - fit 1000\n",384 video 2 40 0 20 0 - - - fit 1000\naudio 2 0 0 30 0 3 - - fit 1000\n",
385 "a four-lane project is written as it was read, three versions on"385 "a four-lane project is written as it was read, three versions on"
@@ -409,7 +409,7 @@ fn a_version_5_project_carries_per_clip_equalizers() {
409 loaded.save_project(&again).expect("save");409 loaded.save_project(&again).expect("save");
410 assert_eq!(410 assert_eq!(
411 std::fs::read_to_string(&again).expect("read back"),411 std::fs::read_to_string(&again).expect("read back"),
412- "edith 15\nplayhead 0\nresolution 1280 720\nfps 30.0\nsource 0 test_av.mp4\n\412+ "edith 16\nplayhead 0\nresolution 1280 720\nfps 30.0\nsource 0 test_av.mp4\n\
413 eq 80.0:-3.0:0.707:ls 1000.0:4.5:1.0:pk\n\413 eq 80.0:-3.0:0.707:ls 1000.0:4.5:1.0:pk\n\
414 eq 12000.0:6.25:0.5:hs\n\414 eq 12000.0:6.25:0.5:hs\n\
415 video 1 0 0 30 0 - 0 - fit 1000\nvideo 1 30 30 60 0 - 1 - fit 1000\n\415 video 1 0 0 30 0 - 0 - fit 1000\nvideo 1 30 30 60 0 - 1 - fit 1000\n\
@@ -444,7 +444,7 @@ fn a_version_6_project_carries_per_clip_colours() {
444 loaded.save_project(&again).expect("save");444 loaded.save_project(&again).expect("save");
445 assert_eq!(445 assert_eq!(
446 std::fs::read_to_string(&again).expect("read back"),446 std::fs::read_to_string(&again).expect("read back"),
447- "edith 15\nplayhead 0\nresolution 1280 720\nfps 30.0\nsource 0 test_av.mp4\n\447+ "edith 16\nplayhead 0\nresolution 1280 720\nfps 30.0\nsource 0 test_av.mp4\n\
448 eq 80.0:-3.0:0.707:ls\n\448 eq 80.0:-3.0:0.707:ls\n\
449 color 0.1:1.2:0.9:-0.3\n\449 color 0.1:1.2:0.9:-0.3\n\
450 color -0.25:1.0:0.0:0.5\n\450 color -0.25:1.0:0.0:0.5\n\
@@ -494,7 +494,7 @@ fn a_version_7_project_carries_a_resolution_and_fit_policies() {
494 loaded.save_project(&again).expect("save");494 loaded.save_project(&again).expect("save");
495 assert_eq!(495 assert_eq!(
496 std::fs::read_to_string(&again).expect("read back"),496 std::fs::read_to_string(&again).expect("read back"),
497- "edith 15\nplayhead 0\nresolution 960 720\nfps 30.0\nsource 0 test_av.mp4\n\497+ "edith 16\nplayhead 0\nresolution 960 720\nfps 30.0\nsource 0 test_av.mp4\n\
498 video 1 0 0 30 0 - - - fill 1000\nvideo 1 30 30 60 0 - - - center 1000\n\498 video 1 0 0 30 0 - - - fill 1000\nvideo 1 30 30 60 0 - - - center 1000\n\
499 audio 1 0 0 60 0 - - - fit 1000\n",499 audio 1 0 0 60 0 - - - fit 1000\n",
500 "a v7 project is written back as the v8 it now is: the same clips, each \500 "a v7 project is written back as the v8 it now is: the same clips, each \
@@ -752,7 +752,7 @@ fn malformed_files_are_numbered_errors_and_never_panics() {
752 752
753 for (text, want) in [753 for (text, want) in [
754 (754 (
755- "edith 16\nsource 0 test_av.mp4\nvideo 1 0 0 30 0 - - - fit\n",755+ "edith 17\nsource 0 test_av.mp4\nvideo 1 0 0 30 0 - - - fit\n",
756 "line 1",756 "line 1",
757 ),757 ),
758 // An eq index the table does not hold, and a band shape there is none.758 // An eq index the table does not hold, and a band shape there is none.
crates/engine/tests/silence.rsmodified+1 -1
@@ -386,7 +386,7 @@ fn scanning_a_clip_and_cutting_what_it_finds() {
386 .expect("save");386 .expect("save");
387 let text = std::fs::read_to_string(&file).expect("read it back");387 let text = std::fs::read_to_string(&file).expect("read it back");
388 assert!(388 assert!(
389- text.starts_with("edith 15"),389+ text.starts_with("edith 16"),
390 "{:?}",390 "{:?}",
391 &text[..16.min(text.len())]391 &text[..16.min(text.len())]
392 );392 );
crates/engine/tests/subtitles.rsmodified+13 -5
@@ -260,7 +260,7 @@ fn a_project_keeps_its_subtitles_across_a_save() {
260 let project = dir.join("cut.edith");260 let project = dir.join("cut.edith");
261 session.save_project(&project).expect("save");261 session.save_project(&project).expect("save");
262 let text = std::fs::read_to_string(&project).expect("read the project back");262 let text = std::fs::read_to_string(&project).expect("read the project back");
263- assert!(text.starts_with("edith 15\n"), "{text}");263+ assert!(text.starts_with("edith 16\n"), "{text}");
264 assert!(264 assert!(
265 text.contains("\nsubtitle - test_subs.srt\n"),265 text.contains("\nsubtitle - test_subs.srt\n"),
266 "the reference is written relative, and no cue is: {text}"266 "the reference is written relative, and no cue is: {text}"
@@ -722,6 +722,7 @@ fn whole(track: usize) -> SubClip {
722 track,722 track,
723 in_us: 0,723 in_us: 0,
724 out_us: 5_000_000,724 out_us: 5_000_000,
725+ link: None,
725 }726 }
726 }727 }
727 728
@@ -754,6 +755,7 @@ fn a_caption_is_placed_trimmed_moved_and_undone_on_its_lane() {
754 track: 0,755 track: 0,
755 in_us: 0,756 in_us: 0,
756 out_us: 2_000_000,757 out_us: 2_000_000,
758+ link: None,
757 }759 }
758 );760 );
759 761
@@ -770,6 +772,7 @@ fn a_caption_is_placed_trimmed_moved_and_undone_on_its_lane() {
770 track: 0,772 track: 0,
771 in_us: 500_000,773 in_us: 500_000,
772 out_us: 2_000_000,774 out_us: 2_000_000,
775+ link: None,
773 }776 }
774 );777 );
775 778
@@ -785,6 +788,7 @@ fn a_caption_is_placed_trimmed_moved_and_undone_on_its_lane() {
785 track: 0,788 track: 0,
786 in_us: 500_000,789 in_us: 500_000,
787 out_us: 2_000_000,790 out_us: 2_000_000,
791+ link: None,
788 }792 }
789 );793 );
790 794
@@ -805,6 +809,7 @@ fn a_caption_is_placed_trimmed_moved_and_undone_on_its_lane() {
805 track: 0,809 track: 0,
806 in_us: 500_000,810 in_us: 500_000,
807 out_us: 2_000_000,811 out_us: 2_000_000,
812+ link: None,
808 },813 },
809 SubClip {814 SubClip {
810 start: 30,815 start: 30,
@@ -812,8 +817,10 @@ fn a_caption_is_placed_trimmed_moved_and_undone_on_its_lane() {
812 track: 0,817 track: 0,
813 in_us: 0,818 in_us: 0,
814 out_us: 2_000_000,819 out_us: 2_000_000,
820+ link: None,
815 },821 },
816 SubClip {822 SubClip {
823+ link: None,
817 start: 30,824 start: 30,
818 ..whole(0)825 ..whole(0)
819 },826 },
@@ -1237,13 +1244,14 @@ fn subtitle_lanes_and_their_captions_survive_a_save() {
1237 track: 0,1244 track: 0,
1238 in_us: 500_000,1245 in_us: 500_000,
1239 out_us: 1_500_000,1246 out_us: 1_500_000,
1247+ link: None,
1240 };1248 };
1241 session.place_sub(s1, 10, caption).expect("a caption goes down");1249 session.place_sub(s1, 10, caption).expect("a caption goes down");
1242 1250
1243 let project = dir.join("cut.edith");1251 let project = dir.join("cut.edith");
1244 session.save_project(&project).expect("save");1252 session.save_project(&project).expect("save");
1245 let text = std::fs::read_to_string(&project).expect("read the project back");1253 let text = std::fs::read_to_string(&project).expect("read the project back");
1246- assert!(text.starts_with("edith 15\n"), "{text}");1254+ assert!(text.starts_with("edith 16\n"), "{text}");
1247 assert!(1255 assert!(
1248 text.contains("\nsub 1 10 45 0 500000 1500000\n"),1256 text.contains("\nsub 1 10 45 0 500000 1500000\n"),
1249 "the placement is one line: where it sits, how long, whose words, and \1257 "the placement is one line: where it sits, how long, whose words, and \
@@ -1309,7 +1317,7 @@ fn a_version_14_project_keeps_its_palette_and_places_nothing() {
1309 let now = dir.join("new.edith");1317 let now = dir.join("new.edith");
1310 loaded.save_project(&now).expect("save");1318 loaded.save_project(&now).expect("save");
1311 let text = std::fs::read_to_string(&now).expect("read back");1319 let text = std::fs::read_to_string(&now).expect("read back");
1312- assert!(text.starts_with("edith 15\n"), "{text}");1320+ assert!(text.starts_with("edith 16\n"), "{text}");
1313 assert!(1321 assert!(
1314 text.contains("\nsubtitle - test_subs.srt\n"),1322 text.contains("\nsubtitle - test_subs.srt\n"),
1315 "the row survives the migration: {text}"1323 "the row survives the migration: {text}"
@@ -1334,7 +1342,7 @@ fn a_caption_naming_a_track_the_palette_does_not_have_is_refused() {
1334 let path = dir.join("bad.edith");1342 let path = dir.join("bad.edith");
1335 std::fs::write(1343 std::fs::write(
1336 &path,1344 &path,
1337- "edith 15\nplayhead 0\nresolution 1280 720\nfps 30.0\nsource 0 test_av.mp4\n\1345+ "edith 16\nplayhead 0\nresolution 1280 720\nfps 30.0\nsource 0 test_av.mp4\n\
1338 subtitle - test_subs.srt\nvideo 1 0 0 30 0 0 - - fit 1000\n\1346 subtitle - test_subs.srt\nvideo 1 0 0 30 0 0 - - fit 1000\n\
1339 audio 1 0 0 30 0 0 - - fit 1000\nsub 1 0 45 3 0 1000000\n",1347 audio 1 0 0 30 0 0 - - fit 1000\nsub 1 0 45 3 0 1000000\n",
1340 )1348 )
@@ -1349,7 +1357,7 @@ fn a_caption_naming_a_track_the_palette_does_not_have_is_refused() {
1349 let empty = dir.join("empty.edith");1357 let empty = dir.join("empty.edith");
1350 std::fs::write(1358 std::fs::write(
1351 &empty,1359 &empty,
1352- "edith 15\nplayhead 0\nresolution 1280 720\nfps 30.0\nsource 0 test_av.mp4\n\1360+ "edith 16\nplayhead 0\nresolution 1280 720\nfps 30.0\nsource 0 test_av.mp4\n\
1353 subtitle - test_subs.srt\nvideo 1 0 0 30 0 0 - - fit 1000\n\1361 subtitle - test_subs.srt\nvideo 1 0 0 30 0 0 - - fit 1000\n\
1354 audio 1 0 0 30 0 0 - - fit 1000\nsub 1 0 45 0 1000000 1000000\n",1362 audio 1 0 0 30 0 0 - - fit 1000\nsub 1 0 45 0 1000000 1000000\n",
1355 )1363 )