mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 10:50:00 +00:00
Add native support for min/max
This commit is contained in:
parent
cc36915241
commit
ef8ddaaa1d
12 changed files with 133 additions and 41 deletions
|
@ -309,7 +309,7 @@ mod cpp_ast {
|
|||
}
|
||||
}
|
||||
|
||||
use crate::expression_tree::{BuiltinFunction, EasingCurve};
|
||||
use crate::expression_tree::{BuiltinFunction, EasingCurve, MinMaxOp};
|
||||
use crate::langtype::{ElementType, Enumeration, EnumerationValue, NativeClass, Type};
|
||||
use crate::layout::Orientation;
|
||||
use crate::llr::{
|
||||
|
@ -2776,6 +2776,21 @@ fn compile_expression(expr: &llr::Expression, ctx: &EvaluationContext) -> String
|
|||
)
|
||||
|
||||
}
|
||||
Expression::MinMax { ty, op, lhs, rhs } => {
|
||||
let ident = match op {
|
||||
MinMaxOp::Min => "min",
|
||||
MinMaxOp::Max => "max",
|
||||
};
|
||||
let lhs_code = compile_expression(lhs, ctx);
|
||||
let rhs_code = compile_expression(rhs, ctx);
|
||||
format!(
|
||||
r#"std::{ident}<{ty}>({lhs_code}, {rhs_code})"#,
|
||||
ty = ty.cpp_type().unwrap_or_default(),
|
||||
ident = ident,
|
||||
lhs_code = lhs_code,
|
||||
rhs_code = rhs_code
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue