added system properties "flatlaf.animation" and "flatlaf.smoothScrolling" to disable all animations or smooth scrolling via command line (without modifying the application)

This commit is contained in:
Karl Tauber
2020-08-08 16:19:36 +02:00
parent fdabca99b2
commit 1ebfe00f3c
7 changed files with 53 additions and 2 deletions

View File

@@ -33,6 +33,7 @@ import com.formdev.flatlaf.FlatDarkLaf;
import com.formdev.flatlaf.FlatIntelliJLaf;
import com.formdev.flatlaf.FlatLaf;
import com.formdev.flatlaf.FlatLightLaf;
import com.formdev.flatlaf.FlatSystemProperties;
import com.formdev.flatlaf.demo.HintManager.Hint;
import com.formdev.flatlaf.demo.extras.*;
import com.formdev.flatlaf.demo.intellijthemes.*;
@@ -266,6 +267,14 @@ class DemoFrame
repaint();
}
private void animationChanged() {
boolean enabled = animationMenuItem.isSelected();
System.setProperty( FlatSystemProperties.ANIMATION, Boolean.toString( enabled ) );
smoothScrollingMenuItem.setEnabled( enabled );
animatedLafChangeMenuItem.setEnabled( enabled );
}
private void smoothScrollingChanged() {
UIManager.put( "ScrollPane.smoothScrolling", smoothScrollingMenuItem.isSelected() );
}
@@ -509,6 +518,7 @@ class DemoFrame
showTitleBarIconMenuItem = new JCheckBoxMenuItem();
underlineMenuSelectionMenuItem = new JCheckBoxMenuItem();
alwaysShowMnemonicsMenuItem = new JCheckBoxMenuItem();
animationMenuItem = new JCheckBoxMenuItem();
smoothScrollingMenuItem = new JCheckBoxMenuItem();
animatedLafChangeMenuItem = new JCheckBoxMenuItem();
JMenuItem showHintsMenuItem = new JMenuItem();
@@ -797,6 +807,13 @@ class DemoFrame
alwaysShowMnemonicsMenuItem.setText("Always show mnemonics");
alwaysShowMnemonicsMenuItem.addActionListener(e -> alwaysShowMnemonics());
optionsMenu.add(alwaysShowMnemonicsMenuItem);
optionsMenu.addSeparator();
//---- animationMenuItem ----
animationMenuItem.setText("Animation");
animationMenuItem.setSelected(true);
animationMenuItem.addActionListener(e -> animationChanged());
optionsMenu.add(animationMenuItem);
//---- smoothScrollingMenuItem ----
smoothScrollingMenuItem.setText("Smooth Scrolling");
@@ -992,6 +1009,7 @@ class DemoFrame
private JCheckBoxMenuItem showTitleBarIconMenuItem;
private JCheckBoxMenuItem underlineMenuSelectionMenuItem;
private JCheckBoxMenuItem alwaysShowMnemonicsMenuItem;
private JCheckBoxMenuItem animationMenuItem;
private JCheckBoxMenuItem smoothScrollingMenuItem;
private JCheckBoxMenuItem animatedLafChangeMenuItem;
private JMenuItem aboutMenuItem;

View File

@@ -418,6 +418,18 @@ new FormModel {
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "alwaysShowMnemonics", false ) )
} )
add( new FormComponent( "javax.swing.JPopupMenu$Separator" ) {
name: "separator9"
} )
add( new FormComponent( "javax.swing.JCheckBoxMenuItem" ) {
name: "animationMenuItem"
"text": "Animation"
"selected": true
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "animationChanged", false ) )
} )
add( new FormComponent( "javax.swing.JCheckBoxMenuItem" ) {
name: "smoothScrollingMenuItem"
"text": "Smooth Scrolling"

View File

@@ -25,6 +25,7 @@ import java.awt.Window;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.beans.Beans;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.File;
@@ -156,6 +157,9 @@ public class IJThemesPanel
}
private void updateThemesList() {
if( Beans.isDesignTime() )
return; // disable if running in GUI builder
int filterLightDark = filterComboBox.getSelectedIndex();
boolean showLight = (filterLightDark != 2);
boolean showDark = (filterLightDark != 1);