mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-02 06:41:14 +00:00
LLR: Fix the repeater indices
This commit is contained in:
parent
9e61d4168b
commit
07ea17fe71
4 changed files with 19 additions and 10 deletions
|
@ -572,8 +572,6 @@ fn generate_sub_component(
|
|||
let mut sub_component_names: Vec<Ident> = vec![];
|
||||
let mut sub_component_types: Vec<Ident> = vec![];
|
||||
|
||||
let mut repeater_count = 0;
|
||||
|
||||
for sub in &component.sub_components {
|
||||
let field_name = ident(&sub.name);
|
||||
let sub_component_id = self::inner_component_id(&sub.ty);
|
||||
|
@ -598,14 +596,14 @@ fn generate_sub_component(
|
|||
|
||||
let sub_component_repeater_count = sub.ty.repeater_count();
|
||||
if sub_component_repeater_count > 0 {
|
||||
let last_repeater: usize = repeater_count + sub_component_repeater_count - 1;
|
||||
let repeater_offset = sub.repeater_offset;
|
||||
let last_repeater: usize = repeater_offset + sub_component_repeater_count - 1;
|
||||
repeated_visit_branch.push(quote!(
|
||||
#repeater_count..=#last_repeater => {
|
||||
Self::FIELD_OFFSETS.#field_name.apply_pin(_self).visit_dynamic_children(dyn_index - #repeater_count, order, visitor)
|
||||
#repeater_offset..=#last_repeater => {
|
||||
Self::FIELD_OFFSETS.#field_name.apply_pin(_self).visit_dynamic_children(dyn_index - #repeater_offset, order, visitor)
|
||||
}
|
||||
));
|
||||
}
|
||||
repeater_count += sub_component_repeater_count;
|
||||
|
||||
sub_component_names.push(field_name);
|
||||
sub_component_types.push(sub_component_id);
|
||||
|
@ -851,7 +849,12 @@ fn generate_item_tree(
|
|||
let (path, component) = follow_sub_component_path(&sub_tree.root, &node.sub_component_path);
|
||||
if node.repeated {
|
||||
assert_eq!(node.children.len(), 0);
|
||||
let repeater_index = node.item_index;
|
||||
let mut repeater_index = node.item_index;
|
||||
let mut sub_component = &sub_tree.root;
|
||||
for i in &node.sub_component_path {
|
||||
repeater_index += sub_component.sub_components[*i].repeater_offset;
|
||||
sub_component = &sub_component.sub_components[*i].ty;
|
||||
}
|
||||
item_tree_array.push(quote!(
|
||||
sixtyfps::re_exports::ItemTreeNode::DynamicTree {
|
||||
index: #repeater_index,
|
||||
|
|
|
@ -255,7 +255,7 @@ impl Expression {
|
|||
Self::Condition { true_expr, .. } => true_expr.ty(ctx),
|
||||
Self::Array { element_ty, .. } => Type::Array(element_ty.clone().into()),
|
||||
Self::Struct { ty, .. } => ty.clone(),
|
||||
Self::PathEvents { .. } => todo!(),
|
||||
Self::PathEvents { .. } => Type::PathData,
|
||||
Self::EasingCurve(_) => Type::Easing,
|
||||
Self::LinearGradient { .. } => Type::Brush,
|
||||
Self::EnumerationValue(e) => Type::Enumeration(e.enumeration.clone()),
|
||||
|
|
|
@ -198,7 +198,7 @@ pub struct SubComponentInstance {
|
|||
pub ty: Rc<SubComponent>,
|
||||
pub name: String,
|
||||
pub index_in_tree: usize,
|
||||
//pub property_values: Vec<(PropertyReference, BindingExpression)>,
|
||||
pub repeater_offset: usize,
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for SubComponentInstance {
|
||||
|
|
|
@ -201,6 +201,7 @@ fn lower_sub_component(
|
|||
};
|
||||
|
||||
let s: Option<ElementRc> = None;
|
||||
let mut repeater_offset = 0;
|
||||
crate::object_tree::recurse_elem(&component.root_element, &s, &mut |element, parent| {
|
||||
let elem = element.borrow();
|
||||
for (p, x) in &elem.property_declarations {
|
||||
|
@ -246,10 +247,12 @@ fn lower_sub_component(
|
|||
property_bindings.push((prop_ref.unwrap(), b.borrow().clone()));
|
||||
}
|
||||
sub_component.sub_components.push(SubComponentInstance {
|
||||
ty,
|
||||
ty: ty.clone(),
|
||||
name: elem.id.clone(),
|
||||
index_in_tree: *elem.item_index.get().unwrap(),
|
||||
repeater_offset,
|
||||
});
|
||||
repeater_offset += ty.repeater_count();
|
||||
}
|
||||
|
||||
Type::Native(n) => {
|
||||
|
@ -307,6 +310,9 @@ fn lower_sub_component(
|
|||
}
|
||||
sub_component.repeated =
|
||||
repeated.into_iter().map(|elem| lower_repeated_component(&elem, &ctx)).collect();
|
||||
for s in &mut sub_component.sub_components {
|
||||
s.repeater_offset += sub_component.repeated.len();
|
||||
}
|
||||
sub_component.popup_windows = component
|
||||
.popup_windows
|
||||
.borrow()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue