Skip to content

CornerRadius border radius value semantic and ergonomic improvements#25050

Open
ickshonpe wants to merge 22 commits into
bevyengine:mainfrom
ickshonpe:border-radius-coords
Open

CornerRadius border radius value semantic and ergonomic improvements#25050
ickshonpe wants to merge 22 commits into
bevyengine:mainfrom
ickshonpe:border-radius-coords

Conversation

@ickshonpe

@ickshonpe ickshonpe commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Objective

The elliptical border-radius PR was merged with a slightly half baked API.

In particular, a corner given a single radius value should be circular or square. For example, with:

Node {
    width: px(200),
    height: px(100),
    border_radius: px(100),
}

it should clamp the radius on both axes to the min half size (50) so we get circular corners, but on main atm you get an elliptical (100, 50) radius corner.

Solution

  • Val2 has the wrong semantics. Added a new struct CornerRadius { x: Val, y: Val }.
  • A CornerRadius created from a single val: Val is mapped to CornerRadius { x: val, y: Val::Auto }.
  • If either field is zero or both are auto, the corner will be square.
  • If one field is auto, the resolved radius will be resolved relative to the node's shortest side and clamped to half its length.
  • BorderRadius's fields are changed from Val2s to CornerRadiuss.
  • The BorderRadius::px and BorderRadius::percent constructors set circular corners.
  • BorderRadius::resolve_single_corner is removed, use CornerRadius::resolve instead.

Testing

There is a new test, two doc tests, and an extra example case in the elliptical radius UI testbed.

`CornerRadius` has different semantics to `Val2`:
- If one field is auto, the resolved radius will be circular with the radius clamped to max half of the min of the node's width or height.
- If either field is zero or both are auto, the node will have square corners.
@ickshonpe ickshonpe added A-UI Graphical user interfaces, styles, layouts, and widgets S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged labels Jul 17, 2026
@github-project-automation github-project-automation Bot moved this to Needs SME Triage in UI Jul 17, 2026
@ickshonpe ickshonpe added D-Straightforward Simple bug fixes and API improvements, docs, test and examples C-Usability A targeted quality-of-life change that makes Bevy easier to use labels Jul 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke!
You can review it at https://pixel-eagle.com/project/B04F67C0-C054-4A6F-92EC-F599FEC2FD1D?filter=PR-25050

If it's expected, please add the M-Deliberate-Rendering-Change label.

If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it.

1 similar comment
@github-actions

Copy link
Copy Markdown
Contributor

Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke!
You can review it at https://pixel-eagle.com/project/B04F67C0-C054-4A6F-92EC-F599FEC2FD1D?filter=PR-25050

If it's expected, please add the M-Deliberate-Rendering-Change label.

If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it.

@gagnus gagnus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks right to me.

@@ -38,8 +38,8 @@ pub enum RoundedCorners {
impl RoundedCorners {
/// Convert the `RoundedCorners` to a `BorderRadius` for use in a `Node`.
pub fn to_border_radius(&self, radius: f32) -> BorderRadius {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It'd be helpful I think if this took Val rather than f32 to standardize it with the underlying API

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I agree, but was going to leave it for a follow up PR as it's not directly related to the corner radius impl.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Feathers border radii are always circular, I don't see the need to make the API more complicated.

Feathers is supposed to be opinionated, it's not a goal to expose every option of the underlying engine.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Well we could also give it a generic type parameter so it can take either an f32 or Val. But it's not a priority and I'd definitely yield to you on this.

- Added and improved doc comments.
- New consts `MAX` and `MAX_RADIUS`
- Renamed `circle` method to `circular`.
- New `new` method.
@github-actions

Copy link
Copy Markdown
Contributor

Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke!
You can review it at https://pixel-eagle.com/project/B04F67C0-C054-4A6F-92EC-F599FEC2FD1D?filter=PR-25050

If it's expected, please add the M-Deliberate-Rendering-Change label.

If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it.

@github-actions

Copy link
Copy Markdown
Contributor

Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke!
You can review it at https://pixel-eagle.com/project/B04F67C0-C054-4A6F-92EC-F599FEC2FD1D?filter=PR-25050

If it's expected, please add the M-Deliberate-Rendering-Change label.

If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it.

2 similar comments
@github-actions

Copy link
Copy Markdown
Contributor

Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke!
You can review it at https://pixel-eagle.com/project/B04F67C0-C054-4A6F-92EC-F599FEC2FD1D?filter=PR-25050

If it's expected, please add the M-Deliberate-Rendering-Change label.

If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it.

@github-actions

Copy link
Copy Markdown
Contributor

Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke!
You can review it at https://pixel-eagle.com/project/B04F67C0-C054-4A6F-92EC-F599FEC2FD1D?filter=PR-25050

If it's expected, please add the M-Deliberate-Rendering-Change label.

If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it.

@ickshonpe ickshonpe added S-Needs-Review Needs reviewer attention (from anyone!) to move forward C-Docs An addition or correction to our documentation C-Code-Quality A section of code that is hard to understand or change and removed S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged labels Jul 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke!
You can review it at https://pixel-eagle.com/project/B04F67C0-C054-4A6F-92EC-F599FEC2FD1D?filter=PR-25050

If it's expected, please add the M-Deliberate-Rendering-Change label.

If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it.

1 similar comment
@github-actions

Copy link
Copy Markdown
Contributor

Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke!
You can review it at https://pixel-eagle.com/project/B04F67C0-C054-4A6F-92EC-F599FEC2FD1D?filter=PR-25050

If it's expected, please add the M-Deliberate-Rendering-Change label.

If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it.

@alice-i-cecile alice-i-cecile added this to the 0.20 milestone Jul 18, 2026
@alice-i-cecile alice-i-cecile added the M-Deliberate-Rendering-Change An intentional change to how tests and examples are rendered label Jul 18, 2026
@alice-i-cecile
alice-i-cecile requested a review from mockersf July 18, 2026 18:24
@alice-i-cecile alice-i-cecile added D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes C-Bug An unexpected or incorrect behavior and removed D-Straightforward Simple bug fixes and API improvements, docs, test and examples labels Jul 18, 2026
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-Bug An unexpected or incorrect behavior C-Code-Quality A section of code that is hard to understand or change C-Docs An addition or correction to our documentation C-Usability A targeted quality-of-life change that makes Bevy easier to use D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes M-Deliberate-Rendering-Change An intentional change to how tests and examples are rendered S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

Status: Needs SME Triage

Development

Successfully merging this pull request may close these issues.

4 participants