# ferro_properties

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/macro-ferro_properties/

**macro** · [`ferroui-base`](/docs/0.5.0/api/ferroui-base/) · v0.5.0

```rust
macro_rules! ferro_properties
```

Declares the property definitions of a type: the accessors, as
[`ferro_property!`](/docs/0.5.0/api/ferroui-base/macro-ferro_property/) declares them one by one, and their registration as
part of the static initialisation of the type.

```ignore
ferro_properties! {
    impl Border {
        /// Defines the `Background` property.
        pub fn background_property() -> StyledProperty<Option<Ref<Brush>>> {
            FerroProperty::register::<Border, _>("Background", None)
        }

        /// Defines the `Child` property (declared by another class).
        pub fn child_property() -> StyledProperty<Option<Ref<Control>>> {
            Decorator::child_property().add_owner::<Border>()
        }
    }
}
```

All the properties are registered, in declaration order (the order of the
static field initialisers of the managed class), when the type is
initialised on a thread: when the first instance of the class or of a
class deriving from it is created, when one of the accessors is first
called, or when the property registry is asked about the type, whichever
comes first. A lookup by name therefore finds every property, whether or
not its accessor was called and whether or not an instance exists. After
that an accessor is a thread-local read, exactly as with
[`ferro_property!`](/docs/0.5.0/api/ferroui-base/macro-ferro_property/).

The owner is a class (`ferro_class!`) or a type
declared with `ferro_static_type!`.

Existing `ferro_property!(..);` invocations can be wrapped in the block
unchanged:

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

A type has one such block. Properties of the type that are declared
elsewhere are named by it: `impl Owner, also [path, ..] { .. }` registers
the properties of the block first and then calls the listed functions in
order. A listed function is either

* the registration function of another block of accessors, declared with
  `ferro_properties! { impl Owner, fn name { .. } }` (an upstream partial
  class in a second file): `also [InputElement::register_gesture_properties]`;
* or a single accessor declared with `ferro_property!(for Owner; ..)`
  (accessors generated by a local macro or interleaved with other items):
  `also [XYFocus::left_property, XYFocus::right_property]`.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/ferro_property.rs#L1327)

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
