diff --git a/hui-examples/examples/align.rs b/hui-examples/examples/align.rs index 1c1c0fd..2316dc8 100644 --- a/hui-examples/examples/align.rs +++ b/hui-examples/examples/align.rs @@ -118,12 +118,12 @@ fn main() { left: 30., right: 40., }, - corner_radius: Some(Corners { + corner_radius: Corners { top_left: 0., top_right: 30., bottom_left: 0., bottom_right: 0., - }), + }, elements: vec![ Box::new(Rect { size: (UiSize::Static(50.), UiSize::Static(50.)), diff --git a/hui-examples/examples/mom_downloader.rs b/hui-examples/examples/mom_downloader.rs index 4e93409..a680e64 100644 --- a/hui-examples/examples/mom_downloader.rs +++ b/hui-examples/examples/mom_downloader.rs @@ -56,7 +56,7 @@ fn main() { padding: Sides::all(10.), size: (UiSize::Static(450.), UiSize::Auto), background: Some(vec4(0.2, 0.2, 0.5, 1.)), - corner_radius: Some(Corners::all(8.)), + corner_radius: Corners::all(8.), elements: elements(|el| { if instant.elapsed().as_secs_f32() < 5. { el.add(Text { diff --git a/hui-examples/examples/rounded_rect.rs b/hui-examples/examples/rounded_rect.rs index f75798e..9a1fa71 100644 --- a/hui-examples/examples/rounded_rect.rs +++ b/hui-examples/examples/rounded_rect.rs @@ -44,12 +44,12 @@ fn main() { align: Alignment::Center.into(), size: (UiSize::Fraction(0.5), UiSize::Fraction(0.5)), background: Some(vec4(1., 0., 0., 1.)), - corner_radius: Some(Corners { + corner_radius: Corners { top_left: 10., top_right: 20., bottom_left: 50., bottom_right: 80. - }), + }, elements: vec![ Box::new(Container { padding: Sides::all(20.), @@ -57,7 +57,7 @@ fn main() { align: Alignment::Center.into(), size: (UiSize::Auto, UiSize::Auto), background: Some(vec4(0.1, 0.1, 0.1, 0.5)), - corner_radius: Some(Corners::all(8.)), + corner_radius: Corners::all(8.), elements: vec![ Box::new(Text { text: "Corners".into(), diff --git a/hui/src/element/builtin/container.rs b/hui/src/element/builtin/container.rs index 913b2bb..a4beb90 100644 --- a/hui/src/element/builtin/container.rs +++ b/hui/src/element/builtin/container.rs @@ -20,7 +20,7 @@ pub struct Container { pub align: Alignment2d, pub background: Option, pub borders: Sides>, - pub corner_radius: Option>, + pub corner_radius: Corners, //pub clip: bool, //TODO clip children pub elements: Vec>, } @@ -39,7 +39,7 @@ impl Default for Container { background: Default::default(), borders: Default::default(), elements: Vec::new(), - corner_radius: None, + corner_radius: Corners::all(0.), } } } @@ -130,7 +130,9 @@ impl UiElement for Container { position, size: ctx.measure.size, color, - rounded_corners: self.corner_radius.map(RoundedCorners::from_radius), + rounded_corners: (self.corner_radius.max_f32() > 0.).then_some({ + RoundedCorners::from_radius(self.corner_radius) + }), }); }