Skip to content

Commit 5640589

Browse files
refactor ui/borders example to use new children! macro (#18962)
# Objective Refactor [`examples/ui/borders.rs`](https://github.com/bevyengine/bevy/blob/7f0490655c3ede945e6babc1f1a1f06b13404aa8/examples/ui/borders.rs) to use the new spawning/hierarchy APIs in 0.16. ## Solution This refactor reduces the number of `.spawn` calls from about 16 to 2, using one spawn for each major feature: * camera2d * ui layout The `Children::spawn` relationship API is used to take advantage of `SpawnIter` for the borders examples in each block. Each block of examples now returns a Bundle into its respective variable, which is then used in combination with the new `label` widget which makes use of the new `impl Bundle` return capability. This allows the ui layout to use a single `.spawn` with the `children!` macro. The blocks of examples are still in separate variables because it felt like a useful way to organize it still, even without needing to spawn at those locations. Functionality of the demo hasn't changed, this is just an API/code update. ## Showcase ![screenshot-2025-04-27-at-18 05 19@2x](https://github.com/user-attachments/assets/5f10b28b-b0f1-4a55-af9f-2e7b05b7b4bf) <details> <summary>Before screenshot</summary> ![screenshot-2025-04-27-at-18 17 12@2x](https://github.com/user-attachments/assets/ae159d96-ba4d-4429-b934-7779470c480a) </details> --------- Co-authored-by: François Mockers <[email protected]>
1 parent c55c69e commit 5640589

File tree

1 file changed

+158
-216
lines changed

1 file changed

+158
-216
lines changed

0 commit comments

Comments
 (0)