-
Notifications
You must be signed in to change notification settings - Fork 187
[win32] Use operations for transform manipulation #1858
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
[win32] Use operations for transform manipulation #1858
Conversation
8be37d6 to
d0d5699
Compare
| storeAndApplyOperationForAllHandles(new TranslateOperation(offsetX, offsetY)); | ||
| } | ||
|
|
||
| private class TransformHandle { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| private class TransformHandle { | |
| private static final class TransformHandle { |
or use a record
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, used a record here
d0d5699 to
8b770c3
Compare
e357142 to
2177652
Compare
| } | ||
|
|
||
| long getHandle(int zoomLevel) { | ||
| return getTransformHandle(zoomLevel).handle; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be removed and getTransformHandle(zoomLevel).handle can be used everywhere instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't this only be possible if we expose the TransformHandle class?
Hmm, thinking about it I probably would not like to do that. TransformHandle is intended as an internal class to simplify the management of different OS handles. From external calls only the OS handle is relevant
| } | ||
| } | ||
|
|
||
| private interface Operation { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a thought. Since we will use Operation for all the resource, does it make sense to extract this as a FunctionalInterface in a separate file and use it everywhere? I can see similar usage in Path and Region as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For records like TransformHandle, RegionHandle, we can have a ResourceHandle instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thought about the same. But I am hesitant to introduce some external class (even if package protected or internal package), because for now it is only used in win32.
HeikoKlare
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change looks overall good, thanks! Only minor comments from my side.
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Transform.java
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Transform.java
Outdated
Show resolved
Hide resolved
examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/graphics/TransformReuseTab.java
Outdated
Show resolved
Hide resolved
1641e2e to
54ca587
Compare
HeikoKlare
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me, the changes are fine now. I have tested them with the GraphicsExample. I have also executed GEF Classic's Draw2d tests against the changes as an additional means of validation: it's SWTGraphics also makes use of SWT's Transform.
54ca587 to
1766b59
Compare
e84e7a1 to
7c10c23
Compare
This commit refactors Transform in the win32 implementation to better support multiple handles for different zoom settings of a Transform when monitor-specific scaling is enabled. The previous implementation only applied adaptions to the initial handle of the transform and relied on the transform not to be changed afterwards. This doesn't cover all scenarios and can lead to unexpected behavior when re-using Transform objects over different zoom settings.
7c10c23 to
e681af1
Compare
e681af1 to
cdca916
Compare
cdca916 to
822860e
Compare
This PR refactors Transform in the win32 implementation to better support multiple handles for different zoom settings of a Transform when monitor-specific scaling is enabled. The previous implementation only applied adaptions to the initial handle of the transform and relied on the transform not to be changed afterwards. This doesn't cover all scenarios and can lead to unexpected behavior when re-using Transform objects over different zoom settings.
How to test
You can test this adaption with the new "Transform Re-usage"-Tab in the GraphicsExample. You need to: