Skip to main content

rustmotion_components/
positioned.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/// Positioned container — children are placed at fixed absolute coordinates.
13/// Like Flutter's Stack/Positioned: each child uses its `position: {x, y}` field.
14#[derive(Debug, Serialize, Deserialize, JsonSchema)]
15pub struct Positioned {
16    #[serde(default)]
17    pub children: Vec<ChildComponent>,
18    #[serde(default)]
19    pub style: CssStyle,
20    #[serde(flatten)]
21    pub timing: TimingConfig,
22    #[serde(default)]
23    pub timeline: Vec<TimelineStep>,
24    #[serde(default)]
25    pub time_scale: Option<f64>,
26    #[serde(default)]
27    pub time_offset: Option<f64>,
28}
29
30rustmotion_core::impl_traits!(Positioned {
31    Animatable => animation,
32    Timed => timing,
33    Styled => style,
34});
35
36impl Painter for Positioned {
37    fn paint_content(
38        &self,
39        _canvas: &Canvas,
40        _layout: &BoxLayout,
41        _props: &rustmotion_core::engine::animator::AnimatedProperties,
42        _ctx: &PaintCtx,
43    ) {
44        // Containers paint nothing of their own. Box decorations are
45        // handled by paint_pass; children are recursed by paint_tree.
46    }
47}