diff --git a/crates/app/src/tests/layout.rs b/crates/app/src/tests/layout.rs index e779900..c50fb70 100644 --- a/crates/app/src/tests/layout.rs +++ b/crates/app/src/tests/layout.rs @@ -2694,3 +2694,48 @@ fn an_external_file_drop_is_heard_by_the_whole_room_and_imports() { "the dock answers an external file drag with nothing: {dock}" ); } + +/// The wheel is the bench's, not a clip's: the user rolled it over the bench +/// and nothing moved unless the pointer happened to sit on a track, because +/// the only listeners were one per bed and one on the ruler strip. The row's +/// listener now sits on the whole row (head column included) and stops there, +/// and `bench-content` answers everything else -- the strip left of the ruler, +/// the ruler itself, the gaps between rows, the space below the last track. +/// Exactly two listeners, so no strip answers one notch twice. +#[test] +fn the_bench_answers_a_wheel_notch_anywhere_over_it() { + let bench = src_text("ui/bench_stance.rs"); + assert_eq!( + bench.matches(".on_scroll_wheel(").count(), + 2, + "the bench has a wheel listener per region again -- a notch would be answered twice" + ); + let row = bench + .find(".id((\"bench-lane\", lane.ord") + .expect("no lane row"); + let bed = bench.find(".id((\"bench-bed\"").expect("no lane bed"); + let row_wheel = bench[row..bed] + .find(".on_scroll_wheel(") + .map(|at| &bench[row + at..bed]) + .expect("the lane row does not answer the wheel -- only its bed does"); + assert!( + row_wheel[..200].contains("cx.stop_propagation();") + && row_wheel[..200].contains("this.timeline_wheel(event, cx)"), + "the row's wheel lost the mapping or its stop: {}", + &row_wheel[..200] + ); + let content = bench.find(".id(\"bench-content\")").expect("no bench content"); + let content_wheel = bench[content..] + .find(".on_scroll_wheel(") + .expect("the bench container does not answer the wheel"); + assert!( + content_wheel < 700 && bench[content..].contains("this.timeline_wheel(event, cx)"), + "the container's wheel listener is not on the container itself" + ); + let ruler = bench.find(".id(\"bench-ruler\")").expect("no ruler"); + let lanes = bench.find(".id(\"bench-lanes\")").expect("no lane column"); + assert!( + !bench[ruler..lanes].contains(".on_scroll_wheel("), + "the ruler answers the wheel on its own again -- one notch, two scrolls" + ); +} diff --git a/crates/app/src/ui/bench_stance.rs b/crates/app/src/ui/bench_stance.rs index f7b31c2..f1bf263 100644 --- a/crates/app/src/ui/bench_stance.rs +++ b/crates/app/src/ui/bench_stance.rs @@ -829,6 +829,17 @@ fn lane_row( .h(px(h)) .flex() .relative() + // The wheel, matched to the legacy timeline's own mapping: ctrl+wheel + // zooms about the pointer, a bare wheel scrolls the bed along the film + // (`Player::timeline_wheel`). On the whole row -- head column and bed + // alike -- not on the bed alone: a hand rolls the wheel wherever it + // left the pointer, and aiming at a clip first is a tax. Stopped here + // so gpui's own overflow scroll on the lane column (`bench-lanes`) and + // `bench-content`'s catch-all below never answer the same notch again. + .on_scroll_wheel(cx.listener(|this, event: &ScrollWheelEvent, _, cx| { + cx.stop_propagation(); + this.timeline_wheel(event, cx); + })) // Dragged, the whole track moves in the stack (`LaneDrag`, // `Player::reorder_lane`) -- let go anywhere along the row, not just // over the head column, since a slot is what is being aimed at. @@ -1148,15 +1159,6 @@ fn lane_row( this.preview_ghost_pick(track, lane, event.event.position.x, cx); }), ) - // The wheel, matched to the legacy timeline's own mapping: - // ctrl+wheel zooms about the pointer, a bare wheel scrolls - // the bed along the film (`Player::timeline_wheel`). Stopped - // here so gpui's own overflow scroll on the lane column - // (`bench-lanes`) never answers the same notch a second time. - .on_scroll_wheel(cx.listener(|this, event: &ScrollWheelEvent, _, cx| { - cx.stop_propagation(); - this.timeline_wheel(event, cx); - })) .children(hitmap::dynamic( move || { ( @@ -1290,6 +1292,15 @@ pub(crate) fn render( .flex() .flex_col() .gap(px(ROW_GAP)) + // The wheel over the WHOLE bench region, not just a bed: the ruler, + // the strip left of it, the gaps between rows and the space below the + // last track all answer a notch here with the same mapping every row + // gives (`Player::timeline_wheel`; the ruler's own former listener + // folded into this one, so no strip answers a notch twice). A row + // stops propagation, so a notch over a track never reaches this. + .on_scroll_wheel(cx.listener(|this, event: &ScrollWheelEvent, _, cx| { + this.timeline_wheel(event, cx); + })) .child( // Pinned ruler: click/drag to seek (reuses `Player::scrub_to`, // the same call the legacy ruler makes), tick marks with mono @@ -1313,13 +1324,6 @@ pub(crate) fn render( this.scrub_to(event.position.x, true, cx); }), ) - // Ctrl+wheel zooms about the pointer, a bare one scrolls the - // bed along -- the same mapping every bed below gives, and - // the legacy ruler's own (`ui/timeline.rs`'s - // `on_scroll_wheel` at its ruler strip). - .on_scroll_wheel(cx.listener(|this, event: &ScrollWheelEvent, _, cx| { - this.timeline_wheel(event, cx); - })) .children(ticks.into_iter().map(|(x, label)| { div().absolute().top_0().left(px(x)).child( div()