Repository navigation
Middle-button pan follows the frame's pointer events, so a drag isn't lost on slow frames - #1132
Open
marcoarnulfo wants to merge 1 commit into
Open
marcoarnulfo wants to merge 1 commit into
marcoarnulfo wants to merge 1 commit into
Conversation
… lost on slow frames (fixes storytold#1131)
This branch has not been deployed
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.
Fixes #1131.
The middle-button pan only looked at the button state and the pointer position at the end of each frame. On a heavy drawing frames are slow, and eframe hands over a whole drag in one go: when the release lands in the same frame as the moves, the button already reads as up when the frame ends and all the movement is dropped. The wheel sums its raw events (
wheel_zoom_points, #660), so it always zooms, which is the "pan doesn't work, only scroll-zoom does" asymmetry in the report, and why it depends on the file and on the zoom level (zooming out on a big drawing makes frames slower). The pan now walks the frame's pointer events in order, like the wheel: a middle press over the drawing starts it (sameinsidecheck as before, so a press over a floating panel still doesn't pan), each move while it is on adds its delta, and the release ends it. At normal frame rates the result is the same as before, since the moves add up to the end-of-frame position.This makes the pan correct on heavy drawings, not smooth: each slow frame still lands as one jump. The frame time itself is #1071, with #997 and #1012 working on it.
I also dropped the
i.focusedcheck from the pan (added with docking in e09fb50, without a test of its own): the wheel zooms in an unfocused window, and a middle click doesn't focus the window on macOS, so the pan silently didn't start there. A pan in progress still ends when the window loses focus. Happy to switch back if the check was there for a reason I missed.The change stays inside the pan block of
canvas.rs, since #1061 (splittingcanvas.rsinto modules), #1059 and #1012 touch the same file; happy to rebase onto any of them if they land first.Validation:
middle_pan_slow_frames::a_middle_drag_that_ends_within_one_slow_frame_still_pans: fails on main (View { center: (100, 70), height: 220 }unchanged after a 100 px drag), passes heremiddle_pan_slow_frames::a_whole_middle_drag_within_one_slow_frame_still_pans(press, moves and release in one frame): fails on main the same way, passes herecargo test -p cadcraft-ui-egui --test middle_pan_slow_frames --test docking_workflows --test mspace_viewport_view --test rapid_clicks --test system_cursorcargo clippy -p cadcraft-ui-egui --all-targets -- -D warnings,cargo fmt --all -- --check