mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 10:50:00 +00:00
ListView: adapt the viewport's width based on the minimum-width of delegate
(Instead of their `width` property)
This commit is contained in:
parent
7e37f19e2c
commit
2df0b8bf20
8 changed files with 24 additions and 24 deletions
|
@ -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()
|
||||
}),
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -132,8 +132,6 @@ pub struct ListViewInfo {
|
|||
// In the repeated component context
|
||||
pub prop_y: PropertyReference,
|
||||
// In the repeated component context
|
||||
pub prop_width: PropertyReference,
|
||||
// In the repeated component context
|
||||
pub prop_height: PropertyReference,
|
||||
}
|
||||
|
||||
|
|
|
@ -655,7 +655,6 @@ fn lower_repeated_component(
|
|||
listview_height: ctx.map_property_reference(&lv.listview_height),
|
||||
listview_width: ctx.map_property_reference(&lv.listview_width),
|
||||
prop_y: sc.mapping.map_property_reference(&geom.y, ctx.state),
|
||||
prop_width: sc.mapping.map_property_reference(&geom.width, ctx.state),
|
||||
prop_height: sc.mapping.map_property_reference(&geom.height, ctx.state),
|
||||
});
|
||||
|
||||
|
|
|
@ -79,7 +79,6 @@ pub fn count_property_use(root: &CompilationUnit) {
|
|||
Some(ParentCtx::new(ctx, Some(idx as u32))),
|
||||
);
|
||||
visit_property(&lv.prop_y, &rep_ctx);
|
||||
visit_property(&lv.prop_width, &rep_ctx);
|
||||
visit_property(&lv.prop_height, &rep_ctx);
|
||||
}
|
||||
for idx in r.data_prop.iter().chain(r.index_prop.iter()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue