Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Val::ZERO Constant #9566

Merged
merged 4 commits into from
Aug 26, 2023
Merged

Conversation

bushrat011899
Copy link
Contributor

Objective

Solution

  • Added Val::ZERO as a constant which is defined as Val::Px(0.).
  • Added manual PartialEq implementation for Val which allows any zero value to equal any other zero value. E.g., Val::Px(0.) == Val::Percent(0.) etc. This is technically a breaking change, as Val::Px(0.) == Val::Percent(0.) now equals true instead of false (as an example)
  • Replaced instances of Val::Px(0.), Val::Percent(0.), etc. with Val::ZERO
  • Fixed bevy_ui::layout::convert::tests::test_convert_from test to account for Taffy not equating Points(0.) and Percent(0.). These tests now use assert_eq!(...) instead of assert!(matches!(...)) which gives easier to diagnose error messages.

* Added `Val::ZERO` as a constant which is defined as `Val::Px(0.)`.
* Added manual `PartialEq` implementation for `Val` which allows any zero value to equal any other zero value. E.g., `Val::Px(0.) == Val::Percent(0.)` etc.
* Replaced instances of `Val::Px(0.)`, `Val::Percent(0.)`, etc. with `Val::ZERO`
* Fixed `bevy_ui::layout::convert::tests::test_convert_from` test to account for Taffy not equating `Points(0.)` and `Percent(0.)`. These tests now use `assert_eq!(...)` instead of `assert!(matches!(...))` which gives easier to diagnose error messages.
@bushrat011899
Copy link
Contributor Author

CI Issues will be resolved by #9562

@alice-i-cecile alice-i-cecile added A-UI Graphical user interfaces, styles, layouts, and widgets C-Usability A simple quality-of-life change that makes Bevy easier to use labels Aug 25, 2023
@alice-i-cecile
Copy link
Member

@jim-ec, want to toss a review on this for us? :)

Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice attention to detail here. Good thought on the custom PartialEq implementation!

@jim-ec
Copy link
Contributor

jim-ec commented Aug 25, 2023

Looks good to me.

crates/bevy_ui/src/geometry.rs Show resolved Hide resolved
crates/bevy_ui/src/layout/convert.rs Outdated Show resolved Hide resolved
crates/bevy_ui/src/ui_node.rs Show resolved Hide resolved
@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it labels Aug 25, 2023
@alice-i-cecile alice-i-cecile added this to the 0.12 milestone Aug 25, 2023
@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Aug 26, 2023
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Aug 26, 2023
Merged via the queue into bevyengine:main with commit 90b3ac7 Aug 26, 2023
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-UI Graphical user interfaces, styles, layouts, and widgets C-Usability A simple quality-of-life change that makes Bevy easier to use S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Val::Zero
4 participants