decal 0.6.0

Declarative DSL for describing scenes and rendering them to SVG or PNG
Documentation
use crate::{
    capabilities::*,
    layout::{
        Node,
        NodeKind,
        Typography,
    },
    macros::impl_node_builder,
    paint::{
        Appearance,
        Resource,
    },
    primitives::FlexDirection,
};
use taffy::{
    Display,
    Style,
};

/// Flex container node.
#[derive(Debug, Default)]
pub struct Flex {
    layout: Style,
    visual: Appearance,
    typography: Typography,
    resources: Vec<Resource>,
}

impl_node_builder! {
    Flex,
    build(this) {
        Node::new(
            NodeKind::Flex,
            this.layout,
            this.visual,
            Some(this.typography),
            this.resources
        )
    }
}

impl Flex {
    /// Creates a new [`Flex`] node.
    ///
    /// # Returns
    /// - [`Self`]
    pub fn new(direction: FlexDirection) -> Self {
        Self {
            layout: Style {
                display: Display::Flex,
                flex_direction: direction.into(),
                ..Default::default()
            },
            ..Default::default()
        }
    }
}

impl Hideable for Flex {
    fn hidden(mut self, value: bool) -> Self {
        self.layout.display = if value { Display::None } else { Display::Flex };
        self
    }
}

impl AspectRatio for Flex {}
impl Background for Flex {}
impl Border for Flex {}
impl RoundedCorners for Flex {}
impl Dimensions for Flex {}
impl Gap for Flex {}
impl FlexContainer for Flex {}
impl ContainerAlignment for Flex {}
impl Margin for Flex {}
impl Padding for Flex {}
impl Clippable for Flex {}
impl Opacity for Flex {}
impl Positioned for Flex {}
impl Transformation for Flex {}
impl Textual for Flex {}
impl SelfAlignment for Flex {}
impl Visibility for Flex {}
impl FilterEffects for Flex {}
impl Blendable for Flex {}