forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'worktree-agent-a33d0eaabab99ec6b'

Browse files at this commit

563161abff03fe476e8be6e188427c3a647b4aadAhmet Kaan GümüşParent: 6830c39afea3b2
crates/app/src/main.rsmodified+20 -17
@@ -86,11 +86,11 @@ struct Player {
86 /// drawn ([`engine::subtitle::CueImage::rgba`]), which is a thing to do86 /// drawn ([`engine::subtitle::CueImage::rgba`]), which is a thing to do
87 /// when the cue changes -- every few seconds -- and not at every repaint.87 /// when the cue changes -- every few seconds -- and not at every repaint.
88 ///88 ///
89- /// The *track* is half the key because the four PGS tracks of a remux are89+ /// The *lane* is half the key because the four PGS tracks of a remux are
90- /// one film's subtitles in four languages: they start at the same90+ /// one film's subtitles in four languages: placed one over the other they
91- /// microsecond, and a picked row that only changed the language would go on91+ /// start at the same microsecond, and a lane whose eye was shut would leave
92- /// showing the one before it.92+ /// the one before it on screen.
93- sub_image: Option<((usize, i64), Arc<RenderImage>)>,93+ sub_image: Option<((Lane, i64), Arc<RenderImage>)>,
94 /// A frame that arrived before its time; shown on the tick it comes due.94 /// A frame that arrived before its time; shown on the tick it comes due.
95 /// The pump's buffer, not transport state -- but a frame waiting here is95 /// The pump's buffer, not transport state -- but a frame waiting here is
96 /// what keeps a finished decoder from reading as [`Transport::Ended`] one96 /// what keeps a finished decoder from reading as [`Transport::Ended`] one
@@ -228,28 +228,31 @@ struct Player {
228 /// by one stroke ([`ActionId::ToggleSnap`]) for the frame-by-frame placement228 /// by one stroke ([`ActionId::ToggleSnap`]) for the frame-by-frame placement
229 /// no magnet may take away.229 /// no magnet may take away.
230 snap: bool,230 snap: bool,
231- /// Whether the cue under the playhead is drawn over the picture. On by231+ /// Whether the subtitle lanes draw at all -- the mute over every lane's eye
232- /// default -- a subtitle imported and then invisible is an import nobody can232+ /// ([`Player::subs_off`]), not a lane of its own. On by default and off by
233- /// tell happened -- and off by one stroke233+ /// one stroke
234 /// ([`ActionId::ToggleSubtitles`](keymap::ActionId::ToggleSubtitles)) for234 /// ([`ActionId::ToggleSubtitles`](keymap::ActionId::ToggleSubtitles)) for
235 /// anyone watching the picture rather than reading it. The player's, not the235 /// anyone watching the picture rather than reading it. The player's, not the
236 /// project's: it changes nothing that is saved and nothing that is exported.236 /// project's: it changes nothing that is saved and nothing that is exported.
237 subs_on: bool,237 subs_on: bool,
238- /// Which subtitle track is the one on screen: an index into238+ /// Which palette row is *selected*: an index into
239- /// [`PlaybackSession::subtitles`], since a file may carry several and only239+ /// [`PlaybackSession::subtitles`], which is what the × takes off
240- /// one can be read at a time. Cleared with the timeline like every other240+ /// ([`ActionId::RemoveSubtitleTrack`](keymap::ActionId::RemoveSubtitleTrack))
241- /// index here -- track 2 of one project is not track 2 of the next.241+ /// and what the list marks. A selection and nothing more -- what is on
242+ /// screen is what is placed on a subtitle lane
243+ /// ([`Player::subtitle_overlay`]), so picking a row shows nothing by itself,
244+ /// exactly as clicking a media row plays nothing. Cleared with the timeline
245+ /// like every other index here -- track 2 of one project is not track 2 of
246+ /// the next.
242 sub_track: usize,247 sub_track: usize,
243 /// The subtitle lanes whose eye is shut: every lane shows its captions248 /// The subtitle lanes whose eye is shut: every lane shows its captions
244 /// until this says otherwise, so a lane that was just added is a lane that249 /// until this says otherwise, so a lane that was just added is a lane that
245 /// draws. Held as the lanes that are *off* rather than a flag per lane, so250 /// draws. Held as the lanes that are *off* rather than a flag per lane, so
246 /// adding one needs no bookkeeping at all.251 /// adding one needs no bookkeeping at all.
247 ///252 ///
248- /// State only this slice: the preview reads the picked palette track still253+ /// Read where the cues are drawn ([`Player::subtitle_overlay`]): shutting an
249- /// ([`Player::sub_picture`]), so shutting an eye marks the header and254+ /// eye takes that lane's plate off the picture and leaves its captions on
250- /// changes nothing over the picture until the slice that draws the lanes'255+ /// the lane. Not saved -- a `.edith` has no line for it yet.
251- /// cues there reads this field. Not saved either -- a `.edith` has no line
252- /// for it yet.
253 ///256 ///
254 /// A [`Lane`] handle is a position among its kind, so a removal or a257 /// A [`Lane`] handle is a position among its kind, so a removal or a
255 /// reorder leaves every shut eye naming another track: they are dropped258 /// reorder leaves every shut eye naming another track: they are dropped
crates/app/src/subs.rsmodified+9 -1
@@ -235,6 +235,11 @@ pub(crate) type Subs = engine::Result<Vec<engine::subtitle::SubtitleTrack>>;
235 /// argv named, an import, and an import into an empty window cannot say the same235 /// argv named, an import, and an import into an empty window cannot say the same
236 /// thing differently, whichever thread read the cues.236 /// thing differently, whichever thread read the cues.
237 ///237 ///
238+/// Worded for where they actually land: a *list* beside the media and nothing
239+/// over the picture -- a track shows when it is dragged onto a subtitle lane
240+/// ([`Player::subtitle_overlay`]), so the tail says the next move rather than
241+/// letting a count read as "and there they are on screen".
242+///
238 /// `None` for a file that gave none and for one whose tracks are on the timeline243 /// `None` for a file that gave none and for one whose tracks are on the timeline
239 /// already -- an import that adds nothing says nothing about subtitles. A244 /// already -- an import that adds nothing says nothing about subtitles. A
240 /// refusal is a tail too, never a failure of the import: the picture and the245 /// refusal is a tail too, never a failure of the import: the picture and the
@@ -243,7 +248,10 @@ pub(crate) fn subtitle_tail(session: &mut PlaybackSession, subs: Subs) -> Option
243 match subs {248 match subs {
244 Ok(tracks) => match session.add_subtitle_tracks(tracks) {249 Ok(tracks) => match session.add_subtitle_tracks(tracks) {
245 0 => None,250 0 => None,
246- n => Some(format!(" — {n} subtitle track(s) in the file")),251+ n => Some(format!(
252+ " — {n} subtitle track(s) in the file, in the subtitle list: drag one onto a \
253+ subtitle track to show it"
254+ )),
247 },255 },
248 Err(e) => Some(format!(" — SUBTITLES UNREAD: {e}")),256 Err(e) => Some(format!(" — SUBTITLES UNREAD: {e}")),
249 }257 }
crates/app/src/tests/media.rsmodified+47 -3
@@ -954,7 +954,14 @@ fn subtitles_arrive_beside_the_media_and_inside_it() {
954 let track = &session.subtitles()[0];954 let track = &session.subtitles()[0];
955 assert_eq!(track.label, "test_subs.srt");955 assert_eq!(track.label, "test_subs.srt");
956 assert_eq!(subtitle_detail(track), "3 cues");956 assert_eq!(subtitle_detail(track), "3 cues");
957- // What the overlay draws at a moment inside the first cue, and between957+ // Arriving is landing in the *list* and nowhere else: no lane is made for
958+ // it, so there is nothing over the picture yet -- the rule every other
959+ // medium follows here, and what `Player::subtitle_overlay` reads.
960+ assert!(
961+ session.subtitle_lanes().is_empty(),
962+ "an import places nothing: the palette is where a track lands"
963+ );
964+ // What the track itself says at a moment inside the first cue, and between
958 // two of them -- the fixture's own timings (0.5-1.5 s, 2.0-3.25 s).965 // two of them -- the fixture's own timings (0.5-1.5 s, 2.0-3.25 s).
959 let text = |t: f64| -> Vec<String> {966 let text = |t: f64| -> Vec<String> {
960 cues_at(&track.cues, t)967 cues_at(&track.cues, t)
@@ -1019,7 +1026,7 @@ fn subtitles_arrive_beside_the_media_and_inside_it() {
1019 assert!(subtitle_detail(&refused).contains("pictures"));1026 assert!(subtitle_detail(&refused).contains("pictures"));
1020 assert!(cues_at(&refused.cues, 1.).is_empty());1027 assert!(cues_at(&refused.cues, 1.).is_empty());
1021 1028
1022- // ...and what the plate and the strip draw after a *cut*: the timeline's1029+ // ...and what an embedded track carried through a *cut* maps to: the timeline's
1023 // own clock, asked of the engine through the very map an export writes1030 // own clock, asked of the engine through the very map an export writes
1024 // the file with (`PlaybackSession::timeline_cues`), so the preview and1031 // the file with (`PlaybackSession::timeline_cues`), so the preview and
1025 // the file cannot drift apart. The numbers are the export's own1032 // the file cannot drift apart. The numbers are the export's own
@@ -1042,7 +1049,7 @@ fn subtitles_arrive_beside_the_media_and_inside_it() {
1042 .collect::<Vec<_>>(),1049 .collect::<Vec<_>>(),
1043 vec![(500_000, 1_500_000), (2_000_000, 3_000_000)]1050 vec![(500_000, 1_500_000), (2_000_000, 3_000_000)]
1044 );1051 );
1045- // The overlay's own two lines, at the same moments as above.1052+ // The export's own two lines, at the same moments as above.
1046 let drawn = |t: f64| -> Vec<String> {1053 let drawn = |t: f64| -> Vec<String> {
1047 cues_at(&mapped, t)1054 cues_at(&mapped, t)
1048 .into_iter()1055 .into_iter()
@@ -1057,4 +1064,41 @@ fn subtitles_arrive_beside_the_media_and_inside_it() {
1057 );1064 );
1058 // ...and the strip's: the second cue is one second wide now, not 1.25.1065 // ...and the strip's: the second cue is one second wide now, not 1.25.
1059 assert_eq!(cue_box(scale, &mapped[1]), (80., 40.));1066 assert_eq!(cue_box(scale, &mapped[1]), (80., 40.));
1067+
1068+ // The last mile, what the plate over the picture actually reads
1069+ // (`Player::subtitle_overlay` -> `PlaybackSession::sub_lane_cues`): a lane
1070+ // added and still empty draws nothing, and the palette row reaches the
1071+ // screen the moment it is *placed* on it -- shifted by where it sits, the
1072+ // way a clip is.
1073+ let lane = session.add_lane(LaneKind::Subtitle);
1074+ assert!(
1075+ session.sub_lane_cues(lane).is_empty(),
1076+ "an empty subtitle lane draws nothing"
1077+ );
1078+ session
1079+ .place_sub(
1080+ lane,
1081+ 0,
1082+ SubClip {
1083+ start: 0,
1084+ frames: 90,
1085+ track: 0,
1086+ in_us: 0,
1087+ out_us: 5_000_000,
1088+ },
1089+ )
1090+ .expect("the palette row goes down on the lane");
1091+ let placed = session.sub_lane_cues(lane);
1092+ let shown = |t: f64| -> Vec<String> {
1093+ cues_at(&placed, t)
1094+ .into_iter()
1095+ .map(|c| c.text.clone())
1096+ .collect()
1097+ };
1098+ // The placement keeps the track's own clock (it starts at frame 0 and
1099+ // holds the whole of it), so the words are back at the times the file
1100+ // wrote them -- the cut above moved the *carried* map, not this one.
1101+ assert_eq!(shown(0.7), ["first line"]);
1102+ assert!(shown(1.8).is_empty(), "between two cues the plate goes");
1103+ assert_eq!(shown(2.5), ["second line\nwith a break"]);
1060 }1104 }
crates/app/src/ui/preview.rsmodified+53 -22
@@ -4,19 +4,23 @@ use crate::*;
4 use crate::ui::widgets::*;4 use crate::ui::widgets::*;
5 5
6 impl Player {6 impl Player {
7- /// The cues of the picked track that are on screen at `at`, over the picture7+ /// The cues the *subtitle lanes* put on screen at `at`, over the picture and
8- /// and nothing else: bottom-centred where every player puts them, white on a8+ /// nothing else: bottom-centred where every player puts them, white on a
9 /// plate so the film underneath cannot swallow them, and each cue its own9 /// plate so the film underneath cannot swallow them, and each cue its own
10 /// plate so two at one moment stack rather than run together.10 /// plate so two at one moment stack rather than run together.
11 ///11 ///
12- /// `None` -- no element at all -- while the toggle is off, with no track12+ /// What is drawn is what was *placed*: a track walked out of a file lands in
13- /// picked, and between cues: the picture is what this window is for, and a13+ /// the palette and nothing more, exactly as a picture or a song does, and it
14- /// permanent empty band across it would be in the way of exactly that.14+ /// reaches the screen when a placement of it sits under the playhead
15+ /// ([`PlaybackSession::sub_lane_cues`], the same map the export writes the
16+ /// file with -- so what is read here is what the file will say). Every lane
17+ /// whose eye is open ([`Player::sub_lane_on`]) draws, so two enabled lanes
18+ /// are two plates: lane order bottom-up, the first lane where a single
19+ /// track's words have always been and each further one stacked above it.
15 ///20 ///
16- /// The cues are the *timeline's* ([`PlaybackSession::timeline_cues`]) and21+ /// `None` -- no element at all -- while the toggle is off, with nothing
17- /// not the track's own: on a cut timeline an embedded track's cues ride the22+ /// placed, and between cues: the picture is what this window is for, and a
18- /// pictures they belong to, and this is the same map the export writes the23+ /// permanent empty band across it would be in the way of exactly that.
19- /// file with -- so what is read here is what the file says.
20 ///24 ///
21 /// A cue off a PGS track is a *picture* and not a line25 /// A cue off a PGS track is a *picture* and not a line
22 /// ([`engine::subtitle::CueImage`]), and is drawn as one: the disc's whole26 /// ([`engine::subtitle::CueImage`]), and is drawn as one: the disc's whole
@@ -37,22 +41,42 @@ impl Player {
37 // going off, the file closing and the gap between two cues are the same41 // going off, the file closing and the gap between two cues are the same
38 // "nothing on screen", and an 8 MB atlas tile may not survive any of42 // "nothing on screen", and an 8 MB atlas tile may not survive any of
39 // them (an early return above this leaked one per toggle-off).43 // them (an early return above this leaked one per toggle-off).
40- let mapped = match self.session.as_ref().filter(|_| self.subs_on) {44+ // Per lane and not one flat list: the plates stack by lane below, and a
41- Some(session) => session.timeline_cues(self.sub_track),45+ // picture's cache key needs the lane it came off ([`Player::sub_picture`]).
42- None => Vec::new(),46+ let lanes: Vec<(Lane, Vec<engine::subtitle::Cue>)> =
43- };47+ match self.session.as_ref().filter(|_| self.subs_on) {
44- let cues = cues_at(&mapped, at);48+ Some(session) => session
45- if cues.is_empty() {49+ .subtitle_lanes()
50+ .into_iter()
51+ .filter(|&lane| self.sub_lane_on(lane))
52+ .map(|lane| {
53+ let cues = session.sub_lane_cues(lane);
54+ (lane, cues_at(&cues, at).into_iter().cloned().collect())
55+ })
56+ .filter(|(_, cues): &(_, Vec<_>)| !cues.is_empty())
57+ .collect(),
58+ None => Vec::new(),
59+ };
60+ if lanes.is_empty() {
46 self.drop_sub_image(window);61 self.drop_sub_image(window);
47 return None;62 return None;
48 }63 }
49 // The first picture cue up, decoded once and kept: two bitmap cues at64 // The first picture cue up, decoded once and kept: two bitmap cues at
50 // one moment is a thing PGS composes into one display set, so there is65 // one moment is a thing PGS composes into one display set, so there is
51- // never a second picture to stack under the first.66+ // never a second picture to stack under the first *on one lane*.
52- let picture = cues67+ //
68+ // corner-cut: two enabled lanes each showing a PGS track draw the lower
69+ // lane's picture alone -- one cache slot, one canvas over the whole
70+ // region, and a second canvas would cover the first anyway. The upgrade
71+ // path is a slot per lane, which wants the plates' stacking rule to mean
72+ // something for canvases too.
73+ let picture = lanes
53 .iter()74 .iter()
54- .find_map(|cue| Some((cue.start_us, cue.image.as_ref()?)))75+ .find_map(|(lane, cues)| {
55- .and_then(|(start_us, image)| self.sub_picture(start_us, image, window));76+ cues.iter()
77+ .find_map(|cue| Some((*lane, cue.start_us, cue.image.as_ref()?)))
78+ })
79+ .and_then(|(lane, start_us, image)| self.sub_picture(lane, start_us, image, window));
56 // A picture is fitted onto the whole region and a plate hangs off the80 // A picture is fitted onto the whole region and a plate hangs off the
57 // bottom of it, and a track is one or the other -- so they are two81 // bottom of it, and a track is one or the other -- so they are two
58 // shapes and not one with the parts switched off.82 // shapes and not one with the parts switched off.
@@ -96,7 +120,13 @@ impl Player {
96 .gap(px(2.))120 .gap(px(2.))
97 // The plate takes no click: the picture behind it is still the121 // The plate takes no click: the picture behind it is still the
98 // drop target the whole window is.122 // drop target the whole window is.
99- .children(cues.into_iter().filter(|c| c.image.is_none()).map(|cue| {123+ //
124+ // Reversed, because a column anchored at the bottom lays its
125+ // children downwards: the *last* lane is written first so the
126+ // first lane keeps the bottom line it has when it is the only
127+ // one, and a second lane stacks above it rather than pushing it
128+ // off its place.
129+ .children(lanes.into_iter().rev().flat_map(|(_, cues)| cues).filter(|c| c.image.is_none()).map(|cue| {
100 div()130 div()
101 .max_w(relative(0.9))131 .max_w(relative(0.9))
102 .px(px(6.))132 .px(px(6.))
@@ -118,7 +148,7 @@ impl Player {
118 )148 )
119 }149 }
120 150
121- /// The cue starting at `start_us` as a drawable picture, decoded on the151+ /// The cue `lane` starts at `start_us` as a drawable picture, decoded on the
122 /// first repaint it is up for and kept until another cue takes its place152 /// first repaint it is up for and kept until another cue takes its place
123 /// ([`Player::sub_image`]). `None` for a display set the decoder refuses,153 /// ([`Player::sub_image`]). `None` for a display set the decoder refuses,
124 /// which draws nothing rather than failing the frame.154 /// which draws nothing rather than failing the frame.
@@ -128,11 +158,12 @@ impl Player {
128 /// sprite atlas by the whole film.158 /// sprite atlas by the whole film.
129 pub(crate) fn sub_picture(159 pub(crate) fn sub_picture(
130 &mut self,160 &mut self,
161+ lane: Lane,
131 start_us: i64,162 start_us: i64,
132 image: &engine::subtitle::CueImage,163 image: &engine::subtitle::CueImage,
133 window: &mut Window,164 window: &mut Window,
134 ) -> Option<Arc<RenderImage>> {165 ) -> Option<Arc<RenderImage>> {
135- let key = (self.sub_track, start_us);166+ let key = (lane, start_us);
136 if let Some((up, ready)) = &self.sub_image167 if let Some((up, ready)) = &self.sub_image
137 && *up == key168 && *up == key
138 {169 {
crates/app/src/ui/timeline.rsmodified+17 -17
@@ -363,8 +363,8 @@ impl Player {
363 let tip: SharedString = match &row.refused {363 let tip: SharedString = match &row.refused {
364 Some(why) => format!("{} — {why}", path.display()),364 Some(why) => format!("{} — {why}", path.display()),
365 None => format!(365 None => format!(
366- "{} — drag it onto a subtitle track to place it, click to show it \366+ "{} — drag it onto a subtitle track to place it; nothing is over \
367- over the picture",367+ the picture until it is placed",
368 path.display()368 path.display()
369 ),369 ),
370 }370 }
@@ -407,13 +407,14 @@ impl Player {
407 .on_drag(SubPick(track), move |_, _, _, cx| {407 .on_drag(SubPick(track), move |_, _, _, cx| {
408 cx.new(|_| Tip(carried.clone()))408 cx.new(|_| Tip(carried.clone()))
409 })409 })
410+ // Selects the row and shows nothing: a
411+ // subtitle track reaches the picture by
412+ // being placed on a subtitle lane, the way
413+ // a film reaches it by being placed on a
414+ // video one. What the selection is for is
415+ // the × and the mark on the row.
410 .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {416 .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {
411 this.sub_track = track;417 this.sub_track = track;
412- // Picking a track is asking to see it: a
413- // click that changed nothing on screen
414- // because the toggle was off would read
415- // as a dead row.
416- this.subs_on = true;
417 cx.notify();418 cx.notify();
418 }))419 }))
419 })420 })
@@ -551,16 +552,15 @@ impl Player {
551 .truncate()552 .truncate()
552 .text_size(px(11.))553 .text_size(px(11.))
553 .text_color(rgb(FG_SECONDARY()))554 .text_color(rgb(FG_SECONDARY()))
554- .child(match (self.subs_on, sub_pick_name(tracks, self.sub_track)) {555+ .child(match self.subs_on {
555- // Which of them is on screen, named by its film:556+ // A palette and not a picker: none of these rows is
556- // the heading over a list of five is where the one557+ // "the one on screen" any more, so the heading names
557- // being shown is worth saying out loud.558+ // no track. What is on screen is on the subtitle
558- (true, Some(pick)) => format!("Subtitles — {pick}"),559+ // lanes, each with its own eye.
559- (true, None) => "Subtitles".to_string(),560+ true => "Subtitles",
560- // The toggle's state where the tracks are listed: a561+ // The mute's state where the tracks are listed: with
561- // list of subtitles nothing on screen is showing has562+ // it off no lane draws, however many are placed.
562- // to say that it is showing none.563+ false => "Subtitles — hidden",
563- (false, _) => "Subtitles — hidden".to_string(),
564 }),564 }),
565 )565 )
566 .child(566 .child(