Initial commit
This commit is contained in:
commit
447b36e8c9
4 changed files with 3903 additions and 0 deletions
21
src/main.rs
Normal file
21
src/main.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
use winit::error::EventLoopError;
|
||||
use xilem::view::{button, flex, label};
|
||||
use xilem::{EventLoop, WidgetView, Xilem};
|
||||
|
||||
#[derive(Default)]
|
||||
struct Counter {
|
||||
num: i32,
|
||||
}
|
||||
|
||||
fn app_logic(data: &mut Counter) -> impl WidgetView<Counter> {
|
||||
flex((
|
||||
label(format!("{}", data.num)),
|
||||
button("increment", |data: &mut Counter| data.num += 1),
|
||||
))
|
||||
}
|
||||
|
||||
fn main() -> Result<(), EventLoopError> {
|
||||
let app = Xilem::new(Counter::default(), app_logic);
|
||||
app.run_windowed(EventLoop::with_user_event(), "Counter app".into())?;
|
||||
Ok(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue