Skip to content

feat(observers): scroll-to-zoom on axis gutters in PlotObserver#262

Merged
dyreby merged 4 commits into
mainfrom
feat/axis-scroll-zoom
Feb 28, 2026
Merged

feat(observers): scroll-to-zoom on axis gutters in PlotObserver#262
dyreby merged 4 commits into
mainfrom
feat/axis-scroll-zoom

Conversation

@dyreby

@dyreby dyreby commented Feb 28, 2026

Copy link
Copy Markdown
Contributor

Implements scroll-to-zoom on axis gutters in PlotObserver, resolving #260.

What changes

When the cursor is over an axis gutter:

  • Left gutter (y-axis): vertical scroll zooms the y-axis only, centered on the cursor's plot-space position
  • Bottom gutter (x-axis): vertical scroll zooms the x-axis only, centered on the cursor's plot-space position
  • Plot area: existing behavior unchanged — scroll pans, pinch zooms

How it works

PlotApp now stores plot_rect: Option<egui::Rect> — the inner plot rect captured from plot_ui.transform().frame() at the end of each frame. On the next frame this rect is used to hit-test the cursor against the left and bottom gutters.

When a gutter is active:

  1. allow_scroll(false) prevents the plot from consuming scroll events as pan
  2. smooth_scroll_delta.y is converted to a zoom factor via exp(delta / 200.0) — the same scale egui_plot uses internally for scroll-to-zoom
  3. plot_ui.zoom_bounds_around_hovered(factor) applies the zoom centered on the hovered position; BoundsModification::Zoom automatically disables auto-bounds, so no set_auto_bounds call is needed

The zoom is guarded on scroll_delta.y != 0.0 so auto-bounds aren't disabled on frames with no scroll activity.

When the cursor is over the left (y-axis) or bottom (x-axis) gutter:
- Disable scroll-to-pan so the plot doesn't consume the events
- Convert vertical scroll delta to a zoom factor via exp(delta/200)
- Apply axis-specific zoom centered on the hovered position

Plot-area behavior (scroll pans, pinch zooms) is unchanged.

Closes #260
…ations

- Increase background sine curve from 301 to 2001 points so it stays
  smooth when zoomed into the region where evaluations cluster near π/2
- Loosen golden section tolerance from 1e-12 to 1e-6, cutting the
  evaluated point count roughly in half (~29 vs ~58 iterations)
- Fix pre-existing clippy::needless_borrows_for_generic_args in ode title
Replace uniform spacing with a cubic remap u³ (u ∈ [-1, 1]).
The cubic has zero slope at u=0, so sample density is highest near
π/2 where the evaluated points cluster and where zooming in previously
revealed line segments.
@dyreby dyreby merged commit 8c532ba into main Feb 28, 2026
1 check passed
@dyreby dyreby deleted the feat/axis-scroll-zoom branch February 28, 2026 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant