mirror of
https://github.com/griffi-gh/hUI.git
synced 2024-11-28 18:08:42 -06:00
remove the need for wrapped option
This commit is contained in:
parent
385d7edb6a
commit
8f6a15e244
|
@ -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.)),
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -20,7 +20,7 @@ pub struct Container {
|
|||
pub align: Alignment2d,
|
||||
pub background: Option<Vec4>,
|
||||
pub borders: Sides<Option<Border>>,
|
||||
pub corner_radius: Option<Corners<f32>>,
|
||||
pub corner_radius: Corners<f32>,
|
||||
//pub clip: bool, //TODO clip children
|
||||
pub elements: Vec<Box<dyn UiElement>>,
|
||||
}
|
||||
|
@ -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)
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue