bevy/crates/bevy_ui/src
Cameron 01649f13e2
Refactor App and SubApp internals for better separation (#9202)
# Objective

This is a necessary precursor to #9122 (this was split from that PR to
reduce the amount of code to review all at once).

Moving `!Send` resource ownership to `App` will make it unambiguously
`!Send`. `SubApp` must be `Send`, so it can't wrap `App`.

## Solution

Refactor `App` and `SubApp` to not have a recursive relationship. Since
`SubApp` no longer wraps `App`, once `!Send` resources are moved out of
`World` and into `App`, `SubApp` will become unambiguously `Send`.

There could be less code duplication between `App` and `SubApp`, but
that would break `App` method chaining.

## Changelog

- `SubApp` no longer wraps `App`.
- `App` fields are no longer publicly accessible.
- `App` can no longer be converted into a `SubApp`.
- Various methods now return references to a `SubApp` instead of an
`App`.
## Migration Guide

- To construct a sub-app, use `SubApp::new()`. `App` can no longer
convert into `SubApp`.
- If you implemented a trait for `App`, you may want to implement it for
`SubApp` as well.
- If you're accessing `app.world` directly, you now have to use
`app.world()` and `app.world_mut()`.
- `App::sub_app` now returns `&SubApp`.
- `App::sub_app_mut`  now returns `&mut SubApp`.
- `App::get_sub_app` now returns `Option<&SubApp>.`
- `App::get_sub_app_mut` now returns `Option<&mut SubApp>.`
2024-03-31 03:16:10 +00:00
..
layout Restore pre 0.13.1 Root Node Layout behavior (#12698) 2024-03-25 19:11:50 +00:00
render Refactor App and SubApp internals for better separation (#9202) 2024-03-31 03:16:10 +00:00
widget feat: derive some common traits on some UI types (#12532) 2024-03-18 03:41:50 +00:00
accessibility.rs resolve all internal ambiguities (#10411) 2024-01-09 19:08:15 +00:00
focus.rs don't attempt to set cursor relative position for zero sized nodes (#12395) 2024-03-10 02:18:40 +00:00
geometry.rs Add with_left, with_right, with_top, with_bottom to UiRect (#12487) 2024-03-15 17:43:39 +00:00
lib.rs Refactor App and SubApp internals for better separation (#9202) 2024-03-31 03:16:10 +00:00
measurement.rs
node_bundles.rs Add border radius to UI nodes (adopted) (#12500) 2024-03-19 22:44:00 +00:00
stack.rs Reduce steady-state allocations in ui_stack_system (#12413) 2024-03-12 13:57:57 +00:00
texture_slice.rs Add border radius to UI nodes (adopted) (#12500) 2024-03-19 22:44:00 +00:00
ui_material.rs Fix incorrect link in UiMaterial documentation (#12361) 2024-03-07 22:09:57 +00:00
ui_node.rs Forbid unsafe in most crates in the engine (#12684) 2024-03-27 03:30:08 +00:00
update.rs Avoid panicking with non-UI nodes (#12213) 2024-02-29 21:36:45 +00:00