forge
Explore
Log in

Don't you dare go Hollow

The bench answers a wheel notch anywhere over it

Browse files at this commit

6ca49065d53f4b454d09465fa2fa825b10d2eb24Ahmet Kaan GümüşParent: 7fbbd0f
  • fix
    • the bench answers a wheel notch anywhere over it
Show full message
🐛 fix(app): the bench answers a wheel notch anywhere over it

The wheel only moved the view when the pointer sat on a track: the only
listeners were one per lane bed and one on the ruler strip, so the head
column, the gaps between rows, the strip left of the ruler and the space
below the last track all swallowed the notch. The row's listener moves up
to the whole row and `bench-content` answers everything else, with the
row still stopping so no strip answers one notch twice. Mapping unchanged
(ctrl zooms about the pointer, bare scrolls the view along).
crates/app/src/tests/layout.rsmodified+45 -0
@@ -2649,3 +2649,48 @@ fn hitmap_names_every_darkroom_pointer_entry_surface() {
26492649 }
26502650 }
26512651 }
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(
829829 .h(px(h))
830830 .flex()
831831 .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+ }))
832843 // Dragged, the whole track moves in the stack (`LaneDrag`,
833844 // `Player::reorder_lane`) -- let go anywhere along the row, not just
834845 // over the head column, since a slot is what is being aimed at.
@@ -1148,15 +1159,6 @@ fn lane_row(
11481159 this.preview_ghost_pick(track, lane, event.event.position.x, cx);
11491160 }),
11501161 )
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- }))
11601162 .children(hitmap::dynamic(
11611163 move || {
11621164 (
@@ -1290,6 +1292,15 @@ pub(crate) fn render(
12901292 .flex()
12911293 .flex_col()
12921294 .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+ }))
12931304 .child(
12941305 // Pinned ruler: click/drag to seek (reuses `Player::scrub_to`,
12951306 // the same call the legacy ruler makes), tick marks with mono
@@ -1313,13 +1324,6 @@ pub(crate) fn render(
13131324 this.scrub_to(event.position.x, true, cx);
13141325 }),
13151326 )
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- }))
13231327 .children(ticks.into_iter().map(|(x, label)| {
13241328 div().absolute().top_0().left(px(x)).child(
13251329 div()