Repository navigation
Conversation
- Added macros crate, GlobalZLayer label, GlobalZLayers resource to store the ordering. - Changed `GlobalZIndex` to wrap a `GlobalZLayer` label. - Updated `ui_stack_system to use the new labels.
…ing through anyway.
Replaces the interned `GlobalZLayer` label with a name string so that `GlobalZIndex` can be serialized and deserialized via reflection. Removes the `bevy_ui_macros` crate, layer names are just static cow strs.
Changed the underlying global z index value back to u32 from i32.
|
@alice-i-cecile One thing your original criteria list never mentioned is whether layers need to be definable at runtime - that is, I presume that scene files will contain layer assignments, but it's not clear if scene files will also decide the ordering between layers, like in a CSS layers declaration. My questions are:
So for example feathers dialog box or menu defines layers which need to be ordered relative to the game's layers. |
…to global-z-layer
|
I think that runtime-defined layers are going to be essential here for UX when using tools to define these layers. |
Yes, the layers are just stored in an ordinary resource,
Yes, plugins can just add new layers to the
It's just a list of strings, so making it loadable from an asset should be trivial. I'm less sure about merging
ATM if a name isn't registered it just fails silently and the UI element is drawn to the default layer. |
|
I've been thinking that one option might be to use GhostNodes to create sub layers and force an ordering. Non-ghost nodes under a root ghost node are promoted to become layout root nodes. If GlobalZIndex/ZIndex on a ghostnode was propagated to its children then we could use that to create ordered sub layers. It would probably need us to unrequire |
|
Yet another argument why ghost nodes need a rebranding... |
|
Could it just use a small set of built-in layers like DEFAULT, MODAL, POPUP, DEBUG with before/after constraints that get resolved together, kinda like configure_sets? That way the order wouldn't depend on plugin build order. |
I think we're all agreed that named layers are desireable, so maybe I've been overthinking this a bit. Ideas about constraints, sub layers, and plugin build order probably can probably be put aside for this PR? Those things are already a problem with integer indices. The only advantage with integers is that the ordering is obvious. So then the only questions this PR needs to answer are:
|
Maybe we won't need them anymore, nicoburns is working on |
Objective
Replace the i32 indices with string names in
GlobalZIndex.Related issues (doesn't entirely solve) #1275, #24564.
Solution
GlobalZIndexnow wraps aCow<'static, str>instead of ani32.The ordering of the
GlobalZIndexstrings is stored theGlobalZLayersresource, which wraps a `Vec<Cow<'static, str>>.Calling
get_indexonGlobalZLayerswith the string layer name returns an index that used byui_stack_systemto determine the finalUiStackordering.Initially I used the design from Local named Z layers for
bevy_ui_render#26260, using a procedural macro anddefine_label!. There were problems though that I realised once I started trying to migrate over the examples and the widgets and feathers crates. The interned labels complicated serialization and reflection.bevy_ui_render's local sub layer labels don't need to be changed at runtime and they don't need to be stored in components on entities.GlobalZIndexis a component though and we need to able to change the order arbitrarily.Kept the name
GlobalZIndexfor now just to reduce the number of changes.Maybe it should use
SmolStrand notCowfor consistancy withbevy_feathers.Not sure if this sufficient for an intial PR or whether it needs more, like some notion of sub layers.
GlobalZIndexcan still be combined withZIndexto get numbered sub layers though.Testing
The output from the UI examples should be unchanged.
AI Disclosure
I wrote the initial implementation using a proc macro but after I realised I had to redo everything to use strings, I had claude do most of the migration and then cleaned up a few things like the floating layers afterwards.