cushy/examples/progress.rs
Jonathan Johnson 2fe28729df
Directly depending on figures
While this was a workaround for a docs.rs issue (Px/Lp are not
linked), I decided having the shorter import path would look better in
the examples.

It probably wasn't necessary to update all of the references in the
internal code, but I decided it was worth the consistency.
2023-12-28 09:35:24 -08:00

37 lines
1 KiB
Rust

use cushy::value::{Dynamic, MapEach};
use cushy::widget::MakeWidget;
use cushy::widgets::progress::Progressable;
use cushy::widgets::slider::Slidable;
use cushy::Run;
use figures::units::Lp;
use figures::Size;
fn main() -> cushy::Result {
let indeterminant = Dynamic::new(false);
let value = Dynamic::new(0_u8);
let progress = (&indeterminant, &value)
.map_each(|(&indeterminant, &value)| (!indeterminant).then_some(value));
value
.clone()
.slider()
.and(
progress
.clone()
.progress_bar()
.expand()
.and(progress.clone().progress_bar().spinner())
.into_columns(),
)
.and("Indeterminant".into_checkbox(indeterminant))
.into_rows()
.fit_horizontally()
.expand()
.and(value.slider())
.and(progress.progress_bar())
.into_columns()
.pad()
.size(Size::squared(Lp::inches(3)))
.centered()
.run()
}