Caption flag resets match the engine's reseek exactly
Browse files at this commitcda6d0eb7cda9bbff1487112cb7cf3e068d4e44bParent: 25855e8- fix
- caption flag resets match the engine's reseek exactly
2 changed files +27 -10
crates/app/src/player/timeline_edit.rsmodified+23 -8
| @@ -455,6 +455,15 @@ impl Player { | ||
| 455 | 455 | let Some(idx) = self.dragged_sub(drag) else { |
| 456 | 456 | return; |
| 457 | 457 | }; |
| 458 | + // Asked before the edit, on the indices the press captured: the | |
| 459 | + // engine's own grouped-with-clips answer, which is exactly when its | |
| 460 | + // move reseeks -- a caption grouped only with other captions moves no | |
| 461 | + // media, and a flag reset without a delivered frame would latch the | |
| 462 | + // seek wait forever. | |
| 463 | + let grouped = self | |
| 464 | + .session | |
| 465 | + .as_ref() | |
| 466 | + .is_some_and(|session| session.caption_grouped_with_clips(drag.lane, idx)); | |
| 458 | 467 | let start = self.sub_drop_frame(drag.sub, x).0; |
| 459 | 468 | match self |
| 460 | 469 | .session |
| @@ -474,9 +483,9 @@ impl Player { | ||
| 474 | 483 | // A lane holds its captions in start order, so the drop moved the |
| 475 | 484 | // mark as well as the box: it is re-read off where the caption |
| 476 | 485 | // landed rather than left on the index it had, which after the move |
| 477 | - // is a neighbour's. A grouped caption dragged its clips with it -- | |
| 478 | - // the engine reseeks itself, and this owes the flag reset a clip's | |
| 479 | - // drop pays at the same moment. | |
| 486 | + // is a neighbour's. A grouped-with-clips caption dragged media with | |
| 487 | + // it -- the engine reseeks itself, and this owes the flag reset a | |
| 488 | + // clip's drop pays at the same moment. | |
| 480 | 489 | Some(Ok(())) => { |
| 481 | 490 | let mark = self |
| 482 | 491 | .session |
| @@ -491,7 +500,7 @@ impl Player { | ||
| 491 | 500 | } |
| 492 | 501 | None => Selection::new(), |
| 493 | 502 | }; |
| 494 | - if drag.sub.link.is_some() { | |
| 503 | + if grouped { | |
| 495 | 504 | self.reset_after_reseek(); |
| 496 | 505 | } |
| 497 | 506 | } |
| @@ -1125,17 +1134,23 @@ impl Player { | ||
| 1125 | 1134 | // timeline's rate. An `Ok` is *not* "something changed" -- an edge that |
| 1126 | 1135 | // stopped at a wall it already stood against is `Ok` with no undo step |
| 1127 | 1136 | // ([`Project::trim_sub`]) -- so only the refusal is ever said out loud. |
| 1128 | - // A lone caption's trim moves nothing that plays, and nothing reseeks; | |
| 1129 | - // a grouped one trimmed its clips with it, and owes the same flag | |
| 1130 | - // reset a clip's trim pays. | |
| 1137 | + // A lone caption's trim -- and one grouped only with other captions -- | |
| 1138 | + // moves nothing that plays and reseeks nothing; a caption grouped with | |
| 1139 | + // clips trimmed them with it and owes the flag reset a clip's trim | |
| 1140 | + // pays. The grouped question is asked before the edit moves indices, | |
| 1141 | + // in the engine's own words, so the two answers can never disagree. | |
| 1131 | 1142 | if trim.lane.kind == LaneKind::Subtitle { |
| 1143 | + let grouped = self | |
| 1144 | + .session | |
| 1145 | + .as_ref() | |
| 1146 | + .is_some_and(|session| session.caption_grouped_with_clips(trim.lane, trim.idx)); | |
| 1132 | 1147 | let trimmed = self |
| 1133 | 1148 | .session |
| 1134 | 1149 | .as_mut() |
| 1135 | 1150 | .map(|session| session.trim_sub(trim.lane, trim.idx, trim.edge, trim.to)); |
| 1136 | 1151 | match trimmed { |
| 1137 | 1152 | Some(Err(e)) => self.notify_user(format!("NOT TRIMMED — {e}").into()), |
| 1138 | - Some(Ok(())) if trim.link.is_some() => self.reset_after_reseek(), | |
| 1153 | + Some(Ok(())) if grouped => self.reset_after_reseek(), | |
| 1139 | 1154 | _ => {} |
| 1140 | 1155 | } |
| 1141 | 1156 | cx.notify(); |
crates/engine/src/playback.rsmodified+4 -2
| @@ -1866,8 +1866,10 @@ impl PlaybackSession { | ||
| 1866 | 1866 | |
| 1867 | 1867 | /// Whether the caption at `idx` of `lane` is grouped with clips on other |
| 1868 | 1868 | /// lanes: the one question every caption edit that can move media has to |
| 1869 | - // ask first, because the answer is whether the edit owes a reseek. | |
| 1870 | - fn caption_grouped_with_clips(&self, lane: Lane, idx: usize) -> bool { | |
| 1869 | + /// ask first, because the answer is whether the edit owes a reseek -- and | |
| 1870 | + /// the front-end owes the same answer, asked before the edit moves the | |
| 1871 | + /// indices, so its flag reset matches the engine's reseek exactly. | |
| 1872 | + pub fn caption_grouped_with_clips(&self, lane: Lane, idx: usize) -> bool { | |
| 1871 | 1873 | self.project |
| 1872 | 1874 | .sub_lane(lane) |
| 1873 | 1875 | .get(idx) |