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

Node::is_empty #15050

Merged
merged 4 commits into from
Sep 5, 2024
Merged

Node::is_empty #15050

merged 4 commits into from
Sep 5, 2024

Conversation

ickshonpe
Copy link
Contributor

Objective

Add a Node::is_empty method to replace the uinode.size().x() <= 0. || uinode.size.y() <= 0. checks.

@ickshonpe ickshonpe added D-Trivial Nice and easy! A great choice to get started with Bevy A-UI Graphical user interfaces, styles, layouts, and widgets C-Code-Quality A section of code that is hard to understand or change labels Sep 5, 2024
@@ -698,7 +698,7 @@ pub fn extract_uinode_text(
};

// Skip if not visible or if size is set to zero (e.g. when a parent is set to `Display::None`)
if !view_visibility.get() || uinode.size().x == 0. || uinode.size().y == 0. {
if !view_visibility.get() || uinode.is_empty() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume the change in behaviour to nodes with negative extents is intentional?

Copy link
Contributor Author

@ickshonpe ickshonpe Sep 5, 2024

Choose a reason for hiding this comment

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

Taffy clamps the layout size to zero or greater, so there shouldn't be any difference between == or <=. Using <= in the is_empty seemed a safer defensive choice though.

@IQuick143
Copy link
Contributor

I assume NaN values need not be handled because it shouldn't even enter the code. (Else it would be good to revise the logic due to how NaN fails all comparisons.)

@ickshonpe
Copy link
Contributor Author

I assume NaN values need not be handled because it shouldn't even enter the code. (Else it would be good to revise the logic due to how NaN fails all comparisons.)

That's right, we shouldn't ever encounter any NaNs here.

@IQuick143 IQuick143 added the S-Needs-Review Needs reviewer attention (from anyone!) to move forward label Sep 5, 2024
@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-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Sep 5, 2024
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Sep 5, 2024
Merged via the queue into bevyengine:main with commit cb221d8 Sep 5, 2024
28 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-Code-Quality A section of code that is hard to understand or change D-Trivial Nice and easy! A great choice to get started with Bevy 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.

3 participants