bevy/crates/bevy_ui/src
VitalyR eb19a9ea0b
Migrate UI bundles to required components (#15898)
# Objective

- Migrate UI bundles to required components, fixes #15889

## Solution

- deprecate `NodeBundle` in favor of `Node`
- deprecate `ImageBundle` in favor of `UiImage`
- deprecate `ButtonBundle` in favor of `Button`

## Testing

CI.

## Migration Guide

- Replace all uses of `NodeBundle` with `Node`. e.g.
```diff
     commands
-        .spawn(NodeBundle {
-            style: Style {
+        .spawn((
+            Node::default(),
+            Style {
                 width: Val::Percent(100.),
                 align_items: AlignItems::Center,
                 justify_content: JustifyContent::Center,
                 ..default()
             },
-            ..default()
-        })
+        ))
``` 
- Replace all uses of `ButtonBundle` with `Button`. e.g.
```diff
                     .spawn((
-                        ButtonBundle {
-                            style: Style {
-                                width: Val::Px(w),
-                                height: Val::Px(h),
-                                // horizontally center child text
-                                justify_content: JustifyContent::Center,
-                                // vertically center child text
-                                align_items: AlignItems::Center,
-                                margin: UiRect::all(Val::Px(20.0)),
-                                ..default()
-                            },
-                            image: image.clone().into(),
+                        Button,
+                        Style {
+                            width: Val::Px(w),
+                            height: Val::Px(h),
+                            // horizontally center child text
+                            justify_content: JustifyContent::Center,
+                            // vertically center child text
+                            align_items: AlignItems::Center,
+                            margin: UiRect::all(Val::Px(20.0)),
                             ..default()
                         },
+                        UiImage::from(image.clone()),
                         ImageScaleMode::Sliced(slicer.clone()),
                     ))
```
- Replace all uses of `ImageBundle` with `UiImage`. e.g.
```diff
-    commands.spawn(ImageBundle {
-        image: UiImage {
+    commands.spawn((
+        UiImage {
             texture: metering_mask,
             ..default()
         },
-        style: Style {
+        Style {
             width: Val::Percent(100.0),
             height: Val::Percent(100.0),
             ..default()
         },
-        ..default()
-    });
+    ));
 ```

---------

Co-authored-by: Carter Anderson <mcanders1@gmail.com>
2024-10-17 21:11:02 +00:00
..
experimental Migrate UI bundles to required components (#15898) 2024-10-17 21:11:02 +00:00
layout Migrate UI bundles to required components (#15898) 2024-10-17 21:11:02 +00:00
render Migrate UI bundles to required components (#15898) 2024-10-17 21:11:02 +00:00
widget Migrate UI bundles to required components (#15898) 2024-10-17 21:11:02 +00:00
accessibility.rs Mark ghost nodes as experimental and partially feature flag them (#15961) 2024-10-16 22:20:48 +00:00
focus.rs Migrate UI bundles to required components (#15898) 2024-10-17 21:11:02 +00:00
geometry.rs Fix *most* clippy lints (#15906) 2024-10-14 20:52:35 +00:00
lib.rs Migrate UI bundles to required components (#15898) 2024-10-17 21:11:02 +00:00
measurement.rs Remove bevy_ui's "bevy_text" feature (#15951) 2024-10-16 16:43:57 +00:00
node_bundles.rs Migrate UI bundles to required components (#15898) 2024-10-17 21:11:02 +00:00
picking_backend.rs Rename the Pickable component and fix incorrect documentation (#15707) 2024-10-07 17:09:57 +00:00
stack.rs Mark ghost nodes as experimental and partially feature flag them (#15961) 2024-10-16 22:20:48 +00:00
ui_material.rs Migrate UI bundles to required components (#15898) 2024-10-17 21:11:02 +00:00
ui_node.rs Migrate UI bundles to required components (#15898) 2024-10-17 21:11:02 +00:00
update.rs Mark ghost nodes as experimental and partially feature flag them (#15961) 2024-10-16 22:20:48 +00:00