Styling: support styling for recently merged changes

This commit is contained in:
Karl Tauber
2021-08-31 16:12:03 +02:00
parent 9118dcf925
commit b12c818862
3 changed files with 69 additions and 6 deletions

View File

@@ -22,10 +22,13 @@ import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Line2D;
import java.awt.geom.Path2D;
import java.util.Map;
import javax.swing.AbstractButton;
import javax.swing.ButtonModel;
import javax.swing.UIManager;
import com.formdev.flatlaf.ui.FlatStyleSupport;
import com.formdev.flatlaf.ui.FlatUIUtils;
import com.formdev.flatlaf.ui.FlatStyleSupport.Styleable;
/**
* "clear" icon for search fields.
@@ -40,14 +43,28 @@ import com.formdev.flatlaf.ui.FlatUIUtils;
public class FlatClearIcon
extends FlatAbstractIcon
{
protected Color clearIconColor = UIManager.getColor( "SearchField.clearIconColor" );
protected Color clearIconHoverColor = UIManager.getColor( "SearchField.clearIconHoverColor" );
protected Color clearIconPressedColor = UIManager.getColor( "SearchField.clearIconPressedColor" );
@Styleable protected Color clearIconColor = UIManager.getColor( "SearchField.clearIconColor" );
@Styleable protected Color clearIconHoverColor = UIManager.getColor( "SearchField.clearIconHoverColor" );
@Styleable protected Color clearIconPressedColor = UIManager.getColor( "SearchField.clearIconPressedColor" );
public FlatClearIcon() {
super( 16, 16, null );
}
/**
* @since TODO
*/
public Object applyStyleProperty( String key, Object value ) {
return FlatStyleSupport.applyToAnnotatedObject( this, key, value );
}
/**
* @since TODO
*/
public Map<String, Class<?>> getStyleableInfos() {
return FlatStyleSupport.getAnnotatedStyleableInfos( this );
}
@Override
protected void paintIcon( Component c, Graphics2D g ) {
if( c instanceof AbstractButton ) {

View File

@@ -21,9 +21,12 @@ import java.awt.Component;
import java.awt.Graphics2D;
import java.awt.geom.Area;
import java.awt.geom.Ellipse2D;
import java.util.Map;
import javax.swing.UIManager;
import com.formdev.flatlaf.ui.FlatButtonUI;
import com.formdev.flatlaf.ui.FlatStyleSupport;
import com.formdev.flatlaf.ui.FlatUIUtils;
import com.formdev.flatlaf.ui.FlatStyleSupport.Styleable;
/**
* "search" icon for search fields.
@@ -38,14 +41,28 @@ import com.formdev.flatlaf.ui.FlatUIUtils;
public class FlatSearchIcon
extends FlatAbstractIcon
{
protected Color searchIconColor = UIManager.getColor( "SearchField.searchIconColor" );
protected Color searchIconHoverColor = UIManager.getColor( "SearchField.searchIconHoverColor" );
protected Color searchIconPressedColor = UIManager.getColor( "SearchField.searchIconPressedColor" );
@Styleable protected Color searchIconColor = UIManager.getColor( "SearchField.searchIconColor" );
@Styleable protected Color searchIconHoverColor = UIManager.getColor( "SearchField.searchIconHoverColor" );
@Styleable protected Color searchIconPressedColor = UIManager.getColor( "SearchField.searchIconPressedColor" );
public FlatSearchIcon() {
super( 16, 16, null );
}
/**
* @since TODO
*/
public Object applyStyleProperty( String key, Object value ) {
return FlatStyleSupport.applyToAnnotatedObject( this, key, value );
}
/**
* @since TODO
*/
public Map<String, Class<?>> getStyleableInfos() {
return FlatStyleSupport.getAnnotatedStyleableInfos( this );
}
@Override
protected void paintIcon( Component c, Graphics2D g ) {
/*

View File

@@ -976,4 +976,33 @@ public class TestFlatStyling
icon.applyStyleProperty( "questionMarkColor", Color.WHITE );
icon.applyStyleProperty( "disabledQuestionMarkColor", Color.WHITE );
}
@Test
void flatClearIcon() {
FlatClearIcon icon = new FlatClearIcon();
icon.applyStyleProperty( "clearIconColor", Color.WHITE );
icon.applyStyleProperty( "clearIconHoverColor", Color.WHITE );
icon.applyStyleProperty( "clearIconPressedColor", Color.WHITE );
}
@Test
void flatSearchIcon() {
FlatSearchIcon icon = new FlatSearchIcon();
flatSearchIcon( icon );
}
@Test
void flatSearchWithHistoryIcon() {
FlatSearchWithHistoryIcon icon = new FlatSearchWithHistoryIcon();
flatSearchIcon( icon );
}
private void flatSearchIcon( FlatSearchIcon icon ) {
icon.applyStyleProperty( "searchIconColor", Color.WHITE );
icon.applyStyleProperty( "searchIconHoverColor", Color.WHITE );
icon.applyStyleProperty( "searchIconPressedColor", Color.WHITE );
}
}