From 6bda03cc0888da4c8c58a221cf1fb8e31f9b9ed9 Mon Sep 17 00:00:00 2001 From: Jean Mertz Date: Thu, 30 Jan 2025 05:47:29 +0100 Subject: [PATCH] chore: impl `PartialEq` for `bevy_ui::Text` and `bevy_text::TextColor` (#17606) Adding these allows using `DetectChangesMut::set_if_neq` to only update the values when needed. Currently you need to get the inner values first (`String` and `Color`), to do any equality checks. --------- Signed-off-by: Jean Mertz --- crates/bevy_text/src/text.rs | 4 ++-- crates/bevy_ui/src/widget/text.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/bevy_text/src/text.rs b/crates/bevy_text/src/text.rs index 968bd7922b..6c63690867 100644 --- a/crates/bevy_text/src/text.rs +++ b/crates/bevy_text/src/text.rs @@ -368,8 +368,8 @@ impl Default for LineHeight { } /// The color of the text for this section. -#[derive(Component, Copy, Clone, Debug, Deref, DerefMut, Reflect)] -#[reflect(Component, Default, Debug)] +#[derive(Component, Copy, Clone, Debug, Deref, DerefMut, Reflect, PartialEq)] +#[reflect(Component, Default, Debug, PartialEq)] pub struct TextColor(pub Color); impl Default for TextColor { diff --git a/crates/bevy_ui/src/widget/text.rs b/crates/bevy_ui/src/widget/text.rs index c5f76ff67b..f8738c9c38 100644 --- a/crates/bevy_ui/src/widget/text.rs +++ b/crates/bevy_ui/src/widget/text.rs @@ -89,8 +89,8 @@ impl Default for TextNodeFlags { /// TextLayout::new_with_justify(JustifyText::Center) /// )); /// ``` -#[derive(Component, Debug, Default, Clone, Deref, DerefMut, Reflect)] -#[reflect(Component, Default, Debug)] +#[derive(Component, Debug, Default, Clone, Deref, DerefMut, Reflect, PartialEq)] +#[reflect(Component, Default, Debug, PartialEq)] #[require(Node, TextLayout, TextFont, TextColor, TextNodeFlags, ContentSize)] pub struct Text(pub String);