mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-12 23:07:15 -06:00
Styling: fixed resolving of UI variables in styles that use other variables
This commit is contained in:
@@ -334,7 +334,7 @@ class UIDefaultsLoader
|
||||
if( newValue == null )
|
||||
throw new IllegalArgumentException( "variable '" + value + "' not found" );
|
||||
|
||||
return newValue;
|
||||
return resolveValueFromUIManager( newValue );
|
||||
}
|
||||
|
||||
if( !value.startsWith( PROPERTY_PREFIX ) )
|
||||
|
||||
@@ -29,6 +29,7 @@ import javax.swing.table.JTableHeader;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import com.formdev.flatlaf.FlatLaf;
|
||||
import com.formdev.flatlaf.icons.*;
|
||||
import com.formdev.flatlaf.util.ColorFunctions;
|
||||
|
||||
@@ -39,12 +40,20 @@ public class TestFlatStyling
|
||||
{
|
||||
@BeforeAll
|
||||
static void setup() {
|
||||
HashMap<String, String> globalExtraDefaults = new HashMap<>();
|
||||
globalExtraDefaults.put( "@var1", "#f00" );
|
||||
globalExtraDefaults.put( "@var2", "@var1" );
|
||||
globalExtraDefaults.put( "var2Resolved", "@var2" );
|
||||
FlatLaf.setGlobalExtraDefaults( globalExtraDefaults );
|
||||
|
||||
TestUtils.setup( false );
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
static void cleanup() {
|
||||
TestUtils.cleanup();
|
||||
|
||||
FlatLaf.setGlobalExtraDefaults( null );
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -171,6 +180,13 @@ public class TestFlatStyling
|
||||
"saturate(darken(@background,20%),10%)" );
|
||||
}
|
||||
|
||||
@Test
|
||||
void parseRecursiveVariables() {
|
||||
Color background = UIManager.getColor( "var2Resolved" );
|
||||
|
||||
testColorStyle( background.getRGB(), "@var2" );
|
||||
}
|
||||
|
||||
private void testColorStyle( int expectedRGB, String style ) {
|
||||
testStyle( "background", new Color( expectedRGB, (expectedRGB & 0xff000000) != 0 ), style );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user