The write-back a history step makes is pinned, and the plate's motive said right
Browse files at this commit07d3b8b21f81ed2424541b13e19064e1c7c30b21Parent: dd8c9bb- test
- the write-back a history step makes is pinned, and the plate's motive said right
4 changed files +70 -13
- crates/app/src/player/actions.rs +8 -3
- crates/app/src/player/library.rs +6 -2
- crates/app/src/subs.rs +9 -5
- crates/app/src/tests/editing.rs +47 -3
crates/app/src/player/actions.rsmodified+8 -3
| @@ -774,9 +774,14 @@ impl HistoryBefore { | ||
| 774 | 774 | #[derive(Clone, Copy, Debug, PartialEq)] |
| 775 | 775 | pub(crate) struct HistoryOutcome { |
| 776 | 776 | pub(crate) sub_track: usize, |
| 777 | - /// The plate the pick drew (`Player::sub_image`) was drawn through a pick | |
| 778 | - /// that no longer stands -- the palette moved under it, or it names another | |
| 779 | - /// row -- so it has to go. | |
| 777 | + /// The plate over the picture (`Player::sub_image`) has to go. Its tile is | |
| 778 | + /// keyed by *where* a cue sits ([`Player::sub_picture`]'s `(lane, | |
| 779 | + /// start_us)`) and carries no track, so a step that moves captions, takes | |
| 780 | + /// one off, or renumbers the track a placement names | |
| 781 | + /// ([`engine::Project::remove_subtitles`] walks `SubClip::track` down) | |
| 782 | + /// cannot be asked of that cache -- the tile at a key can be served for a | |
| 783 | + /// cue it was not drawn from. Conservative on purpose: at most one plate is | |
| 784 | + /// redrawn by the next repaint. | |
| 780 | 785 | pub(crate) drop_sub_image: bool, |
| 781 | 786 | } |
| 782 | 787 |
crates/app/src/player/library.rsmodified+6 -2
| @@ -1751,8 +1751,12 @@ impl Player { | ||
| 1751 | 1751 | .as_ref() |
| 1752 | 1752 | .map_or(0, |session| session.subtitles().len()); |
| 1753 | 1753 | self.sub_track = sub_pick_after_removal(self.sub_track, track, left); |
| 1754 | - // The drawn cue is keyed by that index ([`Player::sub_picture`]) | |
| 1755 | - // and the index now stands for another track. | |
| 1754 | + // The cue over the picture goes with the pick: its tile is | |
| 1755 | + // keyed by *where* the cue sits ([`Player::sub_picture`]'s | |
| 1756 | + // `(lane, start_us)`) and never by the track it shows, so the | |
| 1757 | + // index that moved here is not something that cache can be | |
| 1758 | + // asked about. Conservative, and the same drop a history step | |
| 1759 | + // makes for the same reason ([`Player::step_history`]). | |
| 1756 | 1760 | // |
| 1757 | 1761 | // corner-cut: its atlas tile is not released -- `close_session`'s |
| 1758 | 1762 | // note, for its reason and with its upgrade path. |
crates/app/src/subs.rsmodified+9 -5
| @@ -623,11 +623,15 @@ pub(crate) fn subtitle_rows(tracks: &[engine::subtitle::SubtitleTrack]) -> Vec<S | ||
| 623 | 623 | /// last. Zero on an emptied list, which is the index the section is not drawn at |
| 624 | 624 | /// all. |
| 625 | 625 | /// |
| 626 | -/// Its own function because the pick is what the overlay draws: left where it | |
| 627 | -/// was it would name a different track, and the plate over the picture would | |
| 628 | -/// change language on its own the moment a row above it went. What an export | |
| 629 | -/// writes is *not* this pick and cannot be desynced by a removal -- it is worked | |
| 630 | -/// out from the cues on the timeline each time ([`Player::export_subs`]). | |
| 626 | +/// Its own function because the pick is read as "which row" everywhere it is | |
| 627 | +/// echoed -- the dock highlights the picked row by comparing it | |
| 628 | +/// (`dock_stance`'s `track == player.sub_track`), and the section heading and | |
| 629 | +/// its notices name it -- so left where it was it would highlight one track and | |
| 630 | +/// name another the moment a row above it went. The plate over the picture is | |
| 631 | +/// not on that list: it is drawn from the *placements* on the shown lane | |
| 632 | +/// ([`Player::active_sub_lane`], and the session's own `sub_lane_cues`). What an export | |
| 633 | +/// writes is not this pick either -- it is worked out from the cues on the | |
| 634 | +/// timeline each time ([`Player::export_subs`]). | |
| 631 | 635 | pub(crate) fn sub_pick_after_removal(picked: usize, removed: usize, left: usize) -> usize { |
| 632 | 636 | let picked = match removed < picked { |
| 633 | 637 | true => picked - 1, |
crates/app/src/tests/editing.rsmodified+47 -3
| @@ -2018,9 +2018,9 @@ fn the_windows_settings_caches_follow_the_session_across_undo_and_redo() { | ||
| 2018 | 2018 | /// Rows above the picked subtitle move the pick down with them |
| 2019 | 2019 | /// ([`sub_pick_after_removal`]), and a `^z` of that removal has to move it back |
| 2020 | 2020 | /// up: the palette comes home out of the entry, the pick is an *index* into it, |
| 2021 | -/// and an index left where it was names a different track -- the plate over the | |
| 2022 | -/// picture would change language on its own, and the one already drawn was | |
| 2023 | -/// drawn through the pick that no longer stands. | |
| 2021 | +/// and an index left where it was highlights one row and names another. The | |
| 2022 | +/// plate over the picture goes too, not because it is keyed by the pick -- it is | |
| 2023 | +/// keyed by where a cue sits -- but because the step moves the cues under it. | |
| 2024 | 2024 | #[test] |
| 2025 | 2025 | fn the_subtitle_pick_follows_its_track_across_an_undo_of_a_removal() { |
| 2026 | 2026 | use crate::player::actions::{history_step, HistoryBefore, SessionCaches}; |
| @@ -2095,6 +2095,50 @@ fn the_subtitle_pick_follows_its_track_across_an_undo_of_a_removal() { | ||
| 2095 | 2095 | assert!(out.drop_sub_image, "and the plate goes with it"); |
| 2096 | 2096 | } |
| 2097 | 2097 | |
| 2098 | +/// The app-level write-back of a history step is not reachable from this binary | |
| 2099 | +/// -- `Player` needs a `TestAppContext` this one has none of -- so the wiring is | |
| 2100 | +/// pinned where it can be read: both keyboard doors route through | |
| 2101 | +/// [`Player::step_history`], and its body still keeps the three session caches | |
| 2102 | +/// and the pick, and still drops the plate. What those values *are* is pinned | |
| 2103 | +/// against a real session by the two tests above ([`history_step`] is the free | |
| 2104 | +/// function they drive); this is the copy back into the window's own fields, | |
| 2105 | +/// which no test can call. | |
| 2106 | +#[test] | |
| 2107 | +fn a_history_step_still_takes_its_settings_and_its_pick_back_up() { | |
| 2108 | + let actions = src_text("player/actions.rs"); | |
| 2109 | + for needle in [ | |
| 2110 | + "self.step_history(PlaybackSession::undo);", | |
| 2111 | + "self.step_history(PlaybackSession::redo);", | |
| 2112 | + ] { | |
| 2113 | + assert!( | |
| 2114 | + actions.contains(needle), | |
| 2115 | + "a history door stopped routing through Player::step_history: {needle}" | |
| 2116 | + ); | |
| 2117 | + } | |
| 2118 | + let body = fn_body("step_history"); | |
| 2119 | + // The state the step is asked about, and the answer taken back up: every one | |
| 2120 | + // of these deleted leaves a cache or the pick stale for the next cut, the | |
| 2121 | + // next frame count, or the next repaint. | |
| 2122 | + for needle in [ | |
| 2123 | + "let mut caches = SessionCaches {", | |
| 2124 | + "HistoryBefore::of(", | |
| 2125 | + "self.fps = caches.fps;", | |
| 2126 | + "self.proxies_on = caches.proxies_on;", | |
| 2127 | + "self.auto_proxies_on = caches.auto_proxies_on;", | |
| 2128 | + "self.sub_track = outcome.sub_track;", | |
| 2129 | + "if outcome.drop_sub_image {", | |
| 2130 | + "self.sub_image = None;", | |
| 2131 | + "self.reset_after_reseek();", | |
| 2132 | + ] { | |
| 2133 | + assert!( | |
| 2134 | + body.contains(needle), | |
| 2135 | + "Player::step_history no longer carries `{needle}` -- a history step \ | |
| 2136 | + leaves it behind (the app suite cannot see this: it has no \ | |
| 2137 | + TestAppContext to call the door)" | |
| 2138 | + ); | |
| 2139 | + } | |
| 2140 | +} | |
| 2141 | + | |
| 2098 | 2142 | /// The oracle side of trim-to-playhead (debt #42): needs a subject cut *and* |
| 2099 | 2143 | /// the playhead actually resting on it, unlike the nudge pair above it which |
| 2100 | 2144 | /// only needs a cut -- the "spot" a keyless drag would snap to has to be on |