mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 10:50:00 +00:00
Make conversion from float to int property truncate
- Make sure that in Rust and C++ we also truncate if the properties are
inlined
- Change the interpreter to truncate
This is a redo of commit f5d003d
but truncate instead of round
fixes #5689
This commit is contained in:
parent
8e51563609
commit
51481b101c
6 changed files with 59 additions and 9 deletions
|
@ -2768,11 +2768,14 @@ fn compile_expression(expr: &llr::Expression, ctx: &EvaluationContext) -> String
|
|||
Expression::Cast { from, to } => {
|
||||
let f = compile_expression(from, ctx);
|
||||
match (from.ty(ctx), to) {
|
||||
(Type::Float32, Type::Int32) => {
|
||||
format!("static_cast<int>({f})")
|
||||
}
|
||||
(from, Type::String) if from.as_unit_product().is_some() => {
|
||||
format!("slint::SharedString::from_number({})", f)
|
||||
}
|
||||
(Type::Float32, Type::Model) | (Type::Int32, Type::Model) => {
|
||||
format!("std::make_shared<slint::private_api::UIntModel>(std::max(0, {}))", f)
|
||||
format!("std::make_shared<slint::private_api::UIntModel>(std::max<int>(0, {}))", f)
|
||||
}
|
||||
(Type::Array(_), Type::Model) => f,
|
||||
(Type::Float32, Type::Color) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue