Repository navigation
Named UI paint layers #26260
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
Open
ickshonpe
wants to merge
57
commits into
bevyengine:main
Choose a base branch
from
ickshonpe:UiSubZLayer
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+560
−95
Open
Named UI paint layers #26260
Changes from all commits
Commits
Show all changes
57 commits
Select commit
Hold shift + click to select a range
9caf0b2
Added a new sub_z_layers module to bevy_ui_render
ickshonpe 5a7e59b
Added empty bevy_ui_render\macros sub crate based on bevy_render\macros
ickshonpe 0f278eb
Added bevy_ui_render_macros dependency to bevy_ui_render
ickshonpe 70ef668
Added proc macro `derive_ui_sub_z_layer` to the macros subcrate
ickshonpe fcd67aa
Added draft migration guide
ickshonpe d288b8a
added define_label for UiSubZLayer, UiSubZLayerList resource to track…
ickshonpe 0a25259
Fixed the errors in the UiSubZLayers implementation and trait path.
ickshonpe 287750a
Removed stack_z_offsets module
ickshonpe ba8c3d9
Added draft docs for UiSubZLayerList
ickshonpe 654d4ba
Updated migration guide.
ickshonpe 62606e4
Added UiMaterial changes to the migration guide
ickshonpe e415ecb
Migrated all the extraction functions to use the new layers.
ickshonpe 9c0e6c7
Added pull request # to the migration guide.
ickshonpe c908e02
Merge branch 'main' into UiSubZLayer
ickshonpe 60ce313
Merge branch 'main' into UiSubZLayer
ickshonpe 72018e1
Improved comments, clarifying that the z offsets occupy a clopen rang…
ickshonpe ad078c5
Renamed UiSubLayers to PaintOrder
ickshonpe d64a1bd
Renamed `UiSubZLayers` to `NodePaintSteps`
ickshonpe 6c7e71c
More renamings:
ickshonpe eafa498
Comment cleanup
ickshonpe ea059ea
Cleaned up PaintOrder's implementation.
ickshonpe 1ff9bee
Fixed imports
ickshonpe 730dfc2
Added a from IntoIterator impl for PaintOrder
ickshonpe 41ecded
Fixed more imports
ickshonpe f56aa0b
Replaced NodePaintOrder `all` fn with `ALL` const.
ickshonpe e0c418b
Renamed NodePaintLayers -> NodePaintLayer
ickshonpe 60f3322
Renamed `UiMaterial::sub_z_layer` to `paint_layer`.
ickshonpe ff7f942
Fixed local variable names and comments still refering to sub z layers
ickshonpe d00bf66
Merge branch 'UiSubZLayer' of https://github.com/ickshonpe/bevy into …
ickshonpe 6c291cc
Merge branch 'main' into UiSubZLayer
ickshonpe 6618aa7
Added PaintOrder unit tests
ickshonpe 4896185
Added insert_top and insert_bottom methods.
ickshonpe 1965d0b
updated test for new ordering
ickshonpe cf685e9
Added tests for insert_top + bottom
ickshonpe e8cab68
Updated migration guide.
ickshonpe 5d20185
Added release note
ickshonpe c04d17c
Release content md fixes
ickshonpe ee17621
typo uk -> us spelling
ickshonpe 98460d0
Removed headings from release note
ickshonpe 1b361ff
Merge branch 'main' into UiSubZLayer
ickshonpe 8a85ace
Paint layers are now represents using a ` PaintLayer(SmolStr)` with n…
ickshonpe 42f7587
Added doc comments for the PaintLayer constants.
ickshonpe 7db7c6b
Added doc comment for DEFAULT_PAINT_LAYERS
ickshonpe 71f823b
Made the PaintLayer implementation more consistant with bevy_feather'…
ickshonpe 4771374
Merge branch 'UiSubZLayer' of https://github.com/ickshonpe/bevy into …
ickshonpe 98946e5
Updated PaintLayer's doc comment
ickshonpe 789c5cc
Updated doc comment for `PaintOrder`.
ickshonpe d83907e
Release content edits.
ickshonpe 4520cac
Made DEFAULT_PAINT_LAYERS pub.
ickshonpe 0311ce6
Removed macros dir and licenses
ickshonpe 7359dc6
bevy_ui_render no longer uses an f32 sort key:
ickshonpe 8a0a0d3
Updated release content
ickshonpe 916c391
Merge branch 'main' into UiSubZLayer
ickshonpe 601bd9a
Removed trailing space from release note.
ickshonpe 22afbb3
Merge branch 'main' into UiSubZLayer
ickshonpe b024eb9
Changed paint layer index to use a u32.
ickshonpe a185653
Merge branch 'UiSubZLayer' of https://github.com/ickshonpe/bevy into …
ickshonpe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| --- | ||
| title: "`stack_z_offsets` has been replaced by named z layers" | ||
| pull_requests: [26260] | ||
| --- | ||
|
|
||
| Instead of using explicit `f32` z-offsets, `bevy_ui_render` now has named paint layers. | ||
| The z offset constants in the `stack_z_offsets` module have been replaced by named `PaintLayer` constants. | ||
| The list of layers is stored in back-to-front order in the `PaintOrder` resource. | ||
|
|
||
| `TransparentUi::sort_key` now uses `UiSortKey` instead of `FloatOrd`. UI phase items are ordered first by stack index, then by paint layer index. Use `PaintOrder::get_layer_index` to look up a layer's index, then construct a `UiSortKey` with `UiSortKey::new(stack_index, paint_layer)` | ||
|
|
||
| `ExtractedUiNode::z_order` has been replaced by `stack_index: ComputedStackIndex` and `paint_layer: usize`. | ||
| The `stack_index` fields on `ExtractedBoxShadow`, `ExtractedGradient`, `ExtractedUiMaterialNode`, and `ExtractedUiTextureSlice` now take `ComputedStackIndex` instead of `u32`. | ||
|
|
||
| The `UiMaterial` trait's `stack_z_offset` method has been replaced by `paint_layer`, which should return the `PaintLayer` the material is intended to be drawn to. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| --- | ||
| title: Paint layers | ||
| authors: ["@Ickshonpe"] | ||
| pull_requests: [26260] | ||
| --- | ||
|
|
||
| `bevy_ui_render` now has paint layers. | ||
|
|
||
| The `PaintOrder` resource holds the list of paint layers, in the order they’re drawn from back to front. | ||
|
|
||
| The built-in layers are identified by named `PaintLayer` constants such as `BOX_SHADOW_PAINT_LAYER` and `TEXT_PAINT_LAYER`. | ||
|
|
||
| `UiRenderPlugin` initializes `PaintOrder` with all the builtin layers in the correct order. | ||
|
|
||
| To create a new `PaintLayer`, give it a string name: | ||
|
|
||
| ```rust | ||
| pub const MY_PAINT_LAYER: PaintLayer = PaintLayer::new_static("my_plugin.overlay"); | ||
| ``` | ||
|
|
||
| The `PaintOrder` resource exposes `IndexSet`’s methods through dereferencing, plus these helpers: | ||
|
|
||
| - `insert_before_layer` / `insert_after_layer` place a layer directly below or above an existing layer. | ||
| - `insert_top` / `insert_bottom` place a layer above or below all the other layers. | ||
| - `remove_layer` removes a layer. A built-in element whose layer is removed isn't drawn. | ||
|
|
||
| The insert methods move a layer if it is already present. | ||
|
|
||
| The `UiMaterial` trait has a new `paint_layer()` method that chooses the layer the layer the material is drawn to. | ||
| It defaults to `MATERIAL_PAINT_LAYER`. | ||
|
|
||
| UI render items are sorted using `UiSortKey`, first by `ComputedStackIndex` and then by paint-layer index. | ||
|
|
||
| Extraction functions should look up their layer index with `PaintOrder::get_layer_index` once at the start of the function. Extracted items store `ComputedStackIndex` directly, and `ExtractedUiNode` also stores the paint-layer index. Queue functions construct the sort key with `UiSortKey::new(stack_index, paint_layer)`. The `PaintOrder` resource is also extracted separately, so some queue functions look up the layer index there instead. | ||
|
|
||
| Changing `PaintOrder` at all is expensive, as it triggers a reextraction of all elements. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should include an example of how to migrate GlobalZIndex components.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GlobalZIndex's behaviour is unchanged, it only affects the stack ordering.