Skip to content

Fix scaling anchors in PMv2 applications. - #8349

Merged
dreddy-work merged 3 commits into
mainfrom
dev/dreddy/fix8266_1
Dec 13, 2022
Merged

Fix scaling anchors in PMv2 applications.#8349
dreddy-work merged 3 commits into
mainfrom
dev/dreddy/fix8266_1

Conversation

@dreddy-work

@dreddy-work dreddy-work commented Dec 7, 2022

Copy link
Copy Markdown
Member

Fixes #8266.

In PermonV2 mode applications, when moved from one monitor to the other, Form/Container is scaled with scale factor computed with respect to new DPI on the monitor. However, scaling ratio between non-client and client area is not linear. This is causing few pixels variance when anchors are also scaled with same scale factor.
Anchors are relative to display rectangle. Hence, making change to computing anchor scale factor with respect to change in DisplayRect instead of change in the bounds (a.k.a: scale factor computed with respect to new DPI).

This PR follows #8201.

Microsoft Reviewers: Open in CodeFlow
Fixes #8266.

In PermonV2 mode applications, when moved from one monitor to the other, Form/Container is scaled with scale factor computed with respect to new DPI on the monitor. However, scaling ratio between non-cleant and client area is not linear. This is causing few pixel variance when anchors are also scaled with same scale factor.
Anchors are relative to display rectangle. Hence, computing anchor scale factor with repsect to chnage in Display rect instead of chnage in the bounds (a.k.a: scale factor computed with respect to new DPI).
@dreddy-work
dreddy-work requested a review from a team as a code owner December 7, 2022 23:55
@ghost ghost assigned dreddy-work Dec 7, 2022

@Tanya-Solyanik Tanya-Solyanik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good, it is possible to add tests?

Comment thread src/System.Windows.Forms/src/System/Windows/Forms/Layout/DefaultLayout.cs Outdated
Comment thread src/System.Windows.Forms/src/System/Windows/Forms/Layout/DefaultLayout.cs Outdated
Comment thread src/System.Windows.Forms/src/System/Windows/Forms/Layout/DefaultLayout.cs Outdated
Comment thread src/System.Windows.Forms/src/System/Windows/Forms/Layout/DefaultLayout.cs Outdated
@dreddy-work

Copy link
Copy Markdown
Member Author

Looks good, it is possible to add tests?

We have tests for anchors not just display rectangle. I will look if we need any specific test for the display rect cached but not in this PR>

@dreddy-work
dreddy-work enabled auto-merge (squash) December 12, 2022 21:17

@Tanya-Solyanik Tanya-Solyanik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good. I added some nit picks.

@Tanya-Solyanik Tanya-Solyanik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good!

@dreddy-work
dreddy-work merged commit a1bc20a into main Dec 13, 2022
@dreddy-work
dreddy-work deleted the dev/dreddy/fix8266_1 branch December 13, 2022 00:01
@ghost ghost added this to the 8.0 Preview1 milestone Dec 13, 2022
@dreddy-work

Copy link
Copy Markdown
Member Author

related #8442

@ghost ghost locked as resolved and limited conversation to collaborators Feb 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

3 participants