weblaf
weblaf copied to clipboard
UI scaling factor
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
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.
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)
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.
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?
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.
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:
-
Provide hardcoded states, for example
small
,normal
,medium
andlarge
, which will be selected depending on the currentGraphicsDevice
and/or system settings. Though this approach isn't really that flexible. -
Introduce configurable states, for example
dpi(96)
orscreen(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.
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.
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.