mirror of
https://github.com/griffi-gh/hUI.git
synced 2024-11-25 16:38:42 -06:00
update mom downloader example
This commit is contained in:
parent
b2a318a0f6
commit
3432550566
|
@ -6,14 +6,9 @@ use winit::{
|
||||||
event_loop::{EventLoopBuilder, ControlFlow}
|
event_loop::{EventLoopBuilder, ControlFlow}
|
||||||
};
|
};
|
||||||
use hui::{
|
use hui::{
|
||||||
UiInstance,
|
|
||||||
element::{
|
element::{
|
||||||
progress_bar::ProgressBar,
|
container::{Alignment, Container, Sides}, progress_bar::ProgressBar, text::Text
|
||||||
container::{Container, Sides, Alignment},
|
}, elements, UiDirection, UiInstance, UiSize
|
||||||
text::Text
|
|
||||||
},
|
|
||||||
UiSize,
|
|
||||||
elements,
|
|
||||||
};
|
};
|
||||||
use hui_glium::GliumUiRenderer;
|
use hui_glium::GliumUiRenderer;
|
||||||
|
|
||||||
|
@ -57,38 +52,45 @@ fn main() {
|
||||||
align: (Alignment::Begin, Alignment::Begin),
|
align: (Alignment::Begin, Alignment::Begin),
|
||||||
size: (UiSize::Static(450.), UiSize::Auto),
|
size: (UiSize::Static(450.), UiSize::Auto),
|
||||||
background: Some(vec4(0.2, 0.2, 0.5, 1.)),
|
background: Some(vec4(0.2, 0.2, 0.5, 1.)),
|
||||||
|
corner_radius: Some(8.),
|
||||||
elements: elements(|el| {
|
elements: elements(|el| {
|
||||||
if instant.elapsed().as_secs_f32() < 5. {
|
if instant.elapsed().as_secs_f32() < 5. {
|
||||||
el.add(Text {
|
el.add(Text {
|
||||||
text: "Downloading your mom...".into(),
|
text: "Downloading your mom...".into(),
|
||||||
font: font_handle,
|
font: font_handle,
|
||||||
text_size: 32,
|
text_size: 24,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
el.add(ProgressBar {
|
el.add(ProgressBar {
|
||||||
value: mom_ratio,
|
value: mom_ratio,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
el.add(Text {
|
el.add(Container {
|
||||||
text: format!("{:.2}% ({:.1} GB)", mom_ratio * 100., mom_ratio * 10000.).into(),
|
direction: UiDirection::Horizontal,
|
||||||
font: font_handle,
|
align: (Alignment::End, Alignment::Center),
|
||||||
text_size: 24,
|
size: (UiSize::Fraction(1.), UiSize::Auto),
|
||||||
|
elements: vec![Box::new(Text {
|
||||||
|
text: format!("{:.2}% ({:.1} GB)", mom_ratio * 100., mom_ratio * 10000.).into(),
|
||||||
|
font: font_handle,
|
||||||
|
text_size: 16,
|
||||||
|
..Default::default()
|
||||||
|
})],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
} else if instant.elapsed().as_secs() < 10 {
|
} else if instant.elapsed().as_secs() < 10 {
|
||||||
el.add(Text {
|
el.add(Text {
|
||||||
text: "Error 413 Request Entity Too Large".into(),
|
text: "Error 413: Request Entity Too Large".into(),
|
||||||
font: font_handle,
|
font: font_handle,
|
||||||
color: vec4(1., 0.125, 0.125, 1.),
|
color: vec4(1., 0.125, 0.125, 1.),
|
||||||
text_size: 26,
|
text_size: 20,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
el.add(Text {
|
el.add(Text {
|
||||||
text: format!("Exiting in {}...", 10 - instant.elapsed().as_secs()).into(),
|
text: format!("Exiting in {}...", 10 - instant.elapsed().as_secs()).into(),
|
||||||
font: font_handle,
|
font: font_handle,
|
||||||
text_size: 24,
|
text_size: 16,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
});
|
||||||
} else {
|
} else {
|
||||||
window_target.exit();
|
window_target.exit();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue