mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-06 14:00:55 +03:00
Styling: fixed resolving of UI variables in styles that use other variables
This commit is contained in:
@@ -5,8 +5,8 @@ FlatLaf Change Log
|
|||||||
|
|
||||||
#### New features and improvements
|
#### New features and improvements
|
||||||
|
|
||||||
- Fonts: Added **Roboto
|
- Fonts: Added **Roboto Mono** (https://fonts.google.com/specimen/Roboto+Mono).
|
||||||
Mono** (https://fonts.google.com/specimen/Roboto+Mono). (PR #639, issue #638)
|
(PR #639, issue #638)
|
||||||
|
|
||||||
#### Fixed bugs
|
#### Fixed bugs
|
||||||
|
|
||||||
@@ -20,6 +20,7 @@ FlatLaf Change Log
|
|||||||
#628)
|
#628)
|
||||||
- Avoid that accent color affect some colors in some IntelliJ themes. (issue
|
- Avoid that accent color affect some colors in some IntelliJ themes. (issue
|
||||||
#625)
|
#625)
|
||||||
|
- Styling: Fixed resolving of UI variables in styles that use other variables.
|
||||||
|
|
||||||
|
|
||||||
## 3.0
|
## 3.0
|
||||||
|
|||||||
@@ -334,7 +334,7 @@ class UIDefaultsLoader
|
|||||||
if( newValue == null )
|
if( newValue == null )
|
||||||
throw new IllegalArgumentException( "variable '" + value + "' not found" );
|
throw new IllegalArgumentException( "variable '" + value + "' not found" );
|
||||||
|
|
||||||
return newValue;
|
return resolveValueFromUIManager( newValue );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !value.startsWith( PROPERTY_PREFIX ) )
|
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.AfterAll;
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import com.formdev.flatlaf.FlatLaf;
|
||||||
import com.formdev.flatlaf.icons.*;
|
import com.formdev.flatlaf.icons.*;
|
||||||
import com.formdev.flatlaf.util.ColorFunctions;
|
import com.formdev.flatlaf.util.ColorFunctions;
|
||||||
|
|
||||||
@@ -39,12 +40,20 @@ public class TestFlatStyling
|
|||||||
{
|
{
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
static void setup() {
|
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 );
|
TestUtils.setup( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterAll
|
@AfterAll
|
||||||
static void cleanup() {
|
static void cleanup() {
|
||||||
TestUtils.cleanup();
|
TestUtils.cleanup();
|
||||||
|
|
||||||
|
FlatLaf.setGlobalExtraDefaults( null );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -171,6 +180,13 @@ public class TestFlatStyling
|
|||||||
"saturate(darken(@background,20%),10%)" );
|
"saturate(darken(@background,20%),10%)" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void parseRecursiveVariables() {
|
||||||
|
Color background = UIManager.getColor( "var2Resolved" );
|
||||||
|
|
||||||
|
testColorStyle( background.getRGB(), "@var2" );
|
||||||
|
}
|
||||||
|
|
||||||
private void testColorStyle( int expectedRGB, String style ) {
|
private void testColorStyle( int expectedRGB, String style ) {
|
||||||
testStyle( "background", new Color( expectedRGB, (expectedRGB & 0xff000000) != 0 ), style );
|
testStyle( "background", new Color( expectedRGB, (expectedRGB & 0xff000000) != 0 ), style );
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user