mirror of
https://github.com/danbulant/cushy
synced 2026-06-13 19:42:39 +00:00
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.
27 lines
671 B
Rust
27 lines
671 B
Rust
use std::string::ToString;
|
|
|
|
use cushy::value::Dynamic;
|
|
use cushy::widget::MakeWidget;
|
|
use cushy::Run;
|
|
use figures::units::Lp;
|
|
|
|
fn main() -> cushy::Result {
|
|
let counter = Dynamic::new(0i32);
|
|
let label = counter.map_each(ToString::to_string);
|
|
|
|
label
|
|
.width(Lp::points(100))
|
|
.and("+".into_button().on_click(counter.with_clone(|counter| {
|
|
move |_| {
|
|
*counter.lock() += 1;
|
|
}
|
|
})))
|
|
.and("-".into_button().on_click(counter.with_clone(|counter| {
|
|
move |_| {
|
|
*counter.lock() -= 1;
|
|
}
|
|
})))
|
|
.into_columns()
|
|
.centered()
|
|
.run()
|
|
}
|