The bench shows where the clip will land
Browse files at this commit- fix
- the bench shows where the clip will land
1 changed file +88 -1
crates/app/src/ui/bench_stance.rsmodified+88 -1
| @@ -629,6 +629,20 @@ fn lane_row( | |||
| 629 | let at = this.place_frame(window.mouse_position().x).0; | 629 | let at = this.place_frame(window.mouse_position().x).0; |
| 630 | this.insert_source(&drag.0.clone(), drag.1, Some(lane), Some(at), cx) | 630 | this.insert_source(&drag.0.clone(), drag.1, Some(lane), Some(at), cx) |
| 631 | })) | 631 | })) |
| 632 | + // The landing shadow (`Player::preview_ghost_asset`, the same | ||
| 633 | + // setter `ui/timeline.rs`'s own bed calls) -- guarded on the | ||
| 634 | + // pointer actually being inside this bed's own bounds, since | ||
| 635 | + // `on_drag_move` fires on every painted element of the drag's | ||
| 636 | + // type, not just the one under the pointer. | ||
| 637 | + .on_drag_move(cx.listener( | ||
| 638 | + move |this, event: &DragMoveEvent<AssetDrag>, _, cx| { | ||
| 639 | + if !event.bounds.contains(&event.event.position) { | ||
| 640 | + return; | ||
| 641 | + } | ||
| 642 | + let path = event.drag(cx).0.clone(); | ||
| 643 | + this.preview_ghost_asset(&path, lane, event.event.position.x, cx); | ||
| 644 | + }, | ||
| 645 | + )) | ||
| 632 | .drag_over::<ClipDrag>(|d, _, _, _| d.bg(rgb(DARK_RAISED()))) | 646 | .drag_over::<ClipDrag>(|d, _, _, _| d.bg(rgb(DARK_RAISED()))) |
| 633 | .on_drop(cx.listener(move |this, drag: &ClipDrag, window, cx| { | 647 | .on_drop(cx.listener(move |this, drag: &ClipDrag, window, cx| { |
| 634 | let Some(idx) = this.dragged(drag) else { | 648 | let Some(idx) = this.dragged(drag) else { |
| @@ -636,6 +650,15 @@ fn lane_row( | |||
| 636 | }; | 650 | }; |
| 637 | this.move_clip(drag.lane, idx, lane, window.mouse_position().x, cx) | 651 | this.move_clip(drag.lane, idx, lane, window.mouse_position().x, cx) |
| 638 | })) | 652 | })) |
| 653 | + .on_drag_move(cx.listener( | ||
| 654 | + move |this, event: &DragMoveEvent<ClipDrag>, _, cx| { | ||
| 655 | + if !event.bounds.contains(&event.event.position) { | ||
| 656 | + return; | ||
| 657 | + } | ||
| 658 | + let drag = *event.drag(cx); | ||
| 659 | + this.preview_ghost(&drag, lane, event.event.position.x, cx); | ||
| 660 | + }, | ||
| 661 | + )) | ||
| 639 | // A caption already on a lane moves along it, or onto another | 662 | // A caption already on a lane moves along it, or onto another |
| 640 | // subtitle track, exactly as a clip does (`Player::move_sub`, | 663 | // subtitle track, exactly as a clip does (`Player::move_sub`, |
| 641 | // the same call `ui/timeline.rs`'s own bed makes). | 664 | // the same call `ui/timeline.rs`'s own bed makes). |
| @@ -643,6 +666,25 @@ fn lane_row( | |||
| 643 | .on_drop(cx.listener(move |this, drag: &SubDrag, window, cx| { | 666 | .on_drop(cx.listener(move |this, drag: &SubDrag, window, cx| { |
| 644 | this.move_sub(drag, lane, window.mouse_position().x, cx); | 667 | this.move_sub(drag, lane, window.mouse_position().x, cx); |
| 645 | })) | 668 | })) |
| 669 | + .on_drag_move(cx.listener( | ||
| 670 | + move |this, event: &DragMoveEvent<SubDrag>, _, cx| { | ||
| 671 | + if !event.bounds.contains(&event.event.position) { | ||
| 672 | + return; | ||
| 673 | + } | ||
| 674 | + let drag = *event.drag(cx); | ||
| 675 | + this.preview_ghost_sub(&drag, lane, event.event.position.x, cx); | ||
| 676 | + }, | ||
| 677 | + )) | ||
| 678 | + .drag_over::<SubPick>(|d, _, _, _| d.bg(rgb(DARK_RAISED()))) | ||
| 679 | + .on_drag_move(cx.listener( | ||
| 680 | + move |this, event: &DragMoveEvent<SubPick>, _, cx| { | ||
| 681 | + if !event.bounds.contains(&event.event.position) { | ||
| 682 | + return; | ||
| 683 | + } | ||
| 684 | + let track = event.drag(cx).0; | ||
| 685 | + this.preview_ghost_pick(track, lane, event.event.position.x, cx); | ||
| 686 | + }, | ||
| 687 | + )) | ||
| 646 | // The wheel, matched to the legacy timeline's own mapping: | 688 | // The wheel, matched to the legacy timeline's own mapping: |
| 647 | // ctrl+wheel zooms about the pointer, a bare wheel scrolls | 689 | // ctrl+wheel zooms about the pointer, a bare wheel scrolls |
| 648 | // the bed along the film (`Player::timeline_wheel`). Stopped | 690 | // the bed along the film (`Player::timeline_wheel`). Stopped |
| @@ -653,7 +695,52 @@ fn lane_row( | |||
| 653 | this.timeline_wheel(event, cx); | 695 | this.timeline_wheel(event, cx); |
| 654 | })) | 696 | })) |
| 655 | .children(boxes) | 697 | .children(boxes) |
| 656 | - .children(sub_boxes), | 698 | + .children(sub_boxes) |
| 699 | + // The shadow of the row in flight (`Player::ghost`, set by | ||
| 700 | + // the `on_drag_move` handlers above) -- the same box | ||
| 701 | + // `ui/timeline.rs`'s own bed draws, only while a drag of its | ||
| 702 | + // kind is actually live (`App::has_active_drag`: gpui drops a | ||
| 703 | + // drag without telling anyone) and only on the one lane the | ||
| 704 | + // pointer is over. | ||
| 705 | + .children( | ||
| 706 | + player | ||
| 707 | + .ghost | ||
| 708 | + .filter(|g| g.lane == lane && cx.has_active_drag()) | ||
| 709 | + .map(|g| { | ||
| 710 | + div() | ||
| 711 | + .absolute() | ||
| 712 | + .top_0() | ||
| 713 | + .h_full() | ||
| 714 | + .left(px(scale.px_at(f64::from(g.start) / player.fps))) | ||
| 715 | + .w(px(scale | ||
| 716 | + .width_px(f64::from(g.frames) / player.fps) | ||
| 717 | + .max(GHOST_MIN))) | ||
| 718 | + .rounded(px(3.)) | ||
| 719 | + .border_1() | ||
| 720 | + .border_color(rgb(if g.refused { DROP_REFUSE() } else { INK1() })) | ||
| 721 | + .bg(rgba( | ||
| 722 | + ((if g.refused { DROP_REFUSE() } else { g.tint }) << 8) | ||
| 723 | + | GHOST_ALPHA, | ||
| 724 | + )) | ||
| 725 | + }), | ||
| 726 | + ) | ||
| 727 | + // Where it would land, drawn on every lane so a clip lining | ||
| 728 | + // up with a take one track over can be seen to line up with | ||
| 729 | + // it -- the same cue `ui/timeline.rs` draws. | ||
| 730 | + .children( | ||
| 731 | + player | ||
| 732 | + .snap_cue | ||
| 733 | + .filter(|_| player.trim.is_some() || cx.has_active_drag()) | ||
| 734 | + .map(|frame| { | ||
| 735 | + div() | ||
| 736 | + .absolute() | ||
| 737 | + .top_0() | ||
| 738 | + .h_full() | ||
| 739 | + .left(px(scale.px_at(f64::from(frame) / player.fps))) | ||
| 740 | + .w(px(1.)) | ||
| 741 | + .bg(rgb(INK1())) | ||
| 742 | + }), | ||
| 743 | + ), | ||
| 657 | ) | 744 | ) |
| 658 | } | 745 | } |
| 659 | 746 | ||