🐛 Fix set all rounded corners to 0

This commit is contained in:
Alejandro Alonso 2026-01-16 12:36:50 +01:00 committed by Alonso Torres
parent f42ff27f3d
commit 324d54ad28

View File

@ -90,6 +90,18 @@ impl Type {
} }
} }
pub fn clear_corners(&mut self) {
match self {
Type::Rect(data) => {
data.corners = None;
}
Type::Frame(data) => {
data.corners = None;
}
_ => {}
}
}
pub fn path(&self) -> Option<&Path> { pub fn path(&self) -> Option<&Path> {
match self { match self {
Type::Path(path) => Some(path), Type::Path(path) => Some(path),
@ -694,9 +706,11 @@ impl Shape {
pub fn set_corners(&mut self, raw_corners: (f32, f32, f32, f32)) { pub fn set_corners(&mut self, raw_corners: (f32, f32, f32, f32)) {
if let Some(corners) = make_corners(raw_corners) { if let Some(corners) = make_corners(raw_corners) {
self.shape_type.set_corners(corners); self.shape_type.set_corners(corners);
self.invalidate_bounds(); } else {
self.invalidate_extrect(); self.shape_type.clear_corners();
} }
self.invalidate_bounds();
self.invalidate_extrect();
} }
pub fn set_svg(&mut self, svg: skia::svg::Dom) { pub fn set_svg(&mut self, svg: skia::svg::Dom) {
@ -1590,6 +1604,13 @@ mod tests {
} else { } else {
unreachable!(); unreachable!();
} }
shape.set_corners((0.0, 0.0, 0.0, 0.0));
if let Type::Rect(Rect { corners, .. }) = shape.shape_type {
assert_eq!(corners, None);
} else {
unreachable!();
}
} }
#[test] #[test]