-
Notifications
You must be signed in to change notification settings - Fork 53
Implement a monitor-aware lightweight system to handle HiDPI scaling #766
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
Conversation
@akoch-yatta FYI, this is the solution I eventually came up with. The scaling is done by a scalable figure that is added before the other figures. |
633f729
to
23b3481
Compare
Some additional notes:
|
Never thought of adding the scaling logic into the Viewport. I will try that one out. Looks more concise than my approach. Only problem is probably, that the monitor zoom is not incorporated into the diagram zoom, which affects fonts and images. One question from my side: Why do you put that logic into a subclass of Viewport and not into Viewport itself? Is it because you can overwrite parts of it, and you could break the whole logic? I know it is a Windows only "feature" and hidden behind an opt-in (for now). But in my opinion this behavior should be transparently used without the need to use a specific class, because it is hiding an existing limitation of Windows, that the developer of a GEF plug-in cannot control, e.g. with swt.autoScale=quarter and a zoom of 125% you will have artifacts when scrolling through a diagram otherwise. |
I played a bit around with it. The current solution is not suitable for the palette, correct? You need to apply the same pattern to palette as well (drawing and scaling on a 100% GC). Otherwise you will have artifacts when scrolling in a palette as well. But the Viewport doesn't work here or does it? |
This lightweight-system disables the native HiDPI scaling that is normally done by SWT and instead scales the figures via a ScalableLayeredPane. The main purpose of this class is to reduce the noise that is introduced by rounding, errors when dealing with fractional scaling. To test this functionality, simply pass the MonitorAwareLightweighSystem as an additional argument when constructing the FigureCanvas. See the AutoScaleExample for reference.
23b3481
to
dcaac21
Compare
Touching the Viewport is very scary and at least for now, this functionality should be strictly opt-in. Who knows in what creative ways this class is used by consumers and I can't predict all the ways this might break when suddenly additional figures are injected. When the This is still a draft and perhaps I can find a better way to hide this pane. In which case, this can be made configurable via a system property or something. Having this functionality be "invisible" and without adaptations to the user-code would of course be the ideal solution.
Every gef-classic/org.eclipse.gef/src/org/eclipse/gef/editparts/ScalableRootEditPart.java Lines 173 to 182 in 50e27e3
I assume this is also what you meant with this, correct?
I have adapted this PR to also consider this and inject the This is the editor now, scaled at 200%. Just as a side-note: This is a problem with Draw2D, so it's dangerous to focus on GEF because the same issue also exists in e.g. Zest. Any solution should be universal and sadly limits the avenues from which this problem can be approached... |
@ptziegler thanks for the update. @HeikoKlare and me tried it today, but immediately ran into a brickwall when trying it with an editor with a FreeformViewport e.g. the LogicEditor. We spent a bit of time with it to try to make it work and it was usable with the small changes you'll find in https://github.com/vi-eclipse/gef-classic/tree/monitor-aware-lws, but did not work in other zooms except 100%, because it runs into an endless validation loop when the freeform bounds were set and reset in scaled and unscaled values. I assume there is a proper solution possible for that current limitation? |
@akoch-yatta Can you explain how you reproduced the issue with the LogicEditor? I opened it at 150% zoom without any issues, so I assume there is some additional configuration necessary. Or do you have a small snippet that I could try out? |
@ptziegler probably the relevant change we made is that we changed Note that with the change above some issues pop up. In particular, |
@HeikoKlare Thanks, that was it. After a rebase, the changes to the |
Seems like it's not so easy to find a good and generic solution. We will probably integrate a preliminary solution (based on what Andreas has proposed) into our product soon to allow the usage of monitor-specific scaling without introducing the artifact line issues in GEF diagrams. We will keep sharing our findings with that approach and look forward to syncing on and finding a generic solution to GEF/Draw2d that we can finally adopt. |
Superseded by #770 |
This lightweight-system disables the native HiDPI scaling that is normally done by SWT and instead scales the figures via a ScalableLayeredPane.
The main purpose of this class is to reduce the noise that is introduced by rounding, errors when dealing with fractional scaling.
To test this functionality, simply pass the MonitorAwareLightweighSystem as an additional argument when constructing the FigureCanvas. See the AutoScaleExample for reference