Skip to content

Zoom: keep the slide inside the view when zooming near a border - #375

Open
youms wants to merge 1 commit into
Cimbali:mainfrom
youms:fix/zoom-boundary-clamp
Open

youms wants to merge 1 commit into
Cimbali:mainfrom
youms:fix/zoom-boundary-clamp

Conversation

@youms

@youms youms commented Oct 28, 2026 •

Copy link
Copy Markdown

Selecting a box near an edge of the slide moves the slide away from that edge and leaves a black strip. Zooming again inside the strip compounds the offset until the slide leaves the screen.

Changes extras.py only:

  • Points are clamped to the widget and the shift to [1 - scale, 0], so the slide always covers the view.
  • A box smaller than 1 % of the slide (an accidental click) is ignored and the selection tool stays armed.
  • The scale is capped at 25x.

Tested on Ubuntu 26.04 (WSL), Python 3.14.4, GTK 3.24.52, with a script that drives Zoom.toggle_zoom_target() with synthetic events on a 1920x1080 widget. Selections along the left and right edges leave a black strip on origin/main and none with this branch.

Not tested: a real mouse in a running window, Windows and macOS.

Selecting a box near an edge gave a shift that moved the slide away from
the screen edge (shift_x = +0.44 for a box along the left border),
leaving a black void of that width, and zooming again compounded the
offset until the slide left the screen.

Clamp the zoom to the slide: points are clamped to the widget, the shift
to [1 - scale, 0] so the slide always covers the view, a box smaller
than 1 % of the slide is ignored (accidental click, division by almost
zero) and the scale is capped at 25x.
@Cimbali

Cimbali commented Nov 3, 2026

Copy link
Copy Markdown
Owner

I get clamping to keep slide in frame and protecting against accidental clicks — but what does capping the scale add?

@youms

youms commented Nov 21, 2026

Copy link
Copy Markdown
Author

The 1% span check already prevents division by near-zero and bounds the scale to 100x. The 25x cap was added as a usability guardrail so an accidental small drag (~1–2% of the slide) doesn't produce an extreme 50–90x zoom where a single letter serif fills the entire screen.

That said, if you prefer not having an arbitrary cap and letting the 1% threshold be the sole bound, I'm happy to drop the min(25.0, ...) and leave it at 1. / box_span.

This branch has not been deployed

No deployments
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.

2 participants