From ed91aa4648f5d9a77c5bb3ad5807e1a12f6978d6 Mon Sep 17 00:00:00 2001 From: SchiopuMatei Date: Mon, 15 Mar 2021 20:41:40 +0200 Subject: [PATCH] Added option for downscaling --- .../java/com/formdev/flatlaf/FlatSystemProperties.java | 8 ++++++++ .../src/main/java/com/formdev/flatlaf/util/UIScale.java | 6 +++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatSystemProperties.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatSystemProperties.java index 7ec39204..14b76e86 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatSystemProperties.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatSystemProperties.java @@ -43,6 +43,14 @@ public interface FlatSystemProperties * Default {@code true} */ String UI_SCALE_ENABLED = "flatlaf.uiScale.enabled"; + + /** + * Specifies whether values smaller than 1.0f are allowed for the custom scale factor. + *

+ * Allowed Values {@code false} and {@code true}
+ * Default {@code false} + */ + String UI_DOWNSCALE_ENABLED = "flatlaf.uiDowncale.enabled"; /** * Specifies whether Ubuntu font should be used on Ubuntu Linux. diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/util/UIScale.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/util/UIScale.java index d2e9c269..53a539c8 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/util/UIScale.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/util/UIScale.java @@ -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;