Fix canvas jump to top left corner during pan#249
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes the canvas “jump to top-left” behavior during click-and-drag panning by switching panning to incremental, global-coordinate deltas and handling pixel-accurate scrolling separately from wheel scrolling.
Changes:
- Add a new
pixelScrollRequest(dx, dy)signal fromCanvasand emit incremental global-position deltas during pan. - Keep wheel scrolling on the existing
scrollRequest, but handle panning via 1:1 pixel scroll updates inPPOCRLabel.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| libs/canvas.py | Emit pixel-based pan deltas using ev.globalPos() and update pan anchor incrementally; adjust cursor behavior during pan. |
| PPOCRLabel.py | Connect and implement pixelScrollRequest to apply direct pixel deltas to the scrollbars. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
libs/canvas.py
Outdated
| elif not self.selectedShapes: | ||
| # pan | ||
| QApplication.restoreOverrideCursor() # ? | ||
| self.restoreCursor() |
There was a problem hiding this comment.
In the pan release path, calling self.restoreCursor() pops the application override cursor stack. Since the canvas uses overrideCursor() even for normal hover state, this can leave the app with no override cursor while the mouse is still over the canvas (cursor may briefly revert until the next mouseMoveEvent). Prefer switching back to an appropriate canvas cursor via overrideCursor(...) (or track whether panning pushed a new override and only restore in that case) so cursor state remains consistent after panning ends.
| self.restoreCursor() | |
| self.overrideCursor(CURSOR_DEFAULT) |
… in the pan release path
2.mov
Resolves #248