Support default-font-* properties in Live-Preview

... by changing the resolution for the `WindowItem` to traverse the
item tree from the current item, instead of going to the window.

This doesn't quite fix #4298 because `rem` resolution is still missing.
That requires the built-in default font size function to be fixed as
well, which is non-trivial.

cc #4298
This commit is contained in:
Simon Hausmann 2024-12-03 14:37:55 +01:00 committed by Simon Hausmann
parent 7c02bbd833
commit eb825f2e95
32 changed files with 189 additions and 86 deletions

View file

@ -3916,13 +3916,15 @@ fn compile_builtin_function_call(
BuiltinFunction::ImplicitLayoutInfo(orient) => {
if let [llr::Expression::PropertyReference(pr)] = arguments {
let native = native_prop_info(pr, ctx).0;
let item_rc = access_item_rc(pr, ctx);
format!(
"{vt}->layout_info({{{vt}, const_cast<slint::cbindgen_private::{ty}*>(&{i})}}, {o}, &{window})",
"slint::private_api::item_layout_info({vt}, const_cast<slint::cbindgen_private::{ty}*>(&{i}), {o}, &{window}, {item_rc})",
vt = native.cpp_vtable_getter,
ty = native.class_name,
o = to_cpp_orientation(orient),
i = access_member(pr, ctx),
window = access_window_field(ctx)
window = access_window_field(ctx),
item_rc = item_rc
)
} else {
panic!("internal error: invalid args to ImplicitLayoutInfo {arguments:?}")

View file

@ -2909,10 +2909,11 @@ fn compile_builtin_function_call(
BuiltinFunction::ItemFontMetrics => {
if let [Expression::PropertyReference(pr)] = arguments {
let item = access_member(pr, ctx);
let item_rc = access_item_rc(pr, ctx);
let window_adapter_tokens = access_window_adapter_field(ctx);
item.then(|item| {
quote!(
#item.font_metrics(#window_adapter_tokens)
#item.font_metrics(#window_adapter_tokens, #item_rc)
)
})
} else {
@ -2924,8 +2925,9 @@ fn compile_builtin_function_call(
let item = access_member(pr, ctx);
let window_adapter_tokens = access_window_adapter_field(ctx);
item.then(|item| {
let item_rc = access_item_rc(pr, ctx);
quote!(
sp::Item::layout_info(#item, #orient, #window_adapter_tokens)
sp::Item::layout_info(#item, #orient, #window_adapter_tokens, &#item_rc)
)
})
} else {