diff --git a/CHANGELOG.md b/CHANGELOG.md index dee1a67bd..991ca4536 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,7 +25,8 @@ All notable changes to this project will be documented in this file. - Math functions `log`, and `pow` - Property animations now have a `delay` property, which will delay the start of the animation. - - `sixtyfps::VecModel` in Rust now has an `insert(index, value)` function. + - Rust: Added `sixtyfps::VecModel::insert(&self, index, value)`. + - C++: Added `sixtyfps::VecModel::insert(index, value)`. ### Fixed diff --git a/api/sixtyfps-cpp/include/sixtyfps.h b/api/sixtyfps-cpp/include/sixtyfps.h index c63913a2a..430537187 100644 --- a/api/sixtyfps-cpp/include/sixtyfps.h +++ b/api/sixtyfps-cpp/include/sixtyfps.h @@ -595,6 +595,13 @@ public: data.erase(data.begin() + index); this->row_removed(index, 1); } + + /// Inserts the given value as a new row at the specified index + void insert(size_t index, const ModelData &value) + { + data.insert(data.begin() + index, value); + this->row_added(int(index), 1); + } }; namespace private_api { @@ -700,7 +707,8 @@ public: for (std::size_t i = 0; i < inner->data.size(); ++i) { int index = order == TraversalOrder::BackToFront ? i : inner->data.size() - 1 - i; auto ref = item_at(index); - if (ref.vtable->visit_children_item(ref, -1, order, visitor) != std::numeric_limits::max()) { + if (ref.vtable->visit_children_item(ref, -1, order, visitor) + != std::numeric_limits::max()) { return index; } }