Added option for downscaling

This commit is contained in:
SchiopuMatei
2021-03-15 20:41:40 +02:00
parent 04aa61c2bb
commit ed91aa4648
2 changed files with 13 additions and 1 deletions

View File

@@ -43,6 +43,14 @@ public interface FlatSystemProperties
* <strong>Default</strong> {@code true}
*/
String UI_SCALE_ENABLED = "flatlaf.uiScale.enabled";
/**
* Specifies whether values smaller than 1.0f are allowed for the custom scale factor.
* <p>
* <strong>Allowed Values</strong> {@code false} and {@code true}<br>
* <strong>Default</strong> {@code false}
*/
String UI_DOWNSCALE_ENABLED = "flatlaf.uiDowncale.enabled";
/**
* Specifies whether Ubuntu font should be used on Ubuntu Linux.

View File

@@ -257,6 +257,10 @@ public class UIScale
private static boolean isUserScalingEnabled() {
return FlatSystemProperties.getBoolean( FlatSystemProperties.UI_SCALE_ENABLED, true );
}
private static boolean isDownscalingEnabled() {
return FlatSystemProperties.getBoolean( FlatSystemProperties.UI_DOWNSCALE_ENABLED, false );
}
/**
* Applies a custom scale factor given in system property "flatlaf.uiScale"
@@ -323,7 +327,7 @@ public class UIScale
* Sets the user scale factor.
*/
private static void setUserScaleFactor( float scaleFactor ) {
if( scaleFactor <= 1f )
if( ( !isDownscalingEnabled() && scaleFactor <= 1f ) || scaleFactor <= 0f )
scaleFactor = 1f;
else // round scale factor to 1/4
scaleFactor = Math.round( scaleFactor * 4f ) / 4f;