decal 0.6.0

Declarative DSL for describing scenes and rendering them to SVG or PNG
Documentation
/// Wires a node type into the builder system by providing sealed accessors for
/// layout, visual state, typography, and resources, and by generating the final
/// [`Drawable`] implementation.
///
/// # Parameters
/// - `$node`: The concrete node type.
/// - `build($this)`: A block that consumes the builder state and produces a
///   [`Node`].
macro_rules! impl_node_builder {
    (
        $node:ty,
        build($this:ident) $build:block
    ) => {
        #[allow(private_interfaces)]
        impl crate::capabilities::Sealed for $node {
            #[inline]
            fn layout(&self) -> &taffy::Style {
                &self.layout
            }

            #[inline]
            fn visual(&self) -> &crate::paint::Appearance {
                &self.visual
            }

            #[inline]
            fn typography(&self) -> &crate::layout::Typography {
                &self.typography
            }

            #[inline]
            fn resources(&self) -> &Vec<crate::paint::Resource> {
                &self.resources
            }

            //

            #[inline]
            fn layout_mut(&mut self) -> &mut taffy::Style {
                &mut self.layout
            }

            #[inline]
            fn visual_mut(&mut self) -> &mut crate::paint::Appearance {
                &mut self.visual
            }

            #[inline]
            fn typography_mut(&mut self) -> &mut crate::layout::Typography {
                &mut self.typography
            }

            #[inline]
            fn resources_mut(&mut self) -> &mut Vec<crate::paint::Resource> {
                &mut self.resources
            }
        }

        impl crate::capabilities::Drawable for $node {
            #[inline]
            fn finish(self) -> crate::layout::Node {
                let $this = self;
                $build
            }
        }
    };
}

pub(crate) use impl_node_builder;