The bench answers a wheel notch anywhere over it
Browse files at this commit6ca49065d53f4b454d09465fa2fa825b10d2eb24Parent: 7fbbd0f- fix
- the bench answers a wheel notch anywhere over it
2 changed files +65 -16
crates/app/src/tests/layout.rsmodified+45 -0
| @@ -2649,3 +2649,48 @@ fn hitmap_names_every_darkroom_pointer_entry_surface() { | |||
| 2649 | } | 2649 | } |
| 2650 | } | 2650 | } |
| 2651 | } | 2651 | } |
| 2652 | + | ||
| 2653 | +/// The wheel is the bench's, not a clip's: the user rolled it over the bench | ||
| 2654 | +/// and nothing moved unless the pointer happened to sit on a track, because | ||
| 2655 | +/// the only listeners were one per bed and one on the ruler strip. The row's | ||
| 2656 | +/// listener now sits on the whole row (head column included) and stops there, | ||
| 2657 | +/// and `bench-content` answers everything else -- the strip left of the ruler, | ||
| 2658 | +/// the ruler itself, the gaps between rows, the space below the last track. | ||
| 2659 | +/// Exactly two listeners, so no strip answers one notch twice. | ||
| 2660 | +#[test] | ||
| 2661 | +fn the_bench_answers_a_wheel_notch_anywhere_over_it() { | ||
| 2662 | + let bench = src_text("ui/bench_stance.rs"); | ||
| 2663 | + assert_eq!( | ||
| 2664 | + bench.matches(".on_scroll_wheel(").count(), | ||
| 2665 | + 2, | ||
| 2666 | + "the bench has a wheel listener per region again -- a notch would be answered twice" | ||
| 2667 | + ); | ||
| 2668 | + let row = bench | ||
| 2669 | + .find(".id((\"bench-lane\", lane.ord") | ||
| 2670 | + .expect("no lane row"); | ||
| 2671 | + let bed = bench.find(".id((\"bench-bed\"").expect("no lane bed"); | ||
| 2672 | + let row_wheel = bench[row..bed] | ||
| 2673 | + .find(".on_scroll_wheel(") | ||
| 2674 | + .map(|at| &bench[row + at..bed]) | ||
| 2675 | + .expect("the lane row does not answer the wheel -- only its bed does"); | ||
| 2676 | + assert!( | ||
| 2677 | + row_wheel[..200].contains("cx.stop_propagation();") | ||
| 2678 | + && row_wheel[..200].contains("this.timeline_wheel(event, cx)"), | ||
| 2679 | + "the row's wheel lost the mapping or its stop: {}", | ||
| 2680 | + &row_wheel[..200] | ||
| 2681 | + ); | ||
| 2682 | + let content = bench.find(".id(\"bench-content\")").expect("no bench content"); | ||
| 2683 | + let content_wheel = bench[content..] | ||
| 2684 | + .find(".on_scroll_wheel(") | ||
| 2685 | + .expect("the bench container does not answer the wheel"); | ||
| 2686 | + assert!( | ||
| 2687 | + content_wheel < 700 && bench[content..].contains("this.timeline_wheel(event, cx)"), | ||
| 2688 | + "the container's wheel listener is not on the container itself" | ||
| 2689 | + ); | ||
| 2690 | + let ruler = bench.find(".id(\"bench-ruler\")").expect("no ruler"); | ||
| 2691 | + let lanes = bench.find(".id(\"bench-lanes\")").expect("no lane column"); | ||
| 2692 | + assert!( | ||
| 2693 | + !bench[ruler..lanes].contains(".on_scroll_wheel("), | ||
| 2694 | + "the ruler answers the wheel on its own again -- one notch, two scrolls" | ||
| 2695 | + ); | ||
| 2696 | +} | ||
crates/app/src/ui/bench_stance.rsmodified+20 -16
| @@ -829,6 +829,17 @@ fn lane_row( | |||
| 829 | .h(px(h)) | 829 | .h(px(h)) |
| 830 | .flex() | 830 | .flex() |
| 831 | .relative() | 831 | .relative() |
| 832 | + // The wheel, matched to the legacy timeline's own mapping: ctrl+wheel | ||
| 833 | + // zooms about the pointer, a bare wheel scrolls the bed along the film | ||
| 834 | + // (`Player::timeline_wheel`). On the whole row -- head column and bed | ||
| 835 | + // alike -- not on the bed alone: a hand rolls the wheel wherever it | ||
| 836 | + // left the pointer, and aiming at a clip first is a tax. Stopped here | ||
| 837 | + // so gpui's own overflow scroll on the lane column (`bench-lanes`) and | ||
| 838 | + // `bench-content`'s catch-all below never answer the same notch again. | ||
| 839 | + .on_scroll_wheel(cx.listener(|this, event: &ScrollWheelEvent, _, cx| { | ||
| 840 | + cx.stop_propagation(); | ||
| 841 | + this.timeline_wheel(event, cx); | ||
| 842 | + })) | ||
| 832 | // Dragged, the whole track moves in the stack (`LaneDrag`, | 843 | // Dragged, the whole track moves in the stack (`LaneDrag`, |
| 833 | // `Player::reorder_lane`) -- let go anywhere along the row, not just | 844 | // `Player::reorder_lane`) -- let go anywhere along the row, not just |
| 834 | // over the head column, since a slot is what is being aimed at. | 845 | // over the head column, since a slot is what is being aimed at. |
| @@ -1148,15 +1159,6 @@ fn lane_row( | |||
| 1148 | this.preview_ghost_pick(track, lane, event.event.position.x, cx); | 1159 | this.preview_ghost_pick(track, lane, event.event.position.x, cx); |
| 1149 | }), | 1160 | }), |
| 1150 | ) | 1161 | ) |
| 1151 | - // The wheel, matched to the legacy timeline's own mapping: | ||
| 1152 | - // ctrl+wheel zooms about the pointer, a bare wheel scrolls | ||
| 1153 | - // the bed along the film (`Player::timeline_wheel`). Stopped | ||
| 1154 | - // here so gpui's own overflow scroll on the lane column | ||
| 1155 | - // (`bench-lanes`) never answers the same notch a second time. | ||
| 1156 | - .on_scroll_wheel(cx.listener(|this, event: &ScrollWheelEvent, _, cx| { | ||
| 1157 | - cx.stop_propagation(); | ||
| 1158 | - this.timeline_wheel(event, cx); | ||
| 1159 | - })) | ||
| 1160 | .children(hitmap::dynamic( | 1162 | .children(hitmap::dynamic( |
| 1161 | move || { | 1163 | move || { |
| 1162 | ( | 1164 | ( |
| @@ -1290,6 +1292,15 @@ pub(crate) fn render( | |||
| 1290 | .flex() | 1292 | .flex() |
| 1291 | .flex_col() | 1293 | .flex_col() |
| 1292 | .gap(px(ROW_GAP)) | 1294 | .gap(px(ROW_GAP)) |
| 1295 | + // The wheel over the WHOLE bench region, not just a bed: the ruler, | ||
| 1296 | + // the strip left of it, the gaps between rows and the space below the | ||
| 1297 | + // last track all answer a notch here with the same mapping every row | ||
| 1298 | + // gives (`Player::timeline_wheel`; the ruler's own former listener | ||
| 1299 | + // folded into this one, so no strip answers a notch twice). A row | ||
| 1300 | + // stops propagation, so a notch over a track never reaches this. | ||
| 1301 | + .on_scroll_wheel(cx.listener(|this, event: &ScrollWheelEvent, _, cx| { | ||
| 1302 | + this.timeline_wheel(event, cx); | ||
| 1303 | + })) | ||
| 1293 | .child( | 1304 | .child( |
| 1294 | // Pinned ruler: click/drag to seek (reuses `Player::scrub_to`, | 1305 | // Pinned ruler: click/drag to seek (reuses `Player::scrub_to`, |
| 1295 | // the same call the legacy ruler makes), tick marks with mono | 1306 | // the same call the legacy ruler makes), tick marks with mono |
| @@ -1313,13 +1324,6 @@ pub(crate) fn render( | |||
| 1313 | this.scrub_to(event.position.x, true, cx); | 1324 | this.scrub_to(event.position.x, true, cx); |
| 1314 | }), | 1325 | }), |
| 1315 | ) | 1326 | ) |
| 1316 | - // Ctrl+wheel zooms about the pointer, a bare one scrolls the | ||
| 1317 | - // bed along -- the same mapping every bed below gives, and | ||
| 1318 | - // the legacy ruler's own (`ui/timeline.rs`'s | ||
| 1319 | - // `on_scroll_wheel` at its ruler strip). | ||
| 1320 | - .on_scroll_wheel(cx.listener(|this, event: &ScrollWheelEvent, _, cx| { | ||
| 1321 | - this.timeline_wheel(event, cx); | ||
| 1322 | - })) | ||
| 1323 | .children(ticks.into_iter().map(|(x, label)| { | 1327 | .children(ticks.into_iter().map(|(x, label)| { |
| 1324 | div().absolute().top_0().left(px(x)).child( | 1328 | div().absolute().top_0().left(px(x)).child( |
| 1325 | div() | 1329 | div() |