Skip to content
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

Remove ZIndex::Global #9877

Closed
wants to merge 7 commits into from

Conversation

ickshonpe
Copy link
Contributor

Objective

Remove ZIndex::Global

Fixes #9875

Solution

Change the ZIndex enum into a tuple struct wrapping an i32. This value represents the local z index, replacing what was ZIndex::Local.

ui_stack_system updates UiStack in a single walk of the layout tree.

ui_stack_system benchmark (Yellow is this PR):

cargo run --release --features trace_tracy --example many_buttons -- --no-text --no-borders
stack_system_walk

Changelog

  • ZIndex::Global is removed.
  • ZIndex is now a tuple struct wrapping an i32. This value represents the local z index, replacing what was ZIndex::Local.
    ui_stack_system updates UiStack in a single walk of the layout tree.

Migration Guide

ZIndex is now an 'i32tuple struct. This value represents the local z index, replacing what wasZIndex::Local. ZIndex::Global` has been removed.

* `ZIndex` is now a tuple struct wrapping an `i32`. This value represents the local z index, replacing what was `ZIndex::Local`.
* `ui_stack_system` does its update during a walk of the layout tree .
Fixed formatting.
@james7132
Copy link
Member

This partially reverts #5877. Does #9637 address the issues @oceantume was running into so that this PR doesn't become a regression?

@oceantume
Copy link
Contributor

oceantume commented Sep 20, 2023

This partially reverts #5877. Does #9637 address the issues @oceantume was running into so that this PR doesn't become a regression?

I went over the PR text quickly and didn't see a mention for explicitly defining the order in which root node render relative to each other. Since ECS doesn't guarantee ordering for nodes that aren't hierarchically related, wouldn't that still be an issue?

Sorry, I was a bit confused. Local zindex would still be possible so the above is not a problem. I would make sure that in the new system, local z-index still works for ordering root nodes against each other, but otherwise it should be fine on that side.

Regardless of above, this is a regression in the sense that global zindex allows a node anywhere in a tree to "escape" the tree and render above everything else in the app for example.

Whether this really is a desired feature is debatable though. On simple UIs it's generally not needed, but on the Web, this is often used for rendering deeply nested dropdowns and modals on top of everything else without having to add them to the root (body), and keeping the hierarchy which has effects other than just positioning and ordering (e.g. style inheritence, selectors, etc)

@james7132 james7132 added C-Performance A change motivated by improving speed, memory usage or compile times A-UI Graphical user interfaces, styles, layouts, and widgets X-Controversial There is active debate or serious implications around merging this PR labels Sep 20, 2023
@ickshonpe
Copy link
Contributor Author

Local zindex can still be used to sort the root nodes.

Regardless of above, this is a regression in the sense that global zindex allows a node anywhere in a tree to "escape" the tree and render above everything else in the app for example.

Whether this really is a desired feature is debatable though. On simple UIs it's generally not needed, but on the Web, this is often used for rendering deeply nested dropdowns and modals on top of everything else without having to add them to the root (body), and keeping the hierarchy which has effects other than just positioning and ordering (e.g. style inheritence, selectors, etc)

I hadn't really considered style inheritance. I can see there might be some advantages to keeping the hierarchy, though I'm not really sure. There's no need to rush into this I guess anyway.

@ickshonpe
Copy link
Contributor Author

Closed in favour of #9889

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-UI Graphical user interfaces, styles, layouts, and widgets C-Performance A change motivated by improving speed, memory usage or compile times X-Controversial There is active debate or serious implications around merging this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove ZIndex::Global
3 participants