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
out
}

/// Returns the node's padding-box in object-centered physical coordinates.
Copy link

Choose a reason for hiding this comment

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

padding-box -> content-box

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

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?

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 M-Release-Note Work that should be called out in the blog due to impact S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants