Skip to main content

rustmotion_components/
container.rs

1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3use skia_safe::Canvas;
4
5use rustmotion_core::css::CssStyle;
6use rustmotion_core::engine::layout_pass::BoxLayout;
7use rustmotion_core::schema::TimelineStep;
8use rustmotion_core::traits::{PaintCtx, Painter, TimingConfig};
9
10use crate::ChildComponent;
11
12/// Invisible flex container — the HTML `<div>` equivalent.
13/// No visual defaults (no background, border-radius, or shadow).
14/// Gets `display: flex` automatically, like every other layout container.
15/// Accepts `"type": "div"` as an alias in JSON.
16#[derive(Debug, Serialize, Deserialize, JsonSchema)]
17pub struct ContainerComponent {
18    #[serde(default)]
19    pub children: Vec<ChildComponent>,
20    #[serde(flatten)]
21    pub timing: TimingConfig,
22    #[serde(default)]
23    pub style: CssStyle,
24    #[serde(default)]
25    pub timeline: Vec<TimelineStep>,
26    #[serde(default)]
27    pub stagger: Option<f32>,
28    #[serde(default)]
29    pub time_scale: Option<f64>,
30    #[serde(default)]
31    pub time_offset: Option<f64>,
32}
33
34rustmotion_core::impl_traits!(ContainerComponent {
35    Animatable => animation,
36    Timed => timing,
37    Styled => style,
38});
39
40impl Painter for ContainerComponent {
41    fn paint_content(
42        &self,
43        _canvas: &Canvas,
44        _layout: &BoxLayout,
45        _props: &rustmotion_core::engine::animator::AnimatedProperties,
46        _ctx: &PaintCtx,
47    ) {
48    }
49}