🔀 merge(T9): track removal
Browse files at this commit4 changed files +234 -5
- crates/app/src/keymap.rs +25 -4
- crates/app/src/main.rs +94 -1
- crates/engine/src/playback.rs +7 -0
- crates/engine/src/project.rs +108 -0
crates/app/src/keymap.rsmodified+25 -4
| @@ -66,6 +66,8 @@ pub enum ActionId { | |||
| 66 | Undo, | 66 | Undo, |
| 67 | AddVideoLane, | 67 | AddVideoLane, |
| 68 | AddAudioLane, | 68 | AddAudioLane, |
| 69 | + RemoveVideoLane, | ||
| 70 | + RemoveAudioLane, | ||
| 69 | ToggleMute, | 71 | ToggleMute, |
| 70 | VolumeUp, | 72 | VolumeUp, |
| 71 | VolumeDown, | 73 | VolumeDown, |
| @@ -78,7 +80,7 @@ pub enum ActionId { | |||
| 78 | impl ActionId { | 80 | impl ActionId { |
| 79 | /// Display order everywhere -- the editor lists them in it and | 81 | /// Display order everywhere -- the editor lists them in it and |
| 80 | /// [`Keymap::defaults`] binds them in it. | 82 | /// [`Keymap::defaults`] binds them in it. |
| 81 | - pub const ALL: [ActionId; 33] = [ | 83 | + pub const ALL: [ActionId; 35] = [ |
| 82 | ActionId::Play, | 84 | ActionId::Play, |
| 83 | ActionId::StepBack, | 85 | ActionId::StepBack, |
| 84 | ActionId::StepForward, | 86 | ActionId::StepForward, |
| @@ -105,6 +107,8 @@ impl ActionId { | |||
| 105 | ActionId::Undo, | 107 | ActionId::Undo, |
| 106 | ActionId::AddVideoLane, | 108 | ActionId::AddVideoLane, |
| 107 | ActionId::AddAudioLane, | 109 | ActionId::AddAudioLane, |
| 110 | + ActionId::RemoveVideoLane, | ||
| 111 | + ActionId::RemoveAudioLane, | ||
| 108 | ActionId::ToggleMute, | 112 | ActionId::ToggleMute, |
| 109 | ActionId::VolumeUp, | 113 | ActionId::VolumeUp, |
| 110 | ActionId::VolumeDown, | 114 | ActionId::VolumeDown, |
| @@ -143,6 +147,8 @@ impl ActionId { | |||
| 143 | ActionId::Undo => "Undo", | 147 | ActionId::Undo => "Undo", |
| 144 | ActionId::AddVideoLane => "Add a video track", | 148 | ActionId::AddVideoLane => "Add a video track", |
| 145 | ActionId::AddAudioLane => "Add an audio track", | 149 | ActionId::AddAudioLane => "Add an audio track", |
| 150 | + ActionId::RemoveVideoLane => "Remove the last video track (it must be empty)", | ||
| 151 | + ActionId::RemoveAudioLane => "Remove the last audio track (it must be empty)", | ||
| 146 | ActionId::ToggleMute => "Mute / Unmute", | 152 | ActionId::ToggleMute => "Mute / Unmute", |
| 147 | ActionId::VolumeUp => "Volume up", | 153 | ActionId::VolumeUp => "Volume up", |
| 148 | ActionId::VolumeDown => "Volume down", | 154 | ActionId::VolumeDown => "Volume down", |
| @@ -183,6 +189,8 @@ impl ActionId { | |||
| 183 | ActionId::Undo => "undo", | 189 | ActionId::Undo => "undo", |
| 184 | ActionId::AddVideoLane => "add-video-lane", | 190 | ActionId::AddVideoLane => "add-video-lane", |
| 185 | ActionId::AddAudioLane => "add-audio-lane", | 191 | ActionId::AddAudioLane => "add-audio-lane", |
| 192 | + ActionId::RemoveVideoLane => "remove-video-lane", | ||
| 193 | + ActionId::RemoveAudioLane => "remove-audio-lane", | ||
| 186 | ActionId::ToggleMute => "toggle-mute", | 194 | ActionId::ToggleMute => "toggle-mute", |
| 187 | ActionId::VolumeUp => "volume-up", | 195 | ActionId::VolumeUp => "volume-up", |
| 188 | ActionId::VolumeDown => "volume-down", | 196 | ActionId::VolumeDown => "volume-down", |
| @@ -235,7 +243,9 @@ impl ActionId { | |||
| 235 | | ActionId::Group | 243 | | ActionId::Group |
| 236 | | ActionId::Undo | 244 | | ActionId::Undo |
| 237 | | ActionId::AddVideoLane | 245 | | ActionId::AddVideoLane |
| 238 | - | ActionId::AddAudioLane => Category::Editing, | 246 | + | ActionId::AddAudioLane |
| 247 | + | ActionId::RemoveVideoLane | ||
| 248 | + | ActionId::RemoveAudioLane => Category::Editing, | ||
| 239 | ActionId::ToggleMute | 249 | ActionId::ToggleMute |
| 240 | | ActionId::VolumeUp | 250 | | ActionId::VolumeUp |
| 241 | | ActionId::VolumeDown | 251 | | ActionId::VolumeDown |
| @@ -536,6 +546,13 @@ impl Keymap { | |||
| 536 | // is added often enough to deserve a key that is one press. | 546 | // is added often enough to deserve a key that is one press. |
| 537 | b(ActionId::AddVideoLane, "v", false), | 547 | b(ActionId::AddVideoLane, "v", false), |
| 538 | b(ActionId::AddAudioLane, "a", false), | 548 | b(ActionId::AddAudioLane, "a", false), |
| 549 | + // ...and the pair that takes one back, on ctrl chords: removing | ||
| 550 | + // a track is not a stroke to hit by accident (the resolution key | ||
| 551 | + // is out of the way for the same reason). Ctrl+v would be the | ||
| 552 | + // matching initial and is the paste, so the video one takes the | ||
| 553 | + // key beside it. | ||
| 554 | + b(ActionId::RemoveVideoLane, "b", true), | ||
| 555 | + b(ActionId::RemoveAudioLane, "a", true), | ||
| 539 | b(ActionId::ToggleMute, "m", false), | 556 | b(ActionId::ToggleMute, "m", false), |
| 540 | // The unshifted pair, which is what gpui reports for those two | 557 | // The unshifted pair, which is what gpui reports for those two |
| 541 | // keys ("=" and "-", platform.rs:862): the volume keys every | 558 | // keys ("=" and "-", platform.rs:862): the volume keys every |
| @@ -817,7 +834,7 @@ mod tests { | |||
| 817 | #[test] | 834 | #[test] |
| 818 | fn every_default_stroke_reaches_its_action() { | 835 | fn every_default_stroke_reaches_its_action() { |
| 819 | let k = Keymap::defaults(); | 836 | let k = Keymap::defaults(); |
| 820 | - assert_eq!(k.entries().len(), 35); | 837 | + assert_eq!(k.entries().len(), 37); |
| 821 | assert_eq!(k.lookup("space", false), Some(ActionId::Play)); | 838 | assert_eq!(k.lookup("space", false), Some(ActionId::Play)); |
| 822 | // The seek keys: bare arrows a frame, ctrl arrows a second, and the two | 839 | // The seek keys: bare arrows a frame, ctrl arrows a second, and the two |
| 823 | // ends of the timeline. | 840 | // ends of the timeline. |
| @@ -851,6 +868,10 @@ mod tests { | |||
| 851 | // The track keys are the bare letters; the ctrl ones stay copy/paste. | 868 | // The track keys are the bare letters; the ctrl ones stay copy/paste. |
| 852 | assert_eq!(k.lookup("v", false), Some(ActionId::AddVideoLane)); | 869 | assert_eq!(k.lookup("v", false), Some(ActionId::AddVideoLane)); |
| 853 | assert_eq!(k.lookup("a", false), Some(ActionId::AddAudioLane)); | 870 | assert_eq!(k.lookup("a", false), Some(ActionId::AddAudioLane)); |
| 871 | + // ...and the ctrl ones take a track away, out of the way of a stray | ||
| 872 | + // press. Ctrl+v is the paste, so the video one sits beside it. | ||
| 873 | + assert_eq!(k.lookup("b", true), Some(ActionId::RemoveVideoLane)); | ||
| 874 | + assert_eq!(k.lookup("a", true), Some(ActionId::RemoveAudioLane)); | ||
| 854 | assert_eq!(k.lookup("m", false), Some(ActionId::ToggleMute)); | 875 | assert_eq!(k.lookup("m", false), Some(ActionId::ToggleMute)); |
| 855 | assert_eq!(k.lookup("q", false), Some(ActionId::Equalizer)); | 876 | assert_eq!(k.lookup("q", false), Some(ActionId::Equalizer)); |
| 856 | // The volume pair is the unshifted one, so neither needs a modifier | 877 | // The volume pair is the unshifted one, so neither needs a modifier |
| @@ -1046,7 +1067,7 @@ mod tests { | |||
| 1046 | assert_eq!(whole("edith-keys 1\n").display(ActionId::Cut), "unbound"); | 1067 | assert_eq!(whole("edith-keys 1\n").display(ActionId::Cut), "unbound"); |
| 1047 | // The label is the editor's column, and never the file's word for it. | 1068 | // The label is the editor's column, and never the file's word for it. |
| 1048 | assert_eq!(ActionId::CancelExport.label(), "Cancel export"); | 1069 | assert_eq!(ActionId::CancelExport.label(), "Cancel export"); |
| 1049 | - assert_eq!(ActionId::ALL.len(), 33); | 1070 | + assert_eq!(ActionId::ALL.len(), 35); |
| 1050 | } | 1071 | } |
| 1051 | 1072 | ||
| 1052 | #[test] | 1073 | #[test] |
crates/app/src/main.rsmodified+94 -1
| @@ -870,6 +870,11 @@ impl Player { | |||
| 870 | ActionId::Undo => self.undo(cx), | 870 | ActionId::Undo => self.undo(cx), |
| 871 | ActionId::AddVideoLane => self.add_lane(LaneKind::Video, cx), | 871 | ActionId::AddVideoLane => self.add_lane(LaneKind::Video, cx), |
| 872 | ActionId::AddAudioLane => self.add_lane(LaneKind::Audio, cx), | 872 | ActionId::AddAudioLane => self.add_lane(LaneKind::Audio, cx), |
| 873 | + // The last track of that kind: the one the add key put there, so the | ||
| 874 | + // two strokes undo each other press for press. Any other track goes | ||
| 875 | + // through the × in its own header. | ||
| 876 | + ActionId::RemoveVideoLane => self.remove_last_lane(LaneKind::Video, cx), | ||
| 877 | + ActionId::RemoveAudioLane => self.remove_last_lane(LaneKind::Audio, cx), | ||
| 873 | ActionId::ToggleMute => self.set_volume(|volume| volume.muted = !volume.muted, cx), | 878 | ActionId::ToggleMute => self.set_volume(|volume| volume.muted = !volume.muted, cx), |
| 874 | ActionId::VolumeUp => self.set_volume(|volume| volume.step(true), cx), | 879 | ActionId::VolumeUp => self.set_volume(|volume| volume.step(true), cx), |
| 875 | ActionId::VolumeDown => self.set_volume(|volume| volume.step(false), cx), | 880 | ActionId::VolumeDown => self.set_volume(|volume| volume.step(false), cx), |
| @@ -2490,6 +2495,64 @@ impl Player { | |||
| 2490 | cx.notify(); | 2495 | cx.notify(); |
| 2491 | } | 2496 | } |
| 2492 | 2497 | ||
| 2498 | + /// The × in a track's header: the add taken back, one undo step, and the | ||
| 2499 | + /// engine's own words when it refuses -- those name the clips still on the | ||
| 2500 | + /// track, so the notice says what to delete first. A removal never deletes a | ||
| 2501 | + /// clip. | ||
| 2502 | + /// | ||
| 2503 | + /// Everything holding a `(lane, idx)` is dropped, because the tracks below | ||
| 2504 | + /// the one that went have just moved up an `ord` | ||
| 2505 | + /// ([`engine::Project::remove_lane`]): a selection or an open card kept | ||
| 2506 | + /// across it would be pointing at the *next* track's clip. | ||
| 2507 | + fn remove_lane(&mut self, lane: Lane, cx: &mut Context<Self>) { | ||
| 2508 | + if self.exporting().is_some() { | ||
| 2509 | + return; | ||
| 2510 | + } | ||
| 2511 | + let removed = self | ||
| 2512 | + .session | ||
| 2513 | + .as_mut() | ||
| 2514 | + .map(|session| session.remove_lane(lane)); | ||
| 2515 | + let text = match removed { | ||
| 2516 | + Some(Ok(())) => { | ||
| 2517 | + self.selected = None; | ||
| 2518 | + self.context_menu = None; | ||
| 2519 | + self.eq_open = None; | ||
| 2520 | + self.color_open = None; | ||
| 2521 | + self.speed_open = None; | ||
| 2522 | + self.close_silence(); | ||
| 2523 | + format!( | ||
| 2524 | + "{} REMOVED — {} brings it back", | ||
| 2525 | + lane.label(), | ||
| 2526 | + self.keymap.display(ActionId::Undo) | ||
| 2527 | + ) | ||
| 2528 | + } | ||
| 2529 | + Some(Err(e)) => format!("NO TRACK REMOVED — {e}"), | ||
| 2530 | + None => "NO TRACK REMOVED — open a file first".to_string(), | ||
| 2531 | + }; | ||
| 2532 | + self.notice = Some(text.into()); | ||
| 2533 | + cx.notify(); | ||
| 2534 | + } | ||
| 2535 | + | ||
| 2536 | + /// What the remove keys act on: the last track of that kind, which is the | ||
| 2537 | + /// one the matching add key appended. Nothing at all before a file is open, | ||
| 2538 | + /// where the timeline drawn is a placeholder pair. | ||
| 2539 | + fn remove_last_lane(&mut self, kind: LaneKind, cx: &mut Context<Self>) { | ||
| 2540 | + let last = self.session.as_ref().and_then(|session| { | ||
| 2541 | + session | ||
| 2542 | + .lanes() | ||
| 2543 | + .into_iter() | ||
| 2544 | + .filter(|l| l.kind == kind) | ||
| 2545 | + .next_back() | ||
| 2546 | + }); | ||
| 2547 | + match last { | ||
| 2548 | + Some(lane) => self.remove_lane(lane, cx), | ||
| 2549 | + None => { | ||
| 2550 | + self.notice = Some("NO TRACK REMOVED — open a file first".into()); | ||
| 2551 | + cx.notify(); | ||
| 2552 | + } | ||
| 2553 | + } | ||
| 2554 | + } | ||
| 2555 | + | ||
| 2493 | fn undo(&mut self, cx: &mut Context<Self>) { | 2556 | fn undo(&mut self, cx: &mut Context<Self>) { |
| 2494 | if self.session.as_mut().is_some_and(PlaybackSession::undo) { | 2557 | if self.session.as_mut().is_some_and(PlaybackSession::undo) { |
| 2495 | self.reset_after_reseek(); | 2558 | self.reset_after_reseek(); |
| @@ -5244,6 +5307,12 @@ impl Player { | |||
| 5244 | }); | 5307 | }); |
| 5245 | let name = lane.label(); | 5308 | let name = lane.label(); |
| 5246 | let row_id: SharedString = format!("{name}-clip").into(); | 5309 | let row_id: SharedString = format!("{name}-clip").into(); |
| 5310 | + let remove_id: SharedString = format!("{name}-remove").into(); | ||
| 5311 | + let remove_tip: SharedString = format!( | ||
| 5312 | + "Remove {name} — it must be empty first, and {} brings it back", | ||
| 5313 | + self.keymap.display(ActionId::Undo) | ||
| 5314 | + ) | ||
| 5315 | + .into(); | ||
| 5247 | let sources = self | 5316 | let sources = self |
| 5248 | .session | 5317 | .session |
| 5249 | .as_ref() | 5318 | .as_ref() |
| @@ -5273,13 +5342,37 @@ impl Player { | |||
| 5273 | .w(px(HEADER_W)) | 5342 | .w(px(HEADER_W)) |
| 5274 | .h_full() | 5343 | .h_full() |
| 5275 | .flex() | 5344 | .flex() |
| 5345 | + .flex_col() | ||
| 5276 | .items_center() | 5346 | .items_center() |
| 5277 | .justify_center() | 5347 | .justify_center() |
| 5278 | .rounded(px(3.)) | 5348 | .rounded(px(3.)) |
| 5279 | .bg(rgb(SURFACE)) | 5349 | .bg(rgb(SURFACE)) |
| 5280 | .text_size(px(11.)) | 5350 | .text_size(px(11.)) |
| 5281 | .text_color(rgb(INK_DIM)) | 5351 | .text_color(rgb(INK_DIM)) |
| 5282 | - .child(name), | 5352 | + .child(div().flex_1().flex().items_center().child(name)) |
| 5353 | + // The one thing a header does: take this track away again. | ||
| 5354 | + // A `HIT_MIN` target rather than a glyph-sized one, and it | ||
| 5355 | + // stays put on a track holding clips instead of hiding -- | ||
| 5356 | + // the refusal names them, and a control that vanishes | ||
| 5357 | + // teaches nothing. | ||
| 5358 | + .child( | ||
| 5359 | + div() | ||
| 5360 | + .id(remove_id) | ||
| 5361 | + .flex_none() | ||
| 5362 | + .w_full() | ||
| 5363 | + .h(px(HIT_MIN)) | ||
| 5364 | + .flex() | ||
| 5365 | + .items_center() | ||
| 5366 | + .justify_center() | ||
| 5367 | + .rounded(px(3.)) | ||
| 5368 | + .cursor_pointer() | ||
| 5369 | + .hover(|s| s.bg(rgb(HOVER))) | ||
| 5370 | + .tooltip(move |_, cx| cx.new(|_| Tip(remove_tip.clone())).into()) | ||
| 5371 | + .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { | ||
| 5372 | + this.remove_lane(lane, cx) | ||
| 5373 | + })) | ||
| 5374 | + .child("×"), | ||
| 5375 | + ), | ||
| 5283 | ) | 5376 | ) |
| 5284 | .child( | 5377 | .child( |
| 5285 | // Clips are placed at their own start rather than queued edge | 5378 | // Clips are placed at their own start rather than queued edge |
crates/engine/src/playback.rsmodified+7 -0
| @@ -876,6 +876,13 @@ impl PlaybackSession { | |||
| 876 | self.project.add_lane(kind) | 876 | self.project.add_lane(kind) |
| 877 | } | 877 | } |
| 878 | 878 | ||
| 879 | + /// Drops that empty lane again, in [`Project::remove_lane`]'s words when it | ||
| 880 | + /// refuses. One undo step, and no reseek for the same reason the add needs | ||
| 881 | + /// none: an empty lane was playing nothing. | ||
| 882 | + pub fn remove_lane(&mut self, lane: Lane) -> crate::Result<()> { | ||
| 883 | + self.project.remove_lane(lane) | ||
| 884 | + } | ||
| 885 | + | ||
| 879 | /// Splits every lane at `timeline_secs`, so the two sides become two | 886 | /// Splits every lane at `timeline_secs`, so the two sides become two |
| 880 | /// groups. Metadata only: a split never changes the timeline->source | 887 | /// groups. Metadata only: a split never changes the timeline->source |
| 881 | /// mapping, so the running decoder stays correct and playback does not | 888 | /// mapping, so the running decoder stays correct and playback does not |
crates/engine/src/project.rsmodified+108 -0
| @@ -666,6 +666,67 @@ impl Project { | |||
| 666 | Lane::new(kind, self.lane_count(kind) - 1) | 666 | Lane::new(kind, self.lane_count(kind) - 1) |
| 667 | } | 667 | } |
| 668 | 668 | ||
| 669 | + /// Drops an *empty* lane -- [`add_lane`](Project::add_lane) taken back, and | ||
| 670 | + /// one undo step like it, which restores the lane where it stood. | ||
| 671 | + /// | ||
| 672 | + /// Refused, changing nothing, while the lane holds anything: the refusal | ||
| 673 | + /// names the clips (file and first frame), because a track removal that | ||
| 674 | + /// deleted takes with it would be the one edit nobody sees coming. Refused | ||
| 675 | + /// too for the last lane of its kind, which is `V1` or `A1`: those two are | ||
| 676 | + /// where an import and a paste land ([`Project::paste`] takes lane 0 of each | ||
| 677 | + /// kind and *skips* a kind that is not there), so a project without one | ||
| 678 | + /// would swallow half of every file dropped on it, silently. | ||
| 679 | + /// | ||
| 680 | + /// The lanes below it move up one `ord`, so a handle a caller was holding | ||
| 681 | + /// (a selection, an open card) names the lane after it from here on -- the | ||
| 682 | + /// one thing a front-end owes this call. | ||
| 683 | + pub fn remove_lane(&mut self, lane: Lane) -> crate::Result<()> { | ||
| 684 | + let Some(i) = self.index(lane) else { | ||
| 685 | + return Err(format!("there is no {} to remove", lane.label()).into()); | ||
| 686 | + }; | ||
| 687 | + if self.lane_count(lane.kind) == 1 { | ||
| 688 | + return Err(format!( | ||
| 689 | + "{} is the only {} track: every import lands on it", | ||
| 690 | + lane.label(), | ||
| 691 | + match lane.kind { | ||
| 692 | + LaneKind::Video => "video", | ||
| 693 | + LaneKind::Audio => "audio", | ||
| 694 | + } | ||
| 695 | + ) | ||
| 696 | + .into()); | ||
| 697 | + } | ||
| 698 | + let clips = &self.lanes[i].clips; | ||
| 699 | + if !clips.is_empty() { | ||
| 700 | + // Three names and a count: a lane can hold forty clips and a | ||
| 701 | + // refusal nobody reads to the end says nothing at all. | ||
| 702 | + let named: Vec<String> = clips | ||
| 703 | + .iter() | ||
| 704 | + .take(3) | ||
| 705 | + .map(|c| { | ||
| 706 | + let name = self.sources.get(c.source).map_or_else( | ||
| 707 | + || format!("source {}", c.source), | ||
| 708 | + |s| s.path.display().to_string(), | ||
| 709 | + ); | ||
| 710 | + format!("{name} at frame {}", c.start) | ||
| 711 | + }) | ||
| 712 | + .collect(); | ||
| 713 | + let rest = match clips.len().saturating_sub(named.len()) { | ||
| 714 | + 0 => String::new(), | ||
| 715 | + n => format!(" and {n} more"), | ||
| 716 | + }; | ||
| 717 | + return Err(format!( | ||
| 718 | + "{} still holds {}{rest}: delete those clips (or drag them to \ | ||
| 719 | + another track) first", | ||
| 720 | + lane.label(), | ||
| 721 | + named.join(", ") | ||
| 722 | + ) | ||
| 723 | + .into()); | ||
| 724 | + } | ||
| 725 | + self.snapshot(); | ||
| 726 | + self.lanes.remove(i); | ||
| 727 | + Ok(()) | ||
| 728 | + } | ||
| 729 | + | ||
| 669 | /// Where `lane` sits in [`Project::lanes`], or `None` for a lane that is | 730 | /// Where `lane` sits in [`Project::lanes`], or `None` for a lane that is |
| 670 | /// not there. The one place a handle becomes a position. | 731 | /// not there. The one place a handle becomes a position. |
| 671 | fn index(&self, lane: Lane) -> Option<usize> { | 732 | fn index(&self, lane: Lane) -> Option<usize> { |
| @@ -4783,6 +4844,53 @@ mod tests { | |||
| 4783 | assert_eq!(shape(&p), shape(&three())); | 4844 | assert_eq!(shape(&p), shape(&three())); |
| 4784 | } | 4845 | } |
| 4785 | 4846 | ||
| 4847 | + /// The add taken back: an empty lane comes off, a lane holding clips never | ||
| 4848 | + /// does (and says which clips), the last lane of a kind never does, the | ||
| 4849 | + /// lanes below the one that went move up an `ord`, and one undo puts it | ||
| 4850 | + /// back where it stood. | ||
| 4851 | + #[test] | ||
| 4852 | + fn an_empty_lane_comes_off_again() { | ||
| 4853 | + let mut p = three(); | ||
| 4854 | + let v2 = p.add_lane(LaneKind::Video); | ||
| 4855 | + let v3 = p.add_lane(LaneKind::Video); | ||
| 4856 | + assert!(p.place(v3, 0, clip(0, 0, 3, 0))); | ||
| 4857 | + let why = |r: crate::Result<()>| r.expect_err("refused").to_string(); | ||
| 4858 | + let history = p.history.len(); | ||
| 4859 | + | ||
| 4860 | + // The last lane of its kind stays: `V1`/`A1` are where an import and a | ||
| 4861 | + // paste land, and a project missing one would swallow half of a file | ||
| 4862 | + // dropped on it. | ||
| 4863 | + assert!(why(p.remove_lane(Lane::A1)).contains("only audio track")); | ||
| 4864 | + assert_eq!( | ||
| 4865 | + why(p.remove_lane(Lane::new(LaneKind::Video, 9))), | ||
| 4866 | + "there is no V10 to remove" | ||
| 4867 | + ); | ||
| 4868 | + | ||
| 4869 | + // A lane with clips on it refuses and names them: a track removal never | ||
| 4870 | + // deletes a take. | ||
| 4871 | + let refusal = why(p.remove_lane(v3)); | ||
| 4872 | + assert!(refusal.contains("V3 still holds"), "{refusal}"); | ||
| 4873 | + assert!(refusal.contains(FILE), "{refusal}"); | ||
| 4874 | + assert!(refusal.contains("at frame 0"), "{refusal}"); | ||
| 4875 | + assert_eq!(p.lane_spans(v3), vec![(0, 3)], "the clip is still there"); | ||
| 4876 | + assert_eq!(p.history.len(), history, "a refusal snapshots nothing"); | ||
| 4877 | + | ||
| 4878 | + // The empty one in the middle goes, and `V3` becomes `V2` -- clip and | ||
| 4879 | + // all. | ||
| 4880 | + p.remove_lane(v2).expect("V2 is empty"); | ||
| 4881 | + assert_eq!(p.lane_count(LaneKind::Video), 2); | ||
| 4882 | + assert_eq!(p.lanes(), vec![Lane::V1, Lane::A1, v2]); | ||
| 4883 | + assert_eq!(p.lane_spans(v2), vec![(0, 3)], "the lane below moved up"); | ||
| 4884 | + assert_eq!(p.history.len(), history + 1, "one snapshot per removal"); | ||
| 4885 | + invariants_hold(&p, "remove V2"); | ||
| 4886 | + | ||
| 4887 | + // ...and one stroke puts the empty lane back above it. | ||
| 4888 | + assert!(p.undo()); | ||
| 4889 | + assert_eq!(p.lane_count(LaneKind::Video), 3); | ||
| 4890 | + assert!(p.lane(v2).is_empty(), "back where it stood, still empty"); | ||
| 4891 | + assert_eq!(p.lane_spans(v3), vec![(0, 3)]); | ||
| 4892 | + } | ||
| 4893 | + | ||
| 4786 | /// The grouping rule across more than two lanes: a link id is one *span*, | 4894 | /// The grouping rule across more than two lanes: a link id is one *span*, |
| 4787 | /// on however many lanes carry it -- not a video/audio pair and not a | 4895 | /// on however many lanes carry it -- not a video/audio pair and not a |
| 4788 | /// pairing by `ord`. So a split shares an id with every lane whose half | 4896 | /// pairing by `ord`. So a split shares an id with every lane whose half |