mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-11 06:27:13 -06:00
UIDefaultsLoader: added if() function (inspired by Less CSS)
This commit is contained in:
@@ -405,6 +405,13 @@ class FlatCompletionProvider
|
||||
setParameterizedCompletionParams( '(', ",", ')' );
|
||||
setParameterChoicesProvider( this );
|
||||
|
||||
addFunction( "if",
|
||||
"condition", "evaluates to true if: is not \"null\" and is not \"false\" and is not an integer with zero value",
|
||||
"trueValue", "used if condition is true",
|
||||
"falseValue", "used if condition is false" );
|
||||
addFunction( "lazy",
|
||||
"uiKey", "UI key (without leading '$')" );
|
||||
|
||||
addFunction( "rgb",
|
||||
"red", "0-255 or 0-100%",
|
||||
"green", "0-255 or 0-100%",
|
||||
|
||||
@@ -51,7 +51,11 @@ public class FlatThemeTokenMaker
|
||||
tokenMap.put( "false", Token.LITERAL_BOOLEAN );
|
||||
tokenMap.put( "true", Token.LITERAL_BOOLEAN );
|
||||
|
||||
// functions
|
||||
// general functions
|
||||
tokenMap.put( "if", TOKEN_FUNCTION );
|
||||
tokenMap.put( "lazy", TOKEN_FUNCTION );
|
||||
|
||||
// color functions
|
||||
tokenMap.put( "rgb", TOKEN_FUNCTION );
|
||||
tokenMap.put( "rgba", TOKEN_FUNCTION );
|
||||
tokenMap.put( "hsl", TOKEN_FUNCTION );
|
||||
@@ -72,7 +76,6 @@ public class FlatThemeTokenMaker
|
||||
tokenMap.put( "tint", TOKEN_FUNCTION );
|
||||
tokenMap.put( "shade", TOKEN_FUNCTION );
|
||||
tokenMap.put( "contrast", TOKEN_FUNCTION );
|
||||
tokenMap.put( "lazy", TOKEN_FUNCTION );
|
||||
|
||||
// function options
|
||||
tokenMap.put( "relative", Token.RESERVED_WORD );
|
||||
|
||||
@@ -29,6 +29,24 @@ Prop.true = true
|
||||
Prop.var = @var1
|
||||
Prop.ref = $Prop.string
|
||||
|
||||
Prop.ifNotNull = if(#000,#0f0,#dfd)
|
||||
Prop.ifNull = if(null,#0f0,#dfd)
|
||||
Prop.ifTrue = if(true,#0f0,#dfd)
|
||||
Prop.ifFalse = if(false,#0f0,#dfd)
|
||||
Prop.ifOne = if(1,#0f0,#dfd)
|
||||
Prop.ifZero = if(0,#0f0,#dfd)
|
||||
@varTrue = true
|
||||
@varFalse = false
|
||||
@varTrueValue = #0f0
|
||||
@varFalseValue = #dfd
|
||||
Prop.ifVarTrue = if(@varTrue,@varTrueValue,@varFalseValue)
|
||||
Prop.ifVarFalse = if(@varFalse,@varTrueValue,@varFalseValue)
|
||||
Prop.ifTrueColorFunc = if(true,lighten(#f00,20%),darken(#f00,20%))
|
||||
Prop.ifFalseColorFunc = if(false,lighten(#f00,20%),darken(#f00,20%))
|
||||
Prop.ifUndefinedVar = if(@undefinedVar,#0f0,#dfd)
|
||||
Prop.ifUndefinedProp = if($undefinedProp,#0f0,#dfd)
|
||||
Prop.ifColor = lighten(if(#000,#0f0,#dfd), 10%)
|
||||
Prop.ifColorVar = lighten(if(@varTrue,@varTrueValue,@varFalseValue), 10%)
|
||||
Prop.lazy = lazy(Prop.string)
|
||||
|
||||
Prop.colorFunc1 = rgb(12,34,56)
|
||||
|
||||
Reference in New Issue
Block a user