Skip to content

Make panels draggable on a Retina screen - #15

Merged
stoatworks-labs merged 1 commit into
mainfrom
worktree-canvas-drag
Sep 3, 2026
Merged

stoatworks-labs merged 1 commit into
mainfrom
worktree-canvas-drag

Conversation

@stoatworks-labs

Copy link
Copy Markdown
Owner

Dragging a panel about the emulation canvas did nothing — the grab landed on empty canvas and the drag became a pan. Reported from the first hands-on session with the app.

The cause. zoom is target pixels per canvas pixel (that's what the vertex shader multiplies by), while a pointer arrives from egui in points. At 2x those differ by two, so hit-testing without the conversion halved every click's distance from the top-left corner: a panel drawn on the right of the view was tested for near the middle.

The other half. The grab was taken from where the pointer was when egui decided the press had become a drag — by which time a quick flick has left the panel it was aimed at. It now comes from press_origin, as the previz handles already do.

The test. Drives the real widgets headlessly at set_pixels_per_point(2.0). At 1x the bug does not exist, which is exactly why the existing harness could not see it — worth remembering for any egui app in the fleet. Grab-and-drag, panning on empty canvas, and zoom-about-the-cursor are all covered now; reverting the fix fails the first of them.

🤖 Generated with Claude Code

Dragging a panel about the emulation canvas did nothing: the grab landed on
empty canvas and the drag became a pan. `zoom` is target *pixels* per canvas
pixel — what the vertex shader multiplies by — while a pointer arrives from
egui in *points*, and at 2x those differ by two. Hit-testing without the
conversion halved every click's distance from the top-left corner, so a panel
drawn on the right of the view was tested for near the middle.

The other half of the same problem: the grab was taken from where the pointer
was when egui decided the press had become a drag, by which time a quick flick
has left the panel it was aimed at. It now comes from press_origin, as the
previz handles already do.

The regression test drives the real widgets headlessly at
set_pixels_per_point(2.0) — at 1x the bug does not exist, which is why the
existing harness could not see it. Grab-and-drag, panning on empty canvas, and
zoom-about-the-cursor are all covered now.

Found by dragging panels in the app, which is the first time anyone had.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@stoatworks-labs
stoatworks-labs merged commit 1e91964 into main Sep 3, 2026
1 check passed
@stoatworks-labs
stoatworks-labs deleted the worktree-canvas-drag branch September 3, 2026 23:20
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