Skip to content

Anonymous ghost nodes #17908

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 31 commits into
base: main
Choose a base branch
from
Draft

Conversation

ickshonpe
Copy link
Contributor

@ickshonpe ickshonpe commented Feb 17, 2025

Objective

Another GhostNode alternative:

  • Remove the GhostNode component.
  • When we walk the tree to update nodes just ignore any entities in the hierarchy that don't have a Node component
  • Don't use the Transform with the UI. Instead have fields on Node for translation, rotation and scaling. Propagate them after updating the layout during the update for ComputedNodes. Same with Visibility.

Solution

This removes the ability to have root ghost nodes, because without a ghost node marker component we can't query using a With<GhostNode>, Without<ChildOf> filter.

There are lots of warnings, probably have to replace the GlobalTranform and Visibility components with UI specific types to fix them. But otherwise it seems to work. Some weird problems with the imports too.

* Required `GlobalTransform` instead of `Transform` on `Node`.
* Update node's global transforms during layout updates.
Give every entity in the UI hierarchy a `UiElement` marker component and, if the "ghost_nodes" feature is enabled, implement the `Ghost` trait for `UiElement`
* `Ghost` to `GhostNode`
* `UiElement` to `UiNode`
* `Ghost::Completion` to `GhostNode::Actual`

Both system param impl changes:
* `iter_ui_children` to `iter_actual_actual_children`
* `is_ui_node` to `is_actual_node`

The `experimental` module now only contains the `GhostNode` trait and it's implementation. It works with any hierarchy now, not just UI nodes.

The "ghost_nodes" feature gate and UI specfic navigation implementation has been moved to a new `navigation` module.
Replaced ghost nodes `SystemParam` with a `FlattenChildren<N>` system param
that goes down the tree searching for the descendant child on each branch with an `N` component.
@ickshonpe ickshonpe added the A-UI Graphical user interfaces, styles, layouts, and widgets label Feb 17, 2025
@ickshonpe ickshonpe marked this pull request as draft February 17, 2025 23:18
@ickshonpe ickshonpe added the A-ECS Entities, components, systems, and events label Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events A-UI Graphical user interfaces, styles, layouts, and widgets
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant