Skip to content

Fix canvas jump to top left corner during pan#249

Merged
GreatV merged 2 commits intoPFCCLab:mainfrom
MuhammedOzdogan:bugfix/248-canvas-jump-during-pan
Mar 25, 2026
Merged

Fix canvas jump to top left corner during pan#249
GreatV merged 2 commits intoPFCCLab:mainfrom
MuhammedOzdogan:bugfix/248-canvas-jump-during-pan

Conversation

@MuhammedOzdogan
Copy link
Copy Markdown
Contributor

@MuhammedOzdogan MuhammedOzdogan commented Mar 24, 2026

2.mov

Resolves #248

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 from Canvas and emit incremental global-position deltas during pan.
  • Keep wheel scrolling on the existing scrollRequest, but handle panning via 1:1 pixel scroll updates in PPOCRLabel.

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()
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
self.restoreCursor()
self.overrideCursor(CURSOR_DEFAULT)

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Copy Markdown
Collaborator

@GreatV GreatV left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@GreatV GreatV merged commit 967490c into PFCCLab:main Mar 25, 2026
1 check passed
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.

Bug: Image Canvas "Jump" during Panning

3 participants