A cross-lane shadow clamps where the engine clamps, and the strip says MOVED
Browse files at this commit15b0c7f071f64c9ff2cab7ffc7ca19440db81497Parent: bbc437b- fix
- a cross-lane shadow clamps where the engine clamps, and the strip says MOVED
6 changed files +168 -42
- crates/app/src/player/timeline_edit.rs +20 -8
- crates/app/src/tests/editing.rs +4 -1
- crates/app/src/tests/layout.rs +1 -1
- crates/app/src/timeline_math.rs +40 -24
- crates/app/src/ui/bench_stance.rs +75 -4
- crates/app/src/ui/dock_stance.rs +28 -4
crates/app/src/player/timeline_edit.rsmodified+20 -8
| @@ -399,6 +399,10 @@ impl Player { | |||
| 399 | self.selected.clear(); | 399 | self.selected.clear(); |
| 400 | } | 400 | } |
| 401 | self.reset_after_reseek(); | 401 | self.reset_after_reseek(); |
| 402 | + // The strip names the edit that just happened: a move that | ||
| 403 | + // lands silently leaves the last word (`SPLIT`) standing, and | ||
| 404 | + // an editor reads that as the drag having done nothing. | ||
| 405 | + self.notify_user("MOVED".into()); | ||
| 402 | } | 406 | } |
| 403 | // The three ways a drag is refused, told apart by what the | 407 | // The three ways a drag is refused, told apart by what the |
| 404 | // front-end already knows: a lane's kind, and where the clip was. | 408 | // front-end already knows: a lane's kind, and where the clip was. |
| @@ -431,6 +435,9 @@ impl Player { | |||
| 431 | .into(), | 435 | .into(), |
| 432 | ), | 436 | ), |
| 433 | } | 437 | } |
| 438 | + // The gesture is over: the lane it ended over is nobody's answer any | ||
| 439 | + // more (`Player::drag_lane`, read by `bench-content`'s catch-all). | ||
| 440 | + self.drag_lane = None; | ||
| 434 | cx.notify(); | 441 | cx.notify(); |
| 435 | } | 442 | } |
| 436 | 443 | ||
| @@ -802,7 +809,7 @@ impl Player { | |||
| 802 | /// Where a clip let go at window `x` over lane `to` wants its head: the | 809 | /// Where a clip let go at window `x` over lane `to` wants its head: the |
| 803 | /// frame under the pointer, less however far into the box the hand grabbed | 810 | /// frame under the pointer, less however far into the box the hand grabbed |
| 804 | /// it (so the clip does not jump under the pointer), pulled onto a | 811 | /// it (so the clip does not jump under the pointer), pulled onto a |
| 805 | - /// neighbouring edge when it lands within [`SNAP_PX`] of one. `None` when | 812 | + /// neighbouring edge when it lands within [`Player::drop_snap_frames`] of one. `None` when |
| 806 | /// there is no such clip to move. The engine has the last word on where it | 813 | /// there is no such clip to move. The engine has the last word on where it |
| 807 | /// may actually go -- this is the ask, not the answer. | 814 | /// may actually go -- this is the ask, not the answer. |
| 808 | /// | 815 | /// |
| @@ -912,13 +919,17 @@ impl Player { | |||
| 912 | // Staying on its own lane, the engine clamps the travel into the gap | 919 | // Staying on its own lane, the engine clamps the travel into the gap |
| 913 | // the clip sits in rather than refusing it, so the shadow rests where | 920 | // the clip sits in rather than refusing it, so the shadow rests where |
| 914 | // the release will: flush against the take it was dragged into. Landing | 921 | // the release will: flush against the take it was dragged into. Landing |
| 915 | - // on *another* lane it is refused outright when a take is already | 922 | + // on *another* lane it clamps too ([`cross_room`], the engine's own |
| 916 | - // there, and the shadow says so before the hand lets go -- never a | 923 | + // `move_room` rule) and refuses only a head let go *inside* a take or a |
| 917 | - // silent no-op. | 924 | + // gap too narrow to hold the clip -- the shadow says so before the hand |
| 925 | + // lets go, and never claims a refusal the release would not make. | ||
| 918 | let len = drag.clip.frames(); | 926 | let len = drag.clip.frames(); |
| 919 | let (start, refused) = match to == drag.lane { | 927 | let (start, refused) = match to == drag.lane { |
| 920 | true => (gap_clamp(drag.clip.start, len, start, &neighbours), false), | 928 | true => (gap_clamp(drag.clip.start, len, start, &neighbours), false), |
| 921 | - false => (start, collides(start, len, &neighbours)), | 929 | + false => match cross_room(start, len, &neighbours) { |
| 930 | + Some(landed) => (landed, false), | ||
| 931 | + None => (start, true), | ||
| 932 | + }, | ||
| 922 | }; | 933 | }; |
| 923 | let anchor = Ghost { | 934 | let anchor = Ghost { |
| 924 | lane: to, | 935 | lane: to, |
| @@ -1178,9 +1189,6 @@ impl Player { | |||
| 1178 | } | 1189 | } |
| 1179 | } | 1190 | } |
| 1180 | 1191 | ||
| 1181 | - /// [`SNAP_PX`] in timeline frames at the scale the bed is drawn at: the bed's | ||
| 1182 | - /// own width drops out of it, since a pixel is now worth the same stretch of | ||
| 1183 | - /// timeline wherever the view sits. | ||
| 1184 | /// Whether the magnet is on for the gesture happening *now*: the switch | 1192 | /// Whether the magnet is on for the gesture happening *now*: the switch |
| 1185 | /// ([`Player::snap`]) unless `alt` is held ([`Player::drag_alt`]), which | 1193 | /// ([`Player::snap`]) unless `alt` is held ([`Player::drag_alt`]), which |
| 1186 | /// turns it off for this drag or trim alone -- the temporary override | 1194 | /// turns it off for this drag or trim alone -- the temporary override |
| @@ -1192,6 +1200,10 @@ impl Player { | |||
| 1192 | snap_live(self.snap, self.drag_alt) | 1200 | snap_live(self.snap, self.drag_alt) |
| 1193 | } | 1201 | } |
| 1194 | 1202 | ||
| 1203 | + /// [`SNAP_PX`] in timeline frames at the scale the bed is drawn at: the | ||
| 1204 | + /// bed's own width drops out of it, since a pixel is now worth the same | ||
| 1205 | + /// stretch of timeline wherever the view sits. The edge trims' magnet -- | ||
| 1206 | + /// a drop asks [`Player::drop_snap_frames`]. | ||
| 1195 | pub(crate) fn snap_frames(&self) -> u32 { | 1207 | pub(crate) fn snap_frames(&self) -> u32 { |
| 1196 | self.scale.snap_frames(self.fps) | 1208 | self.scale.snap_frames(self.fps) |
| 1197 | } | 1209 | } |
crates/app/src/tests/editing.rsmodified+4 -1
| @@ -1672,7 +1672,10 @@ fn a_row_dropped_on_the_open_bed_lands_under_the_pointer() { | |||
| 1672 | let clips = [session.lane_clips(Lane::V1), session.lane_clips(Lane::A1)]; | 1672 | let clips = [session.lane_clips(Lane::V1), session.lane_clips(Lane::A1)]; |
| 1673 | let marks = snap_marks(&clips, None, None, frame_at(session.now(), fps), None); | 1673 | let marks = snap_marks(&clips, None, None, frame_at(session.now(), fps), None); |
| 1674 | let under = frame_at(scale.time_at(px_along(px(212.), bed)), fps); | 1674 | let under = frame_at(scale.time_at(px_along(px(212.), bed)), fps); |
| 1675 | - let (at, cue) = landing(under, 0, 0, true, scale.snap_frames(fps), &marks); | 1675 | + // The drop's own magnet, not the trims' finer one -- `Player::place_frame` |
| 1676 | + // ships `drop_snap_frames`, and a test computing with `snap_frames` stops | ||
| 1677 | + // mirroring production the moment the two differ. | ||
| 1678 | + let (at, cue) = landing(under, 0, 0, true, scale.drop_snap_frames(fps), &marks); | ||
| 1676 | assert_eq!((at, cue), (300, None), "the pointer is on frame 300"); | 1679 | assert_eq!((at, cue), (300, None), "the pointer is on frame 300"); |
| 1677 | 1680 | ||
| 1678 | // ...and what the release does with it: the frame back through the same | 1681 | // ...and what the release does with it: the frame back through the same |
crates/app/src/tests/layout.rsmodified+1 -1
| @@ -3072,7 +3072,7 @@ fn the_bench_seam_stops_at_its_floor_and_its_ceiling() { | |||
| 3072 | /// DESIGN §7: "lanes scroll behind the pinned ruler and track heads" -- pinned | 3072 | /// DESIGN §7: "lanes scroll behind the pinned ruler and track heads" -- pinned |
| 3073 | /// means pinned. A clip that starts left of the view sits at a negative `left` | 3073 | /// means pinned. A clip that starts left of the view sits at a negative `left` |
| 3074 | /// inside its bed, and with no clip mask gpui paints it (and its hitbox) over | 3074 | /// inside its bed, and with no clip mask gpui paints it (and its hitbox) over |
| 3075 | -/// the 72 px head column, so V1/A1 and their verbs disappear under the first | 3075 | +/// the `HEAD_W` px head column, so V1/A1 and their verbs disappear under the first |
| 3076 | /// take as soon as the bench is wheeled past frame 0. The mask belongs on the | 3076 | /// take as soon as the bench is wheeled past frame 0. The mask belongs on the |
| 3077 | /// bed itself so a half-scrolled clip still drags on the half that shows. | 3077 | /// bed itself so a half-scrolled clip still drags on the half that shows. |
| 3078 | #[test] | 3078 | #[test] |
crates/app/src/timeline_math.rsmodified+40 -24
| @@ -661,20 +661,33 @@ pub(crate) fn landing( | |||
| 661 | snap_cue(on, under.saturating_sub(grab), len, tol, marks) | 661 | snap_cue(on, under.saturating_sub(grab), len, tol, marks) |
| 662 | } | 662 | } |
| 663 | 663 | ||
| 664 | -/// Whether a clip `len` frames long landing at `start` would sit on top of one | 664 | +/// Where a clip `len` frames long, let go over *another* lane with its head |
| 665 | -/// of `others` -- `(start, end)` of every clip already on the lane it is being | 665 | +/// asked at `at`, really comes to rest -- `None` when the engine refuses the |
| 666 | -/// let go over, less the ones travelling with it. The engine refuses such a | 666 | +/// drop outright. A mirror of [`Project::move_room`]: the release is refused |
| 667 | -/// drop ([`Project::move_selection`]'s `move_room`), so the shadow is drawn as | 667 | +/// only when the asked head sits *inside* a take already there (a clamp has no |
| 668 | -/// refused rather than promising a landing the release will not make: a drag | 668 | +/// answer for that), or when the gap it names is narrower than the clip; |
| 669 | -/// that ends in nothing at all is what an editor reads as a broken timeline. | 669 | +/// otherwise the head is clamped into that gap exactly as a same-lane move is |
| 670 | +/// ([`gap_clamp`]). `others` is `(start, end)` of every clip already on the | ||
| 671 | +/// destination lane, less the ones travelling with this one. | ||
| 670 | /// | 672 | /// |
| 671 | -/// Touching is not overlapping -- a clip laid exactly against the take in front | 673 | +/// The shadow reads this, so a landing the release *will* make is never drawn |
| 672 | -/// of it is the whole point of the magnet. | 674 | +/// as refused -- a whole-span overlap test refuses far more than the engine |
| 673 | -pub(crate) fn collides(start: u32, len: u32, others: &[(u32, u32)]) -> bool { | 675 | +/// does, and a shadow that lies about a refusal reads as a broken timeline. |
| 674 | - let end = start.saturating_add(len); | 676 | +pub(crate) fn cross_room(at: u32, len: u32, others: &[(u32, u32)]) -> Option<u32> { |
| 675 | - others | 677 | + let (mut lo, mut hi) = (0, u32::MAX); |
| 676 | - .iter() | 678 | + for &(other_start, other_end) in others { |
| 677 | - .any(|&(other_start, other_end)| start < other_end && other_start < end) | 679 | + if other_start <= at && at < other_end { |
| 680 | + return None; | ||
| 681 | + } | ||
| 682 | + match other_end <= at { | ||
| 683 | + true => lo = lo.max(other_end), | ||
| 684 | + false => hi = hi.min(other_start), | ||
| 685 | + } | ||
| 686 | + } | ||
| 687 | + match hi - lo < len { | ||
| 688 | + true => None, | ||
| 689 | + false => Some(at.clamp(lo, hi - len)), | ||
| 690 | + } | ||
| 678 | } | 691 | } |
| 679 | 692 | ||
| 680 | /// Where a clip staying on its own lane really comes to rest: `want`, clamped | 693 | /// Where a clip staying on its own lane really comes to rest: `want`, clamped |
| @@ -929,17 +942,20 @@ mod drop_landing_tests { | |||
| 929 | assert_eq!(gap_clamp(500, 100, 9_000, &[]), 9_000); | 942 | assert_eq!(gap_clamp(500, 100, 9_000, &[]), 9_000); |
| 930 | } | 943 | } |
| 931 | 944 | ||
| 932 | - /// The refused state the shadow draws: a head let go on top of a take | 945 | + /// The cross-lane shadow's rule, mirroring the engine: refused only when |
| 933 | - /// already on the lane, which the engine changes nothing for. Laid exactly | 946 | + /// the asked head is inside a take or the gap is too narrow, and otherwise |
| 934 | - /// against one -- what the magnet is for -- is not a collision. | 947 | + /// clamped into the gap rather than refused. The middle case is the |
| 948 | + /// verifier's repro -- an obstacle at (360, 420), a 90-frame clip asked at | ||
| 949 | + /// 315, which the engine lands at 270. | ||
| 935 | #[test] | 950 | #[test] |
| 936 | - fn a_landing_on_top_of_a_take_previews_as_refused() { | 951 | + fn a_cross_lane_landing_clamps_into_the_gap_the_engine_leaves() { |
| 937 | - let others = [(100, 200), (400, 500)]; | 952 | + let others = [(360, 420)]; |
| 938 | - assert!(collides(150, 50, &others), "inside the first take"); | 953 | + assert_eq!(cross_room(315, 90, &others), Some(270), "clamped, not refused"); |
| 939 | - assert!(collides(90, 50, &others), "its head laps the first take"); | 954 | + assert_eq!(cross_room(380, 90, &others), None, "head inside the take"); |
| 940 | - assert!(collides(50, 400, &others), "long enough to swallow both"); | 955 | + assert_eq!(cross_room(100, 90, &others), Some(100), "room to spare"); |
| 941 | - assert!(!collides(50, 50, &others), "tail meets the head exactly"); | 956 | + let tight = [(0, 100), (150, 300)]; |
| 942 | - assert!(!collides(200, 200, &others), "the gap holds it exactly"); | 957 | + assert_eq!(cross_room(120, 90, &tight), None, "the gap is 50 frames wide"); |
| 943 | - assert!(!collides(500, 10, &others), "past the last take"); | 958 | + assert_eq!(cross_room(120, 50, &tight), Some(100), "and holds a 50-frame clip"); |
| 959 | + assert_eq!(cross_room(500, 90, &[]), Some(500), "an empty lane takes it as asked"); | ||
| 944 | } | 960 | } |
| 945 | } | 961 | } |
crates/app/src/ui/bench_stance.rsmodified+75 -4
| @@ -328,7 +328,19 @@ fn clip_box( | |||
| 328 | }, | 328 | }, |
| 329 | { | 329 | { |
| 330 | let ghost = ghost.clone(); | 330 | let ghost = ghost.clone(); |
| 331 | - move |_, _, _, cx| cx.new(|_| Tip(ghost.clone())) | 331 | + let me = cx.entity(); |
| 332 | + move |_, _, _, cx| { | ||
| 333 | + // A fresh gesture inherits nothing: `Player::drag_lane` | ||
| 334 | + // and `Player::drag_x` are the *last live sample* of the | ||
| 335 | + // drag being made, and a drag whose first sample lands | ||
| 336 | + // outside every row would otherwise be let go onto the | ||
| 337 | + // lane the previous one ended over. | ||
| 338 | + me.update(cx, |this, _| { | ||
| 339 | + this.drag_lane = None; | ||
| 340 | + this.drag_x = None; | ||
| 341 | + }); | ||
| 342 | + cx.new(|_| Tip(ghost.clone())) | ||
| 343 | + } | ||
| 332 | }, | 344 | }, |
| 333 | ) | 345 | ) |
| 334 | .tooltip(crate::ui::widgets::tip_hover("Clip", "drag to move", None)) | 346 | .tooltip(crate::ui::widgets::tip_hover("Clip", "drag to move", None)) |
| @@ -717,7 +729,19 @@ fn sub_box( | |||
| 717 | }, | 729 | }, |
| 718 | { | 730 | { |
| 719 | let ghost = ghost.clone(); | 731 | let ghost = ghost.clone(); |
| 720 | - move |_, _, _, cx| cx.new(|_| Tip(ghost.clone())) | 732 | + let me = cx.entity(); |
| 733 | + move |_, _, _, cx| { | ||
| 734 | + // A fresh gesture inherits nothing: `Player::drag_lane` | ||
| 735 | + // and `Player::drag_x` are the *last live sample* of the | ||
| 736 | + // drag being made, and a drag whose first sample lands | ||
| 737 | + // outside every row would otherwise be let go onto the | ||
| 738 | + // lane the previous one ended over. | ||
| 739 | + me.update(cx, |this, _| { | ||
| 740 | + this.drag_lane = None; | ||
| 741 | + this.drag_x = None; | ||
| 742 | + }); | ||
| 743 | + cx.new(|_| Tip(ghost.clone())) | ||
| 744 | + } | ||
| 721 | }, | 745 | }, |
| 722 | ) | 746 | ) |
| 723 | .tooltip(crate::ui::widgets::tip_hover("Subtitle", "drag to move", None)) | 747 | .tooltip(crate::ui::widgets::tip_hover("Subtitle", "drag to move", None)) |
| @@ -892,7 +916,7 @@ fn lane_row( | |||
| 892 | // pointer actually being inside this *row's* bounds, since | 916 | // pointer actually being inside this *row's* bounds, since |
| 893 | // `on_drag_move` fires on every painted element of the drag's | 917 | // `on_drag_move` fires on every painted element of the drag's |
| 894 | // type, not just the one under the pointer. The row and not the | 918 | // type, not just the one under the pointer. The row and not the |
| 895 | - // bed: the head column is 72px of this lane too, and a clip | 919 | + // bed: the head column is `HEAD_W` px of this lane too, and a clip |
| 896 | // dragged out over it is aiming at frame 0 -- the drop it used to | 920 | // dragged out over it is aiming at frame 0 -- the drop it used to |
| 897 | // fall through (nothing under the pointer answered `ClipDrag`) is | 921 | // fall through (nothing under the pointer answered `ClipDrag`) is |
| 898 | // the "I have to be pixel perfect to snap to 0" complaint. | 922 | // the "I have to be pixel perfect to snap to 0" complaint. |
| @@ -905,6 +929,11 @@ fn lane_row( | |||
| 905 | } | 929 | } |
| 906 | let path = event.drag(cx).0.clone(); | 930 | let path = event.drag(cx).0.clone(); |
| 907 | this.drag_x = Some(event.event.position.x); | 931 | this.drag_x = Some(event.event.position.x); |
| 932 | + // The row the catch-all release below aims at. A file's own | ||
| 933 | + // kind is not known until the engine has placed it, so the | ||
| 934 | + // last row hovered is the answer and `Player::insert_source` | ||
| 935 | + // words the refusal if it cannot hold this file. | ||
| 936 | + this.drag_lane = Some(lane); | ||
| 908 | this.drag_alt = event.event.modifiers.alt; | 937 | this.drag_alt = event.event.modifiers.alt; |
| 909 | this.preview_ghost_asset(&path, lane, event.event.position.x, cx); | 938 | this.preview_ghost_asset(&path, lane, event.event.position.x, cx); |
| 910 | }), | 939 | }), |
| @@ -956,6 +985,7 @@ fn lane_row( | |||
| 956 | } | 985 | } |
| 957 | let drag = *event.drag(cx); | 986 | let drag = *event.drag(cx); |
| 958 | this.drag_x = Some(event.event.position.x); | 987 | this.drag_x = Some(event.event.position.x); |
| 988 | + this.drag_lane = held_lane(this.drag_lane, lane, drag.lane); | ||
| 959 | this.drag_alt = event.event.modifiers.alt; | 989 | this.drag_alt = event.event.modifiers.alt; |
| 960 | this.preview_ghost_sub(&drag, lane, event.event.position.x, cx); | 990 | this.preview_ghost_sub(&drag, lane, event.event.position.x, cx); |
| 961 | }), | 991 | }), |
| @@ -976,6 +1006,7 @@ fn lane_row( | |||
| 976 | } | 1006 | } |
| 977 | let track = event.drag(cx).0; | 1007 | let track = event.drag(cx).0; |
| 978 | this.drag_x = Some(event.event.position.x); | 1008 | this.drag_x = Some(event.event.position.x); |
| 1009 | + this.drag_lane = Some(lane); | ||
| 979 | this.drag_alt = event.event.modifiers.alt; | 1010 | this.drag_alt = event.event.modifiers.alt; |
| 980 | this.preview_ghost_pick(track, lane, event.event.position.x, cx); | 1011 | this.preview_ghost_pick(track, lane, event.event.position.x, cx); |
| 981 | }), | 1012 | }), |
| @@ -1096,7 +1127,7 @@ fn lane_row( | |||
| 1096 | // DESIGN §7: the lanes scroll BEHIND the pinned heads. A | 1127 | // DESIGN §7: the lanes scroll BEHIND the pinned heads. A |
| 1097 | // clip whose start is left of the view sits at a negative | 1128 | // clip whose start is left of the view sits at a negative |
| 1098 | // `left`, and without a clip mask gpui paints it -- and its | 1129 | // `left`, and without a clip mask gpui paints it -- and its |
| 1099 | - // hitbox -- straight over the 72px head column, so V1/A1 and | 1130 | + // hitbox -- straight over the `HEAD_W` px head column, so V1/A1 and |
| 1100 | // their verbs vanish under it. The mask cuts painting and | 1131 | // their verbs vanish under it. The mask cuts painting and |
| 1101 | // hit-testing at the bed's own edges together, so the visible | 1132 | // hit-testing at the bed's own edges together, so the visible |
| 1102 | // half of a half-scrolled clip still drags and trims and the | 1133 | // half of a half-scrolled clip still drags and trims and the |
| @@ -1321,6 +1352,46 @@ pub(crate) fn render( | |||
| 1321 | this.drag_alt = window.modifiers().alt; | 1352 | this.drag_alt = window.modifiers().alt; |
| 1322 | this.move_clip(drag.lane, idx, lane, x, cx); | 1353 | this.move_clip(drag.lane, idx, lane, x, cx); |
| 1323 | })) | 1354 | })) |
| 1355 | + // The same catch-all for the other three things a hand can be holding | ||
| 1356 | + // over the bench -- a library row, a caption already down, a palette | ||
| 1357 | + // row. Each lands on the lane its last live sample was over, through | ||
| 1358 | + // the very door that row's own release uses, so the engine words the | ||
| 1359 | + // refusal when that lane cannot hold it. Without these, letting one go | ||
| 1360 | + // off the rows reached nothing at all. | ||
| 1361 | + .on_drop(cx.listener(move |this, drag: &AssetDrag, window, cx| { | ||
| 1362 | + let Some(lane) = this.drag_lane else { | ||
| 1363 | + return; | ||
| 1364 | + }; | ||
| 1365 | + let x = this | ||
| 1366 | + .drag_x | ||
| 1367 | + .take() | ||
| 1368 | + .unwrap_or_else(|| window.mouse_position().x); | ||
| 1369 | + this.drag_alt = window.modifiers().alt; | ||
| 1370 | + let at = this.place_frame(x).0; | ||
| 1371 | + this.insert_source(&drag.0.clone(), drag.1, Some(lane), Some(at), cx); | ||
| 1372 | + })) | ||
| 1373 | + .on_drop(cx.listener(move |this, drag: &SubDrag, window, cx| { | ||
| 1374 | + let Some(lane) = this.drag_lane else { | ||
| 1375 | + return; | ||
| 1376 | + }; | ||
| 1377 | + let x = this | ||
| 1378 | + .drag_x | ||
| 1379 | + .take() | ||
| 1380 | + .unwrap_or_else(|| window.mouse_position().x); | ||
| 1381 | + this.drag_alt = window.modifiers().alt; | ||
| 1382 | + this.move_sub(drag, lane, x, cx); | ||
| 1383 | + })) | ||
| 1384 | + .on_drop(cx.listener(move |this, drag: &SubPick, window, cx| { | ||
| 1385 | + let Some(lane) = this.drag_lane else { | ||
| 1386 | + return; | ||
| 1387 | + }; | ||
| 1388 | + let x = this | ||
| 1389 | + .drag_x | ||
| 1390 | + .take() | ||
| 1391 | + .unwrap_or_else(|| window.mouse_position().x); | ||
| 1392 | + this.drag_alt = window.modifiers().alt; | ||
| 1393 | + this.place_sub(drag.0, lane, x, cx); | ||
| 1394 | + })) | ||
| 1324 | .child( | 1395 | .child( |
| 1325 | // Pinned ruler: click/drag to seek (reuses `Player::scrub_to`, | 1396 | // Pinned ruler: click/drag to seek (reuses `Player::scrub_to`, |
| 1326 | // the same call the legacy ruler makes), tick marks with mono | 1397 | // the same call the legacy ruler makes), tick marks with mono |
crates/app/src/ui/dock_stance.rsmodified+28 -4
| @@ -376,8 +376,20 @@ fn source_row( | |||
| 376 | // drag media in timeline") was the dock showing the *legacy* | 376 | // drag media in timeline") was the dock showing the *legacy* |
| 377 | // panel, which the darkroom bench was never wired against; | 377 | // panel, which the darkroom bench was never wired against; |
| 378 | // this row is the darkroom's own half of that pairing. | 378 | // this row is the darkroom's own half of that pairing. |
| 379 | - .on_drag(AssetDrag(dragged.0, dragged.1), move |_, _, _, cx| { | 379 | + .on_drag(AssetDrag(dragged.0, dragged.1), { |
| 380 | - cx.new(|_| Tip(ghost.clone())) | 380 | + let me = cx.entity(); |
| 381 | + move |_, _, _, cx| { | ||
| 382 | + // A fresh gesture inherits nothing: `Player::drag_lane` | ||
| 383 | + // and `Player::drag_x` are the *last live sample* of the | ||
| 384 | + // drag being made, and a drag whose first sample lands | ||
| 385 | + // outside every row would otherwise be let go onto the | ||
| 386 | + // lane the previous one ended over. | ||
| 387 | + me.update(cx, |this, _| { | ||
| 388 | + this.drag_lane = None; | ||
| 389 | + this.drag_x = None; | ||
| 390 | + }); | ||
| 391 | + cx.new(|_| Tip(ghost.clone())) | ||
| 392 | + } | ||
| 381 | }) | 393 | }) |
| 382 | }) | 394 | }) |
| 383 | .tooltip(crate::ui::widgets::tip_hover("Source", "drag to a lane", None)) | 395 | .tooltip(crate::ui::widgets::tip_hover("Source", "drag to a lane", None)) |
| @@ -675,8 +687,20 @@ fn subtitle_tab_rows( | |||
| 675 | .when(usable, |d| { | 687 | .when(usable, |d| { |
| 676 | d.cursor_pointer() | 688 | d.cursor_pointer() |
| 677 | .hover(|s| s.bg(rgb(DARK_RAISED()))) | 689 | .hover(|s| s.bg(rgb(DARK_RAISED()))) |
| 678 | - .on_drag(SubPick(track), move |_, _, _, cx| { | 690 | + .on_drag(SubPick(track), { |
| 679 | - cx.new(|_| Tip(ghost.clone())) | 691 | + let me = cx.entity(); |
| 692 | + move |_, _, _, cx| { | ||
| 693 | + // A fresh gesture inherits nothing: `Player::drag_lane` | ||
| 694 | + // and `Player::drag_x` are the *last live sample* of the | ||
| 695 | + // drag being made, and a drag whose first sample lands | ||
| 696 | + // outside every row would otherwise be let go onto the | ||
| 697 | + // lane the previous one ended over. | ||
| 698 | + me.update(cx, |this, _| { | ||
| 699 | + this.drag_lane = None; | ||
| 700 | + this.drag_x = None; | ||
| 701 | + }); | ||
| 702 | + cx.new(|_| Tip(ghost.clone())) | ||
| 703 | + } | ||
| 680 | }) | 704 | }) |
| 681 | .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { | 705 | .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { |
| 682 | this.sub_track = track; | 706 | this.sub_track = track; |