FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    ferro_property

    macro · ferroui-base · v0.5.0

    macro_rules! ferro_property
    

    Declares the accessor of a single property definition.

    impl Border {
        ferro_property!(pub fn background_property() -> StyledProperty<Option<Ref<Brush>>> {
            FerroProperty::register::<Border, _>("Background", None)
        });
    }
    

    The property is registered the first time the accessor is called on a thread. Property definitions, like the objects that use them, belong to the thread that created them.

    On its own the macro registers nothing until the accessor is called, so a lookup by name can miss the property. Declare the properties of a type in a ferro_properties! block instead, which also registers them when the type is initialised.

    Where an accessor cannot be written inside the block (it is generated by a local macro, or declared between other items), name the type whose initialisation it belongs to and list it in the block of that type:

    ferro_property!(for XYFocus; pub fn left_property() -> AttachedProperty<..> { .. });
    
    ferro_properties! { impl XYFocus, also [XYFocus::left_property] {} }
    

    View source

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.