A slowed clip refuses the cut in its own words
Browse files at this commitcd9aea87bffbe93cb1a9d2dcc5c66376c2d17b0dParent: 9f50845- fix
- a slowed clip refuses the cut in its own words
1 changed file +36 -7
- crates/app/src/main.rs +36 -7
crates/app/src/main.rsmodified+36 -7
| @@ -7134,15 +7134,22 @@ fn enable(action: ActionId, ctx: Ctx) -> Enable { | |||
| 7134 | // clip, only at a frame its own rate can address, which is the same | 7134 | // clip, only at a frame its own rate can address, which is the same |
| 7135 | // question `splittable` asks. | 7135 | // question `splittable` asks. |
| 7136 | ActionId::Cut => match ctx.clip { | 7136 | ActionId::Cut => match ctx.clip { |
| 7137 | + Some((clip, _)) if !(clip.start < ctx.playhead && ctx.playhead < clip.end()) => { | ||
| 7138 | + Enable::No("only from inside a clip") | ||
| 7139 | + } | ||
| 7140 | + // Inside it, and still not a cut: a slowed clip shows one frame of | ||
| 7141 | + // the file for several frames of the timeline, and only the first of | ||
| 7142 | + // those is a frame the file has ([`Speed::split_at`]). Cutting | ||
| 7143 | + // between two showings of one frame would leave halves whose lengths | ||
| 7144 | + // no longer add up, so it is refused -- and it says *that* rather | ||
| 7145 | + // than repeating "inside a clip" at a playhead that plainly is. | ||
| 7137 | Some((clip, _)) | 7146 | Some((clip, _)) |
| 7138 | - if !(clip.start < ctx.playhead | 7147 | + if clip |
| 7139 | - && ctx.playhead < clip.end() | 7148 | + .speed |
| 7140 | - && clip | 7149 | + .split_at(clip.len(), ctx.playhead - clip.start) |
| 7141 | - .speed | 7150 | + .is_none() => |
| 7142 | - .split_at(clip.len(), ctx.playhead - clip.start) | ||
| 7143 | - .is_some()) => | ||
| 7144 | { | 7151 | { |
| 7145 | - Enable::No("only from inside a clip") | 7152 | + Enable::No("this speed holds one frame here — step to the next") |
| 7146 | } | 7153 | } |
| 7147 | _ => Enable::Yes, | 7154 | _ => Enable::Yes, |
| 7148 | }, | 7155 | }, |
| @@ -10165,6 +10172,28 @@ mod tests { | |||
| 10165 | assert!(!offered(&clip, v1, ActionId::Cut, 30)); | 10172 | assert!(!offered(&clip, v1, ActionId::Cut, 30)); |
| 10166 | assert!(!offered(&clip, v1, ActionId::Cut, 90)); | 10173 | assert!(!offered(&clip, v1, ActionId::Cut, 90)); |
| 10167 | assert!(!offered(&clip, v1, ActionId::Cut, 200)); | 10174 | assert!(!offered(&clip, v1, ActionId::Cut, 200)); |
| 10175 | + // A slowed clip refuses more than the edges do, and it may not say the | ||
| 10176 | + // edges' words while doing it: at a quarter speed each of its sixty | ||
| 10177 | + // source frames is on screen four timeline frames, and only the first of | ||
| 10178 | + // the four is a frame the file has. The three between are inside the | ||
| 10179 | + // clip by any reading of the playhead, so "only from inside a clip" | ||
| 10180 | + // there is a refusal claiming something the screen contradicts. | ||
| 10181 | + let slow = Clip { | ||
| 10182 | + speed: Speed::MIN, | ||
| 10183 | + ..clip | ||
| 10184 | + }; | ||
| 10185 | + assert_eq!(slow.frames(), 240, "a quarter speed is four times as long"); | ||
| 10186 | + assert!(offered(&slow, v1, ActionId::Cut, 34), "34 is a source frame"); | ||
| 10187 | + assert!(!offered(&slow, v1, ActionId::Cut, 35)); | ||
| 10188 | + assert_eq!( | ||
| 10189 | + on(&slow, v1, ActionId::Cut, 35).why(), | ||
| 10190 | + Some("this speed holds one frame here — step to the next"), | ||
| 10191 | + ); | ||
| 10192 | + assert_eq!( | ||
| 10193 | + on(&slow, v1, ActionId::Cut, 30).why(), | ||
| 10194 | + Some("only from inside a clip"), | ||
| 10195 | + "the head is still the edge's refusal, speed or no speed", | ||
| 10196 | + ); | ||
| 10168 | // Regroup is the other way round: only where this clip meets another. | 10197 | // Regroup is the other way round: only where this clip meets another. |
| 10169 | assert!(offered(&clip, v1, ActionId::Regroup, 30)); | 10198 | assert!(offered(&clip, v1, ActionId::Regroup, 30)); |
| 10170 | assert!(offered(&clip, v1, ActionId::Regroup, 90)); | 10199 | assert!(offered(&clip, v1, ActionId::Regroup, 90)); |