From 481eec2c922fc212a730575b031b332a8101e6d9 Mon Sep 17 00:00:00 2001 From: Alice Cecile Date: Sun, 25 Sep 2022 00:39:17 +0000 Subject: [PATCH] Rename `UiColor` to `BackgroundColor` (#6087) # Objective Fixes #6078. The `UiColor` component is unhelpfully named: it is unclear, ambiguous with border color and ## Solution Rename the `UiColor` component (and associated fields) to `BackgroundColor` / `background_colorl`. ## Migration Guide `UiColor` has been renamed to `BackgroundColor`. This change affects `NodeBundle`, `ButtonBundle` and `ImageBundle`. In addition, the corresponding field on `ExtractedUiNode` has been renamed to `background_color` for consistency. --- crates/bevy_ui/src/entity.rs | 20 ++++++++------ crates/bevy_ui/src/lib.rs | 2 +- crates/bevy_ui/src/render/mod.rs | 12 ++++----- crates/bevy_ui/src/ui_node.rs | 11 +++++--- examples/ecs/state.rs | 4 +-- examples/games/alien_cake_addict.rs | 2 +- examples/games/game_menu.rs | 34 ++++++++++++------------ examples/ios/src/lib.rs | 2 +- examples/stress_tests/many_buttons.rs | 11 +++++--- examples/ui/button.rs | 4 +-- examples/ui/scaling.rs | 6 ++--- examples/ui/transparency_ui.rs | 4 +-- examples/ui/ui.rs | 30 ++++++++++----------- examples/window/scale_factor_override.rs | 4 +-- 14 files changed, 78 insertions(+), 68 deletions(-) diff --git a/crates/bevy_ui/src/entity.rs b/crates/bevy_ui/src/entity.rs index 3aa587f564..5b3cf25cb6 100644 --- a/crates/bevy_ui/src/entity.rs +++ b/crates/bevy_ui/src/entity.rs @@ -2,7 +2,7 @@ use crate::{ widget::{Button, ImageMode}, - CalculatedSize, FocusPolicy, Interaction, Node, Style, UiColor, UiImage, + BackgroundColor, CalculatedSize, FocusPolicy, Interaction, Node, Style, UiImage, }; use bevy_ecs::{ bundle::Bundle, @@ -23,8 +23,8 @@ pub struct NodeBundle { pub node: Node, /// Describes the style including flexbox settings pub style: Style, - /// Describes the color of the node - pub color: UiColor, + /// The background color, which serves as a "fill" for this node + pub background_color: BackgroundColor, /// Describes the image of the node pub image: UiImage, /// Whether this node should block interaction with lower nodes @@ -50,8 +50,10 @@ pub struct ImageBundle { pub image_mode: ImageMode, /// The calculated size based on the given image pub calculated_size: CalculatedSize, - /// The color of the node - pub color: UiColor, + /// The background color, which serves as a "fill" for this node + /// + /// When combined with `UiImage`, tints the provided image. + pub background_color: BackgroundColor, /// The image of the node pub image: UiImage, /// Whether this node should block interaction with lower nodes @@ -152,8 +154,10 @@ pub struct ButtonBundle { pub interaction: Interaction, /// Whether this node should block interaction with lower nodes pub focus_policy: FocusPolicy, - /// The color of the node - pub color: UiColor, + /// The background color, which serves as a "fill" for this node + /// + /// When combined with `UiImage`, tints the provided image. + pub background_color: BackgroundColor, /// The image of the node pub image: UiImage, /// The transform of the node @@ -174,7 +178,7 @@ impl Default for ButtonBundle { focus_policy: Default::default(), node: Default::default(), style: Default::default(), - color: Default::default(), + background_color: Default::default(), image: Default::default(), transform: Default::default(), global_transform: Default::default(), diff --git a/crates/bevy_ui/src/lib.rs b/crates/bevy_ui/src/lib.rs index e5a2b21c70..62b5e70cf2 100644 --- a/crates/bevy_ui/src/lib.rs +++ b/crates/bevy_ui/src/lib.rs @@ -90,7 +90,7 @@ impl Plugin for UiPlugin { .register_type::() .register_type::() .register_type::