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

UI scaling factor #352

Open
mgarin opened this issue Dec 28, 2015 · 8 comments
Open

UI scaling factor #352

mgarin opened this issue Dec 28, 2015 · 8 comments

Comments

@mgarin
Copy link
Owner

mgarin commented Dec 28, 2015

Consider adding global UI scaling factor that will affect painting of all WebLaF components. It should probably be passed into Painter interface into main paint method as one of the base settings to ensure painters are aware of it.

Original request:
http://weblookandfeel.com/forum/viewtopic.php?f=4&t=221

@mgarin mgarin self-assigned this Dec 28, 2015
@mgarin mgarin added this to the v1.4.0 milestone Dec 28, 2015
@Sciss
Copy link
Contributor

Sciss commented Dec 28, 2015

That would be amazing, in particular if multiple sizes were supported inside the same GUI. For example with OS X Look-and-Feel you can do

button.putClientProperty("JComponent.sizeVariant", "mini");

Also Nimbus attempted to implemented this, although stupidly it got stuck in the middle, so some things work and others render badly.

@Sciss
Copy link
Contributor

Sciss commented Dec 28, 2015

BTW regarding the forum post - I believe that on OS X you can set a system property for hi-dpi displays that will render all Swing of an application by a scaling factor of two, so as long as you use vector graphics this provides a simple means to get "normal size" widgets on a high-res screen. Not sure something like this exists on Windows and Linux (I don't have a hi-dpi screen)

@mgarin
Copy link
Owner Author

mgarin commented Dec 30, 2015

That would be amazing, in particular if multiple sizes were supported inside the same GUI.

I would rather not mix it with the UI scaling as those are different things - OS X component size variations are about different variations of the same component - those variations might have slightly different predefined settings (like corners round for example) but at the same time have some common things. If you mix it with the scaling it will only create issues.

Variations you are talking about can be easily achieved with the styling system introduced in next update. Actually a lot of components will already have a lot of variations included into the base style. So it will simply be a matter of a few XML lines to add more if you need them - just reduce the rounding and font size slightly, maybe adjust some colors - there you have it, new component variation which can be applied to each component of that type or to some specific components separately.

Not sure something like this exists on Windows and Linux (I don't have a hi-dpi screen)

It seems that there is some kind of support on Windows 8 and 10 - when you are running Swing application it is being scaled up in size (tried on notebook with 3840 x 2160 resolution) but it actually looks horrible - UI and text is so blurry that you can barely work with the application. So I wouldn't call that a sufficient solution for the problem.

And by the way, we actually ended up changing the resolution to 1920 x 1080 as Java applications aren't the only ones having issues with scaling. Plus such resolution places an enormous stress on hardware and causes some serious lags even while browsing some sites. That is slightly an off-topic but everyone I know (except OS X users) simply went back to using Full HD resolution for now even if they have higher resolutions available.

@Sciss
Copy link
Contributor

Sciss commented Feb 27, 2017

It seems that there is some kind of support on Windows 8 and 10

I have actually a user of one of my applications (that uses WebLaF) that has the hi-dpi problem (things rendered too small) on Windows 8.1. Do you remember how to enable up-scaling (even if it looks bad)?

And with the current 1.29 snapshot - can I specify default font size for all components perhaps?

@mgarin
Copy link
Owner Author

mgarin commented Feb 27, 2017

I have actually a user of one of my applications (that uses WebLaF) that has the hi-dpi problem (things rendered too small) on Windows 8.1. Do you remember how to enable up-scaling (even if it looks bad)?

I didn't really enable it anyhow, it simply was there on hi-dpi screen. Probably it was enabled through reading windows UI scaling setting (which was 1.25x by default), but I might be wrong here.

And with the current 1.29 snapshot - can I specify default font size for all components perhaps?

All default fonts are defined within WebFonts class, but you cannot modify them there anyhow. Though those fonts are only used within WebLookAndFeel class as default values for static non-final variables which you can modify, but you need to do that before installing L&F.

Check WebLookAndFeel source code to see the full list of static font variables - you can change any of them to affect specific component or group of components.

@mgarin
Copy link
Owner Author

mgarin commented Mar 22, 2017

One of the possible scaling solutions could be providing different style settings for different DPI cases, maybe in the same way OS-dependant settings can be passed - through specific states.

Though with OS its quite clear - you can have win, mac and other similar states. Not sure what could be done depending on the DPI. A few wild ideas:

  1. Provide hardcoded states, for example small, normal, medium and large, which will be selected depending on the current GraphicsDevice and/or system settings. Though this approach isn't really that flexible.

  2. Introduce configurable states, for example dpi(96) or screen(1920x1080), which will represent a specific condition (or conditions) which should be met for the state to be active. That will allow configuring any component style for specific screen resolution or size.

Though there seem to be no good way of determining screen resolution in Java.
Return of the Toolkit:

Toolkit.getDefaultToolkit().getScreenResolution()

Seem to give a hardcoded value in most cases, though I'm not completely sure about it.

@mgarin
Copy link
Owner Author

mgarin commented Mar 22, 2017

In any case, either of two concepts offered above will only be useful if fonts can be configured within styles along with the other settings. So issue #331 must be implemented first.

@mgarin
Copy link
Owner Author

mgarin commented May 29, 2018

I've been recently looking into possible UI scaling solutions for different OS versions and stumbled upon some issues currently present in Java 8 and 9 (also seem to be bugged on some other versions):
https://bugs.openjdk.java.net/browse/JDK-8080153

Although I have only tested this under Windows 7, 8 and 10.

@mgarin mgarin modified the milestones: v1.4.0, v2.x.x May 27, 2019
@mgarin mgarin removed this from the v2.x.x milestone Apr 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants