mirror of
https://github.com/danbulant/cushy
synced 2026-05-25 12:52:40 +00:00
25 lines
770 B
Rust
25 lines
770 B
Rust
use std::string::ToString;
|
|
|
|
use gooey::value::Dynamic;
|
|
use gooey::widgets::{Align, Button, Expand, Label, Resize, Stack};
|
|
use gooey::{widgets, Run};
|
|
use kludgine::figures::units::Lp;
|
|
|
|
fn main() -> gooey::Result {
|
|
let counter = Dynamic::new(0i32);
|
|
let label = counter.map_each(ToString::to_string);
|
|
Expand::new(Align::centered(Stack::columns(widgets![
|
|
Resize::width(Lp::points(100), Label::new(label)),
|
|
Button::new("+").on_click(counter.with_clone(|counter| {
|
|
move |_| {
|
|
counter.set(counter.get() + 1);
|
|
}
|
|
})),
|
|
Button::new("-").on_click(counter.with_clone(|counter| {
|
|
move |_| {
|
|
counter.set(counter.get() - 1);
|
|
}
|
|
})),
|
|
])))
|
|
.run()
|
|
}
|