Skip to main content

ferroui_base/rendering/composition/generated/
composition_simple_conic_gradient_brush.rs

1// @generated by scripts/generate_composition.py — do not edit
2
3//! `CompositionSimpleConicGradientBrush` (server only).
4//!
5//! Schema attributes: internal.
6
7use bitflags::bitflags;
8use crate::RelativePoint;
9use crate::rendering::composition::expressions::ExpressionVariant;
10use crate::rendering::composition::server::CompositionProperty;
11use crate::rendering::composition::server::CompositionPropertyOf;
12use crate::rendering::composition::server::IServerPropertyHost;
13use crate::rendering::composition::server::ServerPropertyValue;
14use crate::rendering::composition::server::ServerValueChange;
15use crate::rendering::composition::server::props_of;
16use crate::rendering::composition::transport::BatchStreamReader;
17use crate::rendering::composition::transport::BatchStreamWriter;
18use crate::rendering::composition::transport::BatchValue;
19use crate::rendering::composition::transport::BatchValueReader;
20use std::any::Any;
21use std::any::TypeId;
22use std::cell::Cell;
23use std::sync::OnceLock;
24use std::time::Duration;
25
26bitflags! {
27    /// The fields of `CompositionSimpleConicGradientBrush` that changed since its last serialization.
28    #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
29    pub struct CompositionSimpleConicGradientBrushChangedFields: u8 {
30        const ANGLE = 1;
31        const CENTER = 2;
32    }
33}
34
35impl BatchValue for CompositionSimpleConicGradientBrushChangedFields {
36    #[inline]
37    fn write_to(&self, out: &mut Vec<u8>) {
38        self.bits().write_to(out);
39    }
40
41    #[inline]
42    fn read_from(input: &mut BatchValueReader<'_>) -> Self {
43        CompositionSimpleConicGradientBrushChangedFields::from_bits_retain(u8::read_from(input))
44    }
45}
46
47/// The partial methods of `ServerCompositionSimpleConicGradientBrush`: implemented by the class that embeds
48/// [`ServerCompositionSimpleConicGradientBrushProps`]. Every hook defaults to doing nothing.
49pub trait ServerCompositionSimpleConicGradientBrushHooks: IServerPropertyHost {
50    /// `base.DeserializeChangesCore(reader, committedAt)`: reads the changes of
51    /// the hand-written base class `ServerCompositionSimpleGradientBrush`.
52    fn base_deserialize_changes_core(&self, reader: &mut BatchStreamReader<'_>, committed_at: Duration);
53
54    fn deserialize_changes_extra(&self, _reader: &mut BatchStreamReader<'_>) {}
55    fn on_fields_deserialized(&self, _changed: CompositionSimpleConicGradientBrushChangedFields) {}
56
57    fn on_angle_changed(&self) {}
58    fn on_angle_changing(&self) {}
59
60    fn on_center_changed(&self) {}
61    fn on_center_changing(&self) {}
62}
63
64/// The server-side properties of `ServerCompositionSimpleConicGradientBrush`.
65pub struct ServerCompositionSimpleConicGradientBrushProps {
66    angle: Cell<f64>,
67    center: Cell<RelativePoint>,
68}
69
70impl Default for ServerCompositionSimpleConicGradientBrushProps {
71    fn default() -> Self {
72        Self::new()
73    }
74}
75
76impl ServerCompositionSimpleConicGradientBrushProps {
77    /// Creates the properties with every field at the default of its type; the
78    /// values of the UI thread arrive with the first batch.
79    pub fn new() -> Self {
80        Self {
81            angle: Cell::new(Default::default()),
82            center: Cell::new(Default::default()),
83        }
84    }
85
86    /// This block or the block of a base class, by type: what
87    /// `IServerObject::get_props` of the embedding class returns.
88    pub fn find_props(&self, type_id: TypeId) -> Option<&dyn Any> {
89        if type_id == TypeId::of::<Self>() {
90            return Some(self);
91        }
92        None
93    }
94
95    /// The composition property of `Angle`.
96    pub fn id_of_angle_property() -> &'static CompositionPropertyOf<f64> {
97        static PROPERTY: OnceLock<CompositionPropertyOf<f64>> = OnceLock::new();
98        PROPERTY.get_or_init(|| {
99            CompositionProperty::register::<ServerCompositionSimpleConicGradientBrushProps, f64>(
100                "Angle",
101                "ServerCompositionSimpleConicGradientBrush",
102                |obj| props_of::<ServerCompositionSimpleConicGradientBrushProps>(obj).angle.get(),
103                |obj, v| props_of::<ServerCompositionSimpleConicGradientBrushProps>(obj).angle.set(v),
104                Some(|obj| ExpressionVariant::create(props_of::<ServerCompositionSimpleConicGradientBrushProps>(obj).angle.get())),
105                None,
106            )
107        })
108    }
109
110    /// `Angle`.
111    pub fn angle(&self) -> f64 {
112        self.angle.get()
113    }
114
115    pub fn set_angle(&self, host: &dyn ServerCompositionSimpleConicGradientBrushHooks, value: f64) {
116        let old_value = self.angle.get();
117        let mut changed = false;
118        if old_value.differs(&value) {
119            ServerCompositionSimpleConicGradientBrushHooks::on_angle_changing(host);
120            changed = true;
121        }
122        host.set_value(
123            Self::id_of_angle_property().base(),
124            ServerValueChange {
125                equal: old_value.default_equals(&value),
126                old_resource: None,
127                new_resource: None,
128                assign: &mut || self.angle.set(value),
129            },
130        );
131        if changed {
132            ServerCompositionSimpleConicGradientBrushHooks::on_angle_changed(host);
133        }
134    }
135
136    /// The composition property of `Center`.
137    pub fn id_of_center_property() -> &'static CompositionPropertyOf<RelativePoint> {
138        static PROPERTY: OnceLock<CompositionPropertyOf<RelativePoint>> = OnceLock::new();
139        PROPERTY.get_or_init(|| {
140            CompositionProperty::register::<ServerCompositionSimpleConicGradientBrushProps, RelativePoint>(
141                "Center",
142                "ServerCompositionSimpleConicGradientBrush",
143                |obj| props_of::<ServerCompositionSimpleConicGradientBrushProps>(obj).center.get(),
144                |obj, v| props_of::<ServerCompositionSimpleConicGradientBrushProps>(obj).center.set(v),
145                Some(|obj| ExpressionVariant::create(props_of::<ServerCompositionSimpleConicGradientBrushProps>(obj).center.get())),
146                None,
147            )
148        })
149    }
150
151    /// `Center`.
152    pub fn center(&self) -> RelativePoint {
153        self.center.get()
154    }
155
156    pub fn set_center(&self, host: &dyn ServerCompositionSimpleConicGradientBrushHooks, value: RelativePoint) {
157        let old_value = self.center.get();
158        let mut changed = false;
159        if old_value.differs(&value) {
160            ServerCompositionSimpleConicGradientBrushHooks::on_center_changing(host);
161            changed = true;
162        }
163        host.set_value(
164            Self::id_of_center_property().base(),
165            ServerValueChange {
166                equal: old_value.default_equals(&value),
167                old_resource: None,
168                new_resource: None,
169                assign: &mut || self.center.set(value),
170            },
171        );
172        if changed {
173            ServerCompositionSimpleConicGradientBrushHooks::on_center_changed(host);
174        }
175    }
176
177    /// Reads the changes of the object: the base class first, then the
178    /// changed-fields mask and the changed members of this class.
179    pub fn deserialize_changes_core(
180        &self,
181        host: &dyn ServerCompositionSimpleConicGradientBrushHooks,
182        reader: &mut BatchStreamReader<'_>,
183        committed_at: Duration,
184    ) {
185        ServerCompositionSimpleConicGradientBrushHooks::base_deserialize_changes_core(host, reader, committed_at);
186        ServerCompositionSimpleConicGradientBrushHooks::deserialize_changes_extra(host, reader);
187        let changed = reader.read::<CompositionSimpleConicGradientBrushChangedFields>();
188        if changed.contains(CompositionSimpleConicGradientBrushChangedFields::ANGLE) {
189            let value = reader.read::<f64>();
190            self.set_angle(host, value);
191        }
192        if changed.contains(CompositionSimpleConicGradientBrushChangedFields::CENTER) {
193            let value = reader.read::<RelativePoint>();
194            self.set_center(host, value);
195        }
196        ServerCompositionSimpleConicGradientBrushHooks::on_fields_deserialized(host, changed);
197    }
198
199    /// Writes every property of the class, in the form
200    /// [`deserialize_changes_core`](Self::deserialize_changes_core) reads.
201    pub fn serialize_all_changes(
202        writer: &mut BatchStreamWriter<'_>,
203        angle: f64,
204        center: RelativePoint,
205    ) {
206        writer.write(CompositionSimpleConicGradientBrushChangedFields::ANGLE | CompositionSimpleConicGradientBrushChangedFields::CENTER);
207        writer.write(angle);
208        writer.write(center);
209    }
210}