bevy/crates
Ben Frankel e8ae0d6c49
Decouple BackgroundColor from UiImage (#11165)
# Objective

Fixes https://github.com/bevyengine/bevy/issues/11157.

## Solution

Stop using `BackgroundColor` as a color tint for `UiImage`. Add a
`UiImage::color` field for color tint instead. Allow a UI node to
simultaneously include a solid-color background and an image, with the
image rendered on top of the background (this is already how it works
for e.g. text).


![2024-02-29_1709239666_563x520](https://github.com/bevyengine/bevy/assets/12173779/ec50c9ef-4c7f-4ab8-a457-d086ce5b3425)

---

## Changelog

- The `BackgroundColor` component now renders a solid-color background
behind `UiImage` instead of tinting its color.
- Removed `BackgroundColor` from `ImageBundle`, `AtlasImageBundle`, and
`ButtonBundle`.
- Added `UiImage::color`.
- Expanded `RenderUiSystem` variants.
- Renamed `bevy_ui::extract_text_uinodes` to `extract_uinodes_text` for
consistency.

## Migration Guide

- `BackgroundColor` no longer tints the color of UI images. Use
`UiImage::color` for that instead.
- For solid color buttons, replace `ButtonBundle { background_color:
my_color.into(), ... }` with `ButtonBundle { image:
UiImage::default().with_color(my_color), ... }`, and update button
interaction systems to use `UiImage::color` instead of `BackgroundColor`
as well.
- `bevy_ui::RenderUiSystem::ExtractNode` has been split into
`ExtractBackgrounds`, `ExtractImages`, `ExtractBorders`, and
`ExtractText`.
- `bevy_ui::extract_uinodes` has been split into
`bevy_ui::extract_uinode_background_colors` and
`bevy_ui::extract_uinode_images`.
- `bevy_ui::extract_text_uinodes` has been renamed to
`extract_uinode_text`.
2024-03-03 21:35:50 +00:00
..
bevy_a11y Bump Version after Release (#12020) 2024-02-21 20:58:59 +00:00
bevy_animation Replace bevy_log's tracing reexport with bevy_utils' (#12254) 2024-03-02 18:38:04 +00:00
bevy_app Use immutable key for HashMap and HashSet (#12086) 2024-02-26 16:27:40 +00:00
bevy_asset remove repetitive code (#12270) 2024-03-03 07:58:22 +00:00
bevy_audio Bump Version after Release (#12020) 2024-02-21 20:58:59 +00:00
bevy_color Update wgpu to v0.19.3 and unpin web-sys. (#12247) 2024-03-02 00:44:51 +00:00
bevy_core Check cfg during CI and fix feature typos (#12103) 2024-02-25 15:19:27 +00:00
bevy_core_pipeline Replace bevy_log's tracing reexport with bevy_utils' (#12254) 2024-03-02 18:38:04 +00:00
bevy_derive Bump Version after Release (#12020) 2024-02-21 20:58:59 +00:00
bevy_diagnostic Replace bevy_log's tracing reexport with bevy_utils' (#12254) 2024-03-02 18:38:04 +00:00
bevy_dylib Bump Version after Release (#12020) 2024-02-21 20:58:59 +00:00
bevy_dynamic_plugin Document all members of bevy_dynamic_plugin (#12029) 2024-02-22 13:28:52 +00:00
bevy_ecs Use NonMaxUsize for non-component SparseSets (#12083) 2024-03-03 14:55:27 +00:00
bevy_ecs_compile_fail_tests Remove APIs deprecated in 0.13 (#11974) 2024-02-19 19:04:47 +00:00
bevy_encase_derive Bump Version after Release (#12020) 2024-02-21 20:58:59 +00:00
bevy_gilrs Replace bevy_log's tracing reexport with bevy_utils' (#12254) 2024-03-02 18:38:04 +00:00
bevy_gizmos Add basic light gizmos (#12228) 2024-03-03 18:50:46 +00:00
bevy_gltf Replace bevy_log's tracing reexport with bevy_utils' (#12254) 2024-03-02 18:38:04 +00:00
bevy_hierarchy Move commands module into bevy::ecs::world (#12234) 2024-03-02 23:13:45 +00:00
bevy_input Fix missing renaming of Input -> ButtonInput (#12096) 2024-02-24 18:41:17 +00:00
bevy_internal Migrate from LegacyColor to bevy_color::Color (#12163) 2024-02-29 19:35:12 +00:00
bevy_log Update tracing-log requirement from 0.1.2 to 0.2.0 (#10404) 2024-02-27 03:25:42 +00:00
bevy_macro_utils fix some typos (#12038) 2024-02-22 18:55:22 +00:00
bevy_macros_compile_fail_tests Standardize toml format with taplo (#10594) 2023-11-21 01:04:14 +00:00
bevy_math Implement Mul between f32 and direction types (#12276) 2024-03-03 17:44:16 +00:00
bevy_mikktspace fix some typos (#12038) 2024-02-22 18:55:22 +00:00
bevy_pbr PBR: use attenuation instead of base_color for attenuation (#12266) 2024-03-02 22:20:44 +00:00
bevy_ptr Bump Version after Release (#12020) 2024-02-21 20:58:59 +00:00
bevy_reflect Rename Direction2d/3d to Dir2/3 (#12189) 2024-02-28 22:48:43 +00:00
bevy_reflect_compile_fail_tests bevy_reflect_derive: Clean up attribute logic (#11777) 2024-02-12 15:16:27 +00:00
bevy_render Replace bevy_log's tracing reexport with bevy_utils' (#12254) 2024-03-02 18:38:04 +00:00
bevy_scene Move commands module into bevy::ecs::world (#12234) 2024-03-02 23:13:45 +00:00
bevy_sprite Deprecate SpriteSheetBundle and AtlasImageBundle (#12218) 2024-03-03 20:11:15 +00:00
bevy_tasks remove repetitive code (#12270) 2024-03-03 07:58:22 +00:00
bevy_text Migrate from LegacyColor to bevy_color::Color (#12163) 2024-02-29 19:35:12 +00:00
bevy_time Bump Version after Release (#12020) 2024-02-21 20:58:59 +00:00
bevy_transform Move commands module into bevy::ecs::world (#12234) 2024-03-02 23:13:45 +00:00
bevy_ui Decouple BackgroundColor from UiImage (#11165) 2024-03-03 21:35:50 +00:00
bevy_utils fix some typos (#12038) 2024-02-22 18:55:22 +00:00
bevy_window Fix fit_canvas_to_parent (#11278) 2024-03-03 14:33:30 +00:00
bevy_winit Fix fit_canvas_to_parent (#11278) 2024-03-03 14:33:30 +00:00