mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-11 14:37:13 -06:00
AnimatedBorder:
- support repainting only necessary region while animating - use AbstractBorder in test app and fixed insets
This commit is contained in:
@@ -23,7 +23,7 @@ import java.awt.Graphics2D;
|
||||
import java.awt.Insets;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import javax.swing.*;
|
||||
import com.formdev.flatlaf.ui.FlatMarginBorder;
|
||||
import javax.swing.border.AbstractBorder;
|
||||
import com.formdev.flatlaf.ui.FlatUIUtils;
|
||||
import com.formdev.flatlaf.util.AnimatedBorder;
|
||||
import com.formdev.flatlaf.util.ColorFunctions;
|
||||
@@ -133,7 +133,7 @@ public class FlatAnimatedBorderTest
|
||||
* - animates focus indicator color and border width
|
||||
*/
|
||||
private class AnimatedFocusFadeBorder
|
||||
extends FlatMarginBorder
|
||||
extends AbstractBorder
|
||||
implements AnimatedBorder
|
||||
{
|
||||
// needed because otherwise the empty paint method in superclass
|
||||
@@ -155,6 +155,13 @@ public class FlatAnimatedBorderTest
|
||||
FlatUIUtils.paintComponentBorder( (Graphics2D) g, x, y, width, height, 0, lw, 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Insets getBorderInsets( Component c, Insets insets ) {
|
||||
insets.top = insets.bottom = UIScale.scale( 3 );
|
||||
insets.left = insets.right = UIScale.scale( 7 );
|
||||
return insets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getValue( Component c ) {
|
||||
return FlatUIUtils.isPermanentFocusOwner( c ) ? 1 : 0;
|
||||
@@ -174,7 +181,7 @@ public class FlatAnimatedBorderTest
|
||||
* - animates focus indicator at bottom
|
||||
*/
|
||||
private class AnimatedMaterialBorder
|
||||
extends FlatMarginBorder
|
||||
extends AbstractBorder
|
||||
implements AnimatedBorder
|
||||
{
|
||||
// needed because otherwise the empty paint method in superclass
|
||||
@@ -206,6 +213,20 @@ public class FlatAnimatedBorderTest
|
||||
} );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void repaintBorder( Component c, int x, int y, int width, int height ) {
|
||||
// limit repaint to bottom border
|
||||
int lh = UIScale.scale( 2 );
|
||||
c.repaint( x, y + height - lh, width, lh );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Insets getBorderInsets( Component c, Insets insets ) {
|
||||
insets.top = insets.bottom = UIScale.scale( 3 );
|
||||
insets.left = insets.right = UIScale.scale( 7 );
|
||||
return insets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getValue( Component c ) {
|
||||
return FlatUIUtils.isPermanentFocusOwner( c ) ? 1 : 0;
|
||||
@@ -245,7 +266,7 @@ public class FlatAnimatedBorderTest
|
||||
|
||||
@Override
|
||||
public Insets getBorderInsets( Component c ) {
|
||||
return UIScale.scale( new Insets( 4, 4, 4, 4 ) );
|
||||
return UIScale.scale( new Insets( 3, 7, 3, 7 ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user