Skip to content

fix: scaling of display view#901

Merged
kaamui merged 4 commits intoOpenBoard-org:devfrom
letsfindaway:fix-display-scaling
Aug 13, 2024
Merged

fix: scaling of display view#901
kaamui merged 4 commits intoOpenBoard-org:devfrom
letsfindaway:fix-display-scaling

Conversation

@letsfindaway
Copy link
Copy Markdown
Collaborator

This PR fixes the display view scaling issue reported in #887 as follows:

  • scaling shall be based on control view size instead of page size
  • scaling has to take into account the system scale factor
  • refactor: use center() function of QRect instead of own calculation

The problem (and also the resolution using this PR) can be verified in a setup where control and display screen have different aspect ratios.

- scaling shall be based on control view size instead of page size
- scaling has to take into account the system scale factor
- refactor: use center() function of QRect instead of own calculation
- complete area of control screen stays visible and usable
- indicator of what is hidden on the display screen
@letsfindaway
Copy link
Copy Markdown
Collaborator Author

According to the idea of @maehne in #846 I now indicate the visible area of the display screen on the control screen using a gray overlay. The area under the overlay can still be interacted with on the control screen. See here how it looks like:

grafik

The four blue dots indicate the corners of the display screen. For the two forms it is clear on the control screen which part is visible and what is hidden on the display screen.

@maehne
Copy link
Copy Markdown

maehne commented Mar 1, 2024

@letsfindaway: I really like your suggested improvement! The different aspect ratios become increasingly a problem, because 16:10 and 3:2 screens have become more popular over the past years while video projectors typically use 16:9 aspect ratio.

- DisplayManager::hasDisplay() wrongly returned true
  when mUseMultiScreen was false, but a second screen
  was available
- set system scale factor so that complete nominal page
  is visible on control screen
- use the control view widget size instead of the screen size
  for calculation to account for the menu bar height
@kaamui
Copy link
Copy Markdown
Member

kaamui commented Aug 16, 2024

@letsfindaway Just found out that when moving the view, making any action centering the view (erase the board, or double cliking on the hand tool) make the grey borders not display correctly.

Moving the hand again update the whole visible region correctly.

@letsfindaway
Copy link
Copy Markdown
Collaborator Author

letsfindaway commented Aug 16, 2024

@letsfindaway Just found out that when moving the view, making any action centering the view (erase the board, or double cliking on the hand tool) make the grey borders not display correctly.

Moving the hand again update the whole visible region correctly.

Ok, I see. Looks as if the view is not properly updated in that case. I assume that this is a Qt problem. It does not happen for me with Qt6, but only with Qt5.

I could mitigate the problem with this crude hack:

void UBBoardController::centerOn(QPointF scenePoint)
{
    QPointF offset{1, 1};
    mControlView->centerOn(scenePoint - offset);
    mControlView->translate(offset.x(), offset.y());
    UBApplication::applicationController->adjustDisplayView();
}

It seems that translate is updating the foreground properly. So centering on some point beneath the target and then translating solves the issue also for Qt5.

@letsfindaway
Copy link
Copy Markdown
Collaborator Author

letsfindaway commented Aug 18, 2024

The idea of setting the scrollbar position instead of the center (see #1009 (comment)) also fixes this issue. So I will further work on that direction and store/restore the scrollbar position of the view instead of the center point of the scene.

This solution is not a hack, but probably a better way to adjust the view position anyway.

Edit: when further investigation the history of this code, I saw that it was introduced with commit 773dab5. Did you have a specific reason not to use the scrollbar positions, which were already present in the SceneViewState, but to introduce the new variable for the center?

Because introducing the proposed fix would merely mean to replace the work of this commit and to reuse the scroll bar positions instead.

Edit 2: some more tests answered my question: the scroll bar values are not updated when the view is moved. Instead a view transformation is used. So it is clear why the scrollbars cannot work. Next idea would be to save and update the view Transform and to test how the foreground behaves when the transform is changed.

Edit 3: I don't get this working and still don't understand how QGraphicsView::transform() and QGraphicsView::viewportTransform() are interrelated and how the latter could be set. So I currently stop working on that. The workaround works, but it does not solve the issue that the view is slightly moving when switching pages on Qt >= 6.6.2.

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.

3 participants