mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-03 18:29:09 +00:00
feat: color: add HSV methods to slint
This commit is contained in:
parent
ae2e0197f8
commit
d4a3f77877
11 changed files with 236 additions and 1 deletions
|
@ -48,6 +48,9 @@ pub enum BuiltinFunction {
|
|||
/// the "42".is_float()
|
||||
StringIsFloat,
|
||||
ColorRgbaStruct,
|
||||
ColorHue,
|
||||
ColorSaturation,
|
||||
ColorBrightness,
|
||||
ColorBrighter,
|
||||
ColorDarker,
|
||||
ColorTransparentize,
|
||||
|
@ -56,6 +59,7 @@ pub enum BuiltinFunction {
|
|||
ImageSize,
|
||||
ArrayLength,
|
||||
Rgb,
|
||||
Hsv,
|
||||
ColorScheme,
|
||||
TextInputFocused,
|
||||
SetTextInputFocused,
|
||||
|
@ -86,6 +90,7 @@ pub enum BuiltinMacroFunction {
|
|||
/// The argument can be r,g,b,a or r,g,b and they can be percentages or integer.
|
||||
/// transform the argument so it is always rgb(r, g, b, a) with r, g, b between 0 and 255.
|
||||
Rgb,
|
||||
Hsv,
|
||||
/// transform `debug(a, b, c)` into debug `a + " " + b + " " + c`
|
||||
Debug,
|
||||
}
|
||||
|
@ -169,6 +174,18 @@ impl BuiltinFunction {
|
|||
}),
|
||||
args: vec![Type::Color],
|
||||
},
|
||||
BuiltinFunction::ColorHue => Type::Function {
|
||||
return_type: Box::new(Type::Float32),
|
||||
args: vec![Type::Color],
|
||||
},
|
||||
BuiltinFunction::ColorSaturation => Type::Function {
|
||||
return_type: Box::new(Type::Float32),
|
||||
args: vec![Type::Color],
|
||||
},
|
||||
BuiltinFunction::ColorBrightness => Type::Function {
|
||||
return_type: Box::new(Type::Float32),
|
||||
args: vec![Type::Color],
|
||||
},
|
||||
BuiltinFunction::ColorBrighter => Type::Function {
|
||||
return_type: Box::new(Type::Brush),
|
||||
args: vec![Type::Brush, Type::Float32],
|
||||
|
@ -209,6 +226,10 @@ impl BuiltinFunction {
|
|||
return_type: Box::new(Type::Color),
|
||||
args: vec![Type::Int32, Type::Int32, Type::Int32, Type::Float32],
|
||||
},
|
||||
BuiltinFunction::Hsv => Type::Function {
|
||||
return_type: Box::new(Type::Color),
|
||||
args: vec![Type::Float32, Type::Float32, Type::Float32, Type::Float32],
|
||||
},
|
||||
BuiltinFunction::ColorScheme => Type::Function {
|
||||
return_type: Box::new(Type::Enumeration(
|
||||
crate::typeregister::BUILTIN_ENUMS.with(|e| e.ColorScheme.clone()),
|
||||
|
@ -276,6 +297,9 @@ impl BuiltinFunction {
|
|||
BuiltinFunction::ItemMemberFunction(..) => false,
|
||||
BuiltinFunction::StringToFloat | BuiltinFunction::StringIsFloat => true,
|
||||
BuiltinFunction::ColorRgbaStruct
|
||||
| BuiltinFunction::ColorHue
|
||||
| BuiltinFunction::ColorSaturation
|
||||
| BuiltinFunction::ColorBrightness
|
||||
| BuiltinFunction::ColorBrighter
|
||||
| BuiltinFunction::ColorDarker
|
||||
| BuiltinFunction::ColorTransparentize
|
||||
|
@ -291,6 +315,7 @@ impl BuiltinFunction {
|
|||
BuiltinFunction::ImageSize => false,
|
||||
BuiltinFunction::ArrayLength => true,
|
||||
BuiltinFunction::Rgb => true,
|
||||
BuiltinFunction::Hsv => true,
|
||||
BuiltinFunction::SetTextInputFocused => false,
|
||||
BuiltinFunction::TextInputFocused => false,
|
||||
BuiltinFunction::ImplicitLayoutInfo(_) => false,
|
||||
|
@ -331,6 +356,9 @@ impl BuiltinFunction {
|
|||
BuiltinFunction::ItemMemberFunction(..) => false,
|
||||
BuiltinFunction::StringToFloat | BuiltinFunction::StringIsFloat => true,
|
||||
BuiltinFunction::ColorRgbaStruct
|
||||
| BuiltinFunction::ColorHue
|
||||
| BuiltinFunction::ColorSaturation
|
||||
| BuiltinFunction::ColorBrightness
|
||||
| BuiltinFunction::ColorBrighter
|
||||
| BuiltinFunction::ColorDarker
|
||||
| BuiltinFunction::ColorTransparentize
|
||||
|
@ -339,6 +367,7 @@ impl BuiltinFunction {
|
|||
BuiltinFunction::ImageSize => true,
|
||||
BuiltinFunction::ArrayLength => true,
|
||||
BuiltinFunction::Rgb => true,
|
||||
BuiltinFunction::Hsv => true,
|
||||
BuiltinFunction::ImplicitLayoutInfo(_) => true,
|
||||
BuiltinFunction::ItemAbsolutePosition => true,
|
||||
BuiltinFunction::SetTextInputFocused => false,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue