bevy/examples/ui
ickshonpe c5742ff43e
Simplified ui_stack_system (#9889)
# Objective

`ui_stack_system` generates a tree of `StackingContexts` which it then
flattens to get the `UiStack`.

But there's no need to construct a new tree. We can query for nodes with
a global `ZIndex`, add those nodes to the root nodes list and then build
the `UiStack` from a walk of the existing layout tree, ignoring any
branches that have a global `Zindex`.

Fixes #9877

## Solution

Split the `ZIndex` enum into two separate components, `ZIndex` and
`GlobalZIndex`

Query for nodes with a `GlobalZIndex`, add those nodes to the root nodes
list and then build the `UiStack` from a walk of the existing layout
tree, filtering branches by `Without<GlobalZIndex>` so we don't revisit
nodes.

```
cargo run --profile stress-test --features trace_tracy --example many_buttons
```

<img width="672" alt="ui-stack-system-walk-split-enum"
src="https://github.com/bevyengine/bevy/assets/27962798/11e357a5-477f-4804-8ada-c4527c009421">

(Yellow is this PR, red is main)

---

## Changelog
`Zindex`
* The `ZIndex` enum has been split into two separate components `ZIndex`
(which replaces `ZIndex::Local`) and `GlobalZIndex` (which replaces
`ZIndex::Global`). An entity can have both a `ZIndex` and
`GlobalZIndex`, in comparisons `ZIndex` breaks ties if two
`GlobalZIndex` values are equal.

`ui_stack_system`
* Instead of generating a tree of `StackingContexts`, query for nodes
with a `GlobalZIndex`, add those nodes to the root nodes list and then
build the `UiStack` from a walk of the existing layout tree, filtering
branches by `Without<GlobalZIndex` so we don't revisit nodes.

## Migration Guide

The `ZIndex` enum has been split into two separate components `ZIndex`
(which replaces `ZIndex::Local`) and `GlobalZIndex` (which replaces
`ZIndex::Global`). An entity can have both a `ZIndex` and
`GlobalZIndex`, in comparisons `ZIndex` breaks ties if two
`GlobalZindex` values are equal.

---------

Co-authored-by: Gabriel Bourgeois <gabriel.bourgeoisv4si@gmail.com>
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
Co-authored-by: UkoeHB <37489173+UkoeHB@users.noreply.github.com>
2024-09-30 18:43:57 +00:00
..
borders.rs use precomputed border values (#15163) 2024-09-26 23:10:35 +00:00
button.rs Fixing text sizes for examples (#15190) 2024-09-16 23:14:37 +00:00
display_and_visibility.rs Simpler lint fixes: makes ci lints work but disables a lint for now (#15376) 2024-09-24 11:42:59 +00:00
flex_layout.rs Omit font size where it closely matches the default in examples (#13952) 2024-06-20 21:01:28 +00:00
font_atlas_debug.rs Fixing text sizes for examples (#15190) 2024-09-16 23:14:37 +00:00
grid.rs Fixing text sizes for examples (#15190) 2024-09-16 23:14:37 +00:00
overflow_debug.rs Add core and alloc over std Lints (#15281) 2024-09-27 00:59:59 +00:00
overflow.rs Updates default Text font size to 24px (#13603) 2024-05-31 16:41:27 +00:00
relative_cursor_position.rs Fixing text sizes for examples (#15190) 2024-09-16 23:14:37 +00:00
render_ui_to_texture.rs Broaden "Check for bevy_internal imports" CI Task (#15333) 2024-09-20 17:08:37 +00:00
scroll.rs Simpler lint fixes: makes ci lints work but disables a lint for now (#15376) 2024-09-24 11:42:59 +00:00
size_constraints.rs Fixing text sizes for examples (#15190) 2024-09-16 23:14:37 +00:00
text_debug.rs Rename push children to add children (#15196) 2024-09-16 23:16:04 +00:00
text_wrap_debug.rs Simpler lint fixes: makes ci lints work but disables a lint for now (#15376) 2024-09-24 11:42:59 +00:00
text.rs Fix floating point math (#15239) 2024-09-16 23:28:12 +00:00
transparency_ui.rs Fixing text sizes for examples (#15190) 2024-09-16 23:14:37 +00:00
ui_material.rs Simpler lint fixes: makes ci lints work but disables a lint for now (#15376) 2024-09-24 11:42:59 +00:00
ui_scaling.rs Fix floating point math (#15239) 2024-09-16 23:28:12 +00:00
ui_texture_atlas_slice.rs Fixing text sizes for examples (#15190) 2024-09-16 23:14:37 +00:00
ui_texture_atlas.rs Make default behavior for BackgroundColor and BorderColor more intuitive (#14017) 2024-06-25 21:50:41 +00:00
ui_texture_slice_flip_and_tile.rs fix imports in example ui_texture_slice_flip_and_tile (#15064) 2024-09-06 06:00:43 +00:00
ui_texture_slice.rs Fixing text sizes for examples (#15190) 2024-09-16 23:14:37 +00:00
ui.rs UI Scrolling (#15291) 2024-09-23 17:17:58 +00:00
viewport_debug.rs Fix green colors becoming darker in various examples (#12328) 2024-03-05 23:42:03 +00:00
window_fallthrough.rs Fixing text sizes for examples (#15190) 2024-09-16 23:14:37 +00:00
z_index.rs Simplified ui_stack_system (#9889) 2024-09-30 18:43:57 +00:00