Skip to content

Conversation

@ickshonpe
Copy link
Contributor

@ickshonpe ickshonpe commented Nov 21, 2025

Objective

Add helper functions to ComputedNode that return the bounds of the node's border, padding, and content areas.

Solution

Add helper functions border_box, padding_box, and content_box to ComputedNode.

Included a release note. These changes are very trivial and don't really need one, but I've got quite a few more less trivial changes to ComputedNode that I want to add later.

Testing

This PR also includes a couple of trivial tests.

@ickshonpe ickshonpe added A-UI Graphical user interfaces, styles, layouts, and widgets M-Release-Note Work that should be called out in the blog due to impact D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Nov 21, 2025
let mut out = self.border_box();
out.min.x += self.border.left;
out.max.x -= self.border.right;
out.min.y += self.border.top;
Copy link
Contributor

Choose a reason for hiding this comment

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

This might be a stupid comment because I am new, but is this supposed to be out.min.y += self.border.bottom (and the next line should be out.max.y -= self.border.top)? Same comment about this belongs in content_box too

From reading Rect, I had the impression visually that Rect.min is the lower left point defined as (min.x, min.y) and Rect.max is the upper right point e.g (max.x, max.y), and that the BorderRect left/right/top/bottom values are units “towards its center.” If that’s the case, should min.y should be affected by border.bottom instead?

Copy link
Contributor Author

@ickshonpe ickshonpe Nov 21, 2025

Choose a reason for hiding this comment

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

It's confusing but, opposite to bevy_sprite, in bevy_ui the y-axis increases downwards. So Rect::min corresponds to the position of the top-left corner of the UI node and Rect::max corresponds to its bottom-right corner.

Copy link
Contributor

Choose a reason for hiding this comment

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

🤦 Thanks for clarifying for me, I must commit this to memory!

@ickshonpe ickshonpe removed the M-Release-Note Work that should be called out in the blog due to impact label Nov 22, 2025
Copy link
Contributor

@pablo-lua pablo-lua left a comment

Choose a reason for hiding this comment

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

Useful helper methods. LGTM

@pablo-lua pablo-lua 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 Dec 13, 2025
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Dec 14, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Dec 14, 2025
@alice-i-cecile
Copy link
Member

@ickshonpe these merge conflicts are a bit too gnarly for the web UI; can you take a look?

@alice-i-cecile alice-i-cecile added this pull request to the merge queue Dec 15, 2025
Merged via the queue into bevyengine:main with commit c18838f Dec 15, 2025
36 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 D-Straightforward Simple bug fixes and API improvements, docs, test and examples 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.

4 participants