WIP: formatting implementation of translate in rust and C++

This commit is contained in:
Olivier Goffart 2023-04-18 15:47:14 +02:00 committed by Olivier Goffart
parent a3855f1bcb
commit cf746ddf8d
8 changed files with 80 additions and 4 deletions

View file

@ -16,7 +16,7 @@ use std::rc::{Rc, Weak};
pub use crate::namedreference::NamedReference;
pub use crate::passes::resolving;
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq, Eq)]
/// A function built into the run-time
pub enum BuiltinFunction {
GetWindowScaleFactor,

View file

@ -2834,7 +2834,7 @@ fn compile_builtin_function_call(
}
}
BuiltinFunction::Translate => {
format!("slint::private_api::translate({});", a.join(","))
format!("slint::private_api::translate({})", a.join(","))
}
}
}

View file

@ -2442,7 +2442,7 @@ fn compile_builtin_function_call(
quote!(slint::private_unstable_api::re_exports::WindowInner::from_pub(#window_adapter_tokens.window()).set_text_input_focused(#(#a)*))
}
BuiltinFunction::Translate => {
todo!("BuiltinFunction::Translate in rust")
quote!(slint::private_unstable_api::translate(#(#a),*))
}
}
}

View file

@ -117,7 +117,13 @@ pub fn lower_expression(
lower_show_popup(arguments, ctx)
}
tree_Expression::BuiltinFunctionReference(f, _) => {
let arguments = arguments.iter().map(|e| lower_expression(e, ctx)).collect::<_>();
let mut arguments =
arguments.iter().map(|e| lower_expression(e, ctx)).collect::<Vec<_>>();
if *f == BuiltinFunction::Translate {
if let llr_Expression::Array { as_model, .. } = &mut arguments[3] {
*as_model = false;
}
}
llr_Expression::BuiltinFunctionCall { function: f.clone(), arguments }
}
tree_Expression::CallbackReference(nr, _) => {