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 {
9696 pub(crate) lane: Lane,
9797 pub(crate) idx: usize,
9898 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,
99103 /// Already clamped by `PlaybackSession::trim_room`, so the width drawn from
100104 /// it is the width the release commits -- an edge stops under the pointer
101105 /// rather than snapping back after the fact.
102106 pub(crate) to: u32,
103- /// The dragged clip's group, so its other halves' boxes follow the edge on
104- /// screen exactly as the engine will move them.
107+ /// The dragged placement's group, so the boxes of everything it names --
108+ /// clips and captions alike -- follow the edge on screen exactly as the
109+ /// engine will move them.
105110 pub(crate) link: Option<u32>,
106111 }
107112
crates/app/src/keymap.rsmodified+25 -7
@@ -86,6 +86,10 @@ actions! {
8686 Select,
8787 SelectNext,
8888 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,
8993 Delete,
9094 Lift,
9195 Color,
@@ -159,11 +163,12 @@ impl ActionId {
159163 // Neither half's action: it takes the *pair* apart, and the menu
160164 // that offers it hangs on whichever half was right-clicked -- worded
161165 // from the picture's side it read as a video item on an audio clip.
162- ActionId::Detach => "Ungroup the picture and the sound",
163- ActionId::Group => "Group with the clip on another track",
166+ ActionId::Detach => "Ungroup the selection (clips and captions)",
167+ ActionId::Group => "Group the selection (ctrl-click the clips first)",
164168 ActionId::Select => "Select the clip under the playhead (again for the next lane)",
165169 ActionId::SelectNext => "Select the next clip in the lane",
166170 ActionId::SelectPrev => "Select the previous clip in the lane",
171+ ActionId::SelectAll => "Select everything (every clip and caption)",
167172 ActionId::Delete => "Delete",
168173 ActionId::Lift => "Lift (leave a gap)",
169174 ActionId::Color => "Colour…",
@@ -221,6 +226,7 @@ impl ActionId {
221226 ActionId::Select => "select",
222227 ActionId::SelectNext => "select-next",
223228 ActionId::SelectPrev => "select-prev",
229+ ActionId::SelectAll => "select-all",
224230 ActionId::Delete => "delete",
225231 ActionId::Lift => "lift",
226232 ActionId::Color => "color",
@@ -277,6 +283,7 @@ impl ActionId {
277283 | ActionId::Select
278284 | ActionId::SelectNext
279285 | ActionId::SelectPrev
286+ | ActionId::SelectAll
280287 | ActionId::Delete
281288 | ActionId::Lift
282289 | ActionId::Color
@@ -776,6 +783,11 @@ impl Keymap {
776783 b(ActionId::Select, "tab", false),
777784 b(ActionId::SelectNext, "]", false),
778785 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),
779791 b(ActionId::Delete, "x", false),
780792 b(ActionId::Delete, "delete", false),
781793 b(ActionId::Lift, "l", false),
@@ -811,7 +823,10 @@ impl Keymap {
811823 // matching initial and is the paste, so the video one takes the
812824 // key beside it.
813825 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),
815830 // The subtitle pair reads the same way: the unshifted initial
816831 // adds one -- "s" is free, the save is the *ctrl* chord -- and a
817832 // ctrl chord takes it back. Ctrl+s is that save, so the removal
@@ -862,7 +877,7 @@ impl Keymap {
862877 // Making them takes the key next to it, ctrl+o: the pair is one
863878 // subject and the two chords are under the same finger, and
864879 // 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).
866881 b(ActionId::ToggleAutoProxies, "o", true),
867882 // The theme takes ctrl+h -- the h of the word, since "t" is the
868883 // subtitles and ctrl+t takes one off -- and a ctrl chord because
@@ -1143,7 +1158,7 @@ mod tests {
11431158 #[test]
11441159 fn every_default_stroke_reaches_its_action() {
11451160 let k = Keymap::defaults();
1146- assert_eq!(k.entries().len(), 52);
1161+ assert_eq!(k.entries().len(), 53);
11471162 assert_eq!(k.lookup("p", true), Some(ActionId::ToggleProxies));
11481163 assert_eq!(k.lookup("o", true), Some(ActionId::ToggleAutoProxies));
11491164 assert_eq!(k.lookup("f1", false), Some(ActionId::ShowActions));
@@ -1189,9 +1204,12 @@ mod tests {
11891204 assert_eq!(k.lookup("v", false), Some(ActionId::AddVideoLane));
11901205 assert_eq!(k.lookup("a", false), Some(ActionId::AddAudioLane));
11911206 // ...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.
11931210 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));
11951213 // The subtitle pair, the third kind of track: the initial adds and the
11961214 // subtitle letter's chord takes it back.
11971215 assert_eq!(k.lookup("s", false), Some(ActionId::AddSubtitleLane));
crates/app/src/main.rsmodified+8 -6
@@ -116,11 +116,13 @@ struct Player {
116116 /// the head is on screen again, and by every transport ask (a seek, a
117117 /// play/pause) outright -- those are a person saying where to look.
118118 panned: bool,
119- /// Which clip the edit keys act on: the lane it is in and its index there.
120- /// The *clicked* half, not the group -- a group is what gets marked on
121- /// screen, but Lift has to know which half it was aimed at. Indices move
122- /// under every edit, so this is cleared by all of them.
123- selected: Option<(Lane, usize)>,
119+ /// Which placements the edit keys act on: the lane each is in and its
120+ /// index there, every ctrl-click in the order it was made. The *clicked*
121+ /// half and not the group -- a group is what gets marked on screen, but
122+ /// Lift has to know which half it was aimed at -- and the last pick is the
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,
124126 /// The clip menu a right-click opened, if one is up. Holds an index like
125127 /// `selected` does, so it is closed by anything that can move indices --
126128 /// every stroke, and every item of its own.
@@ -660,7 +662,7 @@ fn main() {
660662 // Nobody has scrolled anything yet, so the follow has the
661663 // view: the first frame is drawn where the head is.
662664 panned: false,
663- selected: None,
665+ selected: Selection::new(),
664666 context_menu: None,
665667 picker: None,
666668 library_menu: None,
crates/app/src/oracle.rsmodified+43 -17
@@ -74,6 +74,14 @@ pub(crate) struct Ctx {
7474 /// about a clip.
7575 pub(crate) playable: bool,
7676 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>,
7785 }
7886
7987 /// 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 {
137145 // nothing else* have nothing to act on over a placed subtitle, so they are
138146 // refusals of kind -- not rows at all, rather than rows saying "click a clip
139147 // 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.
141152 //
142153 // And it is *only* those. The playhead actions are about the timeline rather
143154 // 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 {
150161 if ctx.caption
151162 && matches!(
152163 action,
153- ActionId::Copy
154- | ActionId::Delete
155- | ActionId::Lift
156- | ActionId::Detach
157- | ActionId::Group
158- | ActionId::Equalizer
164+ ActionId::Copy | ActionId::Delete | ActionId::Lift | ActionId::Equalizer
159165 )
160166 {
161167 return match action {
@@ -216,11 +222,25 @@ pub(crate) fn enable(action: ActionId, ctx: Ctx) -> Enable {
216222 }
217223 _ => Enable::Yes,
218224 },
219- // Nothing to take apart in a clip that names no group at all. Whether
220- // the group it names still has another half is the engine's question,
221- // like the regroup above.
222- ActionId::Detach => match ctx.clip {
223- Some((clip, _)) if clip.link.is_none() => Enable::No("this clip is not grouped"),
225+ // Nothing to take apart in a placement that names no group at all --
226+ // a clip by its own field, a caption by the one the mark carries.
227+ // Whether the group it names still has another half is the engine's
228+ // question, like the regroup above.
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"),
224244 _ => Enable::Yes,
225245 },
226246 // 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 {
266286 /// caption -- [`enable`] says so, and the strokes and the toolbar read that --
267287 /// but a split, a rate, a grade or a fit listed under a right-clicked caption
268288 /// 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 one
270-/// row that is the caption's ([`Player::lift_sub`], reached through Delete) and
271-/// the rows the card already prints "(global)" beside, which say for themselves
272-/// that they are not about what was clicked.
289+/// video clip the playhead is standing in. So a caption's menu carries the rows
290+/// that are the caption's -- its removal ([`Player::lift_sub`], reached through
291+/// Delete) and, since a caption may be grouped by hand, the group pair over the
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.
273295 pub(crate) fn menu_items(ctx: Ctx) -> Vec<ActionId> {
274296 MENU_ITEMS
275297 .into_iter()
@@ -278,7 +300,11 @@ pub(crate) fn menu_items(ctx: Ctx) -> Vec<ActionId> {
278300 !ctx.caption
279301 || matches!(
280302 action,
281- ActionId::Delete | ActionId::Paste | ActionId::ToggleMute
303+ ActionId::Delete
304+ | ActionId::Paste
305+ | ActionId::ToggleMute
306+ | ActionId::Group
307+ | ActionId::Detach
282308 )
283309 })
284310 .collect()
crates/app/src/player/actions.rsmodified+22 -5
@@ -54,6 +54,7 @@ impl Player {
5454 ActionId::Select => self.select_under_playhead(cx),
5555 ActionId::SelectNext => self.select_step(true, cx),
5656 ActionId::SelectPrev => self.select_step(false, cx),
57+ ActionId::SelectAll => self.select_all(cx),
5758 ActionId::Delete => self.delete_selected(cx),
5859 ActionId::Lift => self.lift_selected(cx),
5960 ActionId::Color => self.open_color(cx),
@@ -213,16 +214,30 @@ impl Player {
213214 let Some(session) = &self.session else {
214215 return Ctx::default();
215216 };
216- let on = on.or(self.selected);
217+ let on = on.or(self.selected.anchor());
217218 let clip = on
218219 .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();
219235 Ctx {
220236 clip,
221237 // The same pair read in the other index space: a subtitle lane's
222238 // own, where the box that was clicked is a caption.
223- caption: on.is_some_and(|(lane, idx)| {
224- lane.kind == LaneKind::Subtitle && idx < session.sub_lane(lane).len()
225- }),
239+ caption,
240+ caption_link: caption.then(|| on.and_then(|(lane, idx)| session.sub_lane(lane).get(idx)).and_then(|s| s.link)).flatten(),
226241 image: clip.is_some_and(|(clip, _)| {
227242 session
228243 .sources()
@@ -235,6 +250,8 @@ impl Player {
235250 subtitles: !session.subtitles().is_empty(),
236251 playable: !nothing_to_play(Some(session)),
237252 exporting: self.exporting().is_some(),
253+ picks: picks.len(),
254+ pick_lanes,
238255 }
239256 }
240257
@@ -347,7 +364,7 @@ impl Player {
347364 if self.session.as_mut().is_some_and(PlaybackSession::undo) {
348365 self.reset_after_reseek();
349366 }
350- self.selected = None;
367+ self.selected.clear();
351368 cx.notify();
352369 }
353370
crates/app/src/player/cards.rsmodified+7 -4
@@ -178,6 +178,7 @@ impl Player {
178178 };
179179 let target = self
180180 .selected
181+ .anchor()
181182 .filter(|(lane, _)| lane.kind == LaneKind::Video)
182183 .or_else(|| session.video_clip_at(session.now()));
183184 match target {
@@ -310,6 +311,7 @@ impl Player {
310311 };
311312 match self
312313 .selected
314+ .anchor()
313315 .or_else(|| session.video_clip_at(session.now()))
314316 {
315317 Some(clip) => {
@@ -452,6 +454,7 @@ impl Player {
452454 };
453455 match self
454456 .selected
457+ .anchor()
455458 .or_else(|| session.video_clip_at(session.now()))
456459 .map(|clip| audio_half(session, clip))
457460 {
@@ -842,7 +845,7 @@ impl Player {
842845 // selection now names a different clip than the one that is
843846 // highlighted -- dropped here as after every other edit that
844847 // moves indexes (a delete, a paste, an undo).
845- self.selected = None;
848+ self.selected.clear();
846849 self.reset_after_reseek();
847850 self.notify_user(
848851 format!(
@@ -881,7 +884,7 @@ impl Player {
881884 // Splitting each silence out and closing the room it no longer
882885 // needs moves indexes exactly as the cut does: the selection
883886 // goes with them.
884- self.selected = None;
887+ self.selected.clear();
885888 self.reset_after_reseek();
886889 self.notify_user(
887890 format!(
@@ -958,7 +961,7 @@ impl Player {
958961 if self.exporting().is_some() {
959962 return;
960963 }
961- let refusal = match (self.selected, &self.session) {
964+ let refusal = match (self.selected.anchor(), &self.session) {
962965 (_, None) => Some("NO TIMELINE — open a file first".to_string()),
963966 (None, _) => Some(format!(
964967 "NOTHING SELECTED — click an audio clip or press {}, then ask again",
@@ -974,7 +977,7 @@ impl Player {
974977 cx.notify();
975978 return;
976979 }
977- let (lane, idx) = self.selected.expect("checked above");
980+ let (lane, idx) = self.selected.anchor().expect("checked above");
978981 let session = self.session.as_ref().expect("checked above");
979982 // What the clip already plays through, or the flat default -- so the
980983 // 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 {
5151 };
5252 match placed {
5353 Ok(true) => {
54- self.selected = None;
54+ self.selected.clear();
5555 self.reset_after_reseek();
5656 }
5757 // The engine's own words: a stream that cannot join this timeline
@@ -145,7 +145,7 @@ impl Player {
145145 // The drawn cue with it, and its tile for the same reason as above.
146146 self.sub_image = None;
147147 self.clipboard = None;
148- self.selected = None;
148+ self.selected.clear();
149149 self.selected_asset = None;
150150 // The subtitle rows go with the timeline they were on, and so does the
151151 // lane that was shown: S1 of one project is not S1 of the next.
@@ -1154,7 +1154,7 @@ impl Player {
11541154 // A copied clip names its source by index, which means a
11551155 // different file -- or none -- in another project.
11561156 self.clipboard = None;
1157- self.selected = None;
1157+ self.selected.clear();
11581158 // A menu can be up while a project is dropped on the window --
11591159 // the scrim swallows clicks, never a drop -- and its index
11601160 // would name some other timeline's clip. The two clip cards
@@ -1256,7 +1256,7 @@ impl Player {
12561256 .map(|session| session.remove_lane(lane));
12571257 let text = match removed {
12581258 Some(Ok(())) => {
1259- self.selected = None;
1259+ self.selected.clear();
12601260 self.context_menu = None;
12611261 self.eq_open = None;
12621262 self.color_open = None;
@@ -1313,7 +1313,7 @@ impl Player {
13131313 return;
13141314 };
13151315 if moved != lane {
1316- self.selected = None;
1316+ self.selected.clear();
13171317 self.context_menu = None;
13181318 self.eq_open = None;
13191319 self.color_open = None;
crates/app/src/player/timeline_edit.rsmodified+225 -61
@@ -27,7 +27,7 @@ impl Player {
2727 if let Some(session) = &mut self.session {
2828 session.cut_at(f64::from(at) / self.fps);
2929 }
30- self.selected = None;
30+ self.selected.clear();
3131 cx.notify();
3232 }
3333
@@ -42,7 +42,7 @@ impl Player {
4242 }
4343 if let Some(session) = &mut self.session {
4444 if session.regroup_at(session.now()) {
45- self.selected = None;
45+ self.selected.clear();
4646 } else {
4747 self.notify_user(
4848 "NOTHING TO REGROUP — put the playhead where two clips meet, on frames that were cut apart"
@@ -61,7 +61,7 @@ impl Player {
6161 if self.exporting().is_some() {
6262 return;
6363 }
64- match (&mut self.session, self.selected) {
64+ match (&mut self.session, self.selected.anchor()) {
6565 (Some(session), Some((lane, idx))) => {
6666 if !session.ungroup(lane, idx) {
6767 self.notify_user(
@@ -77,35 +77,55 @@ impl Player {
7777 cx.notify();
7878 }
7979
80- /// Puts the selected clip back in a group with the clip covering exactly the
81- /// same frames on another track -- the way back from [`Player::detach`], and
82- /// the way to group a picture with sound it was never opened with. The
83- /// partner is not clicked because there is nothing to choose: a group id
84- /// names one span, so only a clip covering these very frames could join it,
85- /// and the engine words what to do when none does.
80+ /// Puts the selection into one group. Two paths, by how much of a
81+ /// selection there is:
82+ ///
83+ /// * **One pick** -- the way back from [`Player::detach`], and the way to
84+ /// group a picture with sound it was never opened with. The partner is
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.
8693 pub(crate) fn group(&mut self, cx: &mut Context<Self>) {
8794 if self.exporting().is_some() {
8895 return;
8996 }
90- let partner = match (&self.session, self.selected) {
91- (Some(session), Some((lane, idx))) => span_partner(session, lane, idx),
92- _ => None,
93- };
94- match (&mut self.session, self.selected, partner) {
95- (Some(session), Some((lane, idx)), Some((other, o_idx))) => {
96- if let Err(e) = session.group(lane, idx, other, o_idx) {
97+ // The picks the selection holds that still name something: a stale
98+ // index (a stroke nobody saw) is not a thing to group.
99+ let picks = self.marks().0;
100+ match (&mut self.session, self.selected.anchor(), picks.len()) {
101+ (_, None, _) => {
102+ self.notify_user("NOTHING GROUPED — click one of the halves first".into())
103+ }
104+ // The hand's group: every pick, one id.
105+ (Some(session), _, 2..) => {
106+ if let Err(e) = session.group_all(&picks) {
97107 self.notify_user(format!("NOT GROUPED — {e}").into());
98108 }
99109 }
100- (Some(_), Some(_), None) => {
101- self.notify_user(
102- "NOTHING TO GROUP WITH — no clip on another track covers exactly these frames"
103- .into(),
104- )
105- }
106- (Some(_), None, _) => {
107- self.notify_user("NOTHING GROUPED — click one of the halves first".into())
110+ // One pick that no longer names anything.
111+ (Some(_), Some(_), 0) => {
112+ self.notify_user("NOTHING GROUPED — that clip is no longer there".into())
108113 }
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+ },
109129 (None, ..) => {}
110130 }
111131 cx.notify();
@@ -120,20 +140,43 @@ impl Player {
120140 if self.exporting().is_some() {
121141 return;
122142 }
123- let selected = self.selected.take();
143+ let selected = self.selected.anchor();
144+ self.selected.clear();
124145 // A caption is marked in its own lane's index space -- that lane holds
125146 // no `Clip` -- so the same key reaches it through the one removal a
126- // placed subtitle has ([`Player::lift_sub`], one undo step). Parity: the
127- // box on a subtitle lane goes by the stroke every other box goes by.
147+ // placed subtitle has ([`Player::lift_sub`], one undo step), unless a
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.
128151 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();
130172 return;
131173 }
132174 // 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 covers
134- // one span, so deleting a take by its audio half is the same edit as by
135- // its picture. What is not a whole take is lifted instead, which is what
136- // reaches a clip on an added track ([`whole_take`]).
175+ // the engine cuts what the clip covers out of the lanes it covers -- a
176+ // lone clip's span out of every lane, a grouped member's own span out
177+ // of its own lane and its caption members off their lanes. What is not
178+ // a whole take is lifted instead, which is what reaches a clip on an
179+ // added track ([`whole_take`]).
137180 let deleted = match (&mut self.session, selected) {
138181 (Some(session), Some((lane, idx))) => match whole_take(session, lane, idx) {
139182 true => session.delete_clip(lane, idx),
@@ -157,7 +200,9 @@ impl Player {
157200 if self.exporting().is_some() {
158201 return;
159202 }
160- match (&mut self.session, self.selected.take()) {
203+ let selected = self.selected.anchor();
204+ self.selected.clear();
205+ match (&mut self.session, selected) {
161206 (Some(session), Some((lane, idx))) => {
162207 if session.lift_clip(lane, idx) {
163208 self.reset_after_reseek();
@@ -181,16 +226,34 @@ impl Player {
181226 // frames is a paste of the wrong thing.
182227 if let Some(clip) = self
183228 .selected
229+ .anchor()
184230 .and_then(|(lane, idx)| session?.lane_clips(lane).get(idx).copied())
185231 {
186232 self.clipboard = Some(clip);
187233 }
188234 }
189235
190- /// The group id of the clicked clip, which is what marks the other half.
191- pub(crate) fn selected_link(&self) -> Option<u32> {
192- let (lane, idx) = self.selected?;
193- self.session.as_ref()?.lane_clips(lane).get(idx)?.link
236+ /// The picks and their group ids, in click order: the two halves of what
237+ /// [`marked`] asks about every box on the bed -- which picks there are, and
238+ /// which groups they carry (a caption's included, which is what marks the
239+ /// 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)
194257 }
195258
196259 /// Drops the copied clip in at the playhead. The engine reseeks itself, so
@@ -202,7 +265,7 @@ impl Player {
202265 _ => false,
203266 };
204267 if pasted {
205- self.selected = None;
268+ self.selected.clear();
206269 self.reset_after_reseek();
207270 }
208271 cx.notify();
@@ -240,7 +303,7 @@ impl Player {
240303 };
241304 match moved {
242305 true => {
243- self.selected = None;
306+ self.selected.clear();
244307 self.reset_after_reseek();
245308 }
246309 // The three ways a drag is refused, told apart by what the
@@ -289,6 +352,9 @@ impl Player {
289352 track,
290353 in_us: 0,
291354 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,
292358 })
293359 }
294360
@@ -308,6 +374,7 @@ impl Player {
308374 // frame is its name on its lane ([`sub_mark`]).
309375 let marked = self
310376 .selected
377+ .anchor()
311378 .filter(|&(lane, _)| lane == to)
312379 .and_then(|(lane, idx)| Some(self.session.as_ref()?.sub_lane(lane).get(idx)?.start));
313380 let text = match (self.sub_of_track(track), &mut self.session) {
@@ -331,11 +398,19 @@ impl Player {
331398 // names its new neighbour -- the caption the next Delete would take.
332399 // The mark goes back on the caption it was on.
333400 (None, Some(start)) => {
334- self.selected = self
401+ let mark = self
335402 .session
336403 .as_ref()
337404 .and_then(|session| sub_mark(session.sub_lane(to), start))
338405 .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+ };
339414 }
340415 (None, None) => {}
341416 }
@@ -385,11 +460,19 @@ impl Player {
385460 // landed rather than left on the index it had, which after the move
386461 // is a neighbour's.
387462 Some(Ok(())) => {
388- self.selected = self
463+ let mark = self
389464 .session
390465 .as_ref()
391466 .and_then(|session| sub_mark(session.sub_lane(to), start))
392467 .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+ };
393476 }
394477 None => {}
395478 }
@@ -425,8 +508,12 @@ impl Player {
425508 // so a mark or an open menu left at or past it names a *different*
426509 // caption now -- and the next Delete would take that one. Both go
427510 // with the caption they were on.
428- if self.selected.is_some_and(|(l, i)| l == lane && i >= idx) {
429- self.selected = None;
511+ if self
512+ .selected
513+ .anchor()
514+ .is_some_and(|(l, i)| l == lane && i >= idx)
515+ {
516+ self.selected.clear();
430517 }
431518 self.context_menu = None;
432519 }
@@ -714,8 +801,19 @@ impl Player {
714801 };
715802 let lanes = session.lanes();
716803 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+ });
717815 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))
719817 }
720818
721819 /// Where a gesture at `raw` lands and the mark that pulled it there, with
@@ -854,12 +952,17 @@ impl Player {
854952 /// Opens the clip menu on the box under the pointer, from the right button
855953 /// wherever it was pressed on that box -- its middle or one of its edge
856954 /// 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.
858959 pub(crate) fn open_menu(&mut self, lane: Lane, idx: usize, at: Point<Pixels>, cx: &mut Context<Self>) {
859960 if self.modal() {
860961 return;
861962 }
862- self.select((lane, idx), cx);
963+ if !self.selected.contains((lane, idx)) {
964+ self.select((lane, idx), cx);
965+ }
863966 self.context_menu = Some(ContextMenu {
864967 lane,
865968 idx,
@@ -869,11 +972,19 @@ impl Player {
869972 cx.notify();
870973 }
871974
872- /// A press on a clip's edge: the start of the drag that changes how much of
873- /// its source it plays. It selects the clip as a press anywhere else on the
975+ /// A press on an edge: the start of the drag that changes how much of a
976+ /// source it plays. It picks the placement as a press anywhere else on the
874977 /// box does -- the edge strip covers the box's own listener (`occlude`), so
875- /// this is the only one that fires there.
876- pub(crate) fn start_trim(&mut self, lane: Lane, idx: usize, edge: Edge, cx: &mut Context<Self>) {
978+ /// this is the only one that fires there -- and ctrl makes that pick the
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+ ) {
877988 if self.modal() || self.exporting().is_some() {
878989 return;
879990 }
@@ -881,9 +992,8 @@ impl Player {
881992 // gesture, the same `Trim`, and the branch is the lane's kind wherever
882993 // the drag is asked about ([`Player::trim_to`],
883994 // [`Player::commit_trim`]). A caption *is* markable -- the mark is its
884- // lane and its index like a clip's ([`Player::select`]) -- but an edge
885- // drag is a trim and not a pick, so this leaves the mark where the hand
886- // left it. No group either: a caption has no half on another lane.
995+ // lane and its index like a clip's ([`Player::pick`]) -- and a caption
996+ // in a group carries its link, so its trim drags the group with it.
887997 if lane.kind == LaneKind::Subtitle {
888998 let Some(sub) = self
889999 .session
@@ -892,15 +1002,22 @@ impl Player {
8921002 else {
8931003 return;
8941004 };
1005+ self.pick((lane, idx), ctrl, cx);
8951006 self.trim = Some(Trim {
8961007 lane,
8971008 idx,
8981009 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+ },
8991016 to: match edge {
9001017 Edge::Start => sub.start,
9011018 Edge::End => sub.end(),
9021019 },
903- link: None,
1020+ link: sub.link,
9041021 });
9051022 cx.notify();
9061023 return;
@@ -912,13 +1029,17 @@ impl Player {
9121029 else {
9131030 return;
9141031 };
915- self.select((lane, idx), cx);
1032+ self.pick((lane, idx), ctrl, cx);
9161033 self.trim = Some(Trim {
9171034 lane,
9181035 idx,
9191036 edge,
9201037 // Where the edge already is: a press that never moves is not an
9211038 // edit, and `Project::trim` refuses exactly that.
1039+ from: match edge {
1040+ Edge::Start => clip.start,
1041+ Edge::End => clip.end(),
1042+ },
9221043 to: match edge {
9231044 Edge::Start => clip.start,
9241045 Edge::End => clip.end(),
@@ -1006,30 +1127,73 @@ impl Player {
10061127 }
10071128
10081129 /// 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 is
1130+ /// own box, and the boxes of everything linked to it, before anything is
10101131 /// 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.
10111135 pub(crate) fn trimmed(&self, lane: Lane, idx: usize, clip: Clip) -> Clip {
10121136 let Some(trim) = self.trim.filter(|t| {
10131137 (t.lane, t.idx) == (lane, idx) || (t.link.is_some() && t.link == clip.link)
10141138 }) else {
10151139 return clip;
10161140 };
1141+ let to = self.followed(trim, (lane, idx), match trim.edge {
1142+ Edge::Start => clip.start,
1143+ Edge::End => clip.end(),
1144+ });
10171145 let still = self.session.as_ref().is_some_and(|session| {
10181146 session
10191147 .sources()
10201148 .get(clip.source)
10211149 .is_some_and(|s| engine::is_image(&s.path))
10221150 });
1023- trimmed_clip(clip, trim.edge, trim.to, still)
1151+ trimmed_clip(clip, trim.edge, to, still)
10241152 }
10251153
10261154 /// 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.
10281158 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)) {
1030- Some(trim) => trimmed_sub(sub, trim.edge, trim.to),
1031- None => sub,
1159+ let Some(trim) = self.trim.filter(|t| {
1160+ (t.lane, t.idx) == (lane, idx) || (t.link.is_some() && t.link == sub.link)
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;
10321182 }
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+ })
10331197 }
10341198
10351199 /// 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 @@
44 use crate::*;
55
66 impl Player {
7- /// The one place a clip becomes *the* selected one: a click, a right-click
8- /// that opens the menu, and every selection key go through here, so what a
9- /// keyboard marks and what a pointer marks are the same state marked the
10- /// same way (group and all -- see [`marked`]).
7+ /// The one place a clip becomes *the* selected one: a plain click, a
8+ /// right-click that opens the menu, and every selection key go through
9+ /// here, so what a keyboard marks and what a pointer marks are the same
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.
1113 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+ }
1327 cx.notify();
1428 }
1529
@@ -27,7 +41,6 @@ impl Player {
2741 .filter_map(|lane| Some((lane, session.lane_clip_at(lane, now)?)))
2842 .collect()
2943 }
30-
3144 /// Selects the clip under the playhead, and on a repeat press the next
3245 /// lane's -- so one key reaches every clip the playhead is over, which is
3346 /// what makes selection (and everything that acts on a selection: delete,
@@ -43,6 +56,7 @@ impl Player {
4356 // means; a selection off the playhead starts the walk over.
4457 let next = self
4558 .selected
59+ .anchor()
4660 .and_then(|sel| under.iter().position(|&clip| clip == sel))
4761 .map_or(first, |at| under[(at + 1) % under.len()]);
4862 self.select(next, cx);
@@ -54,9 +68,10 @@ impl Player {
5468 pub(crate) fn select_step(&mut self, forward: bool, cx: &mut Context<Self>) {
5569 let clips = self
5670 .selected
71+ .anchor()
5772 .zip(self.session.as_ref())
5873 .map_or(0, |((lane, _), session)| session.lane_clips(lane).len());
59- match (self.selected, clips) {
74+ match (self.selected.anchor(), clips) {
6075 // An empty lane is a selection nothing can be stepped from -- as is
6176 // no selection at all, and the playhead answers both.
6277 (Some((lane, idx)), len) if len > 0 => {
@@ -71,6 +86,32 @@ impl Player {
7186 }
7287 }
7388
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+
74115 /// Cycles the fit policy of the clip the picture is coming from -- the
75116 /// clicked one when it is a video clip, else the composite's own, exactly as
76117 /// the colour card picks its target. A whole card for one four-valued
@@ -91,6 +132,7 @@ impl Player {
91132 };
92133 let target = self
93134 .selected
135+ .anchor()
94136 .filter(|(lane, _)| lane.kind == LaneKind::Video)
95137 .or_else(|| session.video_clip_at(session.now()));
96138 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() {
261261
262262 /// What the clip menu offers, and where it hangs. The two items that act on
263263 /// 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 back
265-/// inside 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 acts
267-/// on it -- Delete, which routes to `Player::lift_sub` -- the timeline's global
268-/// item beside it, and nothing else drawn at all. What a placed subtitle used to
269-/// have no menu, and no stroke, to do.
264+/// inapplicable, and a menu at the edge of the window has to come back inside
265+/// it or its last item cannot be clicked at all.
266+///
267+/// A caption's own menu, opened on a box that is not a clip: the rows that act
268+/// on it -- Delete, which routes to `Player::lift_sub`, and the group pair now
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.
270272 #[test]
271273 fn a_caption_is_deleted_by_the_same_row_and_stroke_every_box_is() {
272274 use keymap::ActionId;
@@ -281,26 +283,35 @@ fn a_caption_is_deleted_by_the_same_row_and_stroke_every_box_is() {
281283 assert_eq!(
282284 enable(ActionId::Delete, cap),
283285 Enable::Yes,
284- "the one thing a placed caption can be asked to do",
285- );
286- // The clip rows are refusals of *kind* on a caption, so the menu leaves them
287- // out rather than drawing "click a clip first" over a clicked box.
288- for clip_only in [
289- ActionId::Copy,
290- ActionId::Lift,
291- ActionId::Detach,
292- ActionId::Group,
293- ActionId::Equalizer,
294- ] {
286+ "the one thing a placed caption could always be asked to do",
287+ );
288+ // The clip rows are refusals of *kind* on a caption, so the menu leaves
289+ // them out rather than drawing "click a clip first" over a clicked box.
290+ for clip_only in [ActionId::Copy, ActionId::Lift, ActionId::Equalizer] {
295291 assert_eq!(
296292 enable(clip_only, cap),
297293 Enable::Hidden("this is a caption"),
298294 "{clip_only:?} is not a row on a caption",
299295 );
300296 }
301- // ...and the playhead's actions are *not* among them: the split and the
302- // regroup act at the line and the cards fall back to the clip under it, so a
303- // caption in hand is no reason for them to go dead -- which, hidden, is
297+ // The group rows are the caption's now: a caption out of any group says so
298+ // in the detach's own words, and Group over one pick is the partner hunt.
299+ 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
304315 // exactly what they went: `Player::act` returns without a word on `Hidden`,
305316 // and no click on the bed clears the mark that put them there.
306317 for playhead in [
@@ -320,11 +331,17 @@ fn a_caption_is_deleted_by_the_same_row_and_stroke_every_box_is() {
320331 // ...but live is not *listed*: every one of those rows reaches the clip
321332 // under the playhead and not the caption, and a menu opened on a caption
322333 // 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.
324335 assert_eq!(
325336 menu_items(cap),
326- vec![ActionId::Paste, ActionId::Delete, ActionId::ToggleMute],
327- "the caption's menu is its removal and the global rows alone",
337+ vec![
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",
328345 );
329346 // ...and the same reading with a clip under it is the clip menu, untouched:
330347 // the flag is off wherever a `Clip` was clicked.
@@ -353,6 +370,7 @@ fn one_second(start: u32) -> SubClip {
353370 track: 0,
354371 in_us: 0,
355372 out_us: 1_000_000,
373+ link: None,
356374 }
357375 }
358376
@@ -434,6 +452,82 @@ fn a_caption_placed_before_the_marked_one_leaves_the_mark_on_the_original() {
434452 );
435453 }
436454
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+
437531 /// The playhead's actions with a caption marked: live, and doing what they say.
438532 /// Hidden, they were dead *and* silent -- `Player::act` says nothing on a class
439533 /// 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() {
13381432 // bed: ten seconds in, five seconds past the end of the timeline, and
13391433 // no mark anywhere near enough to pull it back.
13401434 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));
13421436 let under = frame_at(scale.time_at(px_along(px(212.), bed)), fps);
13431437 let (at, cue) = landing(under, 0, 0, true, scale.snap_frames(fps), &marks);
13441438 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() {
266266 assert_eq!(lanes_h(2), 2. * LANE_H + 8.);
267267 }
268268
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+
269318 #[test]
270319 fn a_click_marks_the_whole_group_and_nothing_else() {
271320 let (v, a) = ((Lane::V1, 0), (Lane::A1, 0));
272- // Clicking the video half of group 1 marks the audio half with it.
273- assert!(marked(v, Some(1), Some(v), Some(1)));
274- assert!(marked(a, Some(1), Some(v), Some(1)));
321+ // Clicking the video half of group 1 marks the audio half with it -- the
322+ // pick, and everything sharing its link.
323+ assert!(marked(v, Some(1), &[v], &[Some(1)]));
324+ assert!(marked(a, Some(1), &[v], &[Some(1)]));
275325 // Another group's clips stay unmarked, in either lane.
276- assert!(!marked((Lane::V1, 1), Some(2), Some(v), Some(1)));
277- assert!(!marked((Lane::A1, 1), Some(2), Some(v), Some(1)));
326+ assert!(!marked((Lane::V1, 1), Some(2), &[v], &[Some(1)]));
327+ assert!(!marked((Lane::A1, 1), Some(2), &[v], &[Some(1)]));
278328 // A half a lift left behind has no group: it marks itself only, which
279329 // is what makes it separately deletable. Two ungrouped clips must not
280330 // mark each other by both being ungrouped.
281- assert!(marked(a, None, Some(a), None));
282- assert!(!marked(v, None, Some(a), None));
331+ assert!(marked(a, None, &[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)]));
283338 // Nothing selected marks nothing.
284- assert!(!marked(v, Some(1), None, None));
339+ assert!(!marked(v, Some(1), &[], &[]));
285340 }
286341
287342 #[test]
@@ -435,6 +490,7 @@ fn a_caption_trim_preview_lands_where_the_release_commits() {
435490 track: 0,
436491 in_us: 0,
437492 out_us,
493+ link: None,
438494 };
439495 session
440496 .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() {
10851085 track: 0,
10861086 in_us: 0,
10871087 out_us: 5_000_000,
1088+ link: None,
10881089 },
10891090 )
10901091 .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() {
164164 let lanes: [&[Clip]; 2] = [&video, &audio];
165165
166166 // 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);
168168 all.sort_unstable();
169169 assert_eq!(all, [0, 100, 100, 160, 160, 300, 400, 430]);
170170
171- // The video half in the hand: its own edges are gone, and so are its
172- // group's on the other lane -- both boxes travel with the drag. The
173- // lone audio clip is still a target, which is the whole point: a take
174- // being carried on V1 lands flush with a sound on A1.
175- let mut carried = snap_marks(&lanes, Some((0, 0)), 300);
171+ // The video half in the hand, with its group named as the caller reads it
172+ // off the pick: its own edges are gone, and so are its group's on the
173+ // other lane -- both boxes travel with the drag. The lone audio clip is
174+ // still a target, which is the whole point: a take being carried on V1
175+ // lands flush with a sound on A1.
176+ let mut carried = snap_marks(&lanes, Some((0, 0)), Some(7), 300);
176177 carried.sort_unstable();
177178 assert_eq!(carried, [0, 300, 400, 430]);
178179
179180 // 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]);
181182 }
182183
183184 /// 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::*;
55 /// Whether this clip is a whole take, i.e. whether deleting it may close the
66 /// hole under it: a take is what the first pair of lanes carries between them,
77 /// `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.
910 ///
1011 /// Everything else is a half or a layer, and is *lifted* instead: a half whose
1112 /// 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
2021 .lanes()
2122 .into_iter()
2223 .filter(|&other| other != lane)
23- .flat_map(|other| session.lane_clips(other))
24- .any(|o| o.link.is_some() && o.link == clip.link)
24+ .flat_map(|other| {
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)
2530 };
2631 match (lane.kind, lane.ord) {
2732 (_, 1..) => false,
@@ -69,19 +74,108 @@ pub(crate) fn span_partner(session: &PlaybackSession, lane: Lane, idx: usize) ->
6974 opposite.into_iter().chain(same).find_map(matches)
7075 }
7176
72-/// Whether a click marks this clip: the clip that was clicked always, and the
73-/// other lane's clip of the same group with it. A clip whose group has no other
74-/// half -- what a lift leaves behind -- marks only itself, which is what makes a
75-/// detached half separately deletable.
77+/// What the timeline has picked: every clip and caption a hand ctrl-clicked
78+/// into the selection, in click order and with no two the same. The last of
79+/// them is the [`anchor`](Selection::anchor) -- the one every action that is
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.
76169 pub(crate) fn marked(
77170 here: (Lane, usize),
78171 link: Option<u32>,
79- sel: Option<(Lane, usize)>,
80- sel_link: Option<u32>,
172+ picks: &[(Lane, usize)],
173+ pick_links: &[Option<u32>],
81174 ) -> bool {
82- sel == Some(here) || (link.is_some() && link == sel_link)
175+ picks.contains(&here) || (link.is_some() && pick_links.contains(&link))
83176 }
84177
178+
85179 /// Whether a clip is wide enough to be worth naming.
86180 pub(crate) fn show_label(w: f32) -> bool {
87181 w >= LABEL_MIN_W
@@ -368,18 +462,22 @@ pub(crate) fn snapped(raw: u32, len: u32, tol: u32, marks: &[u32]) -> u32 {
368462
369463 /// The edges worth landing on, off *every* lane: both ends of every clip on the
370464 /// 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 with
372-/// it. `skip` is a lane's place in `lanes` and an index into it. The playhead
373-/// and the head of the timeline go on the end: a clip meets the cursor and the
374-/// start of the show as readily as it meets another take.
465+/// it already is -- and less `skip_link`, the group id of whatever is being
466+/// dragged: its clips travel with it, and so does any caption the id names.
467+/// `skip` is a lane's place in `lanes` and an index into it; `skip_link` is
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.
375471 ///
376472 /// All lanes rather than the one being dropped on, because a cut is made across
377473 /// the timeline: a title on V2 lines up with the shot under it, and a sound
378474 /// 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> {
380- let link = skip
381- .and_then(|(lane, idx)| lanes.get(lane)?.get(idx))
382- .and_then(|clip| clip.link);
475+pub(crate) fn snap_marks(
476+ lanes: &[&[Clip]],
477+ skip: Option<(usize, usize)>,
478+ skip_link: Option<u32>,
479+ playhead: u32,
480+) -> Vec<u32> {
383481 let mut marks: Vec<u32> = lanes
384482 .iter()
385483 .enumerate()
@@ -388,7 +486,8 @@ pub(crate) fn snap_marks(lanes: &[&[Clip]], skip: Option<(usize, usize)>, playhe
388486 .iter()
389487 .enumerate()
390488 .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)
392491 })
393492 .flat_map(|(_, clip)| [clip.start, clip.end()])
394493 })
crates/app/src/ui/inspector.rsmodified+14 -2
@@ -91,7 +91,7 @@ impl Player {
9191 /// with nothing marked the section says how to get one, and each button is
9292 /// dimmed with the oracle's reason rather than missing.
9393 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)| {
9595 let session = self.session.as_ref()?;
9696 let clip = session.lane_clips(lane).get(idx).copied()?;
9797 let source = session.sources().get(clip.source);
@@ -107,15 +107,27 @@ impl Player {
107107 // marked caption -- while the bed draws that caption in the selection's
108108 // own colours and this panel's Delete lifts it. The panel says what is
109109 // 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)| {
111115 let sub = self.session.as_ref()?.sub_lane(lane).get(idx).copied()?;
112116 Some((lane, sub))
113117 });
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);
114122 let head = match (&picked, &caption) {
115123 (Some((lane, _, name, _)), _) => format!("{} · {}", lane.label(), name),
116124 (None, Some((lane, _))) => format!("{} · caption", lane.label()),
117125 (None, None) => "Nothing selected".to_string(),
118126 };
127+ let head = match more {
128+ 0 => head,
129+ n => format!("{head} · and {n} more picked"),
130+ };
119131 let detail = match &picked {
120132 Some((_, clip, _, _)) => format!(
121133 "{} → {} · {} · {}",
crates/app/src/ui/timeline.rsmodified+43 -14
@@ -596,13 +596,20 @@ impl Player {
596596 // The group ids some *other* lane carries: a clip whose id is in here
597597 // has a half elsewhere, and one whose is not is a detached half however
598598 // 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.
599603 let others: Vec<u32> = self.session.as_ref().map_or_else(Vec::new, |session| {
600604 session
601605 .lanes()
602606 .into_iter()
603607 .filter(|&other| other != lane)
604- .flat_map(|other| session.lane_clips(other))
605- .filter_map(|clip| clip.link)
608+ .flat_map(|other| {
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+ })
606613 .collect()
607614 });
608615 let name = lane.label();
@@ -629,7 +636,7 @@ impl Player {
629636 .session
630637 .as_ref()
631638 .map_or(&[][..], PlaybackSession::sources);
632- let (sel, sel_link) = (self.selected, self.selected_link());
639+ let (picks, pick_links) = self.marks();
633640 let audio = lane.kind == LaneKind::Audio;
634641 // A subtitle lane holds no `Clip` and every other lane holds no
635642 // `SubClip`, so the two lists below are never both full and the bed
@@ -964,7 +971,7 @@ impl Player {
964971 f64::from(clip.start) / self.fps,
965972 f64::from(clip.frames()) / self.fps,
966973 );
967- let on = marked((lane, i), clip.link, sel, sel_link);
974+ let on = marked((lane, i), clip.link, &picks, &pick_links);
968975 // A group with a half in the other lane wears its tint;
969976 // one without is outlined, so a detached half is visible
970977 // as detached before anyone clicks it.
@@ -1074,7 +1081,10 @@ impl Player {
10741081 // than jump its head under it.
10751082 this.grab =
10761083 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);
10781088 }),
10791089 )
10801090 // The right button selects exactly as the left one
@@ -1115,8 +1125,14 @@ impl Player {
11151125 .on_mouse_down(
11161126 MouseButton::Left,
11171127 cx.listener(
1118- move |this, _: &MouseDownEvent, _, cx| {
1119- this.start_trim(lane, i, edge, cx);
1128+ move |this, event: &MouseDownEvent, _, cx| {
1129+ this.start_trim(
1130+ lane,
1131+ i,
1132+ edge,
1133+ event.modifiers.control,
1134+ cx,
1135+ );
11201136 },
11211137 ),
11221138 )
@@ -1277,9 +1293,13 @@ impl Player {
12771293 let tip = sub_tip.clone();
12781294 let head = shown_sub.start;
12791295 // Marked the way every other box on this bed is marked,
1280- // in this lane's own index space -- a caption has no
1281- // group, so nothing else lights with it.
1282- let on = sel == Some((lane, i));
1296+ // in this lane's own index space -- and a caption in a
1297+ // group lights with the clips it was pinned to, exactly
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));
12831303 div()
12841304 .id((row_id.clone(), i))
12851305 .absolute()
@@ -1292,6 +1312,8 @@ impl Player {
12921312 .border_1()
12931313 .border_color(rgb(if on {
12941314 STROKE_SELECTED()
1315+ } else if grouped {
1316+ ACCENT_PRIMARY()
12951317 } else {
12961318 FG_SECONDARY()
12971319 }))
@@ -1325,8 +1347,9 @@ impl Player {
13251347 // ...and it marks the caption, exactly as
13261348 // the press that may become a clip's drag
13271349 // marks the clip: picking a caption up and
1328- // putting it back down is a click.
1329- this.select((lane, i), cx);
1350+ // putting it back down is a click. Ctrl
1351+ // toggles it into the selection like a clip.
1352+ this.pick((lane, i), event.modifiers.control, cx);
13301353 }),
13311354 )
13321355 // The right button marks it and hangs the menu at
@@ -1358,8 +1381,14 @@ impl Player {
13581381 .on_mouse_down(
13591382 MouseButton::Left,
13601383 cx.listener(
1361- move |this, _: &MouseDownEvent, _, cx| {
1362- this.start_trim(lane, i, edge, cx);
1384+ move |this, event: &MouseDownEvent, _, cx| {
1385+ this.start_trim(
1386+ lane,
1387+ i,
1388+ edge,
1389+ event.modifiers.control,
1390+ cx,
1391+ );
13631392 },
13641393 ),
13651394 )
crates/engine/tests/export.rsmodified+1 -1
@@ -1010,7 +1010,7 @@ fn a_proxy_is_picture_only_every_frame_a_starting_point_and_cached() {
10101010 session.set_proxies(true);
10111011 session.save_project(&project).expect("save");
10121012 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}");
10141014 assert!(text.contains("\nproxy on\n"), "{text}");
10151015 let reopened = PlaybackSession::open_project(&project).expect("load");
10161016 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)])
826826 track,
827827 in_us,
828828 out_us,
829+ link: None,
829830 },
830831 )
831832 .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() {
449449 track: 0,
450450 in_us: 0,
451451 out_us: 2_000_000,
452+ link: None,
452453 };
453454 project.place_sub(s1, 0, caption).expect("a caption goes down");
454455
@@ -541,6 +542,7 @@ fn a_paste_opens_its_room_under_the_captions_too() {
541542 track: 0,
542543 in_us: 0,
543544 out_us: 2_000_000,
545+ link: None,
544546 },
545547 )
546548 .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() {
9898 track: pick,
9999 in_us: cues[0].start_us,
100100 out_us: cues[0].end_us,
101+ link: None,
101102 },
102103 )
103104 .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() {
291291 let v2 = dir.join("new.edith");
292292 loaded.save_project(&v2).expect("save");
293293 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}");
295295 assert!(
296296 text.contains("\nresolution 1280 720\n"),
297297 "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() {
379379 loaded.save_project(&again).expect("save");
380380 assert_eq!(
381381 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\
383383 video 1 0 0 30 0 3 - - fit 1000\naudio 1\n\
384384 video 2 40 0 20 0 - - - fit 1000\naudio 2 0 0 30 0 3 - - fit 1000\n",
385385 "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() {
409409 loaded.save_project(&again).expect("save");
410410 assert_eq!(
411411 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\
413413 eq 80.0:-3.0:0.707:ls 1000.0:4.5:1.0:pk\n\
414414 eq 12000.0:6.25:0.5:hs\n\
415415 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() {
444444 loaded.save_project(&again).expect("save");
445445 assert_eq!(
446446 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\
448448 eq 80.0:-3.0:0.707:ls\n\
449449 color 0.1:1.2:0.9:-0.3\n\
450450 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() {
494494 loaded.save_project(&again).expect("save");
495495 assert_eq!(
496496 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\
498498 video 1 0 0 30 0 - - - fill 1000\nvideo 1 30 30 60 0 - - - center 1000\n\
499499 audio 1 0 0 60 0 - - - fit 1000\n",
500500 "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() {
752752
753753 for (text, want) in [
754754 (
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",
756756 "line 1",
757757 ),
758758 // 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() {
386386 .expect("save");
387387 let text = std::fs::read_to_string(&file).expect("read it back");
388388 assert!(
389- text.starts_with("edith 15"),
389+ text.starts_with("edith 16"),
390390 "{:?}",
391391 &text[..16.min(text.len())]
392392 );
crates/engine/tests/subtitles.rsmodified+13 -5
@@ -260,7 +260,7 @@ fn a_project_keeps_its_subtitles_across_a_save() {
260260 let project = dir.join("cut.edith");
261261 session.save_project(&project).expect("save");
262262 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}");
264264 assert!(
265265 text.contains("\nsubtitle - test_subs.srt\n"),
266266 "the reference is written relative, and no cue is: {text}"
@@ -722,6 +722,7 @@ fn whole(track: usize) -> SubClip {
722722 track,
723723 in_us: 0,
724724 out_us: 5_000_000,
725+ link: None,
725726 }
726727 }
727728
@@ -754,6 +755,7 @@ fn a_caption_is_placed_trimmed_moved_and_undone_on_its_lane() {
754755 track: 0,
755756 in_us: 0,
756757 out_us: 2_000_000,
758+ link: None,
757759 }
758760 );
759761
@@ -770,6 +772,7 @@ fn a_caption_is_placed_trimmed_moved_and_undone_on_its_lane() {
770772 track: 0,
771773 in_us: 500_000,
772774 out_us: 2_000_000,
775+ link: None,
773776 }
774777 );
775778
@@ -785,6 +788,7 @@ fn a_caption_is_placed_trimmed_moved_and_undone_on_its_lane() {
785788 track: 0,
786789 in_us: 500_000,
787790 out_us: 2_000_000,
791+ link: None,
788792 }
789793 );
790794
@@ -805,6 +809,7 @@ fn a_caption_is_placed_trimmed_moved_and_undone_on_its_lane() {
805809 track: 0,
806810 in_us: 500_000,
807811 out_us: 2_000_000,
812+ link: None,
808813 },
809814 SubClip {
810815 start: 30,
@@ -812,8 +817,10 @@ fn a_caption_is_placed_trimmed_moved_and_undone_on_its_lane() {
812817 track: 0,
813818 in_us: 0,
814819 out_us: 2_000_000,
820+ link: None,
815821 },
816822 SubClip {
823+ link: None,
817824 start: 30,
818825 ..whole(0)
819826 },
@@ -1237,13 +1244,14 @@ fn subtitle_lanes_and_their_captions_survive_a_save() {
12371244 track: 0,
12381245 in_us: 500_000,
12391246 out_us: 1_500_000,
1247+ link: None,
12401248 };
12411249 session.place_sub(s1, 10, caption).expect("a caption goes down");
12421250
12431251 let project = dir.join("cut.edith");
12441252 session.save_project(&project).expect("save");
12451253 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}");
12471255 assert!(
12481256 text.contains("\nsub 1 10 45 0 500000 1500000\n"),
12491257 "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() {
13091317 let now = dir.join("new.edith");
13101318 loaded.save_project(&now).expect("save");
13111319 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}");
13131321 assert!(
13141322 text.contains("\nsubtitle - test_subs.srt\n"),
13151323 "the row survives the migration: {text}"
@@ -1334,7 +1342,7 @@ fn a_caption_naming_a_track_the_palette_does_not_have_is_refused() {
13341342 let path = dir.join("bad.edith");
13351343 std::fs::write(
13361344 &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\
13381346 subtitle - test_subs.srt\nvideo 1 0 0 30 0 0 - - fit 1000\n\
13391347 audio 1 0 0 30 0 0 - - fit 1000\nsub 1 0 45 3 0 1000000\n",
13401348 )
@@ -1349,7 +1357,7 @@ fn a_caption_naming_a_track_the_palette_does_not_have_is_refused() {
13491357 let empty = dir.join("empty.edith");
13501358 std::fs::write(
13511359 &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\
13531361 subtitle - test_subs.srt\nvideo 1 0 0 30 0 0 - - fit 1000\n\
13541362 audio 1 0 0 30 0 0 - - fit 1000\nsub 1 0 45 0 1000000 1000000\n",
13551363 )