forge
Explore
Log in

Don't you dare go Hollow

merge main into focus lane (keep both Deselect and FocusPanels exemptions, entry count 76)

Browse files at this commit

01c40d5d2bfc5282e51beb56326d8d97e7071998Ahmet Kaan GümüşParent: e404617459d6b4

19 changed files +1127 -153

crates/app/src/keymap.rsmodified+13 -3
@@ -118,6 +118,9 @@ actions! {
118118 /// ctrl-click that builds a selection by hand, for the times everything
119119 /// wants selecting at once.
120120 SelectAll,
121+ /// Bare escape with nothing else claiming it: empties a multi-clip
122+ /// selection without touching picks, cards or fullscreen.
123+ Deselect,
121124 Delete,
122125 Lift,
123126 Color,
@@ -262,6 +265,7 @@ impl ActionId {
262265 ActionId::SelectNext => "Select the next clip in the lane",
263266 ActionId::SelectPrev => "Select the previous clip in the lane",
264267 ActionId::SelectAll => "Select everything (every clip and caption)",
268+ ActionId::Deselect => "Clear the selection",
265269 ActionId::Delete => "Delete",
266270 ActionId::Lift => "Lift (leave a gap)",
267271 ActionId::Color => "Colour…",
@@ -342,6 +346,7 @@ impl ActionId {
342346 ActionId::SelectNext => "select-next",
343347 ActionId::SelectPrev => "select-prev",
344348 ActionId::SelectAll => "select-all",
349+ ActionId::Deselect => "deselect",
345350 ActionId::Delete => "delete",
346351 ActionId::Lift => "lift",
347352 ActionId::Color => "color",
@@ -421,6 +426,7 @@ impl ActionId {
421426 | ActionId::SelectNext
422427 | ActionId::SelectPrev
423428 | ActionId::SelectAll
429+ | ActionId::Deselect
424430 | ActionId::Delete
425431 | ActionId::Lift
426432 | ActionId::Color
@@ -1067,6 +1073,10 @@ impl Keymap {
10671073 // below had to move off ctrl+a: a stroke that universal was
10681074 // never really the removal's to keep.
10691075 b(ActionId::SelectAll, "a", true),
1076+ // Bare escape, last in the precedence chain behind every card,
1077+ // search and fullscreen close (render.rs) -- just empties the
1078+ // selection when nothing else claims the key.
1079+ b(ActionId::Deselect, "escape", false),
10701080 b(ActionId::Delete, "x", false),
10711081 b(ActionId::Delete, "delete", false),
10721082 b(ActionId::Lift, "l", false),
@@ -1519,7 +1529,7 @@ mod tests {
15191529 #[test]
15201530 fn every_default_stroke_reaches_its_action() {
15211531 let k = Keymap::defaults();
1522- assert_eq!(k.entries().len(), 75);
1532+ assert_eq!(k.entries().len(), 76);
15231533 // The cut odometer: bare walks one, `<`/`>` (what shift+,/shift+.
15241534 // actually type) strides ten.
15251535 assert_eq!(k.lookup(".", false), Some(ActionId::WalkCutNext));
@@ -1603,9 +1613,9 @@ mod tests {
16031613 assert_eq!(k.lookup("=", false), Some(ActionId::VolumeUp));
16041614 assert_eq!(k.lookup("-", false), Some(ActionId::VolumeDown));
16051615 assert_eq!(k.lookup("+", false), None);
1606- // The chord, and *only* the chord: bare escape reaches no action at all.
1616+ // The chord cancels an export; bare escape falls through to Deselect.
16071617 assert_eq!(k.lookup("escape", true), Some(ActionId::CancelExport));
1608- assert_eq!(k.lookup("escape", false), None);
1618+ assert_eq!(k.lookup("escape", false), Some(ActionId::Deselect));
16091619 // The modifier is half the chord: ctrl+e is not e.
16101620 assert_eq!(k.lookup("e", true), None);
16111621 assert_eq!(k.lookup("space", true), None);
crates/app/src/layout.rsmodified+34 -16
@@ -398,12 +398,19 @@ pub(crate) enum Split {
398398 }
399399
400400 impl Split {
401- /// The two persisted seams -- library/inspector/timeline stay
402- /// unpersisted, out of this diff's scope, same as before it. Read by
403- /// [`load_stance_splits`] and [`save_stance_splits`] together so the
404- /// two can never learn a different set of keys from each other, the
405- /// gap a sixth region would otherwise fall through silently.
406- const PERSISTED: [Split; 2] = [Split::Dock, Split::Bench];
401+ /// Every seam that survives a restart -- all five regions, the file
402+ /// itself the only store (view state stays out of `.edith`, the
403+ /// settled convention). Read by [`load_stance_splits`] and
404+ /// [`save_stance_splits`] together so the set can never learn a
405+ /// different set of keys from each other, the gap a sixth region
406+ /// would otherwise fall through silently.
407+ pub(crate) const PERSISTED: [Split; 5] = [
408+ Split::Library,
409+ Split::Inspector,
410+ Split::Timeline,
411+ Split::Dock,
412+ Split::Bench,
413+ ];
407414
408415 fn key(self) -> &'static str {
409416 match self {
@@ -518,23 +525,30 @@ impl Splits {
518525 }
519526 }
520527
521-/// Where the darkroom's own two dragged sizes live -- dock and bench, the
522-/// only pair with a hand on them so far. Same small, silent round trip as
523-/// [`crate::ui::dock_stance`]'s tab pick: unreadable or absent leaves both
528+/// Where every seam's dragged size lives. Same small, silent round trip as
529+/// [`crate::ui::dock_stance`]'s tab pick: unreadable or absent leaves a seam
524530 /// `None`, which [`split_size`] already reads as "give it the window's own
525531 /// share".
526532 pub(crate) fn stance_splits_config_path() -> std::path::PathBuf {
527533 crate::keymap::Keymap::config_path().with_file_name("stance-splits")
528534 }
529535
530-pub(crate) fn load_stance_splits() -> Splits {
531- load_stance_splits_from(&stance_splits_config_path())
536+pub(crate) fn load_stance_splits(window: Size<Pixels>) -> Splits {
537+ load_stance_splits_from(&stance_splits_config_path(), window)
532538 }
533539
534540 /// One `split=pixels` line per touched seam, read from `path` -- factored out
535541 /// of [`load_stance_splits`] so a test can round-trip a scratch file instead
536-/// of the real config.
537-pub(crate) fn load_stance_splits_from(path: &std::path::Path) -> Splits {
542+/// of the real config. `window` is the size the layout is about to be drawn
543+/// at -- a file written by a wider or taller window can hold a seam past
544+/// this one's own ceiling, so each value is clamped to it here, before it
545+/// ever reaches [`Splits`]. [`split_size`] still re-clamps every frame on
546+/// top of this, but that clamp needs a lane count and a scroll state
547+/// nothing here has yet; this one runs on the three bounds that do not --
548+/// [`SIDE_MAX_FRAC`], [`TIMELINE_MAX_SHARE`] and [`BENCH_MIN_H`] -- so a
549+/// value this open never reaches even the first frame.
550+pub(crate) fn load_stance_splits_from(path: &std::path::Path, window: Size<Pixels>) -> Splits {
551+ let (w, h) = (f32::from(window.width), f32::from(window.height));
538552 let mut splits = Splits::default();
539553 if let Ok(text) = std::fs::read_to_string(path) {
540554 for line in text.lines() {
@@ -547,15 +561,19 @@ pub(crate) fn load_stance_splits_from(path: &std::path::Path) -> Splits {
547561 let Some(split) = Split::PERSISTED.into_iter().find(|s| s.key() == key) else {
548562 continue;
549563 };
564+ let px = match split {
565+ Split::Library | Split::Inspector | Split::Dock => px.min(w * SIDE_MAX_FRAC),
566+ Split::Timeline => px.min(h * TIMELINE_MAX_SHARE),
567+ Split::Bench => px.max(BENCH_MIN_H),
568+ };
550569 splits.set(split, px);
551570 }
552571 }
553572 splits
554573 }
555574
556-/// Writes the sizes a hand has actually dragged -- the legacy three stay
557-/// unpersisted, as they already were before this diff (out of its scope).
558-/// Walks [`Split::PERSISTED`] rather than a hand-written `if let` per field,
575+/// Writes the sizes a hand has actually dragged, one line per seam a hand
576+/// has touched. Walks [`Split::PERSISTED`] rather than a hand-written `if let` per field,
559577 /// so a region added there needs no second, separately-maintained list here.
560578 pub(crate) fn save_stance_splits(splits: &Splits) {
561579 save_stance_splits_to(splits, &stance_splits_config_path());
crates/app/src/library_meta.rsmodified+20 -13
@@ -9,19 +9,26 @@ use crate::*;
99 /// **a different file** -- the next one along -- over the range it was copied
1010 /// from.
1111 ///
12-/// The clip's own file gone means there is nothing to paste: `None`, and the
13-/// next paste says the clipboard is empty rather than putting some other take
14-/// down. Every index past it moves down by one, exactly as the lanes' clips do.
15-pub(crate) fn clipboard_after_remove(clip: Option<Clip>, removed: usize) -> Option<Clip> {
16- let mut clip = clip?;
17- match clip.source.cmp(&removed) {
18- std::cmp::Ordering::Equal => None,
19- std::cmp::Ordering::Greater => {
20- clip.source -= 1;
21- Some(clip)
22- }
23- std::cmp::Ordering::Less => Some(clip),
24- }
12+/// An entry whose own file is gone drops out of the clipboard rather than
13+/// pasting some other take down in its place; a set with even one such
14+/// member is trimmed, not emptied whole, the way a lane keeps every clip a
15+/// removal did not touch. Every index past `removed` moves down by one,
16+/// exactly as the lanes' clips do.
17+pub(crate) fn clipboard_after_remove(
18+ clipboard: Vec<(Lane, Clip)>,
19+ removed: usize,
20+) -> Vec<(Lane, Clip)> {
21+ clipboard
22+ .into_iter()
23+ .filter_map(|(lane, mut clip)| match clip.source.cmp(&removed) {
24+ std::cmp::Ordering::Equal => None,
25+ std::cmp::Ordering::Greater => {
26+ clip.source -= 1;
27+ Some((lane, clip))
28+ }
29+ std::cmp::Ordering::Less => Some((lane, clip)),
30+ })
31+ .collect()
2532 }
2633
2734 /// One library row: a file and one of its audio streams. Plain data, planned
crates/app/src/main.rsmodified+15 -8
@@ -298,9 +298,13 @@ struct Player {
298298 /// reason (a VA-API init), and kept for the life of the process because the
299299 /// answer cannot change while we run. `None` is "not asked yet".
300300 hw_caps: Option<SharedString>,
301- /// The copied clip. Frame ranges only, so it survives the clip it was taken
302- /// from being deleted -- and it outlives the selection.
303- clipboard: Option<Clip>,
301+ /// The copied clip, or clips: frame ranges and the lane each was on, in
302+ /// click order, so it survives the clip (or clips) it was taken from
303+ /// being deleted -- and it outlives the selection. One entry for a plain
304+ /// Copy, the whole ctrl-click set for one made over a selection; either
305+ /// way [`Player::paste`] drops the set at the playhead keeping the gaps
306+ /// and lanes between its members intact.
307+ clipboard: Vec<(Lane, Clip)>,
304308 /// A drag that started on the ruler. Moves anywhere in the window scrub
305309 /// while it is set; the release commits the exact position.
306310 scrubbing: bool,
@@ -385,8 +389,11 @@ struct Player {
385389 /// over no lane: the shadow every proper editor draws under a drag. Set by
386390 /// the lane the pointer is actually over -- that is the one question the
387391 /// line above does not answer -- and drawn only while a drag is live, for
388- /// [`Player::snap_cue`]'s reason.
389- ghost: Option<Ghost>,
392+ /// [`Player::snap_cue`]'s reason. More than one entry only while a
393+ /// set-drag ([`Player::move_clip`]'s `set_move`) is carrying more than
394+ /// the clip under the hand: every other pick draws its own shadow too, at
395+ /// the same delta the anchor's is landing at ([`Player::preview_ghost`]).
396+ ghost: Vec<Ghost>,
390397 /// The slot a track header being dragged is about to drop into, or `None`
391398 /// while the pointer is over no lane: the line drawn between two headers,
392399 /// for the reason [`Player::ghost`] draws a shadow -- where a gesture lands
@@ -935,9 +942,9 @@ fn main() {
935942 decoders: HashMap::new(),
936943 export_seat: None,
937944 hw_caps: None,
938- clipboard: None,
945+ clipboard: Vec::new(),
939946 scrubbing: false,
940- splits: load_stance_splits(),
947+ splits: load_stance_splits(bounds.size),
941948 split_drag: None,
942949 trim: None,
943950 fade_drag: None,
@@ -948,7 +955,7 @@ fn main() {
948955 sub_folded: HashSet::new(),
949956 sub_lane: None,
950957 snap_cue: None,
951- ghost: None,
958+ ghost: Vec::new(),
952959 lane_drop: None,
953960 last_scrub: Instant::now(),
954961 last_target: 0,
crates/app/src/player/actions.rsmodified+8 -2
@@ -98,6 +98,12 @@ impl Player {
9898 ActionId::SelectNext => self.select_step(true, cx),
9999 ActionId::SelectPrev => self.select_step(false, cx),
100100 ActionId::SelectAll => self.select_all(cx),
101+ // Last in escape's precedence chain (render.rs): nothing else
102+ // claimed the key, so it just empties the selection.
103+ ActionId::Deselect => {
104+ self.selected = Selection::new();
105+ cx.notify();
106+ }
101107 ActionId::Delete => self.delete_selected(cx),
102108 ActionId::Lift => self.lift_selected(cx),
103109 ActionId::Color => self.open_color(cx),
@@ -241,7 +247,7 @@ impl Player {
241247 pub(crate) fn toggle_snap(&mut self, cx: &mut Context<Self>) {
242248 self.snap = !self.snap;
243249 self.snap_cue = None;
244- self.ghost = None;
250+ self.ghost.clear();
245251 self.notify_user(match self.snap {
246252 true => "SNAP ON — drags land on clip edges, the playhead and the start".into(),
247253 false => "SNAP OFF — drags land exactly where the hand leaves them".into(),
@@ -364,7 +370,7 @@ impl Player {
364370 }),
365371 playhead: frame_at(session.now(), self.fps),
366372 timeline: true,
367- clipboard: self.clipboard.is_some(),
373+ clipboard: !self.clipboard.is_empty(),
368374 subtitles: !session.subtitles().is_empty(),
369375 playable: !nothing_to_play(self.active_session()),
370376 exporting: self.exporting().is_some(),
crates/app/src/player/library.rsmodified+3 -3
@@ -164,7 +164,7 @@ impl Player {
164164 // A copied clip names its source by *index*, and every index
165165 // past the one that went has just moved down: without this the
166166 // next paste puts some other file on the timeline.
167- self.clipboard = clipboard_after_remove(self.clipboard, idx);
167+ self.clipboard = clipboard_after_remove(std::mem::take(&mut self.clipboard), idx);
168168 self.reset_after_reseek();
169169 // The last row leaves a session naming no file: nothing to
170170 // play, nothing to save and nothing to show, which is the empty
@@ -305,7 +305,7 @@ impl Player {
305305 self.image = None;
306306 // The drawn cue with it, and its tile for the same reason as above.
307307 self.sub_image = None;
308- self.clipboard = None;
308+ self.clipboard.clear();
309309 self.selected.clear();
310310 self.selected_asset = None;
311311 // The subtitle rows go with the timeline they were on, and so does the
@@ -1486,7 +1486,7 @@ impl Player {
14861486 self.name = file_name(path).into();
14871487 // A copied clip names its source by index, which means a
14881488 // different file -- or none -- in another project.
1489- self.clipboard = None;
1489+ self.clipboard.clear();
14901490 self.selected.clear();
14911491 // A menu can be up while a project is dropped on the window --
14921492 // the scrim swallows clicks, never a drop -- and its index
crates/app/src/player/timeline_edit.rsmodified+227 -45
@@ -12,7 +12,7 @@ use crate::*;
1212 /// from a live `MouseExitEvent` still cannot be, and is proven by driving
1313 /// instead.
1414 pub(crate) fn split_drag_owes_save(split: Option<Split>) -> bool {
15- matches!(split, Some(Split::Dock) | Some(Split::Bench))
15+ split.is_some_and(|split| Split::PERSISTED.contains(&split))
1616 }
1717
1818 impl Player {
@@ -250,18 +250,26 @@ impl Player {
250250 cx.notify();
251251 }
252252
253- /// Copies the selected clip. Nothing on screen changes, so no notify.
253+ /// Copies the selection: one entry for a plain click, the whole
254+ /// ctrl-click set -- every pick, its own lane and its own frames -- for
255+ /// one made over more than a clip. Out of the lane each was clicked in:
256+ /// the audio half of a group is a different clip from the video one, and
257+ /// copying the wrong lane's frames is a paste of the wrong thing. Nothing
258+ /// on screen changes, so no notify. Empty rather than touched at all for
259+ /// a selection naming nothing any more, so a stale Copy leaves the
260+ /// clipboard exactly as a stale Paste would find it.
254261 pub(crate) fn copy_selected(&mut self) {
255- let session = self.session.as_ref();
256- // Out of the lane it was clicked in: the audio half of a group is a
257- // different clip from the video one, and copying the wrong lane's
258- // frames is a paste of the wrong thing.
259- if let Some(clip) = self
262+ let Some(session) = self.session.as_ref() else {
263+ return;
264+ };
265+ let picks: Vec<(Lane, Clip)> = self
260266 .selected
261- .anchor()
262- .and_then(|(lane, idx)| session?.lane_clips(lane).get(idx).copied())
263- {
264- self.clipboard = Some(clip);
267+ .picks()
268+ .iter()
269+ .filter_map(|&(lane, idx)| Some((lane, session.lane_clips(lane).get(idx).copied()?)))
270+ .collect();
271+ if !picks.is_empty() {
272+ self.clipboard = picks;
265273 }
266274 }
267275
@@ -288,17 +296,37 @@ impl Player {
288296 (picks, links)
289297 }
290298
291- /// Drops the copied clip in at the playhead. The engine reseeks itself, so
292- /// like a delete this owes the flag reset -- and the selection, whose index
293- /// the insert has just moved.
299+ /// Drops the copied clip -- or the whole copied set -- in at the
300+ /// playhead. A single clipboard entry takes the door it always has
301+ /// ([`PlaybackSession::paste_at`]): across `V1`/`A1`, splitting whatever
302+ /// it lands inside of and rippling the room open, byte-identical to
303+ /// before a set could be copied at all. More than one takes
304+ /// [`PlaybackSession::paste_set_at`] instead: every member lands on the
305+ /// lane it was copied off, at the same distance from the others it had on
306+ /// the bed it was copied from, refused whole rather than opening room --
307+ /// see [`Project::paste_set`] for why a set-paste cannot ripple. The
308+ /// engine reseeks itself either way, so like a delete this owes the flag
309+ /// reset -- and the selection, whose index the insert has just moved.
294310 pub(crate) fn paste(&mut self, cx: &mut Context<Self>) {
295- let pasted = match (&mut self.session, self.clipboard) {
296- (Some(session), Some(clip)) => session.paste_at(session.now(), clip),
311+ let pasted = match (&mut self.session, self.clipboard.as_slice()) {
312+ (Some(session), [(_, clip)]) => session.paste_at(session.now(), *clip),
313+ (Some(session), items) if !items.is_empty() => {
314+ session.paste_set_at(session.now(), items)
315+ }
297316 _ => false,
298317 };
299318 if pasted {
300319 self.selected.clear();
301320 self.reset_after_reseek();
321+ } else if self.clipboard.len() > 1 {
322+ // The set-paste's own refusal, worded like a set-drag's
323+ // ([`Player::move_clip`]) -- a single-clip paste stays silent on
324+ // failure exactly as it always has.
325+ self.notify_user(
326+ "NOT PASTED — another clip already covers where one of the copied clips would \
327+ land"
328+ .into(),
329+ );
302330 }
303331 cx.notify();
304332 }
@@ -310,6 +338,13 @@ impl Player {
310338 /// nothing is said about it. The engine reseeks, so all this owes is the
311339 /// flag reset -- and the selection, whose index was that lane's own and now
312340 /// names a different clip there.
341+ ///
342+ /// A dragged clip that is *itself* one of the selection's picks carries the
343+ /// whole selection with it: every other pick moves the same frame delta,
344+ /// all-or-nothing ([`PlaybackSession::move_selection_to`]), and the picks
345+ /// survive the move -- their indices remapped rather than cleared, since a
346+ /// pick that travels still names the clip it named before. A clip dragged
347+ /// from outside the selection moves alone, exactly as it always has.
313348 pub(crate) fn move_clip(
314349 &mut self,
315350 from: Lane,
@@ -330,10 +365,23 @@ impl Player {
330365 ) else {
331366 return;
332367 };
333- let moved = self
334- .session
335- .as_mut()
336- .is_some_and(|session| session.move_clip_to(from, idx, to, start));
368+ let set_move = self.selected.contains((from, idx)) && self.selected.len() > 1;
369+ let picks: Vec<(Lane, usize)> = self.selected.picks().to_vec();
370+ // Every pick's own start, read before the move touches anything -- the
371+ // only way to find a pick again afterwards, since a lane change or an
372+ // insert can move the index it was named by.
373+ let pre_starts: Vec<Option<u32>> = picks
374+ .iter()
375+ .map(|&(lane, i)| {
376+ self.session
377+ .as_ref()
378+ .and_then(|session| session.lane_clips(lane).get(i).map(|c| c.start))
379+ })
380+ .collect();
381+ let moved = self.session.as_mut().is_some_and(|session| match set_move {
382+ true => session.move_selection_to(&picks, from, idx, to, start),
383+ false => session.move_clip_to(from, idx, to, start),
384+ });
337385 let (kind, lanes) = match from.kind {
338386 LaneKind::Video => ("picture", "video"),
339387 LaneKind::Audio => ("sound", "audio"),
@@ -343,7 +391,18 @@ impl Player {
343391 };
344392 match moved {
345393 true => {
346- self.selected.clear();
394+ // Every pick named a `(lane, ...)` by index into that lane's
395+ // clips, sorted by start -- exactly what an insert or a lane
396+ // change reorders. Re-read by the frame each pick's clip now
397+ // starts at (recorded before the move moved anything), so the
398+ // selection survives naming the clips it named, not the slots
399+ // they used to sit in.
400+ if set_move {
401+ self.selected =
402+ self.remap_selection(&picks, &pre_starts, from, idx, to, was, start);
403+ } else {
404+ self.selected.clear();
405+ }
347406 self.reset_after_reseek();
348407 }
349408 // The three ways a drag is refused, told apart by what the
@@ -360,6 +419,15 @@ impl Player {
360419 // Picked up and put back down where it was: a click, and a click
361420 // says nothing.
362421 false if from == to && start == was => {}
422+ false if set_move => self.notify_user(
423+ format!(
424+ "NOT MOVED — {} clips selected, and another clip already covers where one of \
425+ them would land on {}",
426+ picks.len(),
427+ to.label()
428+ )
429+ .into(),
430+ ),
363431 false => self.notify_user(
364432 format!(
365433 "NOT MOVED — another clip already covers those frames on {}",
@@ -371,6 +439,50 @@ impl Player {
371439 cx.notify();
372440 }
373441
442+ /// What a selection's picks are called after a set-move that shifted every
443+ /// one of them by `landed - was` timeline frames (the delta the dragged
444+ /// clip's own head travelled, which every pick travelled too -- see
445+ /// [`Project::move_selection`]): the clip a pick named is found again by
446+ /// where it now starts, on the lane it stays on (or `to`, for the one
447+ /// that changed lane), rather than by the index it had, which a lane
448+ /// change or an insert can have moved. A pick whose clip cannot be found
449+ /// there any more (a bad index handed in) is dropped rather than guessed
450+ /// at.
451+ fn remap_selection(
452+ &self,
453+ picks: &[(Lane, usize)],
454+ pre_starts: &[Option<u32>],
455+ from: Lane,
456+ dragged: usize,
457+ to: Lane,
458+ was: u32,
459+ landed: u32,
460+ ) -> Selection {
461+ let mut out = Selection::new();
462+ let Some(session) = self.session.as_ref() else {
463+ return out;
464+ };
465+ let delta = i64::from(landed) - i64::from(was);
466+ for (&pick, &old_start) in picks.iter().zip(pre_starts) {
467+ let Some(old_start) = old_start else {
468+ continue;
469+ };
470+ let want = (i64::from(old_start) + delta) as u32;
471+ // Every pick but the dragged clip itself stays on the lane it was
472+ // already on; only the exact clip the hand let go of changed
473+ // lane, so only its own pick is found on `to` rather than `from`.
474+ let now_lane = if pick == (from, dragged) { to } else { pick.0 };
475+ if let Some(found) = session
476+ .lane_clips(now_lane)
477+ .iter()
478+ .position(|c| c.start == want)
479+ {
480+ out.add((now_lane, found));
481+ }
482+ }
483+ out
484+ }
485+
374486 /// The whole of a palette track as a placement: from its own first
375487 /// microsecond to its last cue, and as many timeline frames as that is worth
376488 /// at this rate. What a row dragged out of the Subtitles list carries, and
@@ -405,7 +517,7 @@ impl Player {
405517 }
406518 self.mark_dirty();
407519 self.snap_cue = None;
408- self.ghost = None;
520+ self.ghost.clear();
409521 let at = self.place_frame(x).0;
410522 // What the mark is on, before the lane is renumbered: a caption's start
411523 // frame is its name on its lane ([`sub_mark`]).
@@ -493,7 +605,7 @@ impl Player {
493605 }
494606 self.mark_dirty();
495607 self.snap_cue = None;
496- self.ghost = None;
608+ self.ghost.clear();
497609 let Some(idx) = self.dragged_sub(drag) else {
498610 return;
499611 };
@@ -669,7 +781,7 @@ impl Player {
669781 tint: CLIP_TEXT(),
670782 refused: to.kind != LaneKind::Subtitle,
671783 };
672- self.set_ghost(Some(ghost), cx);
784+ self.set_ghost(vec![ghost], cx);
673785 }
674786
675787 /// The same for a palette row on its way down: it lands at the frame it is
@@ -689,7 +801,7 @@ impl Player {
689801 tint: CLIP_TEXT(),
690802 refused: to.kind != LaneKind::Subtitle,
691803 };
692- self.set_ghost(Some(ghost), cx);
804+ self.set_ghost(vec![ghost], cx);
693805 }
694806
695807 /// Where a clip let go at window `x` over lane `to` wants its head: the
@@ -779,6 +891,15 @@ impl Player {
779891 /// are one answer -- and its own length at this zoom. A lane of the other
780892 /// kind refuses the drop ([`Project::move_clip`]), and the shadow says so
781893 /// before the release does.
894+ ///
895+ /// When the dragged clip is itself one of a multi-pick selection (the same
896+ /// `set_move` test [`Player::move_clip`] commits by), every other pick
897+ /// draws its own shadow too, at the delta the anchor above is landing at --
898+ /// [`Project::move_selection`]'s own clamp is not reread here, so a wall
899+ /// that would narrow the group's travel is seen only at the release, not
900+ /// in the shadow; the anchor's own room is still exact; corner-cut, ceiling
901+ /// a shadow a member or two too wide on a tight bed, upgrade is exposing
902+ /// `move_room` to preview against.
782903 pub(crate) fn preview_ghost(
783904 &mut self,
784905 drag: &ClipDrag,
@@ -786,17 +907,46 @@ impl Player {
786907 x: Pixels,
787908 cx: &mut Context<Self>,
788909 ) {
789- let ghost = self
790- .dragged(drag)
791- .and_then(|idx| self.drop_frame(drag.lane, idx, x))
792- .map(|(start, _)| Ghost {
793- lane: to,
794- start,
795- frames: drag.clip.frames(),
796- tint: self.clip_tint(drag.clip.source),
797- refused: drag.lane.kind != to.kind,
798- });
799- self.set_ghost(ghost, cx);
910+ let Some(idx) = self.dragged(drag) else {
911+ self.set_ghost(Vec::new(), cx);
912+ return;
913+ };
914+ let Some((start, _)) = self.drop_frame(drag.lane, idx, x) else {
915+ self.set_ghost(Vec::new(), cx);
916+ return;
917+ };
918+ let anchor = Ghost {
919+ lane: to,
920+ start,
921+ frames: drag.clip.frames(),
922+ tint: self.clip_tint(drag.clip.source),
923+ refused: drag.lane.kind != to.kind,
924+ };
925+ let mut ghosts = vec![anchor];
926+ if self.selected.contains((drag.lane, idx)) && self.selected.len() > 1 {
927+ let delta = i64::from(start) - i64::from(drag.clip.start);
928+ for &(lane, i) in self.selected.picks() {
929+ if (lane, i) == (drag.lane, idx) {
930+ continue;
931+ }
932+ let Some(clip) = self
933+ .session
934+ .as_ref()
935+ .and_then(|session| session.lane_clips(lane).get(i).copied())
936+ else {
937+ continue;
938+ };
939+ let want = (i64::from(clip.start) + delta).max(0) as u32;
940+ ghosts.push(Ghost {
941+ lane,
942+ start: want,
943+ frames: clip.frames(),
944+ tint: self.clip_tint(clip.source),
945+ refused: anchor.refused,
946+ });
947+ }
948+ }
949+ self.set_ghost(ghosts, cx);
800950 }
801951
802952 /// The line the track in the hand would drop into, on the row the pointer
@@ -860,7 +1010,7 @@ impl Player {
8601010 tint: file_tint(self.sources(), path).unwrap_or(BG_RAISED()),
8611011 refused: lane_refuses(path, to).is_some(),
8621012 };
863- self.set_ghost(Some(ghost), cx);
1013+ self.set_ghost(vec![ghost], cx);
8641014 }
8651015
8661016 /// Sets the shadow, or takes it away, repainting only when it moved -- the
@@ -868,7 +1018,7 @@ impl Player {
8681018 /// root and set again by the lane under the pointer, in that order (gpui
8691019 /// runs the capture phase parent-first), so a pointer over no lane at all
8701020 /// leaves nothing drawn.
871- pub(crate) fn set_ghost(&mut self, ghost: Option<Ghost>, cx: &mut Context<Self>) {
1021+ pub(crate) fn set_ghost(&mut self, ghost: Vec<Ghost>, cx: &mut Context<Self>) {
8721022 if ghost != self.ghost {
8731023 self.ghost = ghost;
8741024 cx.notify();
@@ -1550,6 +1700,38 @@ impl Player {
15501700 cx.notify();
15511701 }
15521702
1703+ /// Widens or narrows the transition the anchor already carries, one
1704+ /// frame at a step, from the inspector's duration row -- ctrl+f/ctrl+x
1705+ /// stay the toggle that seeds a fresh one at one second; this is what
1706+ /// moves it afterwards. The engine clamps both kinds to what the two
1707+ /// clips actually offer ([`Project::set_transition_out`],
1708+ /// [`Project::crossfade`]), so a step past the successor's own length
1709+ /// lands at the successor's length instead of asking for more than
1710+ /// there is.
1711+ pub(crate) fn nudge_transition(&mut self, lane: Lane, idx: usize, step: i32, cx: &mut Context<Self>) {
1712+ if self.exporting().is_some() {
1713+ return;
1714+ }
1715+ let Some(session) = &mut self.session else {
1716+ return;
1717+ };
1718+ let current = match lane.kind {
1719+ LaneKind::Video => session.transition_out_of(lane, idx),
1720+ LaneKind::Audio => session.lane_clips(lane).get(idx).map_or(0, |c| c.fade_out),
1721+ _ => return,
1722+ };
1723+ let frames = (current as i32 + step).max(0) as u32;
1724+ let ok = match lane.kind {
1725+ LaneKind::Video => session.set_transition_out(lane, idx, frames),
1726+ LaneKind::Audio => session.crossfade(lane, idx, frames),
1727+ _ => false,
1728+ };
1729+ if ok {
1730+ self.mark_dirty();
1731+ cx.notify();
1732+ }
1733+ }
1734+
15531735 /// The clip as the drag is showing it: an edge under the pointer moves its
15541736 /// own box, and the boxes of everything linked to it, before anything is
15551737 /// committed. Display only -- the project is not touched until the release.
@@ -1750,9 +1932,9 @@ impl Player {
17501932 Some(MouseButton::Left) => self.drag_split(split, event.position, window, cx),
17511933 // Released outside the window: the up below never came, so this
17521934 // is where the gesture ends. The size is already written to
1753- // `self.splits`, but the darkroom's two persisted seams still
1754- // owe the save `drag_release` would have paid -- without it
1755- // the drag holds for the session and reverts on restart.
1935+ // `self.splits`, but a persisted seam still owes the save
1936+ // `drag_release` would have paid -- without it the drag
1937+ // holds for the session and reverts on restart.
17561938 _ => {
17571939 self.split_drag = None;
17581940 if split_drag_owes_save(Some(split)) {
@@ -1889,10 +2071,10 @@ impl Player {
18892071 }
18902072 if let Some(split) = self.split_drag.take() {
18912073 self.drag_split(split, event.position, window, cx);
1892- // The darkroom's own two seams outlive the window: written once,
1893- // on the release that ends the gesture, the same small-file
1894- // round trip `ui::dock_stance`'s tab pick uses -- not on every
1895- // sample in between, which `drag_move` above never owed a write.
2074+ // Every seam outlives the window: written once, on the release
2075+ // that ends the gesture, the same small-file round trip
2076+ // `ui::dock_stance`'s tab pick uses -- not on every sample in
2077+ // between, which `drag_move` above never owed a write.
18962078 if split_drag_owes_save(Some(split)) {
18972079 save_stance_splits(&self.splits);
18982080 }
crates/app/src/player/transport.rsmodified+51 -18
@@ -46,14 +46,17 @@ impl Player {
4646 let Some(session) = self.preview_session.as_mut().or(self.session.as_mut()) else {
4747 return;
4848 };
49- // Loop-trim (DESIGN.md §6): the transport is kept inside the subject
50- // cut's own span while the mode is on, so a trim can be heard and
51- // seen without a manual replay after every nudge. Checked off the
52- // engine's own clock, not a frame counter this pump keeps -- the
53- // same `now()` [`Player::step`] reads.
54- if session.is_playing() && should_loop_restart(frame_at(session.now(), fps), self.loop_trim)
49+ // Loop-trim and the i/o range (DESIGN.md §6): the transport is kept
50+ // inside the active window while one is armed, so a trim or a marked
51+ // range can be heard and seen without a manual replay after every
52+ // nudge. The range wins over the trim when both are set
53+ // ([`active_loop_window`]). Checked off the engine's own clock, not
54+ // a frame counter this pump keeps -- the same `now()`
55+ // [`Player::step`] reads.
56+ let loop_window = active_loop_window(self.loop_on, self.range, self.loop_trim);
57+ if session.is_playing() && should_loop_restart(frame_at(session.now(), fps), loop_window)
5558 {
56- let start = self.loop_trim.map_or(0, |(lo, _)| lo);
59+ let start = loop_window.map_or(0, |(lo, _)| lo);
5760 session.seek(f64::from(start) / fps);
5861 }
5962 // Whether the span now decoding has yet to hand over a picture, read
@@ -172,6 +175,10 @@ impl Player {
172175 // whole-timeline loop already used, so that race has nothing
173176 // left to win: reaching the end while *either* loop is armed
174177 // restarts rather than halts, regardless of which one owns it.
178+ // A bare i/o range never arms this crossing on its own -- it is
179+ // an export mark first ([`active_loop_window`]) -- so `range`
180+ // only ever widens `armed` through the `loop_on`/`loop_trim`
181+ // terms already here, never past them.
175182 let armed = self.loop_on || self.loop_trim.is_some();
176183 if crosses_into_loop(was, Transport::Ended, armed) {
177184 // The same door the restart button and key use
@@ -179,7 +186,8 @@ impl Player {
179186 // spends only on a repaint -- the pump is already inside one.
180187 // One seam of a one-frame seam: the restart is a fresh seek
181188 // and its reopen, not a gapless splice.
182- let start = loop_restart_frame(self.loop_on, self.loop_trim).unwrap_or(0);
189+ let start =
190+ loop_restart_frame(self.loop_on, self.range, self.loop_trim).unwrap_or(0);
183191 if let Some(session) = self.active_session_mut() {
184192 session.seek(f64::from(start) / fps);
185193 }
@@ -246,7 +254,7 @@ impl Player {
246254 // ...and the shadow a drag is drawn under promises a landing on a lane
247255 // this edit has just reshaped. The next move of the drag draws it
248256 // again; until then it says nothing.
249- self.ghost = None;
257+ self.ghost.clear();
250258 }
251259
252260 /// Jumps the timeline.
@@ -474,20 +482,45 @@ mod tests {
474482 }
475483
476484 /// `loop_restart_frame` picks the seek target the crossing above plays
477- /// from: the trim window's near edge when one is armed (it wins over the
478- /// whole-timeline loop when both happen to be set), the top of the
479- /// timeline for the whole-timeline loop alone, and no restart at all
480- /// with neither armed.
485+ /// from: the i/o range's near edge when one is armed and set (it wins
486+ /// over both the trim window and the whole-timeline loop), the trim
487+ /// window's near edge next, the top of the timeline for the
488+ /// whole-timeline loop alone, and no restart at all with nothing armed.
481489 #[test]
482490 fn loop_restart_frame_prefers_the_trim_window_then_the_whole_timeline_then_nothing() {
483- assert_eq!(loop_restart_frame(false, Some((30, 60))), Some(30));
491+ assert_eq!(loop_restart_frame(false, None, Some((30, 60))), Some(30));
484492 assert_eq!(
485- loop_restart_frame(true, Some((30, 60))),
493+ loop_restart_frame(true, None, Some((30, 60))),
486494 Some(30),
487495 "the trim window wins over the whole-timeline loop"
488496 );
489- assert_eq!(loop_restart_frame(true, None), Some(0));
490- assert_eq!(loop_restart_frame(false, None), None);
497+ assert_eq!(loop_restart_frame(true, None, None), Some(0));
498+ assert_eq!(loop_restart_frame(false, None, None), None);
499+ // The i/o range beats the trim window when both are set...
500+ assert_eq!(
501+ loop_restart_frame(true, Some((10, 20)), Some((30, 60))),
502+ Some(10),
503+ "the marked range wins over the subject-cut trim"
504+ );
505+ // ...and a range alone, with loop off and no trim, never arms a
506+ // restart at all -- it is an export mark first.
507+ assert_eq!(
508+ loop_restart_frame(false, Some((10, 20)), None),
509+ None,
510+ "a bare i/o range must not start looping un-looped playback"
511+ );
512+ // Clearing the range falls back to the trim window, then to the
513+ // whole timeline.
514+ assert_eq!(
515+ loop_restart_frame(true, None, Some((30, 60))),
516+ Some(30),
517+ "clearing the range falls back to the trim window"
518+ );
519+ assert_eq!(
520+ loop_restart_frame(true, None, None),
521+ Some(0),
522+ "clearing both the range and the trim falls back to the whole timeline"
523+ );
491524 }
492525
493526 /// The bug this session fixed: a loop-trim window whose far edge (60)
@@ -509,7 +542,7 @@ mod tests {
509542 Transport::Ended,
510543 armed
511544 ));
512- assert_eq!(loop_restart_frame(loop_on, loop_trim), Some(30));
545+ assert_eq!(loop_restart_frame(loop_on, None, loop_trim), Some(30));
513546 }
514547
515548 /// A loop window sitting entirely before the film's end never reaches
crates/app/src/render.rsmodified+4 -4
@@ -607,12 +607,12 @@ impl Render for Player {
607607 // (`lane_row`), which gpui runs straight after this one: the
608608 // capture phase goes parent first, so a pointer over no lane at
609609 // all -- up in the library, say -- promises nothing.
610- this.set_ghost(None, cx);
610+ this.set_ghost(Vec::new(), cx);
611611 }))
612612 .on_drag_move(
613613 cx.listener(|this, event: &DragMoveEvent<AssetDrag>, _, cx| {
614614 this.preview_place(event.event.position.x, cx);
615- this.set_ghost(None, cx);
615+ this.set_ghost(Vec::new(), cx);
616616 }),
617617 )
618618 // The same pair for the two subtitle gestures, for the same reason:
@@ -620,7 +620,7 @@ impl Render for Player {
620620 // lane, and both are let go somewhere else entirely.
621621 .on_drag_move(cx.listener(|this, event: &DragMoveEvent<SubPick>, _, cx| {
622622 this.preview_place(event.event.position.x, cx);
623- this.set_ghost(None, cx);
623+ this.set_ghost(Vec::new(), cx);
624624 }))
625625 .on_drag_move(cx.listener(|this, event: &DragMoveEvent<SubDrag>, _, cx| {
626626 // The placement gpui froze into the payload, whose *length* is
@@ -629,7 +629,7 @@ impl Render for Player {
629629 let (drag, x) = (*event.drag(cx), event.event.position.x);
630630 let cue = this.sub_drop_frame(drag.sub, x).1;
631631 this.set_cue(cue, x, cx);
632- this.set_ghost(None, cx);
632+ this.set_ghost(Vec::new(), cx);
633633 }))
634634 // Scrubbing is tracked on the root because the pointer leaves the
635635 // 6 px ruler on the first drag and its own listeners then stop
crates/app/src/tests/cards.rsmodified+70 -2
@@ -3,6 +3,7 @@
33
44 use super::*;
55 use crate::audio_cards::EQ_GRAPH_MAX_H;
6+use crate::ui::inspector::transition_of;
67 use std::sync::atomic::Ordering;
78
89 /// FAULT 2's general shape (not just the source dot's menu): `overlaid()`
@@ -186,8 +187,9 @@ fn only_a_chord_gets_out_of_an_export() {
186187 assert!(!cancels_export("e", false, Some(ActionId::Export)));
187188 assert!(!cancels_export("space", false, Some(ActionId::Play)));
188189 assert!(!cancels_export("q", false, None));
189- // The default keymap is what the handler feeds this: the chord reaches the
190- // action, the bare key reaches nothing.
190+ // The default keymap is what the handler feeds this: the chord reaches
191+ // CancelExport, the bare key reaches Deselect instead -- neither of which
192+ // this guard lets cancel a running export.
191193 let k = keymap::Keymap::defaults();
192194 assert!(cancels_export("escape", true, k.lookup("escape", true)));
193195 assert!(!cancels_export("escape", false, k.lookup("escape", false)));
@@ -1207,6 +1209,72 @@ fn a_typed_bitrate_is_a_field_and_not_a_key_capture() {
12071209 assert!(detail.starts_with("6▏"), "{detail}");
12081210 }
12091211
1212+/// [`crate::ui::inspector::transition_of`]: the inspector's duration row
1213+/// appears only for an anchor that actually carries a dissolve or a
1214+/// crossfade, and the room it offers is capped at what the successor clip
1215+/// actually has -- the same clamp [`engine::project::Project::set_transition_out`]/
1216+/// [`engine::project::Project::crossfade`] enforce, read back here without
1217+/// either engine call so the row can never claim more than a step could land
1218+/// in.
1219+#[test]
1220+fn a_duration_row_shows_only_for_a_transition_and_its_room_is_the_successors() {
1221+ // `len` is the clip's own source length (`out_frame`, `in_frame` fixed at
1222+ // 0, `speed` 1x, so `Clip::frames()` reads back exactly `len`).
1223+ fn clip(start: u32, len: u32, transition_out: u32, fade_in: u32, fade_out: u32) -> Clip {
1224+ Clip {
1225+ start,
1226+ in_frame: 0,
1227+ out_frame: len,
1228+ source: 0,
1229+ link: None,
1230+ eq: None,
1231+ color: None,
1232+ transform: None,
1233+ fit: FitPolicy::default(),
1234+ speed: Speed::NORMAL,
1235+ fade_in,
1236+ fade_out,
1237+ transition_out,
1238+ }
1239+ }
1240+ // A plain cut carries neither field, so the row has nothing to show.
1241+ let plain = clip(0, 10, 0, 0, 0);
1242+ let plain_next = clip(10, 15, 0, 0, 0);
1243+ assert_eq!(transition_of(LaneKind::Video, &plain, Some(&plain_next)), None);
1244+
1245+ // A dissolve: video lane, `transition_out` set, an adjacent successor.
1246+ // The room offered is the shorter of the two -- here the successor's own
1247+ // 5-frame length, less than the anchor's 10.
1248+ let a = clip(0, 10, 4, 0, 0);
1249+ let b = clip(10, 5, 0, 0, 0);
1250+ assert_eq!(
1251+ transition_of(LaneKind::Video, &a, Some(&b)),
1252+ Some(("Dissolve", 4, 5))
1253+ );
1254+ // No successor, or a gap before one: no row, same as no transition.
1255+ assert_eq!(transition_of(LaneKind::Video, &a, None), None);
1256+ let gap = clip(11, 5, 0, 0, 0);
1257+ assert_eq!(transition_of(LaneKind::Video, &a, Some(&gap)), None);
1258+
1259+ // A crossfade: audio lane, both ends of the join set
1260+ // ([`Project::crossfade`]'s own signature) -- a one-sided fade (the
1261+ // successor's `fade_in` still 0) is not one, and stays a plain fade.
1262+ let a = clip(0, 10, 0, 0, 3);
1263+ let b = clip(10, 2, 0, 3, 0);
1264+ assert_eq!(
1265+ transition_of(LaneKind::Audio, &a, Some(&b)),
1266+ Some(("Crossfade", 3, 2)),
1267+ "capped at the successor's own 2-frame length, though 3 was asked for"
1268+ );
1269+ let one_sided = clip(10, 2, 0, 0, 0);
1270+ assert_eq!(transition_of(LaneKind::Audio, &a, Some(&one_sided)), None);
1271+
1272+ // A dissolve field on an audio lane, or a fade-only pair on a video
1273+ // lane, name no transition either -- each kind reads only its own lane.
1274+ let dissolving = clip(0, 10, 4, 0, 0);
1275+ assert_eq!(transition_of(LaneKind::Audio, &dissolving, Some(&b)), None);
1276+}
1277+
12101278 #[test]
12111279 fn a_clip_with_no_sound_is_refused_in_the_same_words_whichever_kind_it_is() {
12121280 // A still and a video with no audio track are one answer to one
crates/app/src/tests/editing.rsmodified+335 -6
@@ -1688,19 +1688,35 @@ fn a_copied_clip_is_renumbered_or_dropped_when_a_row_leaves_the_library() {
16881688 };
16891689 // Copied from source 2, source 0 removed: the same file is source 1 now.
16901690 assert_eq!(
1691- clipboard_after_remove(Some(clip(2)), 0).map(|c| c.source),
1692- Some(1),
1691+ clipboard_after_remove(vec![(Lane::V1, clip(2))], 0)
1692+ .into_iter()
1693+ .map(|(_, c)| c.source)
1694+ .collect::<Vec<_>>(),
1695+ vec![1],
16931696 "the clipboard follows its file down the list"
16941697 );
16951698 // Copied from a source *before* the one that went: untouched.
16961699 assert_eq!(
1697- clipboard_after_remove(Some(clip(0)), 2).map(|c| c.source),
1698- Some(0)
1700+ clipboard_after_remove(vec![(Lane::V1, clip(0))], 2)
1701+ .into_iter()
1702+ .map(|(_, c)| c.source)
1703+ .collect::<Vec<_>>(),
1704+ vec![0]
16991705 );
17001706 // Copied from the row that was just removed: there is nothing left to
17011707 // paste, and pasting the next file along would be a lie.
1702- assert!(clipboard_after_remove(Some(clip(1)), 1).is_none());
1703- assert!(clipboard_after_remove(None, 0).is_none());
1708+ assert!(clipboard_after_remove(vec![(Lane::V1, clip(1))], 1).is_empty());
1709+ assert!(clipboard_after_remove(Vec::new(), 0).is_empty());
1710+ // A set with one member's file gone loses only that member -- the rest
1711+ // of the set survives to be pasted, gaps and lanes intact.
1712+ let trimmed = clipboard_after_remove(
1713+ vec![(Lane::V1, clip(1)), (Lane::A1, clip(2))],
1714+ 1,
1715+ );
1716+ assert_eq!(
1717+ trimmed.into_iter().map(|(_, c)| c.source).collect::<Vec<_>>(),
1718+ vec![1]
1719+ );
17041720 }
17051721
17061722 /// The trim-a-clip path through the doors the edge drag uses:
@@ -1900,6 +1916,259 @@ fn a_track_can_be_added_dropped_on_edited_and_taken_back() {
19001916 assert_eq!(format_refusal(&session, Format::Mp4), None);
19011917 }
19021918
1919+/// [`PlaybackSession::move_selection_to`], the door a selection drag uses
1920+/// ([`Player::move_clip`]'s set path): three picks across two lanes, one of
1921+/// them the dragged clip, all travel the *same* frame delta in one call --
1922+/// the same all-or-nothing clamp [`Project::move_room`] already gave a
1923+/// linked group, generalised to an arbitrary selection.
1924+#[test]
1925+fn a_selection_drag_moves_every_pick_by_the_same_delta() {
1926+ use engine::project::LaneKind;
1927+
1928+ let mut session = PlaybackSession::open(asset("test_av.mp4")).expect("open the fixture");
1929+ session.set_gain(0.0);
1930+ let path = session.sources()[0].path.clone();
1931+ session.import(&asset("test_av2.mp4")).expect("av2 matches");
1932+ let second = session.sources()[1].path.clone();
1933+
1934+ // clip0 on V1 at the fixture's own start; clip1 on V1 ten seconds in,
1935+ // appended to the open bed and rippling nothing.
1936+ assert!(session
1937+ .place_stream_at(10.0, &second, 0, None)
1938+ .expect("av2 is on this timeline"));
1939+ let clip0 = session.lane_clips(Lane::V1)[0];
1940+ let clip1 = session.lane_clips(Lane::V1)[1];
1941+ assert_eq!((clip0.start, clip1.start), (0, 300));
1942+
1943+ // clipC on a second video row, well past both of the above.
1944+ let v2 = session.add_lane(LaneKind::Video);
1945+ assert!(session
1946+ .place_stream_at(20.0, &path, 0, Some(v2))
1947+ .expect("test_av.mp4 is on this timeline"));
1948+ let clip_c = session.lane_clips(v2)[0];
1949+ assert_eq!(clip_c.start, 600);
1950+
1951+ let picks = [(Lane::V1, 0), (Lane::V1, 1), (v2, 0)];
1952+ // Drag clip1 fifty frames along its own lane -- the other two picks own
1953+ // no neighbours of their own here, so nothing narrows the room and the
1954+ // full fifty-frame ask goes through for all three.
1955+ assert!(session.move_selection_to(&picks, Lane::V1, 1, Lane::V1, clip1.start + 50));
1956+ assert_eq!(session.lane_clips(Lane::V1)[0].start, clip0.start + 50);
1957+ assert_eq!(session.lane_clips(Lane::V1)[1].start, clip1.start + 50);
1958+ assert_eq!(session.lane_clips(v2)[0].start, clip_c.start + 50);
1959+ // Every pick still names the clip it named: found again by the frame it
1960+ // now starts at -- exactly the lookup `Player::remap_selection` makes
1961+ // once the move lands, which is what keeps a set-move's selection alive
1962+ // rather than clearing it.
1963+ assert_eq!(
1964+ session.lane_clips(Lane::V1)[0],
1965+ Clip { start: clip0.start + 50, ..clip0 }
1966+ );
1967+ assert_eq!(
1968+ session.lane_clips(v2)[0],
1969+ Clip { start: clip_c.start + 50, ..clip_c }
1970+ );
1971+
1972+ assert!(session.undo(), "one step for the whole set-move");
1973+ assert_eq!(session.lane_clips(Lane::V1)[0].start, clip0.start);
1974+ assert_eq!(session.lane_clips(Lane::V1)[1].start, clip1.start);
1975+ assert_eq!(session.lane_clips(v2)[0].start, clip_c.start);
1976+}
1977+
1978+/// One pick with nowhere to go refuses the whole set: the walk onto another
1979+/// clip's own span that already refuses a lone drag
1980+/// (`move_clip_keeps_the_frames_and_refuses_the_rest`, in this crate's own
1981+/// engine tests) refuses a selection drag exactly the same way, and every
1982+/// *other* pick -- which had all the room in the world -- stays exactly
1983+/// where it was rather than moving on its own.
1984+#[test]
1985+fn a_selection_drag_refuses_as_one_set_when_any_pick_cannot_land() {
1986+ use engine::project::LaneKind;
1987+
1988+ let mut session = PlaybackSession::open(asset("test_av.mp4")).expect("open the fixture");
1989+ session.set_gain(0.0);
1990+ let path = session.sources()[0].path.clone();
1991+ session.import(&asset("test_av2.mp4")).expect("av2 matches");
1992+ let second = session.sources()[1].path.clone();
1993+
1994+ assert!(session
1995+ .place_stream_at(10.0, &second, 0, None)
1996+ .expect("av2 is on this timeline"));
1997+ let clip0 = session.lane_clips(Lane::V1)[0];
1998+ let clip1 = session.lane_clips(Lane::V1)[1];
1999+
2000+ let v2 = session.add_lane(LaneKind::Video);
2001+ assert!(session
2002+ .place_stream_at(0.0, &path, 0, Some(v2))
2003+ .expect("test_av.mp4 is on this timeline"));
2004+ let clip_c = session.lane_clips(v2)[0];
2005+ // A clip clip1 is not picked, blocking the road on V2 the drag is about
2006+ // to try: clip1 dragged onto V2 lands its head inside this one.
2007+ assert!(session
2008+ .place_stream_at(10.0, &second, 0, Some(v2))
2009+ .expect("av2 is on this timeline"));
2010+ let blocker = session.lane_clips(v2)[1];
2011+ assert_eq!(blocker.start, 300);
2012+
2013+ let picks = [(Lane::V1, 0), (Lane::V1, 1), (v2, 0)];
2014+ // Dragged onto V2 at a frame inside the blocker: refused outright, the
2015+ // way a lone drag onto another clip already is.
2016+ assert!(!session.move_selection_to(
2017+ &picks,
2018+ Lane::V1,
2019+ 1,
2020+ v2,
2021+ blocker.start + 10
2022+ ));
2023+ // Nothing moved -- not clip1 clamped short of the blocker, and not the
2024+ // two picks that had all the room to spare.
2025+ assert_eq!(session.lane_clips(Lane::V1)[0], clip0);
2026+ assert_eq!(session.lane_clips(Lane::V1)[1], clip1);
2027+ assert_eq!(session.lane_clips(v2)[0], clip_c);
2028+ assert_eq!(session.lane_clips(v2)[1], blocker);
2029+}
2030+
2031+/// A plain click's copy is one clipboard entry, and one entry still takes
2032+/// [`PlaybackSession::paste_at`] -- the door it always has, unchanged by a
2033+/// set ever being able to ride [`PlaybackSession::paste_set_at`] instead.
2034+#[test]
2035+fn a_single_pick_copy_paste_round_trips_unchanged() {
2036+ let mut session = PlaybackSession::open(asset("test_av.mp4")).expect("open the fixture");
2037+ session.set_gain(0.0);
2038+ // `open` seeds V1 with the whole fixture as its own clip -- what a plain
2039+ // click would copy.
2040+ let copied = session.lane_clips(Lane::V1)[0];
2041+
2042+ let at = session.timeline_duration();
2043+ assert!(session.paste_at(at, copied), "a free spot always takes it");
2044+ let pasted = session.lane_clips(Lane::V1)[1];
2045+ assert_eq!(
2046+ (pasted.source, pasted.in_frame, pasted.out_frame),
2047+ (copied.source, copied.in_frame, copied.out_frame),
2048+ "the pasted clip plays the same source frames the copy did"
2049+ );
2050+
2051+ assert!(session.undo(), "one step for the paste");
2052+ assert_eq!(session.lane_clips(Lane::V1).len(), 1);
2053+}
2054+
2055+/// [`PlaybackSession::paste_set_at`], the set-copy's own door
2056+/// ([`Player::paste`]'s multi-entry path): three picks across two lanes, some
2057+/// distance apart, keep that same distance and the same lane each landed on
2058+/// -- the offset [`Project::paste_set`] moves every item by is the one from
2059+/// the earliest pick to `at`, not a collapse onto `V1`/`A1`.
2060+#[test]
2061+fn a_three_pick_copy_paste_preserves_gaps_and_lane_assignment() {
2062+ use engine::project::LaneKind;
2063+
2064+ let mut session = PlaybackSession::open(asset("test_av.mp4")).expect("open the fixture");
2065+ session.set_gain(0.0);
2066+ let path = session.sources()[0].path.clone();
2067+ session.import(&asset("test_av2.mp4")).expect("av2 matches");
2068+ let second = session.sources()[1].path.clone();
2069+
2070+ assert!(session
2071+ .place_stream_at(10.0, &second, 0, None)
2072+ .expect("av2 is on this timeline"));
2073+ let clip0 = session.lane_clips(Lane::V1)[0];
2074+ let clip1 = session.lane_clips(Lane::V1)[1];
2075+
2076+ let v2 = session.add_lane(LaneKind::Video);
2077+ assert!(session
2078+ .place_stream_at(20.0, &path, 0, Some(v2))
2079+ .expect("test_av.mp4 is on this timeline"));
2080+ let clip_c = session.lane_clips(v2)[0];
2081+
2082+ // Copied in click order, out of the lanes each was clicked in -- exactly
2083+ // what `Player::copy_selected` builds.
2084+ let items = [(Lane::V1, clip0), (Lane::V1, clip1), (v2, clip_c)];
2085+ let at = session.timeline_duration();
2086+ assert!(session.paste_set_at(at, &items), "a free spot takes the set");
2087+
2088+ let new0 = session.lane_clips(Lane::V1)[2];
2089+ let new1 = session.lane_clips(Lane::V1)[3];
2090+ let new_c = session.lane_clips(v2)[1];
2091+ // The gaps between picks survive the trip untouched.
2092+ assert_eq!(new1.start - new0.start, clip1.start - clip0.start);
2093+ assert_eq!(new_c.start - new0.start, clip_c.start - clip0.start);
2094+ // And each still plays the source frames it was copied with, off the
2095+ // lane it was copied off of.
2096+ assert_eq!(
2097+ (new0.source, new0.in_frame, new0.out_frame),
2098+ (clip0.source, clip0.in_frame, clip0.out_frame)
2099+ );
2100+ assert_eq!(
2101+ (new_c.source, new_c.in_frame, new_c.out_frame),
2102+ (clip_c.source, clip_c.in_frame, clip_c.out_frame)
2103+ );
2104+
2105+ assert!(session.undo(), "one step for the whole set-paste");
2106+ assert_eq!(session.lane_clips(Lane::V1).len(), 2);
2107+ assert_eq!(session.lane_clips(v2).len(), 1);
2108+}
2109+
2110+/// A set-paste never ripples the bed: a landing that would overlap so much
2111+/// as one existing clip on its own lane refuses the *whole* set, exactly as
2112+/// [`Project::paste_set`] documents, leaving the project as it was rather
2113+/// than placing the picks that had room to spare.
2114+#[test]
2115+fn a_colliding_set_paste_refuses_whole() {
2116+ use engine::project::LaneKind;
2117+
2118+ let mut session = PlaybackSession::open(asset("test_av.mp4")).expect("open the fixture");
2119+ session.set_gain(0.0);
2120+ let path = session.sources()[0].path.clone();
2121+ session.import(&asset("test_av2.mp4")).expect("av2 matches");
2122+ let second = session.sources()[1].path.clone();
2123+
2124+ assert!(session
2125+ .place_stream_at(10.0, &second, 0, None)
2126+ .expect("av2 is on this timeline"));
2127+ let clip0 = session.lane_clips(Lane::V1)[0];
2128+ let clip1 = session.lane_clips(Lane::V1)[1];
2129+
2130+ let v2 = session.add_lane(LaneKind::Video);
2131+ assert!(session
2132+ .place_stream_at(20.0, &path, 0, Some(v2))
2133+ .expect("test_av.mp4 is on this timeline"));
2134+ let clip_c = session.lane_clips(v2)[0];
2135+
2136+ let items = [(Lane::V1, clip0), (Lane::V1, clip1), (v2, clip_c)];
2137+ // A blocker sat right where the V1 half of the set would land: pasting
2138+ // at the timeline's own start walks every item straight back onto the
2139+ // lanes it was copied off of, colliding with everything already there.
2140+ assert!(!session.paste_set_at(0.0, &items));
2141+
2142+ assert_eq!(session.lane_clips(Lane::V1)[0], clip0);
2143+ assert_eq!(session.lane_clips(Lane::V1)[1], clip1);
2144+ assert_eq!(session.lane_clips(v2)[0], clip_c);
2145+ assert_eq!(session.lane_clips(Lane::V1).len(), 2);
2146+ assert_eq!(session.lane_clips(v2).len(), 1);
2147+}
2148+
2149+/// The refactor `move_clip` -> `move_selection` owes: a clip dragged from
2150+/// outside the selection (or with nothing else selected) moves exactly as it
2151+/// always has -- `move_clip_to`'s own door and `move_selection_to`'s
2152+/// selection-of-one both walk the same code, so they cannot drift apart.
2153+#[test]
2154+fn a_lone_clip_drag_is_unchanged_by_the_selection_path() {
2155+ use engine::project::LaneKind;
2156+
2157+ let mut session = PlaybackSession::open(asset("test_av.mp4")).expect("open the fixture");
2158+ session.set_gain(0.0);
2159+ let v2 = session.add_lane(LaneKind::Video);
2160+
2161+ assert!(session.move_clip_to(Lane::V1, 0, v2, 0), "V1 -> V2");
2162+ assert!(session.lane_clips(Lane::V1).is_empty());
2163+ assert_eq!(session.lane_clips(v2).len(), 1);
2164+
2165+ // The other kind of lane is refused exactly as before.
2166+ assert!(!session.move_clip_to(v2, 0, Lane::A1, 0));
2167+ // A drop back where it was picked up is a click, still refused.
2168+ let clip = session.lane_clips(v2)[0];
2169+ assert!(!session.move_clip_to(v2, 0, v2, clip.start));
2170+}
2171+
19032172 /// A caption grouped with a clip on an *added* lane closes its lane's hole
19042173 /// too, not just the first pair's: the same law commit `cdc53a6` gave `V1`
19052174 /// (`whole_take` -> `Project::delete_members`) has to hold from every anchor
@@ -2182,3 +2451,63 @@ fn should_loop_restart_is_play_state_blind_the_pump_gates_it() {
21822451 into-it -- that distinction is pump's is_playing() guard, not this"
21832452 );
21842453 }
2454+
2455+/// This binary has no `TestAppContext` to press a live escape through, so the
2456+/// guard reads the ordering `render.rs`'s key listener actually runs: every
2457+/// card/menu/list close returns before the fallthrough that dispatches
2458+/// `ActionId::Deselect` ever runs, so escape with one of them open closes it
2459+/// and never touches `self.selected` -- the picks made before the card opened
2460+/// are still there once it is gone.
2461+#[test]
2462+fn escape_closes_a_card_before_it_can_ever_reach_deselect() {
2463+ let render_rs = src_text("render.rs");
2464+ let dispatch = render_rs
2465+ .find("if let Some(action) = action {")
2466+ .expect("the keymap fallthrough that fires Deselect");
2467+ for (guard, label) in [
2468+ ("if this.keys_open {", "the keys overlay"),
2469+ ("if this.dock_filter_edit {", "the dock filter"),
2470+ (
2471+ "if this.param_card_key(key, event.keystroke.modifiers.shift, cx) {",
2472+ "a param card",
2473+ ),
2474+ (
2475+ "if escape_leaves_player_fullscreen(key, ctrl, this.player_fullscreen) {",
2476+ "player fullscreen",
2477+ ),
2478+ ("let clip_menu = this.context_menu.take().is_some();", "the clip/row menu or a list"),
2479+ (
2480+ "if key == ESCAPE && !ctrl && this.preview_session.is_some() {",
2481+ "an open preview",
2482+ ),
2483+ ] {
2484+ let at = render_rs
2485+ .find(guard)
2486+ .unwrap_or_else(|| panic!("{label}'s own escape guard moved or was renamed"));
2487+ assert!(
2488+ at < dispatch,
2489+ "{label}'s guard reads after the Deselect dispatch -- escape would \
2490+ clear the selection before this card ever got a look at the key"
2491+ );
2492+ }
2493+}
2494+
2495+/// The other half: with nothing on screen to claim the key, bare escape falls
2496+/// all the way through to `Player::act`, whose `ActionId::Deselect` arm is
2497+/// the one place `self.selected` is emptied by a bare stroke rather than by
2498+/// picking something else.
2499+#[test]
2500+fn escape_with_nothing_open_empties_the_selection() {
2501+ let actions_rs = src_text("player/actions.rs");
2502+ assert!(
2503+ actions_rs.contains("ActionId::Deselect => {")
2504+ && actions_rs.contains("self.selected = Selection::new();"),
2505+ "the Deselect arm no longer clears self.selected"
2506+ );
2507+ let k = keymap::Keymap::defaults();
2508+ assert_eq!(
2509+ k.lookup("escape", false),
2510+ Some(ActionId::Deselect),
2511+ "bare escape must still route to Deselect for that arm to ever run"
2512+ );
2513+}
crates/app/src/tests/layout.rsmodified+48 -12
@@ -2135,22 +2135,48 @@ fn the_notice_plate_declares_a_bounded_wrapping_text_layout() {
21352135 }
21362136
21372137 /// A round trip through the file: what is saved is what the next load reads
2138-/// back, one seam touched and the other left at its default -- a scratch
2139-/// path, not the real config, the same isolation `keymap::tests`' own
2140-/// `load_from`/`save_to` already takes.
2138+/// back, all five seams touched -- a scratch path, not the real config, the
2139+/// same isolation `keymap::tests`' own `load_from`/`save_to` already takes.
2140+/// One of the five is written past its own ceiling (the library, past
2141+/// `SIDE_MAX_FRAC` of the window it is loaded back into): a file written at
2142+/// a wider window must not hand a narrower one an illegal layout, so the
2143+/// load clamps it back down rather than reading it verbatim.
21412144 #[test]
21422145 fn a_saved_seam_survives_a_reload() {
2143- use crate::{Split, Splits, load_stance_splits_from, save_stance_splits_to};
2146+ use crate::{
2147+ BENCH_MIN_H, SIDE_MAX_FRAC, Split, Splits, load_stance_splits_from, save_stance_splits_to,
2148+ };
2149+ use gpui::{Pixels, Size, px, size};
21442150
21452151 let dir = engine::scratch::Scratch::dir("edith-stance-splits");
21462152 let path = dir.join("stance-splits");
2153+ let window: Size<Pixels> = size(px(1280.), px(720.));
21472154
21482155 let mut splits = Splits::default();
2156+ splits.set(Split::Library, 9000.);
2157+ splits.set(Split::Inspector, 200.);
2158+ splits.set(Split::Timeline, 250.);
21492159 splits.set(Split::Dock, 333.);
2160+ splits.set(Split::Bench, 200.);
21502161 save_stance_splits_to(&splits, &path);
2151- let loaded = load_stance_splits_from(&path);
2162+ let loaded = load_stance_splits_from(&path, window);
2163+ assert_eq!(
2164+ loaded.get(Split::Library),
2165+ Some(1280. * SIDE_MAX_FRAC),
2166+ "a library past its own ceiling should clamp to it on load"
2167+ );
2168+ assert_eq!(loaded.get(Split::Inspector), Some(200.));
2169+ assert_eq!(loaded.get(Split::Timeline), Some(250.));
21522170 assert_eq!(loaded.get(Split::Dock), Some(333.));
2153- assert_eq!(loaded.get(Split::Bench), None);
2171+ assert_eq!(loaded.get(Split::Bench), Some(200.));
2172+
2173+ // A bench saved below its own floor clamps up to it, the same ceiling
2174+ // logic mirrored on the one seam whose bound is a minimum.
2175+ let mut low_bench = Splits::default();
2176+ low_bench.set(Split::Bench, 1.);
2177+ save_stance_splits_to(&low_bench, &path);
2178+ let loaded = load_stance_splits_from(&path, window);
2179+ assert_eq!(loaded.get(Split::Bench), Some(BENCH_MIN_H));
21542180 }
21552181
21562182 /// The guard [`crate::split_drag_owes_save`] runs at the moment a drag ends
@@ -2158,18 +2184,18 @@ fn a_saved_seam_survives_a_reload() {
21582184 /// wired to a live `MouseExitEvent` a `TestAppContext`-less test binary
21592185 /// cannot raise -- see `tests/media.rs`'s own note on the same limit, and
21602186 /// the harness drive `D2` in this session's report for the wiring itself).
2161-/// What *is* checkable here without a window: exactly the two persisted
2187+/// What *is* checkable here without a window: exactly the persisted
21622188 /// seams owe that save, the same set `Split::PERSISTED` already names, and a
21632189 /// drag that never started (`None`) owes nothing.
21642190 #[test]
2165-fn only_the_two_persisted_seams_owe_a_save_when_a_drag_loses_the_window() {
2191+fn only_the_persisted_seams_owe_a_save_when_a_drag_loses_the_window() {
21662192 use crate::{Split, player::timeline_edit::split_drag_owes_save};
21672193
21682194 assert!(split_drag_owes_save(Some(Split::Dock)));
21692195 assert!(split_drag_owes_save(Some(Split::Bench)));
2170- assert!(!split_drag_owes_save(Some(Split::Library)));
2171- assert!(!split_drag_owes_save(Some(Split::Inspector)));
2172- assert!(!split_drag_owes_save(Some(Split::Timeline)));
2196+ assert!(split_drag_owes_save(Some(Split::Library)));
2197+ assert!(split_drag_owes_save(Some(Split::Inspector)));
2198+ assert!(split_drag_owes_save(Some(Split::Timeline)));
21732199 assert!(!split_drag_owes_save(None));
21742200 }
21752201
@@ -2178,9 +2204,14 @@ fn only_the_two_persisted_seams_owe_a_save_when_a_drag_loses_the_window() {
21782204 #[test]
21792205 fn a_missing_stance_splits_file_leaves_every_region_at_its_default() {
21802206 use crate::{Split, load_stance_splits_from};
2207+ use gpui::{Pixels, Size, px, size};
21812208
21822209 let dir = engine::scratch::Scratch::dir("edith-stance-splits-missing");
2183- let splits = load_stance_splits_from(&dir.join("nothing-here"));
2210+ let window: Size<Pixels> = size(px(1280.), px(720.));
2211+ let splits = load_stance_splits_from(&dir.join("nothing-here"), window);
2212+ assert_eq!(splits.get(Split::Library), None);
2213+ assert_eq!(splits.get(Split::Inspector), None);
2214+ assert_eq!(splits.get(Split::Timeline), None);
21842215 assert_eq!(splits.get(Split::Dock), None);
21852216 assert_eq!(splits.get(Split::Bench), None);
21862217 }
@@ -2639,6 +2670,11 @@ fn every_action_has_a_darkroom_widget_home_or_explicit_owner() {
26392670 clicks, so a click-through door for \"move keyboard focus\" \
26402671 has nothing to do that a click has not already done",
26412672 ),
2673+ (
2674+ ActionId::Deselect,
2675+ "clicking empty timeline space already clears the selection with the mouse; \
2676+ bare escape is a keyboard-only accelerator for that existing door, not a new one",
2677+ ),
26422678 ];
26432679 let darkroom = [
26442680 "ui/bench_stance.rs",
crates/app/src/timeline_math.rsmodified+30 -8
@@ -362,15 +362,37 @@ pub(crate) fn should_loop_restart(frame: u32, window: Option<(u32, u32)>) -> boo
362362 window.is_some_and(|(_, hi)| frame >= hi)
363363 }
364364
365+/// Which window is actually looping, in priority order: the i/o range
366+/// ([`Player::range`]) beats the subject-cut trim ([`Player::loop_trim`])
367+/// beats the whole timeline -- but only once *something* is already armed
368+/// (`loop_on` or `loop_trim`). A bare in/out mark with neither on is an
369+/// export mark first, not a loop request, so it answers `None` here and
370+/// never restarts anything on its own.
371+pub(crate) fn active_loop_window(
372+ loop_on: bool,
373+ range: Option<(u32, u32)>,
374+ loop_trim: Option<(u32, u32)>,
375+) -> Option<(u32, u32)> {
376+ if !loop_on && loop_trim.is_none() {
377+ return None;
378+ }
379+ range.or(loop_trim)
380+}
381+
365382 /// Where a play resumes from on crossing into [`Transport::Ended`]
366-/// (`Player::pump`): the loop-trim window's own near edge when one is armed,
367-/// *even when its far edge is the film's own last frame* -- half of all cuts
368-/// in a two-clip film sit on the final clip (DESIGN.md §6), so that coincidence
369-/// is not an edge case and must not read as "reached the end, stop". Falls
370-/// back to the whole-timeline loop's top, and `None` -- neither armed --
371-/// restarts nothing, which is the halt this crossing otherwise means.
372-pub(crate) fn loop_restart_frame(loop_on: bool, loop_trim: Option<(u32, u32)>) -> Option<u32> {
373- match loop_trim {
383+/// (`Player::pump`): the active window's own near edge
384+/// ([`active_loop_window`]) when one is armed, *even when its far edge is
385+/// the film's own last frame* -- half of all cuts in a two-clip film sit on
386+/// the final clip (DESIGN.md §6), so that coincidence is not an edge case
387+/// and must not read as "reached the end, stop". Falls back to the
388+/// whole-timeline loop's top, and `None` -- nothing armed -- restarts
389+/// nothing, which is the halt this crossing otherwise means.
390+pub(crate) fn loop_restart_frame(
391+ loop_on: bool,
392+ range: Option<(u32, u32)>,
393+ loop_trim: Option<(u32, u32)>,
394+) -> Option<u32> {
395+ match active_loop_window(loop_on, range, loop_trim) {
374396 Some((lo, _)) => Some(lo),
375397 None => loop_on.then_some(0),
376398 }
crates/app/src/ui/bench_stance.rsmodified+2 -0
@@ -1124,6 +1124,8 @@ fn lane_row(
11241124 .children(
11251125 player
11261126 .ghost
1127+ .iter()
1128+ .copied()
11271129 .filter(|g| g.lane == lane && cx.has_active_drag())
11281130 .map(|g| {
11291131 div()
crates/app/src/ui/inspector.rsmodified+100 -0
@@ -121,6 +121,19 @@ impl Player {
121121 let sub = self.session.as_ref()?.sub_lane(lane).get(idx).copied()?;
122122 Some((lane, sub))
123123 });
124+ // The transition the anchor's clip carries into its successor, if
125+ // any -- a dissolve on a video lane ([`Clip::transition_out`]) or a
126+ // crossfade on an audio lane, told apart from a plain one-sided fade
127+ // by [`Project::crossfade`]'s own signature: both ends of the join
128+ // set together. `cap` is what the pair actually offers, the same
129+ // ceiling the engine's own setters clamp to, so the row never claims
130+ // more room than a step could land in.
131+ let transition = self.selected.anchor().and_then(|(lane, idx)| {
132+ let session = self.session.as_ref()?;
133+ let clips = session.lane_clips(lane);
134+ let (label, frames, cap) = transition_of(lane.kind, clips.get(idx)?, clips.get(idx + 1))?;
135+ Some((lane, idx, label, frames, cap))
136+ });
124137 // A multi-selection is named for its anchor and counted: what the
125138 // panel shows is the anchor's settings, and the count says there is
126139 // more in hand than the panel is showing.
@@ -190,6 +203,14 @@ impl Player {
190203 .text_color(rgb(FG_SECONDARY()))
191204 .child(detail),
192205 )
206+ // The duration field: a value and its own two steppers, the
207+ // shape `mbps_steppers` already draws for the export card's
208+ // bitrate -- present only while the anchor carries a transition,
209+ // since a row for a number that means nothing is a row lying
210+ // about what is selected.
211+ .when_some(transition, |d, (lane, idx, label, frames, cap)| {
212+ d.child(self.transition_duration_row(lane, idx, label, frames, cap, cx))
213+ })
193214 .child(
194215 div()
195216 .flex()
@@ -268,6 +289,56 @@ impl Player {
268289 )
269290 }
270291
292+ /// The duration row a transition-carrying anchor grows under
293+ /// `selection_section`'s detail line: `frames` as the engine counts it,
294+ /// flanked by the −/+ steppers [`Player::mbps_steppers`] already draws
295+ /// for the export card's bitrate row -- a field, not the drag handle
296+ /// `659770a` deliberately shrank the join's hit target away from. Each
297+ /// press nudges by one frame ([`Player::nudge_transition`]); the engine's
298+ /// own setters clamp to `cap`, so a run of presses past what the
299+ /// successor offers stops there rather than erroring.
300+ fn transition_duration_row(
301+ &self,
302+ lane: Lane,
303+ idx: usize,
304+ label: &'static str,
305+ frames: u32,
306+ cap: u32,
307+ cx: &mut Context<Self>,
308+ ) -> impl IntoElement {
309+ let step = |id: &'static str, glyph: &'static str, by: i32, cx: &mut Context<Self>| {
310+ div()
311+ .id(id)
312+ .flex()
313+ .w(px(HIT_MIN))
314+ .h(px(HIT_MIN))
315+ .items_center()
316+ .justify_center()
317+ .rounded(px(3.))
318+ .bg(rgb(BG_RAISED()))
319+ .cursor_pointer()
320+ .hover(|s| s.bg(rgb(BG_HOVER())))
321+ .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {
322+ this.nudge_transition(lane, idx, by, cx);
323+ }))
324+ .child(glyph)
325+ };
326+ div()
327+ .flex_none()
328+ .flex()
329+ .items_center()
330+ .gap(px(6.))
331+ .child(
332+ div()
333+ .flex_1()
334+ .text_size(px(11.))
335+ .text_color(rgb(FG_SECONDARY()))
336+ .child(format!("{label} {frames}f (of {cap}f offered)")),
337+ )
338+ .child(step("transition-down", "−", -1, cx))
339+ .child(step("transition-up", "+", 1, cx))
340+ }
341+
271342 /// The settings that are the *project's* rather than any clip's: the canvas
272343 /// every clip is composed onto, the rate it is cut at, the HDR rendition it
273344 /// is watched in, and the mix everything sums into. They used to be four
@@ -418,6 +489,35 @@ impl Player {
418489 }
419490 }
420491
492+/// The transition a clip carries into its immediate successor, if any -- a
493+/// dissolve on a video lane ([`Clip::transition_out`]) or a crossfade on an
494+/// audio lane, told apart from a plain one-sided fade drag by
495+/// [`Project::crossfade`]'s own signature: both ends of the join set
496+/// together, not just this clip's tail. `cap` is what the pair actually
497+/// offers -- the shorter of the two clips' own lengths -- the same ceiling
498+/// [`Project::set_transition_out`]/[`Project::crossfade`] clamp to, so the
499+/// row this feeds never claims more room than a step could land in.
500+///
501+/// Free of `Context` and of [`PlaybackSession`] alike, so it is testable
502+/// without either -- this test binary has neither a `TestAppContext` nor
503+/// real media to open one with (`split_drag_owes_save`'s own reason for
504+/// being pulled out the same way).
505+pub(crate) fn transition_of(
506+ lane_kind: LaneKind,
507+ clip: &Clip,
508+ next: Option<&Clip>,
509+) -> Option<(&'static str, u32, u32)> {
510+ let next = next.filter(|n| n.start == clip.end())?;
511+ let cap = clip.frames().min(next.frames());
512+ match lane_kind {
513+ LaneKind::Video if clip.transition_out > 0 => Some(("Dissolve", clip.transition_out, cap)),
514+ LaneKind::Audio if clip.fade_out > 0 && next.fade_in > 0 => {
515+ Some(("Crossfade", clip.fade_out, cap))
516+ }
517+ _ => None,
518+ }
519+}
520+
421521 /// A region's own title bar: the same 24 px strip in the library and the
422522 /// inspector, so the two columns read as the pair they are.
423523 pub(crate) fn section_head(title: &'static str) -> impl IntoElement {
crates/app/src/ui/timeline.rsmodified+9 -5
@@ -850,11 +850,15 @@ impl Player {
850850 .snap_cue
851851 .filter(|_| self.trim.is_some() || cx.has_active_drag())
852852 .map(|frame| scale.px_at(f64::from(frame) / self.fps));
853- // The shadow, on the one lane the pointer is over -- and, like the line,
854- // only while the drag that asked for it is still in flight.
855- let ghost = self
853+ // The shadow (or shadows, on a set-drag -- [`Player::preview_ghost`]),
854+ // on the one lane each names -- and, like the line, only while the
855+ // drag that asked for it is still in flight.
856+ let ghost: Vec<Ghost> = self
856857 .ghost
857- .filter(|g| g.lane == lane && cx.has_active_drag());
858+ .iter()
859+ .copied()
860+ .filter(|g| g.lane == lane && cx.has_active_drag())
861+ .collect();
858862 let clips = self
859863 .session
860864 .as_ref()
@@ -1919,7 +1923,7 @@ impl Player {
19191923 // under a drag. Over the clips (it is translucent, so what
19201924 // it would cover shows through) and under the line, which
19211925 // marks the frame this box merely fills.
1922- .children(ghost.map(|g| {
1926+ .children(ghost.into_iter().map(|g| {
19231927 div()
19241928 .absolute()
19251929 .top_0()
crates/app/src/ui/toolbar.rsmodified+13 -1
@@ -170,6 +170,18 @@ impl Player {
170170 - 2. * SPLIT_W;
171171 let clock_w = TIME_W.min(room - 140.).max(96.);
172172 let slider = room >= TRANSPORT_ROOMY;
173+ // Which window the loop button actually restarts, in the same
174+ // priority [`active_loop_window`] picks it in: the marked i/o range
175+ // once something is armed, the subject-cut trim next, the whole
176+ // timeline last.
177+ let armed = self.loop_on || self.loop_trim.is_some();
178+ let loop_hint = if armed && self.range.is_some() {
179+ "restarts from the marked in point on reaching the marked out point, instead of stopping"
180+ } else if self.loop_trim.is_some() {
181+ "restarts from the subject cut's own start on reaching its end, instead of stopping"
182+ } else {
183+ "restarts from the top on reaching the end, instead of stopping"
184+ };
173185 div()
174186 .flex_none()
175187 .h(px(TRANSPORT_H))
@@ -213,7 +225,7 @@ impl Player {
213225 },
214226 None,
215227 "Loop",
216- "restarts from the top on reaching the end, instead of stopping",
228+ loop_hint,
217229 ActionId::Loop,
218230 cx.listener(|this, _: &ClickEvent, window, cx| {
219231 this.act(ActionId::Loop, window, cx)
crates/engine/src/playback.rsmodified+26 -0
@@ -2374,6 +2374,22 @@ impl PlaybackSession {
23742374 self.edit(Dirty::Both, |p| p.move_clip(from, idx, to, start))
23752375 }
23762376
2377+ /// [`move_clip_to`](Self::move_clip_to)'s general form: every one of
2378+ /// `picks` travels the same frame delta as the dragged clip at `idx` of
2379+ /// `from`, all-or-nothing, one undo step for the lot -- what a hand drags
2380+ /// on a selection rather than a lone clip. See
2381+ /// [`Project::move_selection`] for the clamp that makes it all-or-nothing.
2382+ pub fn move_selection_to(
2383+ &mut self,
2384+ picks: &[(Lane, usize)],
2385+ from: Lane,
2386+ idx: usize,
2387+ to: Lane,
2388+ start: u32,
2389+ ) -> bool {
2390+ self.edit(Dirty::Both, |p| p.move_selection(picks, from, idx, to, start))
2391+ }
2392+
23772393 /// Drags one end of that clip to timeline frame `to`, changing how much of
23782394 /// its source it plays and nothing else on the lane -- see [`Project::trim`]
23792395 /// for the walls it is clamped by, which this fills the source lengths in
@@ -2937,6 +2953,16 @@ impl PlaybackSession {
29372953 self.edit(Dirty::Both, |p| p.paste(at, clip))
29382954 }
29392955
2956+ /// [`paste_at`](Self::paste_at)'s general form: [`Project::paste_set`]'s
2957+ /// door, clamped to the timeline's own end the same way -- a set let go
2958+ /// past the last frame lands there rather than carrying black in front of
2959+ /// it, exactly as a lone clip's paste does.
2960+ pub fn paste_set_at(&mut self, timeline_secs: f64, items: &[(Lane, Clip)]) -> bool {
2961+ let at = secs_to_frame(timeline_secs, self.meta.frame_rate)
2962+ .min(self.project.timeline_frames());
2963+ self.edit(Dirty::Both, |p| p.paste_set(at, items))
2964+ }
2965+
29402966 /// Places the whole of `path` played on its audio `stream` at
29412967 /// `timeline_secs`, the way [`paste_at`](Self::paste_at) places a copy --
29422968 /// the door a library row goes through, and the only way a stream other
crates/engine/src/project.rsmodified+119 -7
@@ -3591,23 +3591,71 @@ impl Project {
35913591 /// is on, and a drop that changes neither lane nor frame, which is a clip
35923592 /// picked up and put back down, i.e. a click.
35933593 pub fn move_clip(&mut self, from: Lane, idx: usize, to: Lane, start: u32) -> bool {
3594+ self.move_selection(&[(from, idx)], from, idx, to, start)
3595+ }
3596+
3597+ /// [`move_clip`](Self::move_clip)'s general form: every pick in `picks`
3598+ /// (each with its own link group, exactly as [`group_of`](Self::group_of)
3599+ /// reads it) travels the same distance as the clip at `idx` of `from`,
3600+ /// which alone changes lane, onto `to`. One clamp across the whole set
3601+ /// ([`move_room`](Self::move_room)) is what makes this all-or-nothing: a
3602+ /// neighbour that boxes in *any* member narrows the delta every member
3603+ /// moves by, and a member with no room at all (`lo > hi`) refuses the
3604+ /// whole set rather than moving the rest and leaving that one behind.
3605+ /// `move_clip` is this with a selection of one -- the dragged clip's own
3606+ /// group and nothing else -- so a drag on a clip outside the selection is
3607+ /// byte-identical to before this existed.
3608+ pub fn move_selection(
3609+ &mut self,
3610+ picks: &[(Lane, usize)],
3611+ from: Lane,
3612+ idx: usize,
3613+ to: Lane,
3614+ start: u32,
3615+ ) -> bool {
35943616 let (Some(dest), Some(clip)) = (self.index(to), self.lane(from).get(idx).copied()) else {
35953617 return false;
35963618 };
35973619 if from.kind != to.kind {
35983620 return false;
35993621 }
3600- let members = self.group_of(from, idx).expect("the clip was found");
36013622 let held = self.index(from).expect("the clip was found on it");
3602- // The two halves of one group would land on one span of one lane, which
3603- // is the one thing a link may never mean. Refused rather than clamped:
3604- // the partner moves the same distance, so there is no room for it
3605- // anywhere on that lane.
3623+ // Every pick's own group, unioned: the whole selection moves as one,
3624+ // and a pick's link partners (not themselves picked) come along with
3625+ // it exactly as a lone drag's do.
3626+ let mut members = Members::default();
3627+ for &(lane, i) in picks {
3628+ let Some(group) = self.group_of(lane, i) else {
3629+ continue;
3630+ };
3631+ for m in group.clips {
3632+ if !members.clips.contains(&m) {
3633+ members.clips.push(m);
3634+ }
3635+ }
3636+ for m in group.subs {
3637+ if !members.subs.contains(&m) {
3638+ members.subs.push(m);
3639+ }
3640+ }
3641+ }
3642+ if !members.clips.contains(&(held, idx)) {
3643+ members.clips.push((held, idx));
3644+ }
3645+ // The two halves of *the dragged clip's own* group would land on one
3646+ // span of one lane, which is the one thing a link may never mean --
3647+ // checked against that group alone, not the whole moving set: an
3648+ // unlinked fellow pick already sitting on `dest` is no conflict at
3649+ // all, since it travels by the same delta and `move_room` below
3650+ // leaves it the room to. Refused rather than clamped: the partner
3651+ // moves the same distance, so there is no room for it anywhere on
3652+ // that lane.
3653+ let own_group = self.group_of(from, idx).expect("the clip was found");
36063654 if dest != held
3607- && members
3655+ && own_group
36083656 .clips
36093657 .iter()
3610- .chain(&members.subs)
3658+ .chain(&own_group.subs)
36113659 .any(|&(l, _)| l == dest)
36123660 {
36133661 return false;
@@ -4156,6 +4204,70 @@ impl Project {
41564204 true
41574205 }
41584206
4207+ /// [`paste`](Project::paste)'s general form: every `(lane, clip)` in
4208+ /// `items` lands on the lane it names, its head moved by the offset every
4209+ /// other item moves by too -- `at` less the earliest `start` among them,
4210+ /// so the set's own gaps and lane assignment survive the trip from
4211+ /// clipboard to bed unchanged, rather than collapsing onto `V1`/`A1` the
4212+ /// way a lone clip's copy does.
4213+ ///
4214+ /// All-or-nothing, and **refused** rather than opening room or splitting
4215+ /// a neighbour the way [`paste`](Project::paste) does for one clip:
4216+ /// a set-paste never ripples the bed, so a landing that overlaps so much
4217+ /// as one existing clip on its own lane refuses the whole set, changing
4218+ /// nothing -- the paste's own [`move_selection`](Project::move_selection)
4219+ /// clamps instead of refusing, but a paste has no drag to clamp against,
4220+ /// and a landing moved off the frame asked for is not what a paste means.
4221+ /// `items` empty, naming a lane or a source that is not there, or a clip
4222+ /// with `out_frame <= in_frame`, refuses too, before anything is touched.
4223+ ///
4224+ /// Exactly one history snapshot for the whole set, so one
4225+ /// [`Project::undo`] takes it back. Changes the timeline->source mapping
4226+ /// on every lane an item lands on: the caller must reseek.
4227+ pub fn paste_set(&mut self, at: u32, items: &[(Lane, Clip)]) -> bool {
4228+ let Some(anchor) = items.iter().map(|(_, c)| c.start).min() else {
4229+ return false;
4230+ };
4231+ // Resolved once, up front, off the lanes as they stand now: a lane or
4232+ // source that is not there, or a landing that would overlap a
4233+ // neighbour, refuses the whole set before any of it is written.
4234+ let mut landings: Vec<(usize, Clip)> = Vec::with_capacity(items.len());
4235+ for &(lane, clip) in items {
4236+ let Some(li) = self.index(lane) else {
4237+ return false;
4238+ };
4239+ if self.sources.get(clip.source).is_none() || clip.out_frame <= clip.in_frame {
4240+ return false;
4241+ }
4242+ let delta = i64::from(clip.start) - i64::from(anchor);
4243+ let Ok(start) = u32::try_from(i64::from(at) + delta) else {
4244+ return false;
4245+ };
4246+ let Some(end) = start.checked_add(clip.frames()) else {
4247+ return false;
4248+ };
4249+ if self.lanes[li]
4250+ .clips
4251+ .iter()
4252+ .any(|c| c.start < end && start < c.end())
4253+ {
4254+ return false;
4255+ }
4256+ landings.push((li, Clip { start, ..clip }));
4257+ }
4258+ self.snapshot();
4259+ for (li, mut clip) in landings {
4260+ clip.link = Some(self.new_link());
4261+ clip.fade_in = 0;
4262+ clip.fade_out = 0;
4263+ clip.transition_out = 0;
4264+ let clips = &mut self.lanes[li].clips;
4265+ let idx = clips.partition_point(|c| c.start < clip.start);
4266+ clips.insert(idx, clip);
4267+ }
4268+ true
4269+ }
4270+
41594271 /// Lift the clip at `idx` out of `lane`, leaving a gap: black frames or
41604272 /// silence, and nothing else moves. Refused only for an out-of-range index
41614273 /// (which a lane that is not there always is) -- lifting the last placement