Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replacing the usage of getBoundsInPixels with getBounds #1385

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ShahzaibIbrahim
Copy link
Contributor

Initial native image must be the one that will be used by a widget, thats why using getBounds with initialNativeZoom. This PR just remove the usage of deprecated method getBoundsInPixels wherever possible. This doesn't fix anything broken.

Copy link
Contributor

github-actions bot commented Aug 6, 2024

Test Results

  284 files   -   201    284 suites   - 201   5m 6s ⏱️ - 3m 45s
4 158 tests ±    0  4 150 ✅ +    1   8 💤 ± 0  0 ❌  - 1 
8 246 runs   - 8 140  8 188 ✅  - 8 105  58 💤  - 34  0 ❌  - 1 

Results for commit 2bc5089. ± Comparison against base commit 02e20d6.

♻️ This comment has been updated with latest results.

@@ -7293,7 +7293,7 @@ LRESULT wmNotifyToolTip (NMTTCUSTOMDRAW nmcd, long lParam) {
if (pinfo.iSubItem != 0) x -= gridWidth;
Image image = item.getImage (pinfo.iSubItem);
if (image != null) {
Rectangle rect = image.getBoundsInPixels ();
Rectangle rect = image.getBoundsInPixels();
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it intended that this is only a formatting change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

formatting leftover

@@ -466,7 +466,7 @@ void copyAreaInPixels(Image image, int x, int y) {
if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (image.type != SWT.BITMAP || image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
/* Copy the bitmap area */
Rectangle rect = image.getBoundsInPixels();
Rectangle rect = image.getBounds(data.nativeZoom);
Copy link
Contributor

Choose a reason for hiding this comment

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

This modifies the behavior, doesn't it?
Let's assume getBoundsInPixels() returned (100, 100, 100, 100) and let's assume that data.nativeZoom=125. Then getBounds(data.nativeZoom) will scale up from 100 to 125, i.e., it will return (125, 125, 125, 125). Do I miss something?

Copy link
Contributor

@akoch-yatta akoch-yatta Aug 7, 2024

Choose a reason for hiding this comment

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

Depends what the native zoom of the image is. If the native zoom of the image is 125, then it will return (100, 100, 100, 100). If the native zoom of the image is 100, then yes. Probably would be good to look out for a snippet, where this is used and play around with that.

Copy link
Contributor

Choose a reason for hiding this comment

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

I do not understand that. Why should it return (100, 100, 100, 100) when the native zoom of the image is 125? Within getBounds(int), the "corrected" zoom is used according to DPIUtil.getZoomForAutoscaleProperty(initialNativeZoom), so even if the native zoom of the image is 125, a value of 100 is used for scaling, isn't it?

Copy link
Contributor

@akoch-yatta akoch-yatta Aug 7, 2024

Choose a reason for hiding this comment

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

So you mean the call should be getBounds(getZoom()) to be in the same zoom restrictions as Image uses internally?
That is definetly correct

Copy link
Contributor

Choose a reason for hiding this comment

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

What I meant for example is the scenario was with mode exact or quarter, where the Image was e.g. created on the primary monitor with 125%. Then getBounds(125) would be equal to getZoom() from the image, so it would return (100, 100, 100, 100)

Copy link
Contributor

Choose a reason for hiding this comment

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

That's true. I had the "default" case in mind (i.e., scaling mode integer200) in which I still think that the behavior might change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's true. I had the "default" case in mind (i.e., scaling mode integer200) in which I still think that the behavior might change.

You are right, the behavior changes. I tested it with the snippet 215, where image.getBoundsInPixels() returns Rectangle {0, 0, 5120, 1440} but later scaled due to native zoom (which is 200) to final value image.getBounds(data.nativeZoom) : Rectangle {0, 0, 10240, 2880}

initial native image must be the one that will be used by a widget,
thats why using getBounds with initialNativeZoom
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