diff --git a/hui-examples/examples/align.rs b/hui-examples/examples/align.rs index 2316dc8..fdeced3 100644 --- a/hui-examples/examples/align.rs +++ b/hui-examples/examples/align.rs @@ -92,7 +92,7 @@ fn main() { Box::new(Container { gap: 5., padding: Sides::all(5.), - background: Some(vec4(0., 0., 0., 0.5)), + background: vec4(0., 0., 0., 0.5), direction: UiDirection::Horizontal, elements: { let mut x: Vec> = vec![]; @@ -111,7 +111,7 @@ fn main() { ..Default::default() }), Box::new(Container { - background: Some(vec4(1., 0., 0., 1.)), + background: vec4(1., 0., 0., 1.), padding: Sides { top: 10., bottom: 20., diff --git a/hui-examples/examples/mom_downloader.rs b/hui-examples/examples/mom_downloader.rs index a680e64..9839c8c 100644 --- a/hui-examples/examples/mom_downloader.rs +++ b/hui-examples/examples/mom_downloader.rs @@ -50,12 +50,12 @@ fn main() { hui.add(Container { align: Alignment::Center.into(), size: (UiSize::Fraction(1.), UiSize::Fraction(1.)), - background: Some(vec4(0.1, 0.1, 0.1, 1.)), + background: vec4(0.1, 0.1, 0.1, 1.), elements: vec![Box::new(Container { gap: 5., padding: Sides::all(10.), size: (UiSize::Static(450.), UiSize::Auto), - background: Some(vec4(0.2, 0.2, 0.5, 1.)), + background: vec4(0.2, 0.2, 0.5, 1.), corner_radius: Corners::all(8.), elements: elements(|el| { if instant.elapsed().as_secs_f32() < 5. { diff --git a/hui-examples/examples/rounded_rect.rs b/hui-examples/examples/rounded_rect.rs index 9a1fa71..317a4d5 100644 --- a/hui-examples/examples/rounded_rect.rs +++ b/hui-examples/examples/rounded_rect.rs @@ -43,7 +43,7 @@ fn main() { elements: vec![Box::new(Container { align: Alignment::Center.into(), size: (UiSize::Fraction(0.5), UiSize::Fraction(0.5)), - background: Some(vec4(1., 0., 0., 1.)), + background: vec4(1., 0., 0., 1.), corner_radius: Corners { top_left: 10., top_right: 20., @@ -56,7 +56,7 @@ fn main() { direction: UiDirection::Horizontal, align: Alignment::Center.into(), size: (UiSize::Auto, UiSize::Auto), - background: Some(vec4(0.1, 0.1, 0.1, 0.5)), + background: vec4(0.1, 0.1, 0.1, 0.5), corner_radius: Corners::all(8.), elements: vec![ Box::new(Text { diff --git a/hui-examples/examples/text_weird.rs b/hui-examples/examples/text_weird.rs index f3ecae5..b90c66c 100644 --- a/hui-examples/examples/text_weird.rs +++ b/hui-examples/examples/text_weird.rs @@ -44,7 +44,7 @@ fn main() { hui.add(Container { size: (UiSize::Fraction(1.), UiSize::Fraction(1.)), - background: Some(vec4(0.1, 0.1, 0.1, 1.)), + background: vec4(0.1, 0.1, 0.1, 1.), elements: elements(|elem| { elem.add(Text { text: "THIS LINE SHOULD BE SHARP!".into(), diff --git a/hui/src/element/builtin/container.rs b/hui/src/element/builtin/container.rs index a4beb90..d9c0d2f 100644 --- a/hui/src/element/builtin/container.rs +++ b/hui/src/element/builtin/container.rs @@ -18,7 +18,7 @@ pub struct Container { pub padding: Sides, ///Primary/secondary axis pub align: Alignment2d, - pub background: Option, + pub background: Vec4, pub borders: Sides>, pub corner_radius: Corners, //pub clip: bool, //TODO clip children @@ -125,11 +125,11 @@ impl UiElement for Container { let mut position = ctx.layout.position; //background - if let Some(color) = self.background { + if self.background.z > 0. { ctx.draw.add(UiDrawCommand::Rectangle { position, size: ctx.measure.size, - color, + color: self.background, rounded_corners: (self.corner_radius.max_f32() > 0.).then_some({ RoundedCorners::from_radius(self.corner_radius) }),