diff --git a/core/src/main/java/com/github/weisj/darklaf/graphics/Animator.java b/core/src/main/java/com/github/weisj/darklaf/graphics/Animator.java index cb2631b6..086ecdef 100644 --- a/core/src/main/java/com/github/weisj/darklaf/graphics/Animator.java +++ b/core/src/main/java/com/github/weisj/darklaf/graphics/Animator.java @@ -29,8 +29,13 @@ import java.util.concurrent.atomic.AtomicBoolean; import javax.swing.*; +import com.github.weisj.darklaf.DarkLaf; +import com.github.weisj.darklaf.util.PropertyValue; + /** @author Konstantin Bulenkov */ public abstract class Animator { + + public static final String ANIMATIONS_FLAG = DarkLaf.SYSTEM_PROPERTY_PREFIX + "animations"; private static final ScheduledExecutorService scheduler = createScheduler(); private final int totalFrames; @@ -47,6 +52,7 @@ public abstract class Animator { private int currentFrame; private long startTime; private long stopTime; + private boolean enabled = true; private volatile boolean disposed = false; public Animator(final int totalFrames, final int cycleDuration, final int delayFrames) { @@ -120,11 +126,23 @@ public abstract class Animator { resume(0); } + private boolean animationsEnabled() { + return enabled && !PropertyValue.FALSE.equals(System.getProperty(ANIMATIONS_FLAG)); + } + + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(final boolean enabled) { + this.enabled = enabled; + } + public void resume(final int startFrame) { if (startFrame < 0) { throw new IllegalArgumentException("Starting frame must be non negative."); } - if (cycleDuration == 0 || startFrame >= totalFrames) { + if (cycleDuration == 0 || startFrame >= totalFrames || !animationsEnabled()) { currentFrame = totalFrames - 1; paint(); animationDone(); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollBarListener.java b/core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollBarListener.java index 95a3f416..c05fcad4 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollBarListener.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollBarListener.java @@ -56,10 +56,15 @@ public class DarkScrollBarListener extends MouseAdapter implements AdjustmentLis public DarkScrollBarListener(final JScrollBar scrollbar, final DarkScrollBarUI ui) { this.scrollbar = scrollbar; this.ui = ui; + boolean animationsEnabled = UIManager.getBoolean("ScrollBar.animated"); trackFadeoutAnimator = createTrackFadeoutAnimator(); trackFadeinAnimator = createTrackFadeinAnimator(); thumbFadeoutAnimator = createThumbFadeoutAnimator(); thumbFadeinAnimator = createThumbFadeinAnimator(); + trackFadeoutAnimator.setEnabled(animationsEnabled); + trackFadeinAnimator.setEnabled(animationsEnabled); + thumbFadeoutAnimator.setEnabled(animationsEnabled); + thumbFadeinAnimator.setEnabled(animationsEnabled); } public void uninstall() { diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/DarkToggleButtonListener.java b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/DarkToggleButtonListener.java index 8287a4ab..aed4a79b 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/DarkToggleButtonListener.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/DarkToggleButtonListener.java @@ -40,7 +40,12 @@ public class DarkToggleButtonListener extends DarkButtonListener