From b6e4d171b502359b9859b69af3d6cdf08c9e12ce Mon Sep 17 00:00:00 2001 From: Erick Z <567737+eckz@users.noreply.github.com> Date: Mon, 9 Jun 2025 22:08:17 +0200 Subject: [PATCH] Adding PartialEq to some UI and Text types (#19552) # Objective - During the development of [`bevy_flair`](https://github.com/eckz/bevy_flair) I found [some types lacking `PartialEq`](https://github.com/search?q=repo%3Aeckz%2Fbevy_flair%20%20%22Try%20to%20upstream%20it%20to%20bevy%22&type=code) which made the unit testing a little bit inconvinient. ## Solution - Adding `PartialEq` for the following types: - `LineHeight ` - `TextShadow` - `NodeImageMode` ## Testing - Letting github actions do the testing, this is not an invasive change and `cargo run --bin ci` doesn't seem to work in `main` at the moment. --- crates/bevy_text/src/text.rs | 4 ++-- crates/bevy_ui/src/ui_node.rs | 4 ++-- crates/bevy_ui/src/widget/image.rs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/bevy_text/src/text.rs b/crates/bevy_text/src/text.rs index ecaa8ffd2f..ccfdb2a372 100644 --- a/crates/bevy_text/src/text.rs +++ b/crates/bevy_text/src/text.rs @@ -354,8 +354,8 @@ impl Default for TextFont { /// Specifies the height of each line of text for `Text` and `Text2d` /// /// Default is 1.2x the font size -#[derive(Debug, Clone, Copy, Reflect)] -#[reflect(Debug, Clone)] +#[derive(Debug, Clone, Copy, PartialEq, Reflect)] +#[reflect(Debug, Clone, PartialEq)] pub enum LineHeight { /// Set line height to a specific number of pixels Px(f32), diff --git a/crates/bevy_ui/src/ui_node.rs b/crates/bevy_ui/src/ui_node.rs index 343d8af3cd..2ae820a1a1 100644 --- a/crates/bevy_ui/src/ui_node.rs +++ b/crates/bevy_ui/src/ui_node.rs @@ -2865,8 +2865,8 @@ impl ComputedNodeTarget { } /// Adds a shadow behind text -#[derive(Component, Copy, Clone, Debug, Reflect)] -#[reflect(Component, Default, Debug, Clone)] +#[derive(Component, Copy, Clone, Debug, PartialEq, Reflect)] +#[reflect(Component, Default, Debug, Clone, PartialEq)] pub struct TextShadow { /// Shadow displacement in logical pixels /// With a value of zero the shadow will be hidden directly behind the text diff --git a/crates/bevy_ui/src/widget/image.rs b/crates/bevy_ui/src/widget/image.rs index c65c4df354..9a743595b8 100644 --- a/crates/bevy_ui/src/widget/image.rs +++ b/crates/bevy_ui/src/widget/image.rs @@ -138,8 +138,8 @@ impl From> for ImageNode { } /// Controls how the image is altered to fit within the layout and how the layout algorithm determines the space in the layout for the image -#[derive(Default, Debug, Clone, Reflect)] -#[reflect(Clone, Default)] +#[derive(Default, Debug, Clone, PartialEq, Reflect)] +#[reflect(Clone, Default, PartialEq)] pub enum NodeImageMode { /// The image will be sized automatically by taking the size of the source image and applying any layout constraints. #[default]