diff --git a/crates/app/src/main.rs b/crates/app/src/main.rs index e6c458c..52ed74d 100644 --- a/crates/app/src/main.rs +++ b/crates/app/src/main.rs @@ -385,8 +385,11 @@ struct Player { /// over no lane: the shadow every proper editor draws under a drag. Set by /// the lane the pointer is actually over -- that is the one question the /// line above does not answer -- and drawn only while a drag is live, for - /// [`Player::snap_cue`]'s reason. - ghost: Option, + /// [`Player::snap_cue`]'s reason. More than one entry only while a + /// set-drag ([`Player::move_clip`]'s `set_move`) is carrying more than + /// the clip under the hand: every other pick draws its own shadow too, at + /// the same delta the anchor's is landing at ([`Player::preview_ghost`]). + ghost: Vec, /// The slot a track header being dragged is about to drop into, or `None` /// while the pointer is over no lane: the line drawn between two headers, /// for the reason [`Player::ghost`] draws a shadow -- where a gesture lands @@ -942,7 +945,7 @@ fn main() { sub_folded: HashSet::new(), sub_lane: None, snap_cue: None, - ghost: None, + ghost: Vec::new(), lane_drop: None, last_scrub: Instant::now(), last_target: 0, diff --git a/crates/app/src/player/actions.rs b/crates/app/src/player/actions.rs index cc02bb9..6f76115 100644 --- a/crates/app/src/player/actions.rs +++ b/crates/app/src/player/actions.rs @@ -231,7 +231,7 @@ impl Player { pub(crate) fn toggle_snap(&mut self, cx: &mut Context) { self.snap = !self.snap; self.snap_cue = None; - self.ghost = None; + self.ghost.clear(); self.notify_user(match self.snap { true => "SNAP ON — drags land on clip edges, the playhead and the start".into(), false => "SNAP OFF — drags land exactly where the hand leaves them".into(), diff --git a/crates/app/src/player/timeline_edit.rs b/crates/app/src/player/timeline_edit.rs index 7240e16..4a6f715 100644 --- a/crates/app/src/player/timeline_edit.rs +++ b/crates/app/src/player/timeline_edit.rs @@ -489,7 +489,7 @@ impl Player { } self.mark_dirty(); self.snap_cue = None; - self.ghost = None; + self.ghost.clear(); let at = self.place_frame(x).0; // What the mark is on, before the lane is renumbered: a caption's start // frame is its name on its lane ([`sub_mark`]). @@ -577,7 +577,7 @@ impl Player { } self.mark_dirty(); self.snap_cue = None; - self.ghost = None; + self.ghost.clear(); let Some(idx) = self.dragged_sub(drag) else { return; }; @@ -753,7 +753,7 @@ impl Player { tint: CLIP_TEXT(), refused: to.kind != LaneKind::Subtitle, }; - self.set_ghost(Some(ghost), cx); + self.set_ghost(vec![ghost], cx); } /// The same for a palette row on its way down: it lands at the frame it is @@ -773,7 +773,7 @@ impl Player { tint: CLIP_TEXT(), refused: to.kind != LaneKind::Subtitle, }; - self.set_ghost(Some(ghost), cx); + self.set_ghost(vec![ghost], cx); } /// Where a clip let go at window `x` over lane `to` wants its head: the @@ -863,6 +863,15 @@ impl Player { /// are one answer -- and its own length at this zoom. A lane of the other /// kind refuses the drop ([`Project::move_clip`]), and the shadow says so /// before the release does. + /// + /// When the dragged clip is itself one of a multi-pick selection (the same + /// `set_move` test [`Player::move_clip`] commits by), every other pick + /// draws its own shadow too, at the delta the anchor above is landing at -- + /// [`Project::move_selection`]'s own clamp is not reread here, so a wall + /// that would narrow the group's travel is seen only at the release, not + /// in the shadow; the anchor's own room is still exact; corner-cut, ceiling + /// a shadow a member or two too wide on a tight bed, upgrade is exposing + /// `move_room` to preview against. pub(crate) fn preview_ghost( &mut self, drag: &ClipDrag, @@ -870,17 +879,46 @@ impl Player { x: Pixels, cx: &mut Context, ) { - let ghost = self - .dragged(drag) - .and_then(|idx| self.drop_frame(drag.lane, idx, x)) - .map(|(start, _)| Ghost { - lane: to, - start, - frames: drag.clip.frames(), - tint: self.clip_tint(drag.clip.source), - refused: drag.lane.kind != to.kind, - }); - self.set_ghost(ghost, cx); + let Some(idx) = self.dragged(drag) else { + self.set_ghost(Vec::new(), cx); + return; + }; + let Some((start, _)) = self.drop_frame(drag.lane, idx, x) else { + self.set_ghost(Vec::new(), cx); + return; + }; + let anchor = Ghost { + lane: to, + start, + frames: drag.clip.frames(), + tint: self.clip_tint(drag.clip.source), + refused: drag.lane.kind != to.kind, + }; + let mut ghosts = vec![anchor]; + if self.selected.contains((drag.lane, idx)) && self.selected.len() > 1 { + let delta = i64::from(start) - i64::from(drag.clip.start); + for &(lane, i) in self.selected.picks() { + if (lane, i) == (drag.lane, idx) { + continue; + } + let Some(clip) = self + .session + .as_ref() + .and_then(|session| session.lane_clips(lane).get(i).copied()) + else { + continue; + }; + let want = (i64::from(clip.start) + delta).max(0) as u32; + ghosts.push(Ghost { + lane, + start: want, + frames: clip.frames(), + tint: self.clip_tint(clip.source), + refused: anchor.refused, + }); + } + } + self.set_ghost(ghosts, cx); } /// The line the track in the hand would drop into, on the row the pointer @@ -944,7 +982,7 @@ impl Player { tint: file_tint(self.sources(), path).unwrap_or(BG_RAISED()), refused: lane_refuses(path, to).is_some(), }; - self.set_ghost(Some(ghost), cx); + self.set_ghost(vec![ghost], cx); } /// Sets the shadow, or takes it away, repainting only when it moved -- the @@ -952,7 +990,7 @@ impl Player { /// root and set again by the lane under the pointer, in that order (gpui /// runs the capture phase parent-first), so a pointer over no lane at all /// leaves nothing drawn. - pub(crate) fn set_ghost(&mut self, ghost: Option, cx: &mut Context) { + pub(crate) fn set_ghost(&mut self, ghost: Vec, cx: &mut Context) { if ghost != self.ghost { self.ghost = ghost; cx.notify(); diff --git a/crates/app/src/player/transport.rs b/crates/app/src/player/transport.rs index 2926681..ee0d9b8 100644 --- a/crates/app/src/player/transport.rs +++ b/crates/app/src/player/transport.rs @@ -246,7 +246,7 @@ impl Player { // ...and the shadow a drag is drawn under promises a landing on a lane // this edit has just reshaped. The next move of the drag draws it // again; until then it says nothing. - self.ghost = None; + self.ghost.clear(); } /// Jumps the timeline. diff --git a/crates/app/src/render.rs b/crates/app/src/render.rs index 7de0a68..186a913 100644 --- a/crates/app/src/render.rs +++ b/crates/app/src/render.rs @@ -607,12 +607,12 @@ impl Render for Player { // (`lane_row`), which gpui runs straight after this one: the // capture phase goes parent first, so a pointer over no lane at // all -- up in the library, say -- promises nothing. - this.set_ghost(None, cx); + this.set_ghost(Vec::new(), cx); })) .on_drag_move( cx.listener(|this, event: &DragMoveEvent, _, cx| { this.preview_place(event.event.position.x, cx); - this.set_ghost(None, cx); + this.set_ghost(Vec::new(), cx); }), ) // The same pair for the two subtitle gestures, for the same reason: @@ -620,7 +620,7 @@ impl Render for Player { // lane, and both are let go somewhere else entirely. .on_drag_move(cx.listener(|this, event: &DragMoveEvent, _, cx| { this.preview_place(event.event.position.x, cx); - this.set_ghost(None, cx); + this.set_ghost(Vec::new(), cx); })) .on_drag_move(cx.listener(|this, event: &DragMoveEvent, _, cx| { // The placement gpui froze into the payload, whose *length* is @@ -629,7 +629,7 @@ impl Render for Player { let (drag, x) = (*event.drag(cx), event.event.position.x); let cue = this.sub_drop_frame(drag.sub, x).1; this.set_cue(cue, x, cx); - this.set_ghost(None, cx); + this.set_ghost(Vec::new(), cx); })) // Scrubbing is tracked on the root because the pointer leaves the // 6 px ruler on the first drag and its own listeners then stop diff --git a/crates/app/src/ui/bench_stance.rs b/crates/app/src/ui/bench_stance.rs index 9ca54b8..87c8d9b 100644 --- a/crates/app/src/ui/bench_stance.rs +++ b/crates/app/src/ui/bench_stance.rs @@ -1124,6 +1124,8 @@ fn lane_row( .children( player .ghost + .iter() + .copied() .filter(|g| g.lane == lane && cx.has_active_drag()) .map(|g| { div() diff --git a/crates/app/src/ui/timeline.rs b/crates/app/src/ui/timeline.rs index 11c51e5..6470b11 100644 --- a/crates/app/src/ui/timeline.rs +++ b/crates/app/src/ui/timeline.rs @@ -850,11 +850,15 @@ impl Player { .snap_cue .filter(|_| self.trim.is_some() || cx.has_active_drag()) .map(|frame| scale.px_at(f64::from(frame) / self.fps)); - // The shadow, on the one lane the pointer is over -- and, like the line, - // only while the drag that asked for it is still in flight. - let ghost = self + // The shadow (or shadows, on a set-drag -- [`Player::preview_ghost`]), + // on the one lane each names -- and, like the line, only while the + // drag that asked for it is still in flight. + let ghost: Vec = self .ghost - .filter(|g| g.lane == lane && cx.has_active_drag()); + .iter() + .copied() + .filter(|g| g.lane == lane && cx.has_active_drag()) + .collect(); let clips = self .session .as_ref() @@ -1919,7 +1923,7 @@ impl Player { // under a drag. Over the clips (it is translucent, so what // it would cover shows through) and under the line, which // marks the frame this box merely fills. - .children(ghost.map(|g| { + .children(ghost.into_iter().map(|g| { div() .absolute() .top_0()