Skip to main content

scenes

Macro scenes 

Source
macro_rules! scenes {
    ($($clause:tt)*) => { ... };
}
Expand description

An app’s body, written the way Swift writes it.

scene::commands(scene::group(vec![…]), vec![…]) is the same thing inside out: the scenes read bottom-up, the commands are a second list far from what they attach to, and every body ends in .into_handle(). This reads in the order the app is built.

app::run_scene(|| scenes! {
    window_group { text("main") }
    settings { text("preferences") }
    window("Utility", "utility") { text("a second window") }
    menu_bar_extra("Status", "star.fill") { text("in the menu bar") }
    commands {
        menu("Counter") { button("Reset", || {}) }
        replacing(NewItem) { button("New Count", || {}) }
        after(Help) { button("About", || {}) }
    }
});

Each body is an ordinary block returning anything that is a view — a View, a ViewHandle, or a &str. commands is optional and goes last, which is also where Swift’s .commands { } ends up.

The window, settings and menu_bar_extra clauses are macOS-only, as the scenes themselves are; a scenes! using them does not compile for iOS, which is the same answer Swift gives.