Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write Xilem documentation #392

Open
PoignardAzur opened this issue Jun 12, 2024 · 5 comments
Open

Write Xilem documentation #392

PoignardAzur opened this issue Jun 12, 2024 · 5 comments
Labels
documentation Improvements or additions to documentation

Comments

@PoignardAzur
Copy link
Contributor

PoignardAzur commented Jun 12, 2024

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.
@waywardmonkeys waywardmonkeys added the documentation Improvements or additions to documentation label Jul 25, 2024
@TechComet
Copy link

+1

@fardarter
Copy link

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.

@DJMcNab
Copy link
Member

DJMcNab commented Aug 9, 2024

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.

@TechComet
Copy link

TechComet commented Aug 9, 2024

how open new window ?, and add menus

@DJMcNab
Copy link
Member

DJMcNab commented Aug 12, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

5 participants