CornerRadius border radius value semantic and ergonomic improvements#25050
CornerRadius border radius value semantic and ergonomic improvements#25050ickshonpe wants to merge 22 commits into
CornerRadius border radius value semantic and ergonomic improvements#25050Conversation
`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.
|
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! 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
|
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! 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. |
| @@ -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 { | |||
There was a problem hiding this comment.
It'd be helpful I think if this took Val rather than f32 to standardize it with the underlying API
There was a problem hiding this comment.
I agree, but was going to leave it for a follow up PR as it's not directly related to the corner radius impl.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
|
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! 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. |
|
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! 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
|
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! 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. |
|
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! 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. |
…adius` is used instead.
|
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! 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
|
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! 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. |
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:
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
Val2has the wrong semantics. Added a new structCornerRadius { x: Val, y: Val }.CornerRadiuscreated from a singleval: Valis mapped toCornerRadius { x: val, y: Val::Auto }.BorderRadius's fields are changed fromVal2s toCornerRadiuss.BorderRadius::pxandBorderRadius::percentconstructors set circular corners.BorderRadius::resolve_single_corneris removed, useCornerRadius::resolveinstead.Testing
There is a new test, two doc tests, and an extra example case in the elliptical radius UI testbed.