UIDefaultsDump: output base color used for resolving derived color

This commit is contained in:
Karl Tauber
2022-01-03 18:46:56 +01:00
parent 5c4706cbc9
commit 8c891c7016
2 changed files with 12 additions and 7 deletions

View File

@@ -21,8 +21,9 @@
# a variable base color (usually the current background color of a component). # a variable base color (usually the current background color of a component).
# This works only for a limited set of UI keys. # This works only for a limited set of UI keys.
# #
# The property key is the UI key of a color, which is computed at runtime. # In this properties file:
# The property value is the UI key of the base color. # - The property key is the UI key of a color, which is computed at runtime.
# - The property value is the UI key of the base color.
# #
# This file is not used at runtime. # This file is not used at runtime.
# It is only used in tooling (e.g. UI Defaults Inspector or UIDefaultsDump). # It is only used in tooling (e.g. UI Defaults Inspector or UIDefaultsDump).

View File

@@ -458,12 +458,14 @@ public class UIDefaultsDump
} }
private void dumpColor( PrintWriter out, String key, Color color ) { private void dumpColor( PrintWriter out, String key, Color color ) {
Color resolvedColor = resolveDerivedColor( key, color ); Color[] retBaseColor = new Color[1];
Color resolvedColor = resolveDerivedColor( key, color, retBaseColor );
if( resolvedColor != color && resolvedColor.getRGB() != color.getRGB() ) { if( resolvedColor != color && resolvedColor.getRGB() != color.getRGB() ) {
if( !isIntelliJTheme ) { if( !isIntelliJTheme ) {
System.err.println( "Key '" + key + "': derived colors not equal" ); System.err.println( "Key '" + key + "': derived colors not equal" );
System.err.println( " Default color: " + dumpColorHexAndHSL( color ) ); System.err.println( " Default color: " + dumpColorHexAndHSL( color ) );
System.err.println( " Resolved color: " + dumpColorHexAndHSL( resolvedColor ) ); System.err.println( " Resolved color: " + dumpColorHexAndHSL( resolvedColor ) );
System.err.println( " Base of resolved color: " + dumpColorHexAndHSL( retBaseColor[0] ) );
} }
out.printf( "%s / ", out.printf( "%s / ",
@@ -672,7 +674,7 @@ public class UIDefaultsDump
return properties; return properties;
} }
private Color resolveDerivedColor( String key, Color color ) { private Color resolveDerivedColor( String key, Color color, Color[] retBaseColor ) {
if( !(color instanceof DerivedColor) ) if( !(color instanceof DerivedColor) )
return color; return color;
@@ -693,7 +695,9 @@ public class UIDefaultsDump
throw new IllegalStateException( "Missing base color '" + baseKey + "' for key '" + key + "'." ); throw new IllegalStateException( "Missing base color '" + baseKey + "' for key '" + key + "'." );
if( baseColor instanceof DerivedColor ) if( baseColor instanceof DerivedColor )
baseColor = resolveDerivedColor( (String) baseKey, baseColor ); baseColor = resolveDerivedColor( (String) baseKey, baseColor, retBaseColor );
retBaseColor[0] = baseColor;
Color newColor = FlatUIUtils.deriveColor( color, baseColor ); Color newColor = FlatUIUtils.deriveColor( color, baseColor );