xilem icon indicating copy to clipboard operation
xilem copied to clipboard

Write Xilem documentation

Open PoignardAzur opened this issue 1 year ago • 6 comments

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.

PoignardAzur avatar Jun 12 '24 16:06 PoignardAzur

+1

TechComet avatar Jul 27 '24 22:07 TechComet

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.

fardarter avatar Aug 09 '24 07:08 fardarter

Thank you for your offer. Some starting points.

Basic usage patterns

  • Xilem works based on a mapping of your application state to Views in app_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_logic is 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.

DJMcNab avatar Aug 09 '24 08:08 DJMcNab

how open new window ?, and add menus

TechComet avatar Aug 09 '24 18:08 TechComet

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

DJMcNab avatar Aug 12 '24 10:08 DJMcNab

I opened this PR to make some docs improvements.

ArtyomSinyugin avatar Jan 12 '25 13:01 ArtyomSinyugin