Skip to main content

ferroui_base/rendering/composition/generated/
composition_container_visual.rs

1// @generated by scripts/generate_composition.py — do not edit
2
3//! `CompositionContainerVisual`.
4
5use crate::rendering::composition::animations::ICompositionAnimation;
6use crate::rendering::composition::expressions::ExpressionVariant;
7use crate::rendering::composition::server::CompositionProperty;
8use crate::rendering::composition::transport::BatchStreamReader;
9use crate::rendering::composition::transport::BatchStreamWriter;
10use std::any::Any;
11use std::any::TypeId;
12use std::time::Duration;
13use super::CompositionVisualHooks;
14use super::CompositionVisualProps;
15use super::ServerCompositionVisualHooks;
16use super::ServerCompositionVisualProps;
17
18/// The partial methods of `CompositionContainerVisual`: implemented by the class that embeds
19/// [`CompositionContainerVisualProps`]. Every hook defaults to doing nothing.
20pub trait CompositionContainerVisualHooks: CompositionVisualHooks {
21    fn initialize_defaults_extra(&self) {}
22}
23
24/// The UI-thread properties of `CompositionContainerVisual`.
25pub struct CompositionContainerVisualProps {
26    base: CompositionVisualProps,
27}
28
29impl Default for CompositionContainerVisualProps {
30    fn default() -> Self {
31        Self::new()
32    }
33}
34
35impl CompositionContainerVisualProps {
36    /// Creates the properties with every field at the default of its type.
37    /// The defaults of the schema are applied by
38    /// [`initialize_defaults`](Self::initialize_defaults).
39    pub fn new() -> Self {
40        Self {
41            base: CompositionVisualProps::new(),
42        }
43    }
44
45    /// The properties of the base class.
46    pub fn base(&self) -> &CompositionVisualProps {
47        &self.base
48    }
49
50    /// The `InitializeDefaults` calls of the constructor chain: the base
51    /// classes first, then this class.
52    pub fn initialize_defaults(&self, host: &dyn CompositionContainerVisualHooks) {
53        self.base.initialize_defaults(host);
54        self.initialize_own_defaults(host);
55    }
56
57    /// `InitializeDefaults` of this class alone.
58    pub fn initialize_own_defaults(&self, host: &dyn CompositionContainerVisualHooks) {
59        CompositionContainerVisualHooks::initialize_defaults_extra(host);
60    }
61
62    /// Connects an animation with the named property. Returns `false` when
63    /// neither this class nor its generated bases have an animated property
64    /// of that name: the caller continues with its hand-written base.
65    pub fn start_animation(
66        &self,
67        host: &dyn CompositionContainerVisualHooks,
68        property_name: &str,
69        animation: &dyn ICompositionAnimation,
70        final_value: Option<ExpressionVariant>,
71    ) -> bool {
72        self.base.start_animation(host, property_name, animation, final_value)
73    }
74
75    /// Writes the changes of the object: the base class first, then the
76    /// changed-fields mask and the changed members of this class.
77    pub fn serialize_changes_core(&self, host: &dyn CompositionContainerVisualHooks, writer: &mut BatchStreamWriter<'_>) {
78        self.base.serialize_changes_core(host, writer);
79    }
80}
81
82/// The partial methods of `ServerCompositionContainerVisual`: implemented by the class that embeds
83/// [`ServerCompositionContainerVisualProps`]. Every hook defaults to doing nothing.
84pub trait ServerCompositionContainerVisualHooks: ServerCompositionVisualHooks {
85}
86
87/// The server-side properties of `ServerCompositionContainerVisual`.
88pub struct ServerCompositionContainerVisualProps {
89    base: ServerCompositionVisualProps,
90}
91
92impl Default for ServerCompositionContainerVisualProps {
93    fn default() -> Self {
94        Self::new()
95    }
96}
97
98impl ServerCompositionContainerVisualProps {
99    /// Creates the properties with every field at the default of its type; the
100    /// values of the UI thread arrive with the first batch.
101    pub fn new() -> Self {
102        Self {
103            base: ServerCompositionVisualProps::new(),
104        }
105    }
106
107    /// The properties of the base class.
108    pub fn base(&self) -> &ServerCompositionVisualProps {
109        &self.base
110    }
111
112    /// This block or the block of a base class, by type: what
113    /// `IServerObject::get_props` of the embedding class returns.
114    pub fn find_props(&self, type_id: TypeId) -> Option<&dyn Any> {
115        if type_id == TypeId::of::<Self>() {
116            return Some(self);
117        }
118        self.base.find_props(type_id)
119    }
120
121    /// Reads the changes of the object: the base class first, then the
122    /// changed-fields mask and the changed members of this class.
123    pub fn deserialize_changes_core(
124        &self,
125        host: &dyn ServerCompositionContainerVisualHooks,
126        reader: &mut BatchStreamReader<'_>,
127        committed_at: Duration,
128    ) {
129        self.base.deserialize_changes_core(host, reader, committed_at);
130    }
131
132    /// The composition property with the given name, among the properties
133    /// of this class and of its generated bases that have a variant form.
134    pub fn get_composition_property(name: &str) -> Option<&'static CompositionProperty> {
135        ServerCompositionVisualProps::get_composition_property(name)
136    }
137}