+ S makes a subtitle track, and the file door keeps its own name
Browse files at this commit6830c39b3fc6a9f72d661c34aa594e6466d4148dParent: 57fb0f3- feat
- + S makes a subtitle track, and the file door keeps its own name
9 changed files +146 -52
- crates/app/src/keymap.rs +30 -13
- crates/app/src/oracle.rs +5 -5
- crates/app/src/player/actions.rs +8 -5
- crates/app/src/player/library.rs +42 -8
- crates/app/src/subs.rs +30 -8
- crates/app/src/tests/layout.rs +21 -4
- crates/app/src/ui/library.rs +3 -3
- crates/app/src/ui/timeline.rs +3 -2
- crates/app/src/ui/toolbar.rs +4 -4
crates/app/src/keymap.rsmodified+30 -13
| @@ -99,8 +99,13 @@ actions! { | |||
| 99 | AddAudioLane, | 99 | AddAudioLane, |
| 100 | RemoveVideoLane, | 100 | RemoveVideoLane, |
| 101 | RemoveAudioLane, | 101 | RemoveAudioLane, |
| 102 | - AddSubtitleTrack, | 102 | + AddSubtitleLane, |
| 103 | - RemoveSubtitleTrack, | 103 | + RemoveSubtitleLane, |
| 104 | + /// The palette's own door: a file's subtitle tracks read into the list the | ||
| 105 | + /// panel shows, which is where a lane's words are dragged *from*. Adding a | ||
| 106 | + /// track to that list places nothing -- the pair above it is what makes the | ||
| 107 | + /// timeline row a caption can land on. | ||
| 108 | + ImportSubtitles, | ||
| 104 | ToggleMute, | 109 | ToggleMute, |
| 105 | VolumeUp, | 110 | VolumeUp, |
| 106 | VolumeDown, | 111 | VolumeDown, |
| @@ -172,8 +177,9 @@ impl ActionId { | |||
| 172 | ActionId::AddAudioLane => "Add an audio track", | 177 | ActionId::AddAudioLane => "Add an audio track", |
| 173 | ActionId::RemoveVideoLane => "Remove the last video track (it must be empty)", | 178 | ActionId::RemoveVideoLane => "Remove the last video track (it must be empty)", |
| 174 | ActionId::RemoveAudioLane => "Remove the last audio track (it must be empty)", | 179 | ActionId::RemoveAudioLane => "Remove the last audio track (it must be empty)", |
| 175 | - ActionId::AddSubtitleTrack => "Add subtitles from a file…", | 180 | + ActionId::AddSubtitleLane => "Add a subtitle track", |
| 176 | - ActionId::RemoveSubtitleTrack => "Remove the picked subtitle track", | 181 | + ActionId::RemoveSubtitleLane => "Remove the last subtitle track (it must be empty)", |
| 182 | + ActionId::ImportSubtitles => "Add subtitles from a file…", | ||
| 177 | ActionId::ToggleMute => "Mute / Unmute", | 183 | ActionId::ToggleMute => "Mute / Unmute", |
| 178 | ActionId::VolumeUp => "Volume up", | 184 | ActionId::VolumeUp => "Volume up", |
| 179 | ActionId::VolumeDown => "Volume down", | 185 | ActionId::VolumeDown => "Volume down", |
| @@ -228,8 +234,9 @@ impl ActionId { | |||
| 228 | ActionId::AddAudioLane => "add-audio-lane", | 234 | ActionId::AddAudioLane => "add-audio-lane", |
| 229 | ActionId::RemoveVideoLane => "remove-video-lane", | 235 | ActionId::RemoveVideoLane => "remove-video-lane", |
| 230 | ActionId::RemoveAudioLane => "remove-audio-lane", | 236 | ActionId::RemoveAudioLane => "remove-audio-lane", |
| 231 | - ActionId::AddSubtitleTrack => "add-subtitle-track", | 237 | + ActionId::AddSubtitleLane => "add-subtitle-lane", |
| 232 | - ActionId::RemoveSubtitleTrack => "remove-subtitle-track", | 238 | + ActionId::RemoveSubtitleLane => "remove-subtitle-lane", |
| 239 | + ActionId::ImportSubtitles => "import-subtitles", | ||
| 233 | ActionId::ToggleMute => "toggle-mute", | 240 | ActionId::ToggleMute => "toggle-mute", |
| 234 | ActionId::VolumeUp => "volume-up", | 241 | ActionId::VolumeUp => "volume-up", |
| 235 | ActionId::VolumeDown => "volume-down", | 242 | ActionId::VolumeDown => "volume-down", |
| @@ -319,8 +326,12 @@ impl ActionId { | |||
| 319 | // they add is on the timeline and goes into the file an export | 326 | // they add is on the timeline and goes into the file an export |
| 320 | // writes, where the toggle two headings down only decides whether | 327 | // writes, where the toggle two headings down only decides whether |
| 321 | // this window draws it. | 328 | // this window draws it. |
| 322 | - | ActionId::AddSubtitleTrack | 329 | + | ActionId::AddSubtitleLane |
| 323 | - | ActionId::RemoveSubtitleTrack | 330 | + | ActionId::RemoveSubtitleLane |
| 331 | + // ...and the door that fills the palette those lanes are dragged | ||
| 332 | + // from: it edits no lane, but what it brings in is the project's | ||
| 333 | + // and is saved with it, which is not a view setting. | ||
| 334 | + | ActionId::ImportSubtitles | ||
| 324 | | ActionId::RemoveAudioLane => Category::Editing, | 335 | | ActionId::RemoveAudioLane => Category::Editing, |
| 325 | ActionId::ToggleMute | 336 | ActionId::ToggleMute |
| 326 | | ActionId::VolumeUp | 337 | | ActionId::VolumeUp |
| @@ -806,8 +817,12 @@ impl Keymap { | |||
| 806 | // ctrl chord takes it back. Ctrl+s is that save, so the removal | 817 | // ctrl chord takes it back. Ctrl+s is that save, so the removal |
| 807 | // takes the other letter subtitles already answer to here: "t" | 818 | // takes the other letter subtitles already answer to here: "t" |
| 808 | // shows and hides them, and ctrl+t takes one off the timeline. | 819 | // shows and hides them, and ctrl+t takes one off the timeline. |
| 809 | - b(ActionId::AddSubtitleTrack, "s", false), | 820 | + b(ActionId::AddSubtitleLane, "s", false), |
| 810 | - b(ActionId::RemoveSubtitleTrack, "t", true), | 821 | + b(ActionId::RemoveSubtitleLane, "t", true), |
| 822 | + // Reading a file's tracks into the palette is not adding a | ||
| 823 | + // track to the timeline, so it is not the bare "s": ctrl+i, the | ||
| 824 | + // i of import, free and next to nothing that deletes. | ||
| 825 | + b(ActionId::ImportSubtitles, "i", true), | ||
| 811 | b(ActionId::ToggleMute, "m", false), | 826 | b(ActionId::ToggleMute, "m", false), |
| 812 | // The unshifted pair, which is what gpui reports for those two | 827 | // The unshifted pair, which is what gpui reports for those two |
| 813 | // keys ("=" and "-", platform.rs:862): the volume keys every | 828 | // keys ("=" and "-", platform.rs:862): the volume keys every |
| @@ -1123,7 +1138,7 @@ mod tests { | |||
| 1123 | #[test] | 1138 | #[test] |
| 1124 | fn every_default_stroke_reaches_its_action() { | 1139 | fn every_default_stroke_reaches_its_action() { |
| 1125 | let k = Keymap::defaults(); | 1140 | let k = Keymap::defaults(); |
| 1126 | - assert_eq!(k.entries().len(), 51); | 1141 | + assert_eq!(k.entries().len(), 52); |
| 1127 | assert_eq!(k.lookup("p", true), Some(ActionId::ToggleProxies)); | 1142 | assert_eq!(k.lookup("p", true), Some(ActionId::ToggleProxies)); |
| 1128 | assert_eq!(k.lookup("o", true), Some(ActionId::ToggleAutoProxies)); | 1143 | assert_eq!(k.lookup("o", true), Some(ActionId::ToggleAutoProxies)); |
| 1129 | assert_eq!(k.lookup("f1", false), Some(ActionId::ShowActions)); | 1144 | assert_eq!(k.lookup("f1", false), Some(ActionId::ShowActions)); |
| @@ -1174,8 +1189,10 @@ mod tests { | |||
| 1174 | assert_eq!(k.lookup("a", true), Some(ActionId::RemoveAudioLane)); | 1189 | assert_eq!(k.lookup("a", true), Some(ActionId::RemoveAudioLane)); |
| 1175 | // The subtitle pair, the third kind of track: the initial adds and the | 1190 | // The subtitle pair, the third kind of track: the initial adds and the |
| 1176 | // subtitle letter's chord takes it back. | 1191 | // subtitle letter's chord takes it back. |
| 1177 | - assert_eq!(k.lookup("s", false), Some(ActionId::AddSubtitleTrack)); | 1192 | + assert_eq!(k.lookup("s", false), Some(ActionId::AddSubtitleLane)); |
| 1178 | - assert_eq!(k.lookup("t", true), Some(ActionId::RemoveSubtitleTrack)); | 1193 | + assert_eq!(k.lookup("t", true), Some(ActionId::RemoveSubtitleLane)); |
| 1194 | + // ...and the palette's own door, which adds no track to the timeline. | ||
| 1195 | + assert_eq!(k.lookup("i", true), Some(ActionId::ImportSubtitles)); | ||
| 1179 | assert_eq!(k.lookup("m", false), Some(ActionId::ToggleMute)); | 1196 | assert_eq!(k.lookup("m", false), Some(ActionId::ToggleMute)); |
| 1180 | assert_eq!(k.lookup("q", false), Some(ActionId::Equalizer)); | 1197 | assert_eq!(k.lookup("q", false), Some(ActionId::Equalizer)); |
| 1181 | // The volume pair is the unshifted one, so neither needs a modifier | 1198 | // The volume pair is the unshifted one, so neither needs a modifier |
crates/app/src/oracle.rsmodified+5 -5
| @@ -186,11 +186,11 @@ pub(crate) fn enable(action: ActionId, ctx: Ctx) -> Enable { | |||
| 186 | // Nothing to draw over the picture, so nothing to switch off: the | 186 | // Nothing to draw over the picture, so nothing to switch off: the |
| 187 | // library says how subtitles arrive, and this row would flip a state | 187 | // library says how subtitles arrive, and this row would flip a state |
| 188 | // with no visible half either way. | 188 | // with no visible half either way. |
| 189 | - // ...and nothing to take off the timeline either, for the same reason: | 189 | + // |
| 190 | - // the row would name a track that is not there. | 190 | + // The × on a palette row is refused by this very fact and asks this very |
| 191 | - ActionId::ToggleSubtitles | ActionId::RemoveSubtitleTrack if !ctx.subtitles => { | 191 | + // arm ([`Player::remove_subtitle_track`]): an empty list is a list with |
| 192 | - Enable::No("no subtitles yet") | 192 | + // no row to take off, said in the same words the toggle says it in. |
| 193 | - } | 193 | + ActionId::ToggleSubtitles if !ctx.subtitles => Enable::No("no subtitles yet"), |
| 194 | // Not `No`: with nothing running there is no export for this to be | 194 | // Not `No`: with nothing running there is no export for this to be |
| 195 | // about at all, which is what keeps `esc` -- the same key -- a quiet | 195 | // about at all, which is what keeps `esc` -- the same key -- a quiet |
| 196 | // way out of a card rather than a line about exports. | 196 | // way out of a card rather than a line about exports. |
crates/app/src/player/actions.rsmodified+8 -5
| @@ -73,11 +73,14 @@ impl Player { | |||
| 73 | // through the × in its own header. | 73 | // through the × in its own header. |
| 74 | ActionId::RemoveVideoLane => self.remove_last_lane(LaneKind::Video, cx), | 74 | ActionId::RemoveVideoLane => self.remove_last_lane(LaneKind::Video, cx), |
| 75 | ActionId::RemoveAudioLane => self.remove_last_lane(LaneKind::Audio, cx), | 75 | ActionId::RemoveAudioLane => self.remove_last_lane(LaneKind::Audio, cx), |
| 76 | - // The same chooser the + S button opens, and the picked row -- the | 76 | + // The third kind of track, added and taken back exactly as the two |
| 77 | - // one the panel draws highlighted -- for the removal: the × on any | 77 | + // above it: what a caption is dragged onto. The words themselves |
| 78 | - // other row is that row's own door, and both doors are one call. | 78 | + // arrive by the door below, which places nothing. |
| 79 | - ActionId::AddSubtitleTrack => self.pick_and_add_subtitles(cx), | 79 | + ActionId::AddSubtitleLane => self.add_lane(LaneKind::Subtitle, cx), |
| 80 | - ActionId::RemoveSubtitleTrack => self.remove_subtitle_track(self.sub_track, cx), | 80 | + ActionId::RemoveSubtitleLane => self.remove_last_lane(LaneKind::Subtitle, cx), |
| 81 | + // The chooser the palette's own button opens: a file's tracks into | ||
| 82 | + // the list, the file itself joining nothing. | ||
| 83 | + ActionId::ImportSubtitles => self.pick_and_add_subtitles(cx), | ||
| 81 | ActionId::ToggleMute => self.set_volume(|volume| volume.muted = !volume.muted, cx), | 84 | ActionId::ToggleMute => self.set_volume(|volume| volume.muted = !volume.muted, cx), |
| 82 | ActionId::VolumeUp => self.set_volume(|volume| volume.step(true), cx), | 85 | ActionId::VolumeUp => self.set_volume(|volume| volume.step(true), cx), |
| 83 | ActionId::VolumeDown => self.set_volume(|volume| volume.step(false), cx), | 86 | ActionId::VolumeDown => self.set_volume(|volume| volume.step(false), cx), |
crates/app/src/player/library.rsmodified+42 -8
| @@ -693,7 +693,7 @@ impl Player { | |||
| 693 | // same question -- and *before* the chooser rather than after it: a door | 693 | // same question -- and *before* the chooser rather than after it: a door |
| 694 | // that opens a dialog, waits for a file and only then says the timeline | 694 | // that opens a dialog, waits for a file and only then says the timeline |
| 695 | // was never there is the second door disagreeing with the first. | 695 | // was never there is the second door disagreeing with the first. |
| 696 | - if let Some(why) = self.enable(ActionId::AddSubtitleTrack, None).why() { | 696 | + if let Some(why) = self.enable(ActionId::ImportSubtitles, None).why() { |
| 697 | let text = format!("NO SUBTITLES ADDED — {why}"); | 697 | let text = format!("NO SUBTITLES ADDED — {why}"); |
| 698 | eprintln!("{text}"); | 698 | eprintln!("{text}"); |
| 699 | self.notify_user(text.into()); | 699 | self.notify_user(text.into()); |
| @@ -784,12 +784,17 @@ impl Player { | |||
| 784 | ) { | 784 | ) { |
| 785 | let text = match added { | 785 | let text = match added { |
| 786 | Some(Ok(0)) => format!( | 786 | Some(Ok(0)) => format!( |
| 787 | - "{}'s subtitles are on the timeline already", | 787 | + "{}'s subtitles are in the palette already", |
| 788 | file_name(path) | 788 | file_name(path) |
| 789 | ), | 789 | ), |
| 790 | + // Where they are and what to do with them: the tracks are in the | ||
| 791 | + // palette and nothing is placed until one is dragged onto an S | ||
| 792 | + // track, which is the whole of what this door does. | ||
| 790 | Some(Ok(n)) => format!( | 793 | Some(Ok(n)) => format!( |
| 791 | - "SUBTITLES {} — {n} track(s), showing over the picture, {} hides them", | 794 | + "SUBTITLES {} — {n} track(s) in the palette — drag one onto an S track ({} adds \ |
| 795 | + one), showing over the picture meanwhile, {} hides them", | ||
| 792 | file_name(path), | 796 | file_name(path), |
| 797 | + self.keymap.display(ActionId::AddSubtitleLane), | ||
| 793 | self.keymap.display(ActionId::ToggleSubtitles) | 798 | self.keymap.display(ActionId::ToggleSubtitles) |
| 794 | ), | 799 | ), |
| 795 | Some(Err(e)) => format!("SUBTITLE IMPORT FAILED: {e}"), | 800 | Some(Err(e)) => format!("SUBTITLE IMPORT FAILED: {e}"), |
| @@ -818,7 +823,10 @@ impl Player { | |||
| 818 | // action with nothing to act on, and the engine's "there is no subtitle | 823 | // action with nothing to act on, and the engine's "there is no subtitle |
| 819 | // track 0" is an index nobody typed. A real removal that fails still | 824 | // track 0" is an index nobody typed. A real removal that fails still |
| 820 | // says what the engine said, below. | 825 | // says what the engine said, below. |
| 821 | - if let Some(why) = self.enable(ActionId::RemoveSubtitleTrack, None).why() { | 826 | + // The palette's list is what this takes a row off, and an empty list is |
| 827 | + // the very fact the toggle is refused by -- so the same arm answers | ||
| 828 | + // both (oracle.rs) rather than a second reading of the same state. | ||
| 829 | + if let Some(why) = self.enable(ActionId::ToggleSubtitles, None).why() { | ||
| 822 | let text = format!("NO SUBTITLES REMOVED — {why}"); | 830 | let text = format!("NO SUBTITLES REMOVED — {why}"); |
| 823 | eprintln!("{text}"); | 831 | eprintln!("{text}"); |
| 824 | self.notify_user(text.into()); | 832 | self.notify_user(text.into()); |
| @@ -849,8 +857,9 @@ impl Player { | |||
| 849 | // note, for its reason and with its upgrade path. | 857 | // note, for its reason and with its upgrade path. |
| 850 | self.sub_image = None; | 858 | self.sub_image = None; |
| 851 | format!( | 859 | format!( |
| 852 | - "{name} REMOVED — {} puts a file's subtitles back on, the file itself stays off", | 860 | + "{name} REMOVED — {} puts a file's subtitles back in the palette, the file \ |
| 853 | - self.keymap.display(ActionId::AddSubtitleTrack) | 861 | + itself stays off", |
| 862 | + self.keymap.display(ActionId::ImportSubtitles) | ||
| 854 | ) | 863 | ) |
| 855 | } | 864 | } |
| 856 | Some(Err(e)) => format!("NO SUBTITLES REMOVED — {e}"), | 865 | Some(Err(e)) => format!("NO SUBTITLES REMOVED — {e}"), |
| @@ -956,8 +965,16 @@ impl Player { | |||
| 956 | let lane = session.add_lane(kind); | 965 | let lane = session.add_lane(kind); |
| 957 | self.notify_user( | 966 | self.notify_user( |
| 958 | format!( | 967 | format!( |
| 959 | - "{} ADDED — drag a clip onto it, {} takes it back", | 968 | + "{} ADDED — drag {} onto it, {} takes it back", |
| 960 | lane.label(), | 969 | lane.label(), |
| 970 | + // A subtitle lane takes no clip at all: what lands on it | ||
| 971 | + // is a palette row, so the notice names the panel the | ||
| 972 | + // hand has to go to rather than "a clip", which is the | ||
| 973 | + // one thing that will never work here. | ||
| 974 | + match kind { | ||
| 975 | + LaneKind::Subtitle => "a subtitle from the panel", | ||
| 976 | + _ => "a clip", | ||
| 977 | + }, | ||
| 961 | self.keymap.display(ActionId::Undo) | 978 | self.keymap.display(ActionId::Undo) |
| 962 | ) | 979 | ) |
| 963 | .into(), | 980 | .into(), |
| @@ -1079,8 +1096,25 @@ impl Player { | |||
| 1079 | }); | 1096 | }); |
| 1080 | match last { | 1097 | match last { |
| 1081 | Some(lane) => self.remove_lane(lane, cx), | 1098 | Some(lane) => self.remove_lane(lane, cx), |
| 1099 | + // Two different nothings: no timeline at all, and a timeline whose | ||
| 1100 | + // lanes of this kind have all gone -- which is the ordinary state of | ||
| 1101 | + // the subtitle ones, since a project starts with none. "Open a file | ||
| 1102 | + // first" over an open file is a notice that reads as a bug. | ||
| 1082 | None => { | 1103 | None => { |
| 1083 | - self.notify_user("NO TRACK REMOVED — open a file first".into()); | 1104 | + self.notify_user( |
| 1105 | + match self.session.is_some() { | ||
| 1106 | + true => format!( | ||
| 1107 | + "NO TRACK REMOVED — there is no {} track to remove", | ||
| 1108 | + match kind { | ||
| 1109 | + LaneKind::Video => "video", | ||
| 1110 | + LaneKind::Audio => "audio", | ||
| 1111 | + LaneKind::Subtitle => "subtitle", | ||
| 1112 | + } | ||
| 1113 | + ), | ||
| 1114 | + false => "NO TRACK REMOVED — open a file first".to_string(), | ||
| 1115 | + } | ||
| 1116 | + .into(), | ||
| 1117 | + ); | ||
| 1084 | cx.notify(); | 1118 | cx.notify(); |
| 1085 | } | 1119 | } |
| 1086 | } | 1120 | } |
crates/app/src/subs.rsmodified+30 -8
| @@ -323,17 +323,24 @@ pub(crate) fn subtitle_plan( | |||
| 323 | picks: &[usize], | 323 | picks: &[usize], |
| 324 | ) -> String { | 324 | ) -> String { |
| 325 | let mut parts: Vec<String> = Vec::new(); | 325 | let mut parts: Vec<String> = Vec::new(); |
| 326 | - // "none" is the engine's word for an empty pick list and would read as a | 326 | + // "none" is the engine's word for having nothing to say and would read as a |
| 327 | - // verdict on the tracks named after it. | 327 | + // verdict on the tracks named after it. Anything else is the sentence the |
| 328 | - if !picks.is_empty() { | 328 | + // export is actually planned from -- the lanes' own, wherever the timeline |
| 329 | - parts.push(plan); | 329 | + // places words ([`engine::export::planned_subtitles`]) -- and it is kept |
| 330 | + // whatever the palette picks are: dropping it on an empty pick list is how a | ||
| 331 | + // card showing "S1 eng — past the last picture" said nothing at all. | ||
| 332 | + if plan != "none" { | ||
| 333 | + parts.push(plan.clone()); | ||
| 330 | } | 334 | } |
| 331 | parts.extend( | 335 | parts.extend( |
| 332 | tracks | 336 | tracks |
| 333 | .iter() | 337 | .iter() |
| 334 | .enumerate() | 338 | .enumerate() |
| 335 | - .filter(|(i, _)| !picks.contains(i)) | 339 | + .filter(|(i, track)| !picks.contains(i) && !spoken_for(&plan, track)) |
| 336 | - .map(|(_, track)| format!("{} — no cues here", track.label)), | 340 | + // Not "no cues here": a row the export leaves out is a row nothing |
| 341 | + // on the timeline placed, and what puts that right is the drag -- | ||
| 342 | + // the same sentence the import notice ends with. | ||
| 343 | + .map(|(_, track)| format!("{} — in the palette, on no track", track.label)), | ||
| 337 | ); | 344 | ); |
| 338 | let named = parts.join("; "); | 345 | let named = parts.join("; "); |
| 339 | if named.chars().count() <= SUB_PLAN_CHARS { | 346 | if named.chars().count() <= SUB_PLAN_CHARS { |
| @@ -347,7 +354,7 @@ pub(crate) fn subtitle_plan( | |||
| 347 | match ( | 354 | match ( |
| 348 | track.refused.is_some(), | 355 | track.refused.is_some(), |
| 349 | track.is_bitmap(), | 356 | track.is_bitmap(), |
| 350 | - picks.contains(&i), | 357 | + picks.contains(&i) || spoken_for(&plan, track), |
| 351 | ) { | 358 | ) { |
| 352 | (true, _, _) => unread += 1, | 359 | (true, _, _) => unread += 1, |
| 353 | (_, true, _) => pictures += 1, | 360 | (_, true, _) => pictures += 1, |
| @@ -360,7 +367,7 @@ pub(crate) fn subtitle_plan( | |||
| 360 | [ | 367 | [ |
| 361 | (pictures, "pictures"), | 368 | (pictures, "pictures"), |
| 362 | (unread, "unread"), | 369 | (unread, "unread"), |
| 363 | - (off, "no cues here"), | 370 | + (off, "in the palette, on no track"), |
| 364 | ] | 371 | ] |
| 365 | .into_iter() | 372 | .into_iter() |
| 366 | .filter(|(n, _)| *n > 0) | 373 | .filter(|(n, _)| *n > 0) |
| @@ -369,6 +376,21 @@ pub(crate) fn subtitle_plan( | |||
| 369 | counted.join("; ") | 376 | counted.join("; ") |
| 370 | } | 377 | } |
| 371 | 378 | ||
| 379 | +/// Whether the engine's sentence already speaks for this row: with words placed | ||
| 380 | +/// on lanes, every clause of it names the palette row its lane shows | ||
| 381 | +/// ([`engine::export::planned_subtitles`]) -- and a line that embeds a track and | ||
| 382 | +/// then says the same track is on no track is a line contradicting itself. | ||
| 383 | +/// | ||
| 384 | +/// corner-cut: the match is the label found in the sentence, because the engine | ||
| 385 | +/// hands back one string and not the rows it spoke for. Ceiling: two rows whose | ||
| 386 | +/// labels are one a prefix of the other ("eng", "eng 2") -- with the longer one | ||
| 387 | +/// placed, the shorter loses its clause; it never gains a wrong one. Upgrade | ||
| 388 | +/// path: `planned_subtitles` handing its clauses back as data, the same upgrade | ||
| 389 | +/// [`subtitle_plan`]'s own note names. | ||
| 390 | +fn spoken_for(plan: &str, track: &engine::subtitle::SubtitleTrack) -> bool { | ||
| 391 | + !track.label.is_empty() && plan.contains(track.label.as_str()) | ||
| 392 | +} | ||
| 393 | + | ||
| 372 | /// Every subtitle track one file gave, kept together. Plain data, planned | 394 | /// Every subtitle track one file gave, kept together. Plain data, planned |
| 373 | /// before anything is drawn -- the grouping is the branchy part and it is the | 395 | /// before anything is drawn -- the grouping is the branchy part and it is the |
| 374 | /// same answer whatever a styling puts around it. | 396 | /// same answer whatever a styling puts around it. |
crates/app/src/tests/layout.rsmodified+21 -4
| @@ -759,7 +759,7 @@ fn the_card_names_the_subtitle_it_leaves_off_and_counts_them_when_it_cannot() { | |||
| 759 | // What the engine answers about the one pick that reached it, and what | 759 | // What the engine answers about the one pick that reached it, and what |
| 760 | // this side knows about the row that did not. | 760 | // this side knows about the row that did not. |
| 761 | let named = subtitle_plan("[ASS] → embedded".to_string(), &two, &[0]); | 761 | let named = subtitle_plan("[ASS] → embedded".to_string(), &two, &[0]); |
| 762 | - assert_eq!(named, "[ASS] → embedded; [ASS] [FOR DUB] — no cues here"); | 762 | + assert_eq!(named, "[ASS] → embedded; [ASS] [FOR DUB] — in the palette, on no track"); |
| 763 | assert!( | 763 | assert!( |
| 764 | named.chars().count() <= SUB_PLAN_CHARS, | 764 | named.chars().count() <= SUB_PLAN_CHARS, |
| 765 | "two tracks fit the value box: {named}" | 765 | "two tracks fit the value box: {named}" |
| @@ -778,13 +778,30 @@ fn the_card_names_the_subtitle_it_leaves_off_and_counts_them_when_it_cannot() { | |||
| 778 | // and the nine picture ones, which the engine drops itself. | 778 | // and the nine picture ones, which the engine drops itself. |
| 779 | let picks: Vec<usize> = (0..31usize).collect(); | 779 | let picks: Vec<usize> = (0..31usize).collect(); |
| 780 | let counted = subtitle_plan("22 tracks → embedded (…)".to_string(), &many, &picks); | 780 | let counted = subtitle_plan("22 tracks → embedded (…)".to_string(), &many, &picks); |
| 781 | - assert_eq!(counted, "22 of 35 → embedded; 9 pictures; 1 unread; 3 no cues here"); | 781 | + assert_eq!( |
| 782 | + counted, | ||
| 783 | + "22 of 35 → embedded; 9 pictures; 1 unread; 3 in the palette, on no track" | ||
| 784 | + ); | ||
| 782 | assert!( | 785 | assert!( |
| 783 | counted.chars().count() <= SUB_PLAN_CHARS, | 786 | counted.chars().count() <= SUB_PLAN_CHARS, |
| 784 | "thirty-five tracks still fit the value box: {counted}" | 787 | "thirty-five tracks still fit the value box: {counted}" |
| 785 | ); | 788 | ); |
| 786 | // Nothing on the timeline at all is still the engine's word for it. | 789 | // Nothing on the timeline at all is still the engine's word for it. |
| 787 | assert_eq!(subtitle_plan("none".to_string(), &[], &[]), "none"); | 790 | assert_eq!(subtitle_plan("none".to_string(), &[], &[]), "none"); |
| 791 | + // The lanes are what an export writes once anything is placed on one, and | ||
| 792 | + // the engine words that whole ([`engine::export::planned_subtitles`]) -- | ||
| 793 | + // including the lanes it carries *nothing* of, which is a sentence with no | ||
| 794 | + // pick behind it at all. That used to be dropped on the floor: the card said | ||
| 795 | + // "[ASS] — no cues here" twice and never said what became of the lane. | ||
| 796 | + let placed = "S1 [ASS] — past the last picture".to_string(); | ||
| 797 | + assert_eq!( | ||
| 798 | + subtitle_plan(placed.clone(), &two, &[]), | ||
| 799 | + "S1 [ASS] — past the last picture; [ASS] [FOR DUB] — in the palette, on no track" | ||
| 800 | + ); | ||
| 801 | + // ...and the row that sentence speaks for gets no clause of its own: a line | ||
| 802 | + // that names a lane's track and then calls the same track unplaced is the | ||
| 803 | + // card contradicting itself in one breath. | ||
| 804 | + assert!(!subtitle_plan(placed, &two[..1], &[]).contains("in the palette")); | ||
| 788 | } | 805 | } |
| 789 | 806 | ||
| 790 | /// The list is in the order tracks were added, which is not the order a | 807 | /// The list is in the order tracks were added, which is not the order a |
| @@ -884,9 +901,9 @@ fn the_text_tab_carries_the_add_subtitles_door() { | |||
| 884 | let at = library | 901 | let at = library |
| 885 | .find("\"add-subtitles\"") | 902 | .find("\"add-subtitles\"") |
| 886 | .expect("no add-subtitles control in the library column"); | 903 | .expect("no add-subtitles control in the library column"); |
| 887 | - let block = &library[at..(at + 1400).min(library.len())]; | 904 | + let block = &library[at..(at + 1600).min(library.len())]; |
| 888 | assert!( | 905 | assert!( |
| 889 | - block.contains("ActionId::AddSubtitleTrack"), | 906 | + block.contains("ActionId::ImportSubtitles"), |
| 890 | "the button is a door of its own rather than the action: {block}" | 907 | "the button is a door of its own rather than the action: {block}" |
| 891 | ); | 908 | ); |
| 892 | assert!( | 909 | assert!( |
crates/app/src/ui/library.rsmodified+3 -3
| @@ -319,9 +319,9 @@ impl Player { | |||
| 319 | true => "Add subtitles from a file…", | 319 | true => "Add subtitles from a file…", |
| 320 | false => "Add subtitles", | 320 | false => "Add subtitles", |
| 321 | }, | 321 | }, |
| 322 | - "reads a file's subtitle tracks onto this timeline — the file itself \ | 322 | + "reads a file's subtitle tracks into the palette below — drag one onto an S \ |
| 323 | - joins nothing", | 323 | + track to place it; the file itself joins nothing", |
| 324 | - ActionId::AddSubtitleTrack, | 324 | + ActionId::ImportSubtitles, |
| 325 | cx.listener(|this, _: &ClickEvent, _, cx| this.pick_and_add_subtitles(cx)), | 325 | cx.listener(|this, _: &ClickEvent, _, cx| this.pick_and_add_subtitles(cx)), |
| 326 | ))) | 326 | ))) |
| 327 | }) | 327 | }) |
crates/app/src/ui/timeline.rsmodified+3 -2
| @@ -322,7 +322,7 @@ impl Player { | |||
| 322 | let groups = subtitle_rows(tracks); | 322 | let groups = subtitle_rows(tracks); |
| 323 | // What the row's × says the way back is, in the stroke this keymap | 323 | // What the row's × says the way back is, in the stroke this keymap |
| 324 | // actually binds: a file's subtitles go on without the file. | 324 | // actually binds: a file's subtitles go on without the file. |
| 325 | - let add_key = self.keymap.display(ActionId::AddSubtitleTrack); | 325 | + let add_key = self.keymap.display(ActionId::ImportSubtitles); |
| 326 | // One file's tracks need no prefix saying which file: it is the only | 326 | // One file's tracks need no prefix saying which file: it is the only |
| 327 | // one, and every row would carry the same word. | 327 | // one, and every row would carry the same word. |
| 328 | let several_files = groups.len() > 1; | 328 | let several_files = groups.len() > 1; |
| @@ -376,7 +376,8 @@ impl Player { | |||
| 376 | // the tooltip is what says which track it takes off. | 376 | // the tooltip is what says which track it takes off. |
| 377 | let remove_tip: SharedString = | 377 | let remove_tip: SharedString = |
| 378 | format!( | 378 | format!( |
| 379 | - "Remove {title} — {} puts a file's subtitles back on", | 379 | + "Remove {title} from the palette — {} puts a file's subtitles \ |
| 380 | + back in it", | ||
| 380 | add_key | 381 | add_key |
| 381 | ) | 382 | ) |
| 382 | .into(); | 383 | .into(); |
crates/app/src/ui/toolbar.rsmodified+4 -4
| @@ -307,15 +307,15 @@ impl Player { | |||
| 307 | }), | 307 | }), |
| 308 | )) | 308 | )) |
| 309 | .child(self.action_control( | 309 | .child(self.action_control( |
| 310 | - "add-subtitle-track", | 310 | + "add-subtitle-lane", |
| 311 | 0., | 311 | 0., |
| 312 | BG_RAISED(), | 312 | BG_RAISED(), |
| 313 | None, | 313 | None, |
| 314 | "+ S", | 314 | "+ S", |
| 315 | - "adds every subtitle track in a file you pick", | 315 | + "adds a subtitle track under the ones there", |
| 316 | - ActionId::AddSubtitleTrack, | 316 | + ActionId::AddSubtitleLane, |
| 317 | cx.listener(|this, _: &ClickEvent, _, cx| { | 317 | cx.listener(|this, _: &ClickEvent, _, cx| { |
| 318 | - this.pick_and_add_subtitles(cx) | 318 | + this.add_lane(LaneKind::Subtitle, cx) |
| 319 | }), | 319 | }), |
| 320 | )) | 320 | )) |
| 321 | .child(separator()) | 321 | .child(separator()) |