Make panels draggable on a Retina screen - #15
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
zoomis 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