forge
Explore
Log in

Don't you dare go Hollow

A caption is taken off the lane by the same stroke and row a clip is

Browse files at this commit

888f39d0a7ce97c761f2c6e5c5a652c023b1f77aAhmet Kaan GümüşParent: 3da7bd9
  • feat
    • a caption is taken off the lane by the same stroke and row a clip is
Show full message
✨ feat(timeline): a caption is taken off the lane by the same stroke and row a clip is

A placed caption could only be lifted by a ✕ that vanished on narrow
boxes. Captions are now marked by a click, lifted by x/delete and the
menu, and dragged — parity with every other thing on a lane.

The mark is keyed by a caption's start frame, so a refused drop, a
sorted insert or a removal cannot shift it onto the caption beside it.
With a caption marked the playhead actions stay live while its menu
carries only its own rows: the playhead's clip actions — split, rate,
grade, fit — would read as the caption's.
crates/app/src/oracle.rsmodified+53 -0
@@ -51,6 +51,12 @@ pub(crate) struct Ctx {
5151 /// and the clip-relative answers stand aside: those actions find their own
5252 /// clip under the playhead and word their own refusal.
5353 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,
5460 /// The clip plays a still ([`engine::is_image`]), which has no sound to
5561 /// reach at all -- not the lane's business, because a still sits on a video
5662 /// lane exactly like a take whose sound is one lane down.
@@ -127,6 +133,36 @@ pub(crate) fn enable(action: ActionId, ctx: Ctx) -> Enable {
127133 _ => Enable::No("an export is running"),
128134 };
129135 }
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+ }
130166 match action {
131167 // -- class: what kind of thing the action is about. The equalizer
132168 // 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 {
224260 /// a waveform, an equalizer on a picture -- is not a row at all, so a future
225261 /// action cannot appear where it does not apply by being added to
226262 /// [`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.
227273 pub(crate) fn menu_items(ctx: Ctx) -> Vec<ActionId> {
228274 MENU_ITEMS
229275 .into_iter()
230276 .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+ })
231284 .collect()
232285 }
233286
crates/app/src/player/actions.rsmodified+6 -1
@@ -213,11 +213,16 @@ impl Player {
213213 let Some(session) = &self.session else {
214214 return Ctx::default();
215215 };
216+ let on = on.or(self.selected);
216217 let clip = on
217- .or(self.selected)
218218 .and_then(|(lane, idx)| session.lane_clips(lane).get(idx).map(|clip| (*clip, lane)));
219219 Ctx {
220220 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+ }),
221226 image: clip.is_some_and(|(clip, _)| {
222227 session
223228 .sources()
crates/app/src/player/timeline_edit.rsmodified+75 -11
@@ -121,6 +121,14 @@ impl Player {
121121 return;
122122 }
123123 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+ }
124132 // Whichever lane it was clicked in: the index is that lane's own, and
125133 // the ripple cuts the clip's span out of every lane -- a group covers
126134 // one span, so deleting a take by its audio half is the same edit as by
@@ -296,6 +304,12 @@ impl Player {
296304 self.snap_cue = None;
297305 self.ghost = None;
298306 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));
299313 let text = match (self.sub_of_track(track), &mut self.session) {
300314 (Some(sub), Some(session)) => match session.place_sub(to, at, sub) {
301315 Ok(()) => None,
@@ -309,8 +323,21 @@ impl Player {
309323 ),
310324 (_, None) => Some("NOT PLACED — open a file first".to_string()),
311325 };
312- if let Some(text) = text {
313- self.notify_user(text.into());
326+ match (text, marked) {
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) => {}
314341 }
315342 cx.notify();
316343 }
@@ -338,20 +365,46 @@ impl Player {
338365 return;
339366 };
340367 let start = self.sub_drop_frame(drag.sub, x).0;
341- if let Some(Err(e)) = self
368+ match self
342369 .session
343370 .as_mut()
344371 .map(|session| session.move_sub(drag.lane, idx, to, start))
345372 {
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 => {}
347395 }
348396 cx.notify();
349397 }
350398
351- /// The × on a caption's own box: it comes off the lane and leaves the gap,
352- /// one undo step ([`PlaybackSession::lift_sub`]). The palette row it played
353- /// stays in the list, which is what makes this a lift and not a removal --
354- /// and the way a subtitle lane is emptied so it can be taken off at all.
399+ /// A caption off its lane, leaving the gap, one undo step
400+ /// ([`PlaybackSession::lift_sub`]). The palette row it played stays in the
401+ /// list, which is what makes this a lift and not a removal -- and the way a
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.
355408 pub(crate) fn lift_sub(&mut self, lane: Lane, idx: usize, cx: &mut Context<Self>) {
356409 if self.exporting().is_some() {
357410 return;
@@ -367,6 +420,16 @@ impl Player {
367420 ),
368421 false => "NOTHING LIFTED — that caption is not there any more".to_string(),
369422 };
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+ }
370433 self.notify_user(text.into());
371434 cx.notify();
372435 }
@@ -817,9 +880,10 @@ impl Player {
817880 // A caption's edge, on a lane that holds no `Clip` at all: the same
818881 // gesture, the same `Trim`, and the branch is the lane's kind wherever
819882 // the drag is asked about ([`Player::trim_to`],
820- // [`Player::commit_trim`]). No selection -- a placement is not in the
821- // clip selection's index space -- and no group: a caption has no half
822- // on another lane.
883+ // [`Player::commit_trim`]). A caption *is* markable -- the mark is its
884+ // lane and its index like a clip's ([`Player::select`]) -- but an edge
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.
823887 if lane.kind == LaneKind::Subtitle {
824888 let Some(sub) = self
825889 .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() {
263263 /// the playhead rather than on the clicked clip are the ones that can be
264264 /// inapplicable, and a menu at the edge of the window has to come back
265265 /// 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+
266464 #[test]
267465 fn the_clip_menu_dims_what_the_playhead_is_not_on_and_stays_in_the_window() {
268466 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) ->
201201 }
202202 }
203203
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+
204218 /// The part of a clip's box that is on the bed, in the box's own pixels:
205219 /// `(left, width)` of its intersection with the visible strip. Everything drawn
206220 /// *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 {
103103 image,
104104 ))
105105 });
106- let head = match &picked {
107- Some((lane, _, name, _)) => format!("{} · {}", lane.label(), name),
108- None => "Nothing selected".to_string(),
106+ // A subtitle lane holds no `Clip`, so the read above answers `None` on a
107+ // marked caption -- while the bed draws that caption in the selection's
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(),
109118 };
110119 let detail = match &picked {
111120 Some((_, clip, _, _)) => format!(
@@ -115,7 +124,17 @@ impl Player {
115124 span_label(f64::from(clip.frames()) / self.fps),
116125 clip.speed,
117126 ),
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+ },
119138 };
120139 div()
121140 .flex()
@@ -128,7 +147,7 @@ impl Player {
128147 div()
129148 .flex_none()
130149 .truncate()
131- .text_color(rgb(match picked.is_some() {
150+ .text_color(rgb(match picked.is_some() || caption.is_some() {
132151 true => FG_PRIMARY(),
133152 false => FG_SECONDARY(),
134153 }))
@@ -139,6 +158,11 @@ impl Player {
139158 .border_color(rgb(clip_kind(lane.kind, *image)))
140159 .pl(px(6.))
141160 })
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+ })
142166 .child(head),
143167 )
144168 .child(
crates/app/src/ui/overlays.rsmodified+18 -7
@@ -470,8 +470,13 @@ impl Player {
470470 ) -> Option<impl IntoElement> {
471471 let menu = self.context_menu?;
472472 let session = self.session.as_ref()?;
473- let clip = *session.lane_clips(menu.lane).get(menu.idx)?;
474- let source = session.sources().get(clip.source).cloned()?;
473+ // Both `None` when the menu was opened on a caption: a subtitle lane
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());
475480 let secs = |frames: u32| timecode(f64::from(frames) / self.fps, self.fps);
476481 let row = |n: usize| {
477482 div()
@@ -487,7 +492,7 @@ impl Player {
487492 .rounded(px(3.))
488493 };
489494 let mut rows: Vec<AnyElement> = Vec::new();
490- if menu.details {
495+ if let (true, Some((clip, source))) = (menu.details, clip.zip(source.clone())) {
491496 // Read-only, so no ids and no hover: this side is a card, not a
492497 // list of things to click. Each value is one truncated line, which
493498 // is what keeps the height below the one the clamp was given.
@@ -596,7 +601,10 @@ impl Player {
596601 .into_any_element(),
597602 );
598603 }
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(|_| {
600608 row(rows.len())
601609 .cursor_pointer()
602610 .hover(|s| s.bg(rgb(BG_HOVER())))
@@ -610,15 +618,18 @@ impl Player {
610618 // No stroke reaches this one, and a blank column would read
611619 // as one that was forgotten.
612620 .child(div().text_color(rgb(FG_SECONDARY())).child("…"))
613- .into_any_element(),
614- );
621+ .into_any_element()
622+ }));
615623 }
616624 // The height the card is *placed* by and the height its list is drawn
617625 // to are one number: placed by a taller one, the card would hang off the
618626 // window's floor -- the very thing the clamp is for.
619627 let list_h = menu_rows_h(rows.len(), viewport);
620628 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();
622633 Some(
623634 scrim()
624635 // Click away closes it, either button, and the press is
crates/app/src/ui/timeline.rsmodified+58 -50
@@ -664,8 +664,8 @@ impl Player {
664664 // What a caption's box says clicking it does; the media boxes' tooltip
665665 // names edits a placement has none of (no group, no speed, no ripple).
666666 let sub_tip: SharedString =
667- "Drag it along the lane or onto another subtitle track, an end to trim it, × takes it \
668- off"
667+ "Drag it along the lane or onto another subtitle track, an end to trim it, x or the \
668+ right button takes it off"
669669 .into();
670670 // What this track plays at, on the header it belongs to: shown only
671671 // when it is not unity, because a column 40 px wide has room for a
@@ -1248,8 +1248,10 @@ impl Player {
12481248 }))
12491249 // The same bed's other kind of box: a stretch of a palette
12501250 // track placed on this lane, dragged along it, dragged onto
1251- // another subtitle lane, trimmed at either end and lifted
1252- // off by its own ×. Empty on every lane that is not a
1251+ // another subtitle lane, trimmed at either end, marked by 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
12531255 // subtitle one, which is why there is one row and not two.
12541256 .children(subs.iter().enumerate().map(|(i, placed)| {
12551257 // What the drag payload names, and what an edge drag is
@@ -1274,6 +1276,10 @@ impl Player {
12741276 label.clone().unwrap_or_else(|| lane.label()).into();
12751277 let tip = sub_tip.clone();
12761278 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));
12771283 div()
12781284 .id((row_id.clone(), i))
12791285 .absolute()
@@ -1284,11 +1290,18 @@ impl Player {
12841290 .overflow_hidden()
12851291 .rounded(px(3.))
12861292 .border_1()
1287- .border_color(rgb(FG_SECONDARY()))
1293+ .border_color(rgb(if on {
1294+ STROKE_SELECTED()
1295+ } else {
1296+ FG_SECONDARY()
1297+ }))
12881298 // The captions' own colour, dimmed on a lane whose
12891299 // eye is shut: what is not being drawn over the
1290- // picture is still on the lane, and says so.
1291- .bg(rgb(CLIP_TEXT()))
1300+ // picture is still on the lane, and says so. Marked,
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() }))
12921305 .when(!shown, |d| d.opacity(0.55))
12931306 .cursor_pointer()
12941307 .hover(|s| s.border_color(rgb(ACCENT_PRIMARY())))
@@ -1309,7 +1322,22 @@ impl Player {
13091322 // than jumping its head under it.
13101323 this.grab =
13111324 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);
13131341 }),
13141342 )
13151343 // The two strips a drag lengthens it by, on the same
@@ -1340,7 +1368,20 @@ impl Player {
13401368 cx.stop_propagation();
13411369 this.timeline_wheel(event, cx);
13421370 },
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+ );
13441385 zone = match edge {
13451386 Edge::Start => zone.left_0(),
13461387 Edge::End => zone.right_0(),
@@ -1362,47 +1403,14 @@ impl Player {
13621403 .child(label),
13631404 )
13641405 })
1365- // The way back off the lane, on the box itself: a
1366- // caption is not in the clip selection's index
1367- // space, so no stroke reaches it -- and a lane
1368- // holding one cannot be removed either
1369- // ([`Project::remove_lane`] refuses it), which
1370- // would leave a placement nobody could undo but by
1371- // undoing. Only where the box is wide enough to
1372- // hold a target beside its name; narrower than that
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+ // The way back off the lane is the way every other
1407+ // box takes: the Delete stroke on the marked caption
1408+ // and the Delete row of its own menu
1409+ // ([`Player::lift_sub`]). The × that used to sit
1410+ // here is gone with them -- it was drawn only where
1411+ // the box was wide enough to hold it, so the one
1412+ // removal a caption had was the one a zoomed-out
1413+ // caption did not have.
14061414 }))
14071415 // ...and where the words actually are inside those boxes:
14081416 // the cues this lane shows on *this* timeline, in a band