FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    ferro_class_info

    macro · ferroui-base · v0.5.0

    macro_rules! ferro_class_info
    

    Declares the facts about a class that untyped code (markup, untyped bindings) needs and cannot derive: its default constructor, the interface handles its handle converts to and its markup metadata. Every part is optional; the parts may be written in any order.

    ferro_class!(SolidColorBrush: Brush);
    ferro_class_info!(SolidColorBrush {
        new: SolidColorBrush::new,
        interfaces: [Rc<dyn IBrush>],
    });
    
    ferro_class!(Panel: Control);
    ferro_class_info!(Panel {
        new: Panel::new,
        markup: {
            content: Children,
            properties: [
                Children: Rc<Controls> { get: Panel::children },
            ],
        },
    });
    
    • new is a function without parameters that returns the handle of a new instance. It implements DefaultConstructible for the class, the static path to the constructor, and becomes TypeInfo::default_constructor with the tables of types (the feature type-tables; see TypeInfo::with_constructor).
    • interfaces lists the handle types I that Ref<Class> converts to with Into<I>, or, as I => function, with the given fn(Ref<Class>) -> I (for an interface of another crate, for which the conversion trait cannot be implemented). They are registered with the untyped value conversions when the class is initialised, for the class and every class deriving from it (a more derived class that lists the same interface takes precedence for its own instances), and are listed by TypeInfo::interfaces.
    • markup states what markup needs beyond the registered properties of the class, which need no declaration: the content property, plain (non-registered) properties and collections, constructors with arguments, methods, static values, events and attributes. The parts are the ones of ferro_markup_type! (without handles, this and base, which follow from the class); instance members are called with &Ref<Class>, so Class::method paths work as callables. It becomes TypeInfo::markup: constant data that costs nothing until it is read.

    View source

    Availability

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