Write Xilem documentation
Xilem's lack of documentation is one of the problems new users complain about the most often. We need to avoid staying in that state for too long.
We should at least document:
- All pub items.
- Basic usage patterns.
- How to create your first app.
- The general project architecture.
- Some of the project's history, eg the "Xilem classic" thing.
+1
If someone wants to teach me:
- basic usage patterns
- how to create your first app,
I'll write them up.
I don't even know rust yet (aside from very trivial syntax), so you'd get the view from someone very attentive to assumptions.
Thank you for your offer. Some starting points.
Basic usage patterns
- Xilem works based on a mapping of your application state to
Views inapp_logic - These create widgets, which your users interact with
- When these interactions happen, callbacks in your views are called
- These update the app state, and so your
app_logicis called again - The new view is then applied to the widgets.
How to create your first app
You'd add a dependency to Xilem (probably on the main branch), then set up your app:
fn app_logic(data: &mut i32) -> impl WidgetView<i32> {
flex((label(format!("{data}")), button("increment", |data: &mut i32| data+=1)))
}
fn main() -> Result<(), EventLoopError> {
let app = Xilem::new(0, app_logic);
app.run_windowed(EventLoop::with_user_event(), "Centered Flex".into())?;
Ok(())
}
A slightly more advanced pattern would use a custom struct in place of the i32, there.
how open new window ?, and add menus
Xilem and Masonry currently only support a single window. To open that window, you should see our examples.
Feel free to open a Zulip discussion around menus so we can mentor your implementation of them
I opened this PR to make some docs improvements.