Render every pick's ghost during a set-drag
Browse files at this commit1dc3c45002efc5ce4630b921f2e4beaac7723448Parent: 33ae7d9- feat
- render every pick's ghost during a set-drag
7 changed files +78 -31
- crates/app/src/main.rs +6 -3
- crates/app/src/player/actions.rs +1 -1
- crates/app/src/player/timeline_edit.rs +55 -17
- crates/app/src/player/transport.rs +1 -1
- crates/app/src/render.rs +4 -4
- crates/app/src/ui/bench_stance.rs +2 -0
- crates/app/src/ui/timeline.rs +9 -5
crates/app/src/main.rsmodified+6 -3
| @@ -385,8 +385,11 @@ struct Player { | |||
| 385 | /// over no lane: the shadow every proper editor draws under a drag. Set by | 385 | /// over no lane: the shadow every proper editor draws under a drag. Set by |
| 386 | /// the lane the pointer is actually over -- that is the one question the | 386 | /// the lane the pointer is actually over -- that is the one question the |
| 387 | /// line above does not answer -- and drawn only while a drag is live, for | 387 | /// line above does not answer -- and drawn only while a drag is live, for |
| 388 | - /// [`Player::snap_cue`]'s reason. | 388 | + /// [`Player::snap_cue`]'s reason. More than one entry only while a |
| 389 | - ghost: Option<Ghost>, | 389 | + /// set-drag ([`Player::move_clip`]'s `set_move`) is carrying more than |
| 390 | + /// the clip under the hand: every other pick draws its own shadow too, at | ||
| 391 | + /// the same delta the anchor's is landing at ([`Player::preview_ghost`]). | ||
| 392 | + ghost: Vec<Ghost>, | ||
| 390 | /// The slot a track header being dragged is about to drop into, or `None` | 393 | /// The slot a track header being dragged is about to drop into, or `None` |
| 391 | /// while the pointer is over no lane: the line drawn between two headers, | 394 | /// while the pointer is over no lane: the line drawn between two headers, |
| 392 | /// for the reason [`Player::ghost`] draws a shadow -- where a gesture lands | 395 | /// for the reason [`Player::ghost`] draws a shadow -- where a gesture lands |
| @@ -942,7 +945,7 @@ fn main() { | |||
| 942 | sub_folded: HashSet::new(), | 945 | sub_folded: HashSet::new(), |
| 943 | sub_lane: None, | 946 | sub_lane: None, |
| 944 | snap_cue: None, | 947 | snap_cue: None, |
| 945 | - ghost: None, | 948 | + ghost: Vec::new(), |
| 946 | lane_drop: None, | 949 | lane_drop: None, |
| 947 | last_scrub: Instant::now(), | 950 | last_scrub: Instant::now(), |
| 948 | last_target: 0, | 951 | last_target: 0, |
crates/app/src/player/actions.rsmodified+1 -1
| @@ -231,7 +231,7 @@ impl Player { | |||
| 231 | pub(crate) fn toggle_snap(&mut self, cx: &mut Context<Self>) { | 231 | pub(crate) fn toggle_snap(&mut self, cx: &mut Context<Self>) { |
| 232 | self.snap = !self.snap; | 232 | self.snap = !self.snap; |
| 233 | self.snap_cue = None; | 233 | self.snap_cue = None; |
| 234 | - self.ghost = None; | 234 | + self.ghost.clear(); |
| 235 | self.notify_user(match self.snap { | 235 | self.notify_user(match self.snap { |
| 236 | true => "SNAP ON — drags land on clip edges, the playhead and the start".into(), | 236 | true => "SNAP ON — drags land on clip edges, the playhead and the start".into(), |
| 237 | false => "SNAP OFF — drags land exactly where the hand leaves them".into(), | 237 | false => "SNAP OFF — drags land exactly where the hand leaves them".into(), |
crates/app/src/player/timeline_edit.rsmodified+55 -17
| @@ -489,7 +489,7 @@ impl Player { | |||
| 489 | } | 489 | } |
| 490 | self.mark_dirty(); | 490 | self.mark_dirty(); |
| 491 | self.snap_cue = None; | 491 | self.snap_cue = None; |
| 492 | - self.ghost = None; | 492 | + self.ghost.clear(); |
| 493 | let at = self.place_frame(x).0; | 493 | let at = self.place_frame(x).0; |
| 494 | // What the mark is on, before the lane is renumbered: a caption's start | 494 | // What the mark is on, before the lane is renumbered: a caption's start |
| 495 | // frame is its name on its lane ([`sub_mark`]). | 495 | // frame is its name on its lane ([`sub_mark`]). |
| @@ -577,7 +577,7 @@ impl Player { | |||
| 577 | } | 577 | } |
| 578 | self.mark_dirty(); | 578 | self.mark_dirty(); |
| 579 | self.snap_cue = None; | 579 | self.snap_cue = None; |
| 580 | - self.ghost = None; | 580 | + self.ghost.clear(); |
| 581 | let Some(idx) = self.dragged_sub(drag) else { | 581 | let Some(idx) = self.dragged_sub(drag) else { |
| 582 | return; | 582 | return; |
| 583 | }; | 583 | }; |
| @@ -753,7 +753,7 @@ impl Player { | |||
| 753 | tint: CLIP_TEXT(), | 753 | tint: CLIP_TEXT(), |
| 754 | refused: to.kind != LaneKind::Subtitle, | 754 | refused: to.kind != LaneKind::Subtitle, |
| 755 | }; | 755 | }; |
| 756 | - self.set_ghost(Some(ghost), cx); | 756 | + self.set_ghost(vec![ghost], cx); |
| 757 | } | 757 | } |
| 758 | 758 | ||
| 759 | /// The same for a palette row on its way down: it lands at the frame it is | 759 | /// The same for a palette row on its way down: it lands at the frame it is |
| @@ -773,7 +773,7 @@ impl Player { | |||
| 773 | tint: CLIP_TEXT(), | 773 | tint: CLIP_TEXT(), |
| 774 | refused: to.kind != LaneKind::Subtitle, | 774 | refused: to.kind != LaneKind::Subtitle, |
| 775 | }; | 775 | }; |
| 776 | - self.set_ghost(Some(ghost), cx); | 776 | + self.set_ghost(vec![ghost], cx); |
| 777 | } | 777 | } |
| 778 | 778 | ||
| 779 | /// Where a clip let go at window `x` over lane `to` wants its head: the | 779 | /// Where a clip let go at window `x` over lane `to` wants its head: the |
| @@ -863,6 +863,15 @@ impl Player { | |||
| 863 | /// are one answer -- and its own length at this zoom. A lane of the other | 863 | /// are one answer -- and its own length at this zoom. A lane of the other |
| 864 | /// kind refuses the drop ([`Project::move_clip`]), and the shadow says so | 864 | /// kind refuses the drop ([`Project::move_clip`]), and the shadow says so |
| 865 | /// before the release does. | 865 | /// before the release does. |
| 866 | + /// | ||
| 867 | + /// When the dragged clip is itself one of a multi-pick selection (the same | ||
| 868 | + /// `set_move` test [`Player::move_clip`] commits by), every other pick | ||
| 869 | + /// draws its own shadow too, at the delta the anchor above is landing at -- | ||
| 870 | + /// [`Project::move_selection`]'s own clamp is not reread here, so a wall | ||
| 871 | + /// that would narrow the group's travel is seen only at the release, not | ||
| 872 | + /// in the shadow; the anchor's own room is still exact; corner-cut, ceiling | ||
| 873 | + /// a shadow a member or two too wide on a tight bed, upgrade is exposing | ||
| 874 | + /// `move_room` to preview against. | ||
| 866 | pub(crate) fn preview_ghost( | 875 | pub(crate) fn preview_ghost( |
| 867 | &mut self, | 876 | &mut self, |
| 868 | drag: &ClipDrag, | 877 | drag: &ClipDrag, |
| @@ -870,17 +879,46 @@ impl Player { | |||
| 870 | x: Pixels, | 879 | x: Pixels, |
| 871 | cx: &mut Context<Self>, | 880 | cx: &mut Context<Self>, |
| 872 | ) { | 881 | ) { |
| 873 | - let ghost = self | 882 | + let Some(idx) = self.dragged(drag) else { |
| 874 | - .dragged(drag) | 883 | + self.set_ghost(Vec::new(), cx); |
| 875 | - .and_then(|idx| self.drop_frame(drag.lane, idx, x)) | 884 | + return; |
| 876 | - .map(|(start, _)| Ghost { | 885 | + }; |
| 877 | - lane: to, | 886 | + let Some((start, _)) = self.drop_frame(drag.lane, idx, x) else { |
| 878 | - start, | 887 | + self.set_ghost(Vec::new(), cx); |
| 879 | - frames: drag.clip.frames(), | 888 | + return; |
| 880 | - tint: self.clip_tint(drag.clip.source), | 889 | + }; |
| 881 | - refused: drag.lane.kind != to.kind, | 890 | + let anchor = Ghost { |
| 882 | - }); | 891 | + lane: to, |
| 883 | - self.set_ghost(ghost, cx); | 892 | + start, |
| 893 | + frames: drag.clip.frames(), | ||
| 894 | + tint: self.clip_tint(drag.clip.source), | ||
| 895 | + refused: drag.lane.kind != to.kind, | ||
| 896 | + }; | ||
| 897 | + let mut ghosts = vec![anchor]; | ||
| 898 | + if self.selected.contains((drag.lane, idx)) && self.selected.len() > 1 { | ||
| 899 | + let delta = i64::from(start) - i64::from(drag.clip.start); | ||
| 900 | + for &(lane, i) in self.selected.picks() { | ||
| 901 | + if (lane, i) == (drag.lane, idx) { | ||
| 902 | + continue; | ||
| 903 | + } | ||
| 904 | + let Some(clip) = self | ||
| 905 | + .session | ||
| 906 | + .as_ref() | ||
| 907 | + .and_then(|session| session.lane_clips(lane).get(i).copied()) | ||
| 908 | + else { | ||
| 909 | + continue; | ||
| 910 | + }; | ||
| 911 | + let want = (i64::from(clip.start) + delta).max(0) as u32; | ||
| 912 | + ghosts.push(Ghost { | ||
| 913 | + lane, | ||
| 914 | + start: want, | ||
| 915 | + frames: clip.frames(), | ||
| 916 | + tint: self.clip_tint(clip.source), | ||
| 917 | + refused: anchor.refused, | ||
| 918 | + }); | ||
| 919 | + } | ||
| 920 | + } | ||
| 921 | + self.set_ghost(ghosts, cx); | ||
| 884 | } | 922 | } |
| 885 | 923 | ||
| 886 | /// The line the track in the hand would drop into, on the row the pointer | 924 | /// The line the track in the hand would drop into, on the row the pointer |
| @@ -944,7 +982,7 @@ impl Player { | |||
| 944 | tint: file_tint(self.sources(), path).unwrap_or(BG_RAISED()), | 982 | tint: file_tint(self.sources(), path).unwrap_or(BG_RAISED()), |
| 945 | refused: lane_refuses(path, to).is_some(), | 983 | refused: lane_refuses(path, to).is_some(), |
| 946 | }; | 984 | }; |
| 947 | - self.set_ghost(Some(ghost), cx); | 985 | + self.set_ghost(vec![ghost], cx); |
| 948 | } | 986 | } |
| 949 | 987 | ||
| 950 | /// Sets the shadow, or takes it away, repainting only when it moved -- the | 988 | /// Sets the shadow, or takes it away, repainting only when it moved -- the |
| @@ -952,7 +990,7 @@ impl Player { | |||
| 952 | /// root and set again by the lane under the pointer, in that order (gpui | 990 | /// root and set again by the lane under the pointer, in that order (gpui |
| 953 | /// runs the capture phase parent-first), so a pointer over no lane at all | 991 | /// runs the capture phase parent-first), so a pointer over no lane at all |
| 954 | /// leaves nothing drawn. | 992 | /// leaves nothing drawn. |
| 955 | - pub(crate) fn set_ghost(&mut self, ghost: Option<Ghost>, cx: &mut Context<Self>) { | 993 | + pub(crate) fn set_ghost(&mut self, ghost: Vec<Ghost>, cx: &mut Context<Self>) { |
| 956 | if ghost != self.ghost { | 994 | if ghost != self.ghost { |
| 957 | self.ghost = ghost; | 995 | self.ghost = ghost; |
| 958 | cx.notify(); | 996 | cx.notify(); |
crates/app/src/player/transport.rsmodified+1 -1
| @@ -246,7 +246,7 @@ impl Player { | |||
| 246 | // ...and the shadow a drag is drawn under promises a landing on a lane | 246 | // ...and the shadow a drag is drawn under promises a landing on a lane |
| 247 | // this edit has just reshaped. The next move of the drag draws it | 247 | // this edit has just reshaped. The next move of the drag draws it |
| 248 | // again; until then it says nothing. | 248 | // again; until then it says nothing. |
| 249 | - self.ghost = None; | 249 | + self.ghost.clear(); |
| 250 | } | 250 | } |
| 251 | 251 | ||
| 252 | /// Jumps the timeline. | 252 | /// Jumps the timeline. |
crates/app/src/render.rsmodified+4 -4
| @@ -607,12 +607,12 @@ impl Render for Player { | |||
| 607 | // (`lane_row`), which gpui runs straight after this one: the | 607 | // (`lane_row`), which gpui runs straight after this one: the |
| 608 | // capture phase goes parent first, so a pointer over no lane at | 608 | // capture phase goes parent first, so a pointer over no lane at |
| 609 | // all -- up in the library, say -- promises nothing. | 609 | // all -- up in the library, say -- promises nothing. |
| 610 | - this.set_ghost(None, cx); | 610 | + this.set_ghost(Vec::new(), cx); |
| 611 | })) | 611 | })) |
| 612 | .on_drag_move( | 612 | .on_drag_move( |
| 613 | cx.listener(|this, event: &DragMoveEvent<AssetDrag>, _, cx| { | 613 | cx.listener(|this, event: &DragMoveEvent<AssetDrag>, _, cx| { |
| 614 | this.preview_place(event.event.position.x, cx); | 614 | this.preview_place(event.event.position.x, cx); |
| 615 | - this.set_ghost(None, cx); | 615 | + this.set_ghost(Vec::new(), cx); |
| 616 | }), | 616 | }), |
| 617 | ) | 617 | ) |
| 618 | // The same pair for the two subtitle gestures, for the same reason: | 618 | // The same pair for the two subtitle gestures, for the same reason: |
| @@ -620,7 +620,7 @@ impl Render for Player { | |||
| 620 | // lane, and both are let go somewhere else entirely. | 620 | // lane, and both are let go somewhere else entirely. |
| 621 | .on_drag_move(cx.listener(|this, event: &DragMoveEvent<SubPick>, _, cx| { | 621 | .on_drag_move(cx.listener(|this, event: &DragMoveEvent<SubPick>, _, cx| { |
| 622 | this.preview_place(event.event.position.x, cx); | 622 | this.preview_place(event.event.position.x, cx); |
| 623 | - this.set_ghost(None, cx); | 623 | + this.set_ghost(Vec::new(), cx); |
| 624 | })) | 624 | })) |
| 625 | .on_drag_move(cx.listener(|this, event: &DragMoveEvent<SubDrag>, _, cx| { | 625 | .on_drag_move(cx.listener(|this, event: &DragMoveEvent<SubDrag>, _, cx| { |
| 626 | // The placement gpui froze into the payload, whose *length* is | 626 | // The placement gpui froze into the payload, whose *length* is |
| @@ -629,7 +629,7 @@ impl Render for Player { | |||
| 629 | let (drag, x) = (*event.drag(cx), event.event.position.x); | 629 | let (drag, x) = (*event.drag(cx), event.event.position.x); |
| 630 | let cue = this.sub_drop_frame(drag.sub, x).1; | 630 | let cue = this.sub_drop_frame(drag.sub, x).1; |
| 631 | this.set_cue(cue, x, cx); | 631 | this.set_cue(cue, x, cx); |
| 632 | - this.set_ghost(None, cx); | 632 | + this.set_ghost(Vec::new(), cx); |
| 633 | })) | 633 | })) |
| 634 | // Scrubbing is tracked on the root because the pointer leaves the | 634 | // Scrubbing is tracked on the root because the pointer leaves the |
| 635 | // 6 px ruler on the first drag and its own listeners then stop | 635 | // 6 px ruler on the first drag and its own listeners then stop |
crates/app/src/ui/bench_stance.rsmodified+2 -0
| @@ -1124,6 +1124,8 @@ fn lane_row( | |||
| 1124 | .children( | 1124 | .children( |
| 1125 | player | 1125 | player |
| 1126 | .ghost | 1126 | .ghost |
| 1127 | + .iter() | ||
| 1128 | + .copied() | ||
| 1127 | .filter(|g| g.lane == lane && cx.has_active_drag()) | 1129 | .filter(|g| g.lane == lane && cx.has_active_drag()) |
| 1128 | .map(|g| { | 1130 | .map(|g| { |
| 1129 | div() | 1131 | div() |
crates/app/src/ui/timeline.rsmodified+9 -5
| @@ -850,11 +850,15 @@ impl Player { | |||
| 850 | .snap_cue | 850 | .snap_cue |
| 851 | .filter(|_| self.trim.is_some() || cx.has_active_drag()) | 851 | .filter(|_| self.trim.is_some() || cx.has_active_drag()) |
| 852 | .map(|frame| scale.px_at(f64::from(frame) / self.fps)); | 852 | .map(|frame| scale.px_at(f64::from(frame) / self.fps)); |
| 853 | - // The shadow, on the one lane the pointer is over -- and, like the line, | 853 | + // The shadow (or shadows, on a set-drag -- [`Player::preview_ghost`]), |
| 854 | - // only while the drag that asked for it is still in flight. | 854 | + // on the one lane each names -- and, like the line, only while the |
| 855 | - let ghost = self | 855 | + // drag that asked for it is still in flight. |
| 856 | + let ghost: Vec<Ghost> = self | ||
| 856 | .ghost | 857 | .ghost |
| 857 | - .filter(|g| g.lane == lane && cx.has_active_drag()); | 858 | + .iter() |
| 859 | + .copied() | ||
| 860 | + .filter(|g| g.lane == lane && cx.has_active_drag()) | ||
| 861 | + .collect(); | ||
| 858 | let clips = self | 862 | let clips = self |
| 859 | .session | 863 | .session |
| 860 | .as_ref() | 864 | .as_ref() |
| @@ -1919,7 +1923,7 @@ impl Player { | |||
| 1919 | // under a drag. Over the clips (it is translucent, so what | 1923 | // under a drag. Over the clips (it is translucent, so what |
| 1920 | // it would cover shows through) and under the line, which | 1924 | // it would cover shows through) and under the line, which |
| 1921 | // marks the frame this box merely fills. | 1925 | // marks the frame this box merely fills. |
| 1922 | - .children(ghost.map(|g| { | 1926 | + .children(ghost.into_iter().map(|g| { |
| 1923 | div() | 1927 | div() |
| 1924 | .absolute() | 1928 | .absolute() |
| 1925 | .top_0() | 1929 | .top_0() |