Skip to main content

bind

Macro bind 

Source
macro_rules! bind {
    ($state:expr, $ui:expr, $( $id:expr => $name:ident $( : $ty:ident $(($arg:expr))? )? ),* $(,)?) => { ... };
    (@wire $state:expr, $ui:expr, $id:expr, $name:ident) => { ... };
    (@sync $state:expr, $ui:expr, $id:expr, $name:ident) => { ... };
    (@wire $state:expr, $ui:expr, $id:expr, $name:ident : bool) => { ... };
    (@sync $state:expr, $ui:expr, $id:expr, $name:ident : bool) => { ... };
    (@wire $state:expr, $ui:expr, $id:expr, $name:ident : choice($count:expr)) => { ... };
    (@sync $state:expr, $ui:expr, $id:expr, $name:ident : choice($count:expr)) => { ... };
}
Expand description

Bind Slint properties to truce parameters.

Generates both the on_<name>_changed callback wiring (UI → host) and returns a sync closure (host → UI) called each frame.

§Syntax

truce_slint::bind! { state, ui,
    PARAM_ID => property_name,              // float (default)
    PARAM_ID => property_name: bool,        // boolean
}

property_name must match the Slint property name. The macro calls ui.on_<name>_changed(...) and ui.set_<name>(...) via identifier concatenation.

§Example

let ui = MyPluginUi::new().unwrap();
truce_slint::bind! { state, ui,
    P::Gain   => gain,
    P::Pan    => pan,
    P::Bypass => bypass: bool,
}