mirror of
https://github.com/danbulant/cushy
synced 2026-06-19 06:21:15 +00:00
Closes #98 This finishes my initial refactoring of the dynamic system to add support for several dataflows including: - Pure data sources that can be implemented using an `Owned<T>` at the root of a graph of `Dynamic<U>`/`DynamicReader<U>`s. - Read-only data sinks. I thought this would be more useful across other widgets, but in general, Progress and Label seem like the only types that this applies to currently. - The ability to mix/match Dynamic/DynamicReader in tuple-based for_each/map_each.
26 lines
643 B
Rust
26 lines
643 B
Rust
use cushy::value::{Dynamic, IntoReader};
|
|
use cushy::widget::MakeWidget;
|
|
use cushy::Run;
|
|
use figures::units::Lp;
|
|
|
|
fn main() -> cushy::Result {
|
|
let counter = Dynamic::new(0i32);
|
|
|
|
counter
|
|
.clone()
|
|
.into_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()
|
|
}
|