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
8393cf48a3
commit
c80f42f900
|
@ -92,7 +92,7 @@ fn main() {
|
||||||
Box::new(Container {
|
Box::new(Container {
|
||||||
gap: 5.,
|
gap: 5.,
|
||||||
padding: Sides::all(5.),
|
padding: Sides::all(5.),
|
||||||
background: Some(vec4(0., 0., 0., 0.5)),
|
background: vec4(0., 0., 0., 0.5),
|
||||||
direction: UiDirection::Horizontal,
|
direction: UiDirection::Horizontal,
|
||||||
elements: {
|
elements: {
|
||||||
let mut x: Vec<Box<dyn UiElement>> = vec![];
|
let mut x: Vec<Box<dyn UiElement>> = vec![];
|
||||||
|
@ -111,7 +111,7 @@ fn main() {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}),
|
}),
|
||||||
Box::new(Container {
|
Box::new(Container {
|
||||||
background: Some(vec4(1., 0., 0., 1.)),
|
background: vec4(1., 0., 0., 1.),
|
||||||
padding: Sides {
|
padding: Sides {
|
||||||
top: 10.,
|
top: 10.,
|
||||||
bottom: 20.,
|
bottom: 20.,
|
||||||
|
|
|
@ -50,12 +50,12 @@ fn main() {
|
||||||
hui.add(Container {
|
hui.add(Container {
|
||||||
align: Alignment::Center.into(),
|
align: Alignment::Center.into(),
|
||||||
size: (UiSize::Fraction(1.), UiSize::Fraction(1.)),
|
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 {
|
elements: vec![Box::new(Container {
|
||||||
gap: 5.,
|
gap: 5.,
|
||||||
padding: Sides::all(10.),
|
padding: Sides::all(10.),
|
||||||
size: (UiSize::Static(450.), UiSize::Auto),
|
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.),
|
corner_radius: Corners::all(8.),
|
||||||
elements: elements(|el| {
|
elements: elements(|el| {
|
||||||
if instant.elapsed().as_secs_f32() < 5. {
|
if instant.elapsed().as_secs_f32() < 5. {
|
||||||
|
|
|
@ -43,7 +43,7 @@ fn main() {
|
||||||
elements: vec![Box::new(Container {
|
elements: vec![Box::new(Container {
|
||||||
align: Alignment::Center.into(),
|
align: Alignment::Center.into(),
|
||||||
size: (UiSize::Fraction(0.5), UiSize::Fraction(0.5)),
|
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 {
|
corner_radius: Corners {
|
||||||
top_left: 10.,
|
top_left: 10.,
|
||||||
top_right: 20.,
|
top_right: 20.,
|
||||||
|
@ -56,7 +56,7 @@ fn main() {
|
||||||
direction: UiDirection::Horizontal,
|
direction: UiDirection::Horizontal,
|
||||||
align: Alignment::Center.into(),
|
align: Alignment::Center.into(),
|
||||||
size: (UiSize::Auto, UiSize::Auto),
|
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.),
|
corner_radius: Corners::all(8.),
|
||||||
elements: vec![
|
elements: vec![
|
||||||
Box::new(Text {
|
Box::new(Text {
|
||||||
|
|
|
@ -44,7 +44,7 @@ fn main() {
|
||||||
|
|
||||||
hui.add(Container {
|
hui.add(Container {
|
||||||
size: (UiSize::Fraction(1.), UiSize::Fraction(1.)),
|
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| {
|
elements: elements(|elem| {
|
||||||
elem.add(Text {
|
elem.add(Text {
|
||||||
text: "THIS LINE SHOULD BE SHARP!".into(),
|
text: "THIS LINE SHOULD BE SHARP!".into(),
|
||||||
|
|
|
@ -18,7 +18,7 @@ pub struct Container {
|
||||||
pub padding: Sides<f32>,
|
pub padding: Sides<f32>,
|
||||||
///Primary/secondary axis
|
///Primary/secondary axis
|
||||||
pub align: Alignment2d,
|
pub align: Alignment2d,
|
||||||
pub background: Option<Vec4>,
|
pub background: Vec4,
|
||||||
pub borders: Sides<Option<Border>>,
|
pub borders: Sides<Option<Border>>,
|
||||||
pub corner_radius: Corners<f32>,
|
pub corner_radius: Corners<f32>,
|
||||||
//pub clip: bool, //TODO clip children
|
//pub clip: bool, //TODO clip children
|
||||||
|
@ -125,11 +125,11 @@ impl UiElement for Container {
|
||||||
let mut position = ctx.layout.position;
|
let mut position = ctx.layout.position;
|
||||||
|
|
||||||
//background
|
//background
|
||||||
if let Some(color) = self.background {
|
if self.background.z > 0. {
|
||||||
ctx.draw.add(UiDrawCommand::Rectangle {
|
ctx.draw.add(UiDrawCommand::Rectangle {
|
||||||
position,
|
position,
|
||||||
size: ctx.measure.size,
|
size: ctx.measure.size,
|
||||||
color,
|
color: self.background,
|
||||||
rounded_corners: (self.corner_radius.max_f32() > 0.).then_some({
|
rounded_corners: (self.corner_radius.max_f32() > 0.).then_some({
|
||||||
RoundedCorners::from_radius(self.corner_radius)
|
RoundedCorners::from_radius(self.corner_radius)
|
||||||
}),
|
}),
|
||||||
|
|
Loading…
Reference in a new issue