From 1c0246b8f3521d8c338f2a6edb690bc66368837a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Thu, 20 Aug 2026 23:50:19 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(ui):=20the=20bench=20shows=20t?= =?UTF-8?q?he=20shadow=20before=20the=20clip=20lands?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The darkroom bench's lane bed wired on_drag_move for AssetDrag, ClipDrag, SubDrag and SubPick to the existing preview_ghost* setters (Player::preview_ghost_asset/preview_ghost/preview_ghost_sub/ preview_ghost_pick), and paints the ghost box + snap-cue line as absolute children of the bed -- the same reused state and math the legacy ui/timeline.rs bed already draws with, filtered to the lane the pointer is over and only while a drag is live. --- crates/app/src/ui/bench_stance.rs | 89 ++++++++++++++++++++++++++++++- 1 file changed, 88 insertions(+), 1 deletion(-) diff --git a/crates/app/src/ui/bench_stance.rs b/crates/app/src/ui/bench_stance.rs index ce21947..0adc56d 100644 --- a/crates/app/src/ui/bench_stance.rs +++ b/crates/app/src/ui/bench_stance.rs @@ -629,6 +629,20 @@ fn lane_row( let at = this.place_frame(window.mouse_position().x).0; this.insert_source(&drag.0.clone(), drag.1, Some(lane), Some(at), cx) })) + // The landing shadow (`Player::preview_ghost_asset`, the same + // setter `ui/timeline.rs`'s own bed calls) -- guarded on the + // pointer actually being inside this bed's own bounds, since + // `on_drag_move` fires on every painted element of the drag's + // type, not just the one under the pointer. + .on_drag_move(cx.listener( + move |this, event: &DragMoveEvent, _, cx| { + if !event.bounds.contains(&event.event.position) { + return; + } + let path = event.drag(cx).0.clone(); + this.preview_ghost_asset(&path, lane, event.event.position.x, cx); + }, + )) .drag_over::(|d, _, _, _| d.bg(rgb(DARK_RAISED()))) .on_drop(cx.listener(move |this, drag: &ClipDrag, window, cx| { let Some(idx) = this.dragged(drag) else { @@ -636,6 +650,15 @@ fn lane_row( }; this.move_clip(drag.lane, idx, lane, window.mouse_position().x, cx) })) + .on_drag_move(cx.listener( + move |this, event: &DragMoveEvent, _, cx| { + if !event.bounds.contains(&event.event.position) { + return; + } + let drag = *event.drag(cx); + this.preview_ghost(&drag, lane, event.event.position.x, cx); + }, + )) // A caption already on a lane moves along it, or onto another // subtitle track, exactly as a clip does (`Player::move_sub`, // the same call `ui/timeline.rs`'s own bed makes). @@ -643,6 +666,25 @@ fn lane_row( .on_drop(cx.listener(move |this, drag: &SubDrag, window, cx| { this.move_sub(drag, lane, window.mouse_position().x, cx); })) + .on_drag_move(cx.listener( + move |this, event: &DragMoveEvent, _, cx| { + if !event.bounds.contains(&event.event.position) { + return; + } + let drag = *event.drag(cx); + this.preview_ghost_sub(&drag, lane, event.event.position.x, cx); + }, + )) + .drag_over::(|d, _, _, _| d.bg(rgb(DARK_RAISED()))) + .on_drag_move(cx.listener( + move |this, event: &DragMoveEvent, _, cx| { + if !event.bounds.contains(&event.event.position) { + return; + } + let track = event.drag(cx).0; + this.preview_ghost_pick(track, lane, event.event.position.x, cx); + }, + )) // The wheel, matched to the legacy timeline's own mapping: // ctrl+wheel zooms about the pointer, a bare wheel scrolls // the bed along the film (`Player::timeline_wheel`). Stopped @@ -653,7 +695,52 @@ fn lane_row( this.timeline_wheel(event, cx); })) .children(boxes) - .children(sub_boxes), + .children(sub_boxes) + // The shadow of the row in flight (`Player::ghost`, set by + // the `on_drag_move` handlers above) -- the same box + // `ui/timeline.rs`'s own bed draws, only while a drag of its + // kind is actually live (`App::has_active_drag`: gpui drops a + // drag without telling anyone) and only on the one lane the + // pointer is over. + .children( + player + .ghost + .filter(|g| g.lane == lane && cx.has_active_drag()) + .map(|g| { + div() + .absolute() + .top_0() + .h_full() + .left(px(scale.px_at(f64::from(g.start) / player.fps))) + .w(px(scale + .width_px(f64::from(g.frames) / player.fps) + .max(GHOST_MIN))) + .rounded(px(3.)) + .border_1() + .border_color(rgb(if g.refused { DROP_REFUSE() } else { INK1() })) + .bg(rgba( + ((if g.refused { DROP_REFUSE() } else { g.tint }) << 8) + | GHOST_ALPHA, + )) + }), + ) + // Where it would land, drawn on every lane so a clip lining + // up with a take one track over can be seen to line up with + // it -- the same cue `ui/timeline.rs` draws. + .children( + player + .snap_cue + .filter(|_| player.trim.is_some() || cx.has_active_drag()) + .map(|frame| { + div() + .absolute() + .top_0() + .h_full() + .left(px(scale.px_at(f64::from(frame) / player.fps))) + .w(px(1.)) + .bg(rgb(INK1())) + }), + ), ) }