A caption is taken off the lane by the same stroke and row a clip is
Browse files at this commit888f39d0a7ce97c761f2c6e5c5a652c023b1f77aParent: 3da7bd9- feat
- a caption is taken off the lane by the same stroke and row a clip is
8 changed files +451 -74
- crates/app/src/oracle.rs +53 -0
- crates/app/src/player/actions.rs +6 -1
- crates/app/src/player/timeline_edit.rs +75 -11
- crates/app/src/tests/editing.rs +198 -0
- crates/app/src/timeline_math.rs +14 -0
- crates/app/src/ui/inspector.rs +29 -5
- crates/app/src/ui/overlays.rs +18 -7
- crates/app/src/ui/timeline.rs +58 -50
crates/app/src/oracle.rsmodified+53 -0
| @@ -51,6 +51,12 @@ pub(crate) struct Ctx { | |||
| 51 | /// and the clip-relative answers stand aside: those actions find their own | 51 | /// and the clip-relative answers stand aside: those actions find their own |
| 52 | /// clip under the playhead and word their own refusal. | 52 | /// clip under the playhead and word their own refusal. |
| 53 | pub(crate) clip: Option<(Clip, Lane)>, | 53 | pub(crate) clip: Option<(Clip, Lane)>, |
| 54 | + /// What was clicked is a placed caption and not a clip: a subtitle lane | ||
| 55 | + /// holds no `Clip` at all, so [`Ctx::clip`] is `None` there and the | ||
| 56 | + /// clip-relative answers would read it as "nothing marked". Its own flag, | ||
| 57 | + /// so the one action a caption has -- coming off the lane again -- is a | ||
| 58 | + /// live row while the rest are not rows at all. | ||
| 59 | + pub(crate) caption: bool, | ||
| 54 | /// The clip plays a still ([`engine::is_image`]), which has no sound to | 60 | /// The clip plays a still ([`engine::is_image`]), which has no sound to |
| 55 | /// reach at all -- not the lane's business, because a still sits on a video | 61 | /// reach at all -- not the lane's business, because a still sits on a video |
| 56 | /// lane exactly like a take whose sound is one lane down. | 62 | /// lane exactly like a take whose sound is one lane down. |
| @@ -127,6 +133,36 @@ pub(crate) fn enable(action: ActionId, ctx: Ctx) -> Enable { | |||
| 127 | _ => Enable::No("an export is running"), | 133 | _ => Enable::No("an export is running"), |
| 128 | }; | 134 | }; |
| 129 | } | 135 | } |
| 136 | + // A caption is not a clip: the actions that act on *the marked clip and | ||
| 137 | + // nothing else* have nothing to act on over a placed subtitle, so they are | ||
| 138 | + // refusals of kind -- not rows at all, rather than rows saying "click a clip | ||
| 139 | + // first" over a clicked caption. Delete is the one that means something: it | ||
| 140 | + // routes to [`Player::lift_sub`] when what is marked is a caption. | ||
| 141 | + // | ||
| 142 | + // And it is *only* those. The playhead actions are about the timeline rather | ||
| 143 | + // than about what is marked -- the split and the regroup act at the line | ||
| 144 | + // ([`Player::cut`], [`Player::regroup`]), and the grade, the rate, the fit | ||
| 145 | + // and the scan fall back to the clip under it -- so a caption in hand is no | ||
| 146 | + // reason for them to stop. Hiding them here made them dead *and* silent | ||
| 147 | + // ([`Player::act`] returns without a word on `Hidden`) from the moment a | ||
| 148 | + // caption was clicked until something else was, which no click on the bed | ||
| 149 | + // undoes: there is no handler there to clear the mark. | ||
| 150 | + if ctx.caption | ||
| 151 | + && matches!( | ||
| 152 | + action, | ||
| 153 | + ActionId::Copy | ||
| 154 | + | ActionId::Delete | ||
| 155 | + | ActionId::Lift | ||
| 156 | + | ActionId::Detach | ||
| 157 | + | ActionId::Group | ||
| 158 | + | ActionId::Equalizer | ||
| 159 | + ) | ||
| 160 | + { | ||
| 161 | + return match action { | ||
| 162 | + ActionId::Delete => Enable::Yes, | ||
| 163 | + _ => Enable::Hidden("this is a caption"), | ||
| 164 | + }; | ||
| 165 | + } | ||
| 130 | match action { | 166 | match action { |
| 131 | // -- class: what kind of thing the action is about. The equalizer | 167 | // -- class: what kind of thing the action is about. The equalizer |
| 132 | // filters samples, and a video clip has none of its own here: the sound | 168 | // filters samples, and a video clip has none of its own here: the sound |
| @@ -224,10 +260,27 @@ pub(crate) fn enable(action: ActionId, ctx: Ctx) -> Enable { | |||
| 224 | /// a waveform, an equalizer on a picture -- is not a row at all, so a future | 260 | /// a waveform, an equalizer on a picture -- is not a row at all, so a future |
| 225 | /// action cannot appear where it does not apply by being added to | 261 | /// action cannot appear where it does not apply by being added to |
| 226 | /// [`MENU_ITEMS`] alone. | 262 | /// [`MENU_ITEMS`] alone. |
| 263 | +/// | ||
| 264 | +/// Being *live* and *belonging in this menu* are two different questions, and | ||
| 265 | +/// only this one is the menu's. The playhead actions stay live over a marked | ||
| 266 | +/// caption -- [`enable`] says so, and the strokes and the toolbar read that -- | ||
| 267 | +/// but a split, a rate, a grade or a fit listed under a right-clicked caption | ||
| 268 | +/// reads as something the caption is about to get, when what they reach is the | ||
| 269 | +/// video clip the playhead is standing in. So a caption's menu carries the one | ||
| 270 | +/// row that is the caption's ([`Player::lift_sub`], reached through Delete) and | ||
| 271 | +/// the rows the card already prints "(global)" beside, which say for themselves | ||
| 272 | +/// that they are not about what was clicked. | ||
| 227 | pub(crate) fn menu_items(ctx: Ctx) -> Vec<ActionId> { | 273 | pub(crate) fn menu_items(ctx: Ctx) -> Vec<ActionId> { |
| 228 | MENU_ITEMS | 274 | MENU_ITEMS |
| 229 | .into_iter() | 275 | .into_iter() |
| 230 | .filter(|&action| enable(action, ctx).listed()) | 276 | .filter(|&action| enable(action, ctx).listed()) |
| 277 | + .filter(|&action| { | ||
| 278 | + !ctx.caption | ||
| 279 | + || matches!( | ||
| 280 | + action, | ||
| 281 | + ActionId::Delete | ActionId::Paste | ActionId::ToggleMute | ||
| 282 | + ) | ||
| 283 | + }) | ||
| 231 | .collect() | 284 | .collect() |
| 232 | } | 285 | } |
| 233 | 286 | ||
crates/app/src/player/actions.rsmodified+6 -1
| @@ -213,11 +213,16 @@ impl Player { | |||
| 213 | let Some(session) = &self.session else { | 213 | let Some(session) = &self.session else { |
| 214 | return Ctx::default(); | 214 | return Ctx::default(); |
| 215 | }; | 215 | }; |
| 216 | + let on = on.or(self.selected); | ||
| 216 | let clip = on | 217 | let clip = on |
| 217 | - .or(self.selected) | ||
| 218 | .and_then(|(lane, idx)| session.lane_clips(lane).get(idx).map(|clip| (*clip, lane))); | 218 | .and_then(|(lane, idx)| session.lane_clips(lane).get(idx).map(|clip| (*clip, lane))); |
| 219 | Ctx { | 219 | Ctx { |
| 220 | clip, | 220 | clip, |
| 221 | + // The same pair read in the other index space: a subtitle lane's | ||
| 222 | + // own, where the box that was clicked is a caption. | ||
| 223 | + caption: on.is_some_and(|(lane, idx)| { | ||
| 224 | + lane.kind == LaneKind::Subtitle && idx < session.sub_lane(lane).len() | ||
| 225 | + }), | ||
| 221 | image: clip.is_some_and(|(clip, _)| { | 226 | image: clip.is_some_and(|(clip, _)| { |
| 222 | session | 227 | session |
| 223 | .sources() | 228 | .sources() |
crates/app/src/player/timeline_edit.rsmodified+75 -11
| @@ -121,6 +121,14 @@ impl Player { | |||
| 121 | return; | 121 | return; |
| 122 | } | 122 | } |
| 123 | let selected = self.selected.take(); | 123 | let selected = self.selected.take(); |
| 124 | + // A caption is marked in its own lane's index space -- that lane holds | ||
| 125 | + // no `Clip` -- so the same key reaches it through the one removal a | ||
| 126 | + // placed subtitle has ([`Player::lift_sub`], one undo step). Parity: the | ||
| 127 | + // box on a subtitle lane goes by the stroke every other box goes by. | ||
| 128 | + if let Some((lane, idx)) = selected.filter(|(lane, _)| lane.kind == LaneKind::Subtitle) { | ||
| 129 | + self.lift_sub(lane, idx, cx); | ||
| 130 | + return; | ||
| 131 | + } | ||
| 124 | // Whichever lane it was clicked in: the index is that lane's own, and | 132 | // Whichever lane it was clicked in: the index is that lane's own, and |
| 125 | // the ripple cuts the clip's span out of every lane -- a group covers | 133 | // the ripple cuts the clip's span out of every lane -- a group covers |
| 126 | // one span, so deleting a take by its audio half is the same edit as by | 134 | // one span, so deleting a take by its audio half is the same edit as by |
| @@ -296,6 +304,12 @@ impl Player { | |||
| 296 | self.snap_cue = None; | 304 | self.snap_cue = None; |
| 297 | self.ghost = None; | 305 | self.ghost = None; |
| 298 | let at = self.place_frame(x).0; | 306 | let at = self.place_frame(x).0; |
| 307 | + // What the mark is on, before the lane is renumbered: a caption's start | ||
| 308 | + // frame is its name on its lane ([`sub_mark`]). | ||
| 309 | + let marked = self | ||
| 310 | + .selected | ||
| 311 | + .filter(|&(lane, _)| lane == to) | ||
| 312 | + .and_then(|(lane, idx)| Some(self.session.as_ref()?.sub_lane(lane).get(idx)?.start)); | ||
| 299 | let text = match (self.sub_of_track(track), &mut self.session) { | 313 | let text = match (self.sub_of_track(track), &mut self.session) { |
| 300 | (Some(sub), Some(session)) => match session.place_sub(to, at, sub) { | 314 | (Some(sub), Some(session)) => match session.place_sub(to, at, sub) { |
| 301 | Ok(()) => None, | 315 | Ok(()) => None, |
| @@ -309,8 +323,21 @@ impl Player { | |||
| 309 | ), | 323 | ), |
| 310 | (_, None) => Some("NOT PLACED — open a file first".to_string()), | 324 | (_, None) => Some("NOT PLACED — open a file first".to_string()), |
| 311 | }; | 325 | }; |
| 312 | - if let Some(text) = text { | 326 | + match (text, marked) { |
| 313 | - self.notify_user(text.into()); | 327 | + (Some(text), _) => self.notify_user(text.into()), |
| 328 | + // It went down, and a lane holds its captions in start order | ||
| 329 | + // ([`Project::place_sub`]'s sorted insert), so one placed *before* | ||
| 330 | + // the marked caption slid it one along and the index left behind | ||
| 331 | + // names its new neighbour -- the caption the next Delete would take. | ||
| 332 | + // The mark goes back on the caption it was on. | ||
| 333 | + (None, Some(start)) => { | ||
| 334 | + self.selected = self | ||
| 335 | + .session | ||
| 336 | + .as_ref() | ||
| 337 | + .and_then(|session| sub_mark(session.sub_lane(to), start)) | ||
| 338 | + .map(|i| (to, i)); | ||
| 339 | + } | ||
| 340 | + (None, None) => {} | ||
| 314 | } | 341 | } |
| 315 | cx.notify(); | 342 | cx.notify(); |
| 316 | } | 343 | } |
| @@ -338,20 +365,46 @@ impl Player { | |||
| 338 | return; | 365 | return; |
| 339 | }; | 366 | }; |
| 340 | let start = self.sub_drop_frame(drag.sub, x).0; | 367 | let start = self.sub_drop_frame(drag.sub, x).0; |
| 341 | - if let Some(Err(e)) = self | 368 | + match self |
| 342 | .session | 369 | .session |
| 343 | .as_mut() | 370 | .as_mut() |
| 344 | .map(|session| session.move_sub(drag.lane, idx, to, start)) | 371 | .map(|session| session.move_sub(drag.lane, idx, to, start)) |
| 345 | { | 372 | { |
| 346 | - self.notify_user(format!("NOT MOVED — {e}").into()); | 373 | + Some(Err(e)) => { |
| 374 | + // Nothing moved ([`Project::move_sub`] refuses before its | ||
| 375 | + // snapshot), so nothing was renumbered and the mark is left | ||
| 376 | + // exactly where it was. Re-reading it off the frame the drop | ||
| 377 | + // *asked* for used to hand it to whatever caption already | ||
| 378 | + // covered that frame -- the drop at the left edge saturates to | ||
| 379 | + // 0 ([`landing`]), so a refused drag marked, and the next | ||
| 380 | + // Delete lifted, a caption the hand never touched. | ||
| 381 | + self.notify_user(format!("NOT MOVED — {e}").into()); | ||
| 382 | + } | ||
| 383 | + // A lane holds its captions in start order, so the drop moved the | ||
| 384 | + // mark as well as the box: it is re-read off where the caption | ||
| 385 | + // landed rather than left on the index it had, which after the move | ||
| 386 | + // is a neighbour's. | ||
| 387 | + Some(Ok(())) => { | ||
| 388 | + self.selected = self | ||
| 389 | + .session | ||
| 390 | + .as_ref() | ||
| 391 | + .and_then(|session| sub_mark(session.sub_lane(to), start)) | ||
| 392 | + .map(|i| (to, i)); | ||
| 393 | + } | ||
| 394 | + None => {} | ||
| 347 | } | 395 | } |
| 348 | cx.notify(); | 396 | cx.notify(); |
| 349 | } | 397 | } |
| 350 | 398 | ||
| 351 | - /// The × on a caption's own box: it comes off the lane and leaves the gap, | 399 | + /// A caption off its lane, leaving the gap, one undo step |
| 352 | - /// one undo step ([`PlaybackSession::lift_sub`]). The palette row it played | 400 | + /// ([`PlaybackSession::lift_sub`]). The palette row it played stays in the |
| 353 | - /// stays in the list, which is what makes this a lift and not a removal -- | 401 | + /// list, which is what makes this a lift and not a removal -- and the way a |
| 354 | - /// and the way a subtitle lane is emptied so it can be taken off at all. | 402 | + /// subtitle lane is emptied so it can be taken off at all. |
| 403 | + /// | ||
| 404 | + /// The one door out for a placed caption: the Delete key | ||
| 405 | + /// ([`Player::delete_selected`]) and the Delete row of its own menu both | ||
| 406 | + /// land here, so there is one removal and one undo step however it is asked | ||
| 407 | + /// for. | ||
| 355 | pub(crate) fn lift_sub(&mut self, lane: Lane, idx: usize, cx: &mut Context<Self>) { | 408 | pub(crate) fn lift_sub(&mut self, lane: Lane, idx: usize, cx: &mut Context<Self>) { |
| 356 | if self.exporting().is_some() { | 409 | if self.exporting().is_some() { |
| 357 | return; | 410 | return; |
| @@ -367,6 +420,16 @@ impl Player { | |||
| 367 | ), | 420 | ), |
| 368 | false => "NOTHING LIFTED — that caption is not there any more".to_string(), | 421 | false => "NOTHING LIFTED — that caption is not there any more".to_string(), |
| 369 | }; | 422 | }; |
| 423 | + if lifted { | ||
| 424 | + // Everything after it on that lane slid down one ([`Vec::remove`]), | ||
| 425 | + // so a mark or an open menu left at or past it names a *different* | ||
| 426 | + // caption now -- and the next Delete would take that one. Both go | ||
| 427 | + // with the caption they were on. | ||
| 428 | + if self.selected.is_some_and(|(l, i)| l == lane && i >= idx) { | ||
| 429 | + self.selected = None; | ||
| 430 | + } | ||
| 431 | + self.context_menu = None; | ||
| 432 | + } | ||
| 370 | self.notify_user(text.into()); | 433 | self.notify_user(text.into()); |
| 371 | cx.notify(); | 434 | cx.notify(); |
| 372 | } | 435 | } |
| @@ -817,9 +880,10 @@ impl Player { | |||
| 817 | // A caption's edge, on a lane that holds no `Clip` at all: the same | 880 | // A caption's edge, on a lane that holds no `Clip` at all: the same |
| 818 | // gesture, the same `Trim`, and the branch is the lane's kind wherever | 881 | // gesture, the same `Trim`, and the branch is the lane's kind wherever |
| 819 | // the drag is asked about ([`Player::trim_to`], | 882 | // the drag is asked about ([`Player::trim_to`], |
| 820 | - // [`Player::commit_trim`]). No selection -- a placement is not in the | 883 | + // [`Player::commit_trim`]). A caption *is* markable -- the mark is its |
| 821 | - // clip selection's index space -- and no group: a caption has no half | 884 | + // lane and its index like a clip's ([`Player::select`]) -- but an edge |
| 822 | - // on another lane. | 885 | + // drag is a trim and not a pick, so this leaves the mark where the hand |
| 886 | + // left it. No group either: a caption has no half on another lane. | ||
| 823 | if lane.kind == LaneKind::Subtitle { | 887 | if lane.kind == LaneKind::Subtitle { |
| 824 | let Some(sub) = self | 888 | let Some(sub) = self |
| 825 | .session | 889 | .session |
crates/app/src/tests/editing.rsmodified+198 -0
| @@ -263,6 +263,204 @@ fn every_audio_stream_of_a_file_is_a_row_usable_or_not() { | |||
| 263 | /// the playhead rather than on the clicked clip are the ones that can be | 263 | /// the playhead rather than on the clicked clip are the ones that can be |
| 264 | /// inapplicable, and a menu at the edge of the window has to come back | 264 | /// inapplicable, and a menu at the edge of the window has to come back |
| 265 | /// inside it or its last item cannot be clicked at all. | 265 | /// inside it or its last item cannot be clicked at all. |
| 266 | +/// A caption's own menu, opened on a box that is not a clip: one row that acts | ||
| 267 | +/// on it -- Delete, which routes to `Player::lift_sub` -- the timeline's global | ||
| 268 | +/// item beside it, and nothing else drawn at all. What a placed subtitle used to | ||
| 269 | +/// have no menu, and no stroke, to do. | ||
| 270 | +#[test] | ||
| 271 | +fn a_caption_is_deleted_by_the_same_row_and_stroke_every_box_is() { | ||
| 272 | + use keymap::ActionId; | ||
| 273 | + // A subtitle lane holds no `Clip`, so this is what the player reads off a | ||
| 274 | + // right-clicked caption: nothing in the clip index space, and `caption`. | ||
| 275 | + let cap = Ctx { | ||
| 276 | + caption: true, | ||
| 277 | + timeline: true, | ||
| 278 | + ..Ctx::default() | ||
| 279 | + }; | ||
| 280 | + assert!(cap.clip.is_none(), "a caption is never a clip"); | ||
| 281 | + assert_eq!( | ||
| 282 | + enable(ActionId::Delete, cap), | ||
| 283 | + Enable::Yes, | ||
| 284 | + "the one thing a placed caption can be asked to do", | ||
| 285 | + ); | ||
| 286 | + // The clip rows are refusals of *kind* on a caption, so the menu leaves them | ||
| 287 | + // out rather than drawing "click a clip first" over a clicked box. | ||
| 288 | + for clip_only in [ | ||
| 289 | + ActionId::Copy, | ||
| 290 | + ActionId::Lift, | ||
| 291 | + ActionId::Detach, | ||
| 292 | + ActionId::Group, | ||
| 293 | + ActionId::Equalizer, | ||
| 294 | + ] { | ||
| 295 | + assert_eq!( | ||
| 296 | + enable(clip_only, cap), | ||
| 297 | + Enable::Hidden("this is a caption"), | ||
| 298 | + "{clip_only:?} is not a row on a caption", | ||
| 299 | + ); | ||
| 300 | + } | ||
| 301 | + // ...and the playhead's actions are *not* among them: the split and the | ||
| 302 | + // regroup act at the line and the cards fall back to the clip under it, so a | ||
| 303 | + // caption in hand is no reason for them to go dead -- which, hidden, is | ||
| 304 | + // exactly what they went: `Player::act` returns without a word on `Hidden`, | ||
| 305 | + // and no click on the bed clears the mark that put them there. | ||
| 306 | + for playhead in [ | ||
| 307 | + ActionId::Cut, | ||
| 308 | + ActionId::Regroup, | ||
| 309 | + ActionId::Color, | ||
| 310 | + ActionId::Speed, | ||
| 311 | + ActionId::Fit, | ||
| 312 | + ActionId::Silence, | ||
| 313 | + ] { | ||
| 314 | + assert_eq!( | ||
| 315 | + enable(playhead, cap), | ||
| 316 | + Enable::Yes, | ||
| 317 | + "{playhead:?} is about the playhead and not about the mark", | ||
| 318 | + ); | ||
| 319 | + } | ||
| 320 | + // ...but live is not *listed*: every one of those rows reaches the clip | ||
| 321 | + // under the playhead and not the caption, and a menu opened on a caption | ||
| 322 | + // that offered a grade would read as the caption's. The caption's menu is | ||
| 323 | + // its one row and the global pair the card already names as global. | ||
| 324 | + assert_eq!( | ||
| 325 | + menu_items(cap), | ||
| 326 | + vec![ActionId::Paste, ActionId::Delete, ActionId::ToggleMute], | ||
| 327 | + "the caption's menu is its removal and the global rows alone", | ||
| 328 | + ); | ||
| 329 | + // ...and the same reading with a clip under it is the clip menu, untouched: | ||
| 330 | + // the flag is off wherever a `Clip` was clicked. | ||
| 331 | + assert!(menu_items(Ctx { | ||
| 332 | + timeline: true, | ||
| 333 | + ..Ctx::default() | ||
| 334 | + }) | ||
| 335 | + .contains(&ActionId::Cut)); | ||
| 336 | +} | ||
| 337 | + | ||
| 338 | +/// A timeline with a subtitle palette and an empty subtitle lane: what a | ||
| 339 | +/// caption is placed on, at the fixture's own rate. | ||
| 340 | +fn with_subtitle_lane() -> (PlaybackSession, Lane) { | ||
| 341 | + let mut session = PlaybackSession::open(asset("test_av.mp4")).expect("open the fixture"); | ||
| 342 | + session.set_gain(0.0); | ||
| 343 | + subtitle_notice(&mut session, &asset("test_subs.mkv")).expect("the mkv carries subtitles"); | ||
| 344 | + let lane = session.add_lane(LaneKind::Subtitle); | ||
| 345 | + (session, lane) | ||
| 346 | +} | ||
| 347 | + | ||
| 348 | +/// A second of palette track 0, to be placed wherever the test drops it. | ||
| 349 | +fn one_second(start: u32) -> SubClip { | ||
| 350 | + SubClip { | ||
| 351 | + start, | ||
| 352 | + frames: 30, | ||
| 353 | + track: 0, | ||
| 354 | + in_us: 0, | ||
| 355 | + out_us: 1_000_000, | ||
| 356 | + } | ||
| 357 | +} | ||
| 358 | + | ||
| 359 | +/// A drop the engine *refuses* moves nothing -- so it must move no mark either. | ||
| 360 | +/// A drag towards the left edge saturates to frame 0 (`landing`), and reading | ||
| 361 | +/// the mark back off the frame the drop asked for handed it to whatever caption | ||
| 362 | +/// already covered frame 0: the next Delete then lifted a caption the hand never | ||
| 363 | +/// touched. The mark stays on the caption that did not move. | ||
| 364 | +#[test] | ||
| 365 | +fn a_refused_caption_drop_leaves_the_mark_where_it_was() { | ||
| 366 | + use crate::sub_mark; | ||
| 367 | + let (mut session, lane) = with_subtitle_lane(); | ||
| 368 | + session.place_sub(lane, 0, one_second(0)).expect("A goes down"); | ||
| 369 | + session | ||
| 370 | + .place_sub(lane, 60, one_second(0)) | ||
| 371 | + .expect("B goes down after it"); | ||
| 372 | + let before = session.sub_lane(lane).to_vec(); | ||
| 373 | + // The mark is on B, the caption in hand: index 1 of the lane. | ||
| 374 | + assert_eq!(sub_mark(session.sub_lane(lane), 60), Some(1)); | ||
| 375 | + | ||
| 376 | + let err = session | ||
| 377 | + .move_sub(lane, 1, lane, 0) | ||
| 378 | + .expect_err("A already covers frame 0"); | ||
| 379 | + assert!(err.to_string().contains("already covers"), "{err}"); | ||
| 380 | + assert_eq!(session.sub_lane(lane), before, "a refusal moved nothing"); | ||
| 381 | + // The trap this pins: the frame the drop *asked* for names A, so the old | ||
| 382 | + // re-read marked A -- the caption nobody dragged -- and `x` lifted it. | ||
| 383 | + assert_eq!( | ||
| 384 | + sub_mark(session.sub_lane(lane), 0), | ||
| 385 | + Some(0), | ||
| 386 | + "frame 0 is A's, which is why a refused drop must not re-read the mark", | ||
| 387 | + ); | ||
| 388 | + // Nothing was renumbered, so B is still index 1 and still the marked one. | ||
| 389 | + assert_eq!(sub_mark(session.sub_lane(lane), 60), Some(1)); | ||
| 390 | +} | ||
| 391 | + | ||
| 392 | +/// A lane inserts its captions in start order (`Project::place_sub`), so one | ||
| 393 | +/// placed *before* the marked caption slides it one along: the mark left on its | ||
| 394 | +/// old index would name the caption that just arrived, and `x` would lift that | ||
| 395 | +/// one instead. The mark is kept by the caption's start frame, which is its name | ||
| 396 | +/// on its lane, so it follows the caption it was on. | ||
| 397 | +#[test] | ||
| 398 | +fn a_caption_placed_before_the_marked_one_leaves_the_mark_on_the_original() { | ||
| 399 | + use crate::sub_mark; | ||
| 400 | + let (mut session, lane) = with_subtitle_lane(); | ||
| 401 | + session | ||
| 402 | + .place_sub(lane, 100, one_second(0)) | ||
| 403 | + .expect("A goes down"); | ||
| 404 | + let marked = session.sub_lane(lane)[0].start; | ||
| 405 | + assert_eq!(sub_mark(session.sub_lane(lane), marked), Some(0)); | ||
| 406 | + | ||
| 407 | + session | ||
| 408 | + .place_sub(lane, 0, one_second(0)) | ||
| 409 | + .expect("the new one goes down before it"); | ||
| 410 | + assert_eq!( | ||
| 411 | + session | ||
| 412 | + .sub_lane(lane) | ||
| 413 | + .iter() | ||
| 414 | + .map(|s| s.start) | ||
| 415 | + .collect::<Vec<_>>(), | ||
| 416 | + [0, 100], | ||
| 417 | + "the lane holds them in start order", | ||
| 418 | + ); | ||
| 419 | + // What the player does with the mark across that placement. | ||
| 420 | + let mark = sub_mark(session.sub_lane(lane), marked).expect("A is still there"); | ||
| 421 | + assert_eq!(mark, 1, "A slid one along and the mark went with it"); | ||
| 422 | + | ||
| 423 | + // ...and the Delete that stroke reaches takes A, not the caption that | ||
| 424 | + // arrived: `Player::delete_selected` routes a caption's mark to `lift_sub`. | ||
| 425 | + assert!(session.lift_sub(lane, mark)); | ||
| 426 | + assert_eq!( | ||
| 427 | + session | ||
| 428 | + .sub_lane(lane) | ||
| 429 | + .iter() | ||
| 430 | + .map(|s| s.start) | ||
| 431 | + .collect::<Vec<_>>(), | ||
| 432 | + [0], | ||
| 433 | + "the caption the user marked is the one that died", | ||
| 434 | + ); | ||
| 435 | +} | ||
| 436 | + | ||
| 437 | +/// The playhead's actions with a caption marked: live, and doing what they say. | ||
| 438 | +/// Hidden, they were dead *and* silent -- `Player::act` says nothing on a class | ||
| 439 | +/// refusal -- from the first click on a caption until something else was | ||
| 440 | +/// clicked, and no click on the bed clears that mark. | ||
| 441 | +#[test] | ||
| 442 | +fn the_playhead_actions_still_work_with_a_caption_marked() { | ||
| 443 | + use keymap::ActionId; | ||
| 444 | + let cap = Ctx { | ||
| 445 | + caption: true, | ||
| 446 | + timeline: true, | ||
| 447 | + ..Ctx::default() | ||
| 448 | + }; | ||
| 449 | + assert_eq!(enable(ActionId::Cut, cap), Enable::Yes); | ||
| 450 | + assert_eq!(enable(ActionId::Regroup, cap), Enable::Yes); | ||
| 451 | + | ||
| 452 | + // And the edits themselves, on a timeline holding a placed caption: the | ||
| 453 | + // split at the playhead and the rejoin at the seam it leaves. | ||
| 454 | + let (mut session, lane) = with_subtitle_lane(); | ||
| 455 | + session.place_sub(lane, 0, one_second(0)).expect("it goes down"); | ||
| 456 | + let clips = session.lane_clips(Lane::V1).len(); | ||
| 457 | + assert!(session.cut_at(2.0), "the playhead splits the clip under it"); | ||
| 458 | + assert_eq!(session.lane_clips(Lane::V1).len(), clips + 1); | ||
| 459 | + assert!(session.regroup_at(2.0), "and the seam rejoins"); | ||
| 460 | + assert_eq!(session.lane_clips(Lane::V1).len(), clips); | ||
| 461 | + assert_eq!(session.sub_lane(lane).len(), 1, "the caption is untouched"); | ||
| 462 | +} | ||
| 463 | + | ||
| 266 | #[test] | 464 | #[test] |
| 267 | fn the_clip_menu_dims_what_the_playhead_is_not_on_and_stays_in_the_window() { | 465 | fn the_clip_menu_dims_what_the_playhead_is_not_on_and_stays_in_the_window() { |
| 268 | use keymap::{ActionId, Keymap}; | 466 | use keymap::{ActionId, Keymap}; |
crates/app/src/timeline_math.rsmodified+14 -0
| @@ -201,6 +201,20 @@ pub(crate) fn live_idx<T: Copy + PartialEq>(clips: &[T], idx: usize, clip: T) -> | |||
| 201 | } | 201 | } |
| 202 | } | 202 | } |
| 203 | 203 | ||
| 204 | +/// Which index a lane's mark is on after that lane was renumbered: the caption | ||
| 205 | +/// that starts at `start`, and `None` when it is not there any more. | ||
| 206 | +/// | ||
| 207 | +/// The mark on a caption is an index like a clip's ([`Player::selected`]), and a | ||
| 208 | +/// subtitle lane both *inserts in start order* ([`engine::Project::place_sub`]) | ||
| 209 | +/// and removes, so any placement or lift renumbers every caption after it and an | ||
| 210 | +/// index left as it was names a neighbour -- the caption the next Delete would | ||
| 211 | +/// take. So the mark is read off the caption's start frame before such an edit | ||
| 212 | +/// and found again by it after: captions on a lane are disjoint and in order, so | ||
| 213 | +/// a start frame names exactly one of them and is the identity an index is not. | ||
| 214 | +pub(crate) fn sub_mark(subs: &[SubClip], start: u32) -> Option<usize> { | ||
| 215 | + subs.iter().position(|s| s.start == start) | ||
| 216 | +} | ||
| 217 | + | ||
| 204 | /// The part of a clip's box that is on the bed, in the box's own pixels: | 218 | /// The part of a clip's box that is on the bed, in the box's own pixels: |
| 205 | /// `(left, width)` of its intersection with the visible strip. Everything drawn | 219 | /// `(left, width)` of its intersection with the visible strip. Everything drawn |
| 206 | /// *inside* a box -- its waveform, its name, its speed badge -- is placed in | 220 | /// *inside* a box -- its waveform, its name, its speed badge -- is placed in |
crates/app/src/ui/inspector.rsmodified+29 -5
| @@ -103,9 +103,18 @@ impl Player { | |||
| 103 | image, | 103 | image, |
| 104 | )) | 104 | )) |
| 105 | }); | 105 | }); |
| 106 | - let head = match &picked { | 106 | + // A subtitle lane holds no `Clip`, so the read above answers `None` on a |
| 107 | - Some((lane, _, name, _)) => format!("{} · {}", lane.label(), name), | 107 | + // marked caption -- while the bed draws that caption in the selection's |
| 108 | - None => "Nothing selected".to_string(), | 108 | + // own colours and this panel's Delete lifts it. The panel says what is |
| 109 | + // marked or it is telling the user the opposite of what they can see. | ||
| 110 | + let caption = self.selected.filter(|_| picked.is_none()).and_then(|(lane, idx)| { | ||
| 111 | + let sub = self.session.as_ref()?.sub_lane(lane).get(idx).copied()?; | ||
| 112 | + Some((lane, sub)) | ||
| 113 | + }); | ||
| 114 | + let head = match (&picked, &caption) { | ||
| 115 | + (Some((lane, _, name, _)), _) => format!("{} · {}", lane.label(), name), | ||
| 116 | + (None, Some((lane, _))) => format!("{} · caption", lane.label()), | ||
| 117 | + (None, None) => "Nothing selected".to_string(), | ||
| 109 | }; | 118 | }; |
| 110 | let detail = match &picked { | 119 | let detail = match &picked { |
| 111 | Some((_, clip, _, _)) => format!( | 120 | Some((_, clip, _, _)) => format!( |
| @@ -115,7 +124,17 @@ impl Player { | |||
| 115 | span_label(f64::from(clip.frames()) / self.fps), | 124 | span_label(f64::from(clip.frames()) / self.fps), |
| 116 | clip.speed, | 125 | clip.speed, |
| 117 | ), | 126 | ), |
| 118 | - None => "Click a clip on the timeline to see its settings".to_string(), | 127 | + // The words' own span, in the same shape a clip's is written in -- |
| 128 | + // and no speed, because a caption has none to change. | ||
| 129 | + None => match &caption { | ||
| 130 | + Some((_, sub)) => format!( | ||
| 131 | + "{} → {} · {} · words", | ||
| 132 | + timecode(f64::from(sub.start) / self.fps, self.fps), | ||
| 133 | + timecode(f64::from(sub.end()) / self.fps, self.fps), | ||
| 134 | + span_label(f64::from(sub.frames) / self.fps), | ||
| 135 | + ), | ||
| 136 | + None => "Click a clip on the timeline to see its settings".to_string(), | ||
| 137 | + }, | ||
| 119 | }; | 138 | }; |
| 120 | div() | 139 | div() |
| 121 | .flex() | 140 | .flex() |
| @@ -128,7 +147,7 @@ impl Player { | |||
| 128 | div() | 147 | div() |
| 129 | .flex_none() | 148 | .flex_none() |
| 130 | .truncate() | 149 | .truncate() |
| 131 | - .text_color(rgb(match picked.is_some() { | 150 | + .text_color(rgb(match picked.is_some() || caption.is_some() { |
| 132 | true => FG_PRIMARY(), | 151 | true => FG_PRIMARY(), |
| 133 | false => FG_SECONDARY(), | 152 | false => FG_SECONDARY(), |
| 134 | })) | 153 | })) |
| @@ -139,6 +158,11 @@ impl Player { | |||
| 139 | .border_color(rgb(clip_kind(lane.kind, *image))) | 158 | .border_color(rgb(clip_kind(lane.kind, *image))) |
| 140 | .pl(px(6.)) | 159 | .pl(px(6.)) |
| 141 | }) | 160 | }) |
| 161 | + .when_some(caption.as_ref(), |d, (lane, _)| { | ||
| 162 | + d.border_l_2() | ||
| 163 | + .border_color(rgb(clip_kind(lane.kind, false))) | ||
| 164 | + .pl(px(6.)) | ||
| 165 | + }) | ||
| 142 | .child(head), | 166 | .child(head), |
| 143 | ) | 167 | ) |
| 144 | .child( | 168 | .child( |
crates/app/src/ui/overlays.rsmodified+18 -7
| @@ -470,8 +470,13 @@ impl Player { | |||
| 470 | ) -> Option<impl IntoElement> { | 470 | ) -> Option<impl IntoElement> { |
| 471 | let menu = self.context_menu?; | 471 | let menu = self.context_menu?; |
| 472 | let session = self.session.as_ref()?; | 472 | let session = self.session.as_ref()?; |
| 473 | - let clip = *session.lane_clips(menu.lane).get(menu.idx)?; | 473 | + // Both `None` when the menu was opened on a caption: a subtitle lane |
| 474 | - let source = session.sources().get(clip.source).cloned()?; | 474 | + // holds no `Clip` and a caption plays no source file. The rows are the |
| 475 | + // oracle's either way ([`Ctx::caption`]), so what the card *has* is | ||
| 476 | + // asked for where it is used rather than at the door -- refusing here | ||
| 477 | + // would be a right-click that opens nothing. | ||
| 478 | + let clip = session.lane_clips(menu.lane).get(menu.idx).copied(); | ||
| 479 | + let source = clip.and_then(|clip| session.sources().get(clip.source).cloned()); | ||
| 475 | let secs = |frames: u32| timecode(f64::from(frames) / self.fps, self.fps); | 480 | let secs = |frames: u32| timecode(f64::from(frames) / self.fps, self.fps); |
| 476 | let row = |n: usize| { | 481 | let row = |n: usize| { |
| 477 | div() | 482 | div() |
| @@ -487,7 +492,7 @@ impl Player { | |||
| 487 | .rounded(px(3.)) | 492 | .rounded(px(3.)) |
| 488 | }; | 493 | }; |
| 489 | let mut rows: Vec<AnyElement> = Vec::new(); | 494 | let mut rows: Vec<AnyElement> = Vec::new(); |
| 490 | - if menu.details { | 495 | + if let (true, Some((clip, source))) = (menu.details, clip.zip(source.clone())) { |
| 491 | // Read-only, so no ids and no hover: this side is a card, not a | 496 | // Read-only, so no ids and no hover: this side is a card, not a |
| 492 | // list of things to click. Each value is one truncated line, which | 497 | // list of things to click. Each value is one truncated line, which |
| 493 | // is what keeps the height below the one the clamp was given. | 498 | // is what keeps the height below the one the clamp was given. |
| @@ -596,7 +601,10 @@ impl Player { | |||
| 596 | .into_any_element(), | 601 | .into_any_element(), |
| 597 | ); | 602 | ); |
| 598 | } | 603 | } |
| 599 | - rows.push( | 604 | + // What a caption has no other side to turn over to: its file, its |
| 605 | + // source range and its bitrate are a clip's, and a row that opened | ||
| 606 | + // an empty card would be the stub this menu does not draw. | ||
| 607 | + rows.extend(clip.map(|_| { | ||
| 600 | row(rows.len()) | 608 | row(rows.len()) |
| 601 | .cursor_pointer() | 609 | .cursor_pointer() |
| 602 | .hover(|s| s.bg(rgb(BG_HOVER()))) | 610 | .hover(|s| s.bg(rgb(BG_HOVER()))) |
| @@ -610,15 +618,18 @@ impl Player { | |||
| 610 | // No stroke reaches this one, and a blank column would read | 618 | // No stroke reaches this one, and a blank column would read |
| 611 | // as one that was forgotten. | 619 | // as one that was forgotten. |
| 612 | .child(div().text_color(rgb(FG_SECONDARY())).child("…")) | 620 | .child(div().text_color(rgb(FG_SECONDARY())).child("…")) |
| 613 | - .into_any_element(), | 621 | + .into_any_element() |
| 614 | - ); | 622 | + })); |
| 615 | } | 623 | } |
| 616 | // The height the card is *placed* by and the height its list is drawn | 624 | // The height the card is *placed* by and the height its list is drawn |
| 617 | // to are one number: placed by a taller one, the card would hang off the | 625 | // to are one number: placed by a taller one, the card would hang off the |
| 618 | // window's floor -- the very thing the clamp is for. | 626 | // window's floor -- the very thing the clamp is for. |
| 619 | let list_h = menu_rows_h(rows.len(), viewport); | 627 | let list_h = menu_rows_h(rows.len(), viewport); |
| 620 | let (x, y) = menu_at(menu.at, viewport, MENU_PAD * 2. + list_h); | 628 | let (x, y) = menu_at(menu.at, viewport, MENU_PAD * 2. + list_h); |
| 621 | - let full: SharedString = source.path.display().to_string().into(); | 629 | + let full: SharedString = source |
| 630 | + .map(|source| source.path.display().to_string()) | ||
| 631 | + .unwrap_or_default() | ||
| 632 | + .into(); | ||
| 622 | Some( | 633 | Some( |
| 623 | scrim() | 634 | scrim() |
| 624 | // Click away closes it, either button, and the press is | 635 | // Click away closes it, either button, and the press is |
crates/app/src/ui/timeline.rsmodified+58 -50
| @@ -664,8 +664,8 @@ impl Player { | |||
| 664 | // What a caption's box says clicking it does; the media boxes' tooltip | 664 | // What a caption's box says clicking it does; the media boxes' tooltip |
| 665 | // names edits a placement has none of (no group, no speed, no ripple). | 665 | // names edits a placement has none of (no group, no speed, no ripple). |
| 666 | let sub_tip: SharedString = | 666 | let sub_tip: SharedString = |
| 667 | - "Drag it along the lane or onto another subtitle track, an end to trim it, × takes it \ | 667 | + "Drag it along the lane or onto another subtitle track, an end to trim it, x or the \ |
| 668 | - off" | 668 | + right button takes it off" |
| 669 | .into(); | 669 | .into(); |
| 670 | // What this track plays at, on the header it belongs to: shown only | 670 | // What this track plays at, on the header it belongs to: shown only |
| 671 | // when it is not unity, because a column 40 px wide has room for a | 671 | // when it is not unity, because a column 40 px wide has room for a |
| @@ -1248,8 +1248,10 @@ impl Player { | |||
| 1248 | })) | 1248 | })) |
| 1249 | // The same bed's other kind of box: a stretch of a palette | 1249 | // The same bed's other kind of box: a stretch of a palette |
| 1250 | // track placed on this lane, dragged along it, dragged onto | 1250 | // track placed on this lane, dragged along it, dragged onto |
| 1251 | - // another subtitle lane, trimmed at either end and lifted | 1251 | + // another subtitle lane, trimmed at either end, marked by a |
| 1252 | - // off by its own ×. Empty on every lane that is not a | 1252 | + // click and lifted off by the Delete row of its own menu or |
| 1253 | + // the stroke that row names -- the doors every other box on | ||
| 1254 | + // the bed has. Empty on every lane that is not a | ||
| 1253 | // subtitle one, which is why there is one row and not two. | 1255 | // subtitle one, which is why there is one row and not two. |
| 1254 | .children(subs.iter().enumerate().map(|(i, placed)| { | 1256 | .children(subs.iter().enumerate().map(|(i, placed)| { |
| 1255 | // What the drag payload names, and what an edge drag is | 1257 | // What the drag payload names, and what an edge drag is |
| @@ -1274,6 +1276,10 @@ impl Player { | |||
| 1274 | label.clone().unwrap_or_else(|| lane.label()).into(); | 1276 | label.clone().unwrap_or_else(|| lane.label()).into(); |
| 1275 | let tip = sub_tip.clone(); | 1277 | let tip = sub_tip.clone(); |
| 1276 | let head = shown_sub.start; | 1278 | let head = shown_sub.start; |
| 1279 | + // Marked the way every other box on this bed is marked, | ||
| 1280 | + // in this lane's own index space -- a caption has no | ||
| 1281 | + // group, so nothing else lights with it. | ||
| 1282 | + let on = sel == Some((lane, i)); | ||
| 1277 | div() | 1283 | div() |
| 1278 | .id((row_id.clone(), i)) | 1284 | .id((row_id.clone(), i)) |
| 1279 | .absolute() | 1285 | .absolute() |
| @@ -1284,11 +1290,18 @@ impl Player { | |||
| 1284 | .overflow_hidden() | 1290 | .overflow_hidden() |
| 1285 | .rounded(px(3.)) | 1291 | .rounded(px(3.)) |
| 1286 | .border_1() | 1292 | .border_1() |
| 1287 | - .border_color(rgb(FG_SECONDARY())) | 1293 | + .border_color(rgb(if on { |
| 1294 | + STROKE_SELECTED() | ||
| 1295 | + } else { | ||
| 1296 | + FG_SECONDARY() | ||
| 1297 | + })) | ||
| 1288 | // The captions' own colour, dimmed on a lane whose | 1298 | // The captions' own colour, dimmed on a lane whose |
| 1289 | // eye is shut: what is not being drawn over the | 1299 | // eye is shut: what is not being drawn over the |
| 1290 | - // picture is still on the lane, and says so. | 1300 | + // picture is still on the lane, and says so. Marked, |
| 1291 | - .bg(rgb(CLIP_TEXT())) | 1301 | + // it takes the selection's colours instead, the same |
| 1302 | + // pair a marked clip takes -- what Delete will act | ||
| 1303 | + // on has one look on this bed and not two. | ||
| 1304 | + .bg(rgb(if on { BG_SELECTED() } else { CLIP_TEXT() })) | ||
| 1292 | .when(!shown, |d| d.opacity(0.55)) | 1305 | .when(!shown, |d| d.opacity(0.55)) |
| 1293 | .cursor_pointer() | 1306 | .cursor_pointer() |
| 1294 | .hover(|s| s.border_color(rgb(ACCENT_PRIMARY()))) | 1307 | .hover(|s| s.border_color(rgb(ACCENT_PRIMARY()))) |
| @@ -1309,7 +1322,22 @@ impl Player { | |||
| 1309 | // than jumping its head under it. | 1322 | // than jumping its head under it. |
| 1310 | this.grab = | 1323 | this.grab = |
| 1311 | this.frame_under(event.position.x).saturating_sub(head); | 1324 | this.frame_under(event.position.x).saturating_sub(head); |
| 1312 | - cx.notify(); | 1325 | + // ...and it marks the caption, exactly as |
| 1326 | + // the press that may become a clip's drag | ||
| 1327 | + // marks the clip: picking a caption up and | ||
| 1328 | + // putting it back down is a click. | ||
| 1329 | + this.select((lane, i), cx); | ||
| 1330 | + }), | ||
| 1331 | + ) | ||
| 1332 | + // The right button marks it and hangs the menu at | ||
| 1333 | + // the pointer, the clip menu opened on the clip | ||
| 1334 | + // box's own rule -- the Delete row of it is this | ||
| 1335 | + // caption's, and the rows a caption has no use for | ||
| 1336 | + // are not drawn ([`oracle::enable`]). | ||
| 1337 | + .on_mouse_down( | ||
| 1338 | + MouseButton::Right, | ||
| 1339 | + cx.listener(move |this, event: &MouseDownEvent, _, cx| { | ||
| 1340 | + this.open_menu(lane, i, event.position, cx); | ||
| 1313 | }), | 1341 | }), |
| 1314 | ) | 1342 | ) |
| 1315 | // The two strips a drag lengthens it by, on the same | 1343 | // The two strips a drag lengthens it by, on the same |
| @@ -1340,7 +1368,20 @@ impl Player { | |||
| 1340 | cx.stop_propagation(); | 1368 | cx.stop_propagation(); |
| 1341 | this.timeline_wheel(event, cx); | 1369 | this.timeline_wheel(event, cx); |
| 1342 | }, | 1370 | }, |
| 1343 | - )); | 1371 | + )) |
| 1372 | + // Occluded, so the box's own | ||
| 1373 | + // right-button listener never fires | ||
| 1374 | + // here: the same menu, opened by the | ||
| 1375 | + // same call, exactly as a clip's | ||
| 1376 | + // edge strip does it. | ||
| 1377 | + .on_mouse_down( | ||
| 1378 | + MouseButton::Right, | ||
| 1379 | + cx.listener( | ||
| 1380 | + move |this, event: &MouseDownEvent, _, cx| { | ||
| 1381 | + this.open_menu(lane, i, event.position, cx); | ||
| 1382 | + }, | ||
| 1383 | + ), | ||
| 1384 | + ); | ||
| 1344 | zone = match edge { | 1385 | zone = match edge { |
| 1345 | Edge::Start => zone.left_0(), | 1386 | Edge::Start => zone.left_0(), |
| 1346 | Edge::End => zone.right_0(), | 1387 | Edge::End => zone.right_0(), |
| @@ -1362,47 +1403,14 @@ impl Player { | |||
| 1362 | .child(label), | 1403 | .child(label), |
| 1363 | ) | 1404 | ) |
| 1364 | }) | 1405 | }) |
| 1365 | - // The way back off the lane, on the box itself: a | 1406 | + // The way back off the lane is the way every other |
| 1366 | - // caption is not in the clip selection's index | 1407 | + // box takes: the Delete stroke on the marked caption |
| 1367 | - // space, so no stroke reaches it -- and a lane | 1408 | + // and the Delete row of its own menu |
| 1368 | - // holding one cannot be removed either | 1409 | + // ([`Player::lift_sub`]). The × that used to sit |
| 1369 | - // ([`Project::remove_lane`] refuses it), which | 1410 | + // here is gone with them -- it was drawn only where |
| 1370 | - // would leave a placement nobody could undo but by | 1411 | + // the box was wide enough to hold it, so the one |
| 1371 | - // undoing. Only where the box is wide enough to | 1412 | + // removal a caption had was the one a zoomed-out |
| 1372 | - // hold a target beside its name; narrower than that | 1413 | + // caption did not have. |
| 1373 | - // it is lifted after zooming in, exactly as it is | ||
| 1374 | - // trimmed after zooming in. | ||
| 1375 | - // | ||
| 1376 | - // Clear of the tail's own trim strip by that | ||
| 1377 | - // strip's width: both occlude and this one is drawn | ||
| 1378 | - // last, so hard against the right edge it swallowed | ||
| 1379 | - // every press meant for the edge and the tail could | ||
| 1380 | - // not be dragged at all (caught driving it). | ||
| 1381 | - .when(vis_w >= 2. * HIT_MIN + EDGE_W, |d| { | ||
| 1382 | - d.child( | ||
| 1383 | - div() | ||
| 1384 | - .id(("sub-lift", i)) | ||
| 1385 | - .absolute() | ||
| 1386 | - .top_0() | ||
| 1387 | - .left(px(vis_x + vis_w - HIT_MIN - EDGE_W)) | ||
| 1388 | - .w(px(HIT_MIN)) | ||
| 1389 | - .h(px(HIT_MIN)) | ||
| 1390 | - .flex() | ||
| 1391 | - .items_center() | ||
| 1392 | - .justify_center() | ||
| 1393 | - .occlude() | ||
| 1394 | - .rounded(px(3.)) | ||
| 1395 | - .cursor_pointer() | ||
| 1396 | - .hover(|s| s.bg(rgb(BG_HOVER()))) | ||
| 1397 | - .on_click(cx.listener( | ||
| 1398 | - move |this, _: &ClickEvent, _, cx| { | ||
| 1399 | - cx.stop_propagation(); | ||
| 1400 | - this.lift_sub(lane, i, cx); | ||
| 1401 | - }, | ||
| 1402 | - )) | ||
| 1403 | - .child("×"), | ||
| 1404 | - ) | ||
| 1405 | - }) | ||
| 1406 | })) | 1414 | })) |
| 1407 | // ...and where the words actually are inside those boxes: | 1415 | // ...and where the words actually are inside those boxes: |
| 1408 | // the cues this lane shows on *this* timeline, in a band | 1416 | // the cues this lane shows on *this* timeline, in a band |