bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Add more tools for UI tree traversal

Open villor opened this issue 1 year ago • 0 comments

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_hierarchy module to ui_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] Rename functions for consistency with HierarchyQueryExt
    • [x] get_parent -> parent
    • [x] iter_ui_children -> iter_children
      • Decided against naming it children because it an iterator, rather than a slice like in HierarchyQueryExt.
  • Other renames
    • [x] is_ui_node -> is_ui_entity
      • Motivation: Previous name may indicate that it checks only for Node.
    • [x] is_changed -> children_is_changed
  • Add utilities
    • [x] root_ancestor
    • [x] iter_ancestors
    • [x] iter_descendants
    • [x] iter_descendants_depth_first
    • [ ] iter_leaves
    • [ ] iter_siblings
    • [ ] parent_is_changed
  • 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.

villor avatar Oct 15 '24 10:10 villor