mirror of
https://github.com/griffi-gh/hUI.git
synced 2024-11-21 22:58:42 -06:00
Remoev option wrapper for bg color
This commit is contained in:
parent
8f6a15e244
commit
ecc137bcd5
|
@ -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<Box<dyn UiElement>> = 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.,
|
||||
|
|
|
@ -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. {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -18,7 +18,7 @@ pub struct Container {
|
|||
pub padding: Sides<f32>,
|
||||
///Primary/secondary axis
|
||||
pub align: Alignment2d,
|
||||
pub background: Option<Vec4>,
|
||||
pub background: Vec4,
|
||||
pub borders: Sides<Option<Border>>,
|
||||
pub corner_radius: Corners<f32>,
|
||||
//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)
|
||||
}),
|
||||
|
|
Loading…
Reference in a new issue