💄 Title keys: the ease row says when the playhead is outside the title, and next-key says when the key is past its end
Browse files at this commit8e0ee9c9ad794f6203faa4a89b46485384961229Parent: 48a175d3 changed files +27 -3
- crates/app/src/player/titling.rs +11 -2
- crates/app/src/ui/cards/curve.rs +14 -0
- crates/app/src/ui/cards/keys.rs +2 -1
crates/app/src/player/titling.rsmodified+11 -2
| @@ -475,7 +475,8 @@ impl Player { | |||
| 475 | } | 475 | } |
| 476 | 476 | ||
| 477 | /// Seeks the playhead to the next (`forward`) or the previous key of the selected title, and | 477 | /// Seeks the playhead to the next (`forward`) or the previous key of the selected title, and |
| 478 | - /// says so when there is none that way. | 478 | + /// says so when there is none that way. Keys past the title's last frame are held but never |
| 479 | + /// reached; when the only keys ahead are such keys, the message says that instead. | ||
| 479 | pub(crate) fn jump_title_key(&mut self, forward: bool, cx: &mut Context<Self>) { | 480 | pub(crate) fn jump_title_key(&mut self, forward: bool, cx: &mut Context<Self>) { |
| 480 | let Some((_, t)) = self.title_target() else { | 481 | let Some((_, t)) = self.title_target() else { |
| 481 | return; | 482 | return; |
| @@ -492,7 +493,15 @@ impl Player { | |||
| 492 | self.seek(at, cx); | 493 | self.seek(at, cx); |
| 493 | } | 494 | } |
| 494 | None => { | 495 | None => { |
| 495 | - self.notify_user(if forward { "No later key on this title" } else { "No earlier key on this title" }.into()); | 496 | + // A key past the end sits after every frame of the title, so it can only be ahead |
| 497 | + // of the playhead going forward. | ||
| 498 | + let past_end_ahead = forward && t.keys.iter().any(|k| k.at >= t.frames && t.start + k.at > now); | ||
| 499 | + let message = match (forward, past_end_ahead) { | ||
| 500 | + (true, true) => "The next key is past the title's end", | ||
| 501 | + (true, false) => "No later key on this title", | ||
| 502 | + (false, _) => "No earlier key on this title", | ||
| 503 | + }; | ||
| 504 | + self.notify_user(message.into()); | ||
| 496 | cx.notify(); | 505 | cx.notify(); |
| 497 | } | 506 | } |
| 498 | } | 507 | } |
crates/app/src/ui/cards/curve.rsmodified+14 -0
| @@ -166,6 +166,20 @@ impl Player { | |||
| 166 | } | 166 | } |
| 167 | } | 167 | } |
| 168 | 168 | ||
| 169 | + /// Why the ease row of `target` is disabled while there is no key on the playhead. A title | ||
| 170 | + /// asks for the playhead to move into it when it lies outside the title, where no key can be. | ||
| 171 | + pub(crate) fn ease_reason(&self, target: CurveTarget) -> &'static str { | ||
| 172 | + let outside = match target { | ||
| 173 | + CurveTarget::Title(idx) => self | ||
| 174 | + .session | ||
| 175 | + .as_ref() | ||
| 176 | + .and_then(|s| s.titles().get(idx)) | ||
| 177 | + .is_some_and(|t| self.title_key_frame(t).is_none()), | ||
| 178 | + CurveTarget::Key(_) | CurveTarget::Effect(_) => false, | ||
| 179 | + }; | ||
| 180 | + if outside { "Move the playhead into the title" } else { "Add a key first" } | ||
| 181 | + } | ||
| 182 | + | ||
| 169 | /// The box of the editor for `target`, made on first use and recorded at prepaint. | 183 | /// The box of the editor for `target`, made on first use and recorded at prepaint. |
| 170 | pub(crate) fn curve_bounds_for(&self, target: CurveTarget) -> Rc<Cell<Bounds<Pixels>>> { | 184 | pub(crate) fn curve_bounds_for(&self, target: CurveTarget) -> Rc<Cell<Bounds<Pixels>>> { |
| 171 | self.curve_bounds.borrow_mut().entry(target).or_default().clone() | 185 | self.curve_bounds.borrow_mut().entry(target).or_default().clone() |
crates/app/src/ui/cards/keys.rsmodified+2 -1
| @@ -202,6 +202,7 @@ impl Player { | |||
| 202 | Some(current) => KeyEase::ALL.iter().position(|e| *e == current).unwrap_or(usize::MAX), | 202 | Some(current) => KeyEase::ALL.iter().position(|e| *e == current).unwrap_or(usize::MAX), |
| 203 | None => usize::MAX, | 203 | None => usize::MAX, |
| 204 | }; | 204 | }; |
| 205 | + let reason = self.ease_reason(target); | ||
| 205 | let on_pick = Rc::new(on_pick); | 206 | let on_pick = Rc::new(on_pick); |
| 206 | let chips = kit::segmented_equal("key-ease", &labels, selected, here.is_some(), None, move |pick, _, app| { | 207 | let chips = kit::segmented_equal("key-ease", &labels, selected, here.is_some(), None, move |pick, _, app| { |
| 207 | // A custom pick keeps the curve the key already has, or starts from CSS `ease`. | 208 | // A custom pick keeps the curve the key already has, or starts from CSS `ease`. |
| @@ -227,7 +228,7 @@ impl Player { | |||
| 227 | .top(px(0.)) | 228 | .top(px(0.)) |
| 228 | .left(px(0.)) | 229 | .left(px(0.)) |
| 229 | .size_full() | 230 | .size_full() |
| 230 | - .tooltip(overlay_tip_hover("Add a key first", "", None)), | 231 | + .tooltip(overlay_tip_hover(reason, "", None)), |
| 231 | ) | 232 | ) |
| 232 | }); | 233 | }); |
| 233 | // The curve shows the draft while a handle is held, else the key's own custom ease. | 234 | // The curve shows the draft while a handle is held, else the key's own custom ease. |