mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-30 23:27:22 +00:00
C++ part of element_ids
Simplify a bit the llr generation so that there is less code duplication between Rust and C++
This commit is contained in:
parent
8add2e4ebd
commit
43a336b534
8 changed files with 95 additions and 39 deletions
|
@ -43,6 +43,23 @@ public:
|
|||
return result;
|
||||
}
|
||||
|
||||
/// Find all elements matching the given element_id.
|
||||
template<typename T>
|
||||
static SharedVector<ElementHandle> find_by_element_id(const ComponentHandle<T> &component,
|
||||
std::string_view element_id)
|
||||
{
|
||||
cbindgen_private::Slice<uint8_t> element_id_view {
|
||||
const_cast<unsigned char *>(reinterpret_cast<const unsigned char *>(element_id.data())),
|
||||
element_id.size()
|
||||
};
|
||||
auto vrc = component.into_dyn();
|
||||
SharedVector<ElementHandle> result;
|
||||
cbindgen_private::slint_testing_element_find_by_element_id(
|
||||
&vrc, &element_id_view,
|
||||
reinterpret_cast<SharedVector<cbindgen_private::ItemWeak> *>(&result));
|
||||
return result;
|
||||
}
|
||||
|
||||
/// Returns true if the underlying element still exists; false otherwise.
|
||||
bool is_valid() const { return private_api::upgrade_item_weak(inner).has_value(); }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue