bevy
bevy copied to clipboard
Add more tools for UI tree traversal
Objective
- Stage two of #15609
- Extends the UI traversal utilities and updates the API signature for feature parity/consistency with
HierarchyQueryExt.
Solution
- [x] Rename module and SystemParam
- [x]
ghost_hierarchymodule toui_tree- Motivation: This is no longer just about ghost nodes. The utilities also help traversing only UI nodes when there can be other entities beneath the UI tree, like text nodes.
- [x]
UiChildren->UiTree- Motivation: The utilities are no longer just about children, but the whole UI tree.
- [x]
- [x] Rename functions for consistency with
HierarchyQueryExt- [x]
get_parent->parent - [x]
iter_ui_children->iter_children- Decided against naming it
childrenbecause it an iterator, rather than a slice like inHierarchyQueryExt.
- Decided against naming it
- [x]
- Other renames
- [x]
is_ui_node->is_ui_entity- Motivation: Previous name may indicate that it checks only for
Node.
- Motivation: Previous name may indicate that it checks only for
- [x]
is_changed->children_is_changed
- [x]
- Add utilities
- [x]
root_ancestor - [x]
iter_ancestors - [x]
iter_descendants - [x]
iter_descendants_depth_first - [ ]
iter_leaves - [ ]
iter_siblings - [ ]
parent_is_changed
- [x]
- Bonus utilities
- [ ]
is_root - [ ]
is_leaf - [ ]
child_index- The index of a child among its siblings
- [ ]
Testing
- Added more unit tests for the new utilities
Migration Guide
- TODO: Only breaks some code relying on main (because of the renames). If merged before 0.15 release, there will be no breaking changes coming from 0.14 since these APIs are new to 0.15.