ListView: adapt the viewport's width based on the minimum-width of delegate

(Instead of their `width` property)
This commit is contained in:
Olivier Goffart 2025-01-21 13:23:26 +01:00
parent 7e37f19e2c
commit 2df0b8bf20
8 changed files with 24 additions and 24 deletions

View file

@ -2487,7 +2487,6 @@ fn generate_repeated_component(
if let Some(listview) = &repeated.listview {
let p_y = access_member(&listview.prop_y, &ctx);
let p_height = access_member(&listview.prop_height, &ctx);
let p_width = access_member(&listview.prop_width, &ctx);
repeater_struct.members.push((
Access::Public, // Because Repeater accesses it
@ -2498,7 +2497,7 @@ fn generate_repeated_component(
"[[maybe_unused]] auto self = this;".into(),
format!("{}.set(*offset_y);", p_y),
format!("*offset_y += {}.get();", p_height),
format!("return {}.get();", p_width),
"return layout_info({&static_vtable, const_cast<void *>(static_cast<const void *>(this))}, slint::cbindgen_private::Orientation::Horizontal).min;".into(),
]),
..Function::default()
}),

View file

@ -1768,16 +1768,15 @@ fn generate_repeated_component(
let extra_fn = if let Some(listview) = &repeated.listview {
let p_y = access_member(&listview.prop_y, &ctx).unwrap();
let p_height = access_member(&listview.prop_height, &ctx).unwrap();
let p_width = access_member(&listview.prop_width, &ctx).unwrap();
quote! {
fn listview_layout(
self: core::pin::Pin<&Self>,
self: ::core::pin::Pin<&Self>,
offset_y: &mut sp::LogicalLength,
) -> sp::LogicalLength {
let _self = self;
#p_y.set(*offset_y);
*offset_y += #p_height.get();
#p_width.get()
sp::LogicalLength::new(self.as_ref().layout_info(sp::Orientation::Horizontal).min)
}
}
} else {