HiDPI scaling with Newt

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

HiDPI scaling with Newt

Jake
Hi,

We use the NewtCanvasSWT in our eclipse RCP application and have just switched to using Oxygen, which supports hiDPI scaling.

We see a similar problem to this issue (http://forum.jogamp.org/SWT-GLCanvas-with-DPI-scaling-in-Eclipse-td4038566.html) that the canvas is not scaled and shows up smaller than expected.

I have tried setting the scaling manually using setSurfaceScale but it doesn't seem to do anything.

Looking at the source code, the setSurfaceScale method of WindowImpl never sets the requested scale into the scale used (with the possible exception of OSX, where the osx WindowDriver class overrides this method), so methods like defineSize are not using the correct scaling factor.

Am I missing something? Or is setting the scale not fully implement for Newt for windows and x11?

Thanks,

Jake
Reply | Threaded
Open this post in threaded view
|

Re: HiDPI scaling with Newt

gouessej
Administrator
Hello

The HiDPI support in NEWT works only under OS X. I thought that it was working under Windows too but it doesn't. Feel free to contribute even though it's not a trivial task especially under Windows. Improving the X11 window driver should be easier.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: HiDPI scaling with Newt

Jake
Thanks I will have a look.

Just using reflection to force new scaling factors changed the scale of the what was drawn, but it didn't change the canvas size (for reasons mentioned in the other ticket).

I might initially try to override the getClientArea method of the newt canvas to not return the scaled values, and see if that works.

I fear it might require deep diving into what SWT expects from a UI component for it to work with hiDPI...
Reply | Threaded
Open this post in threaded view
|

Re: HiDPI scaling with Newt

Jake
The approach of overriding the getClientArea call and replacing it with one that reverts the application of the scaling factor seems to work well, but I have no idea if this is the "correct" way to handle the situation.

I will see if I can find anyone with more SWT expertise than me to see if there is a better way.
Reply | Threaded
Open this post in threaded view
|

Re: HiDPI scaling with Newt

gouessej
Administrator
Please can you post a diff or something showing your code? It seems to be an acceptable workaround in the meantime until the bug is fixed in NEWT itself.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: HiDPI scaling with Newt

Jake
Simply doing this override of getClientArea:

canvas = new NewtCanvasSWT(this, SWT.NONE,window) {
       
        @SuppressWarnings("restriction")
                @Override
        public Rectangle getClientArea() {
       
        Rectangle rect = super.getClientArea();
        return DPIUtil.autoScaleUp(rect);
       
        }
        };

Seems to have fixed everything (i have yet to test on mac). Not ideal since it uses the internal API for SWT. I am yet to find any documentation for writing HiDPI widgets for SWT.
Reply | Threaded
Open this post in threaded view
|

Re: HiDPI scaling with Newt

gouessej
Administrator
Ok I knew this workaround, I saw it in the legacy version of Ardor3D. This class might not be in all SWT JARs. Do you use Maven?
Julien Gouesse | Personal blog | Website