fix: small scene shifts when switching pages#1220
Merged
kaamui merged 2 commits intoOpenBoard-org:devfrom Feb 12, 2025
Merged
Conversation
Member
|
Hi @letsfindaway, could you please rebase this PR to the current state of the Thank you |
- visible scene area is affected by scene transformation and the view scrollbar values - clearly separate changes to those two - save and restore both using the SceneViewState - UBBoardController: - always use centerRestore when re-centering a scene - UBBoardController::centerOn only affect transformation - fix keeping the scene point when zooming - save scrollbars and transform in persistViewPositionOnCurrentScene - add a restoreViewPositionOnCurrentScene - save and restore view position in setActiveDocumentScene - remove redundant saveViewState - UBGraphicsScene: - remove no longer used lastCenter and setLastCenter - remove associated no longer used SceneViewState functions
- remove unnecessary includes in UBBoardController - make getter functions const in UBBoardController - re-add and improve workaround for foreground not repainted after scrolling on Qt5 - use transform instead of viewportTransform when retrieving scaling factor (same result on both, but cleaner and faster) - add comment explaining calculations in UBBoardController::zoom - widen nullptr guard in UBBoardController::updateSystemScaleFactor - remove duplicate definition of UBBoardController::activeScene - improve initialization in UBGraphicsScene::SceneViewState
20275f1 to
978ce83
Compare
Collaborator
Author
Done! |
This was referenced Feb 12, 2025
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.
This PR fixes the small shift of scenes when switching pages initially reported in #1009. Even if the effects of this problem depend on the Qt version use, it is an unclean procedure in the OpenBoard code that causes this.
There are two methods to move the visible region of a
QGraphicsView:OpenBoard uses both, and that is not a good idea:
centerOn()(changing scrollbar values) andtranslate()(changing transformation) is used to restore it.Even with this PR scrollbar values and transformations are used, but they are clearly separated. A first idea of using transformations only was skipped, because the scroll area of the
QGraphicsViewcannot be guaranteed to never scroll. E.g. the mouse wheel produces an event, which is processed by the scroll area and affects the scrollbar values.To remember the position and zoom factor of a scene, a
SceneViewStateis used which already provides the necessary information. It was however not consistently used.Here is a list of tests I have successfully performed with the updated code:
Technical details of the changes:
SceneViewStateUBBoardController:centerRestorewhen re-centering a sceneUBBoardController::centerOnonly affect transformationpersistViewPositionOnCurrentScenerestoreViewPositionOnCurrentScenesetActiveDocumentScenesaveViewStateUBGraphicsScene:lastCenterandsetLastCenterSceneViewStatefunctions