Skip to main content

ferroui_base/rendering/composition/generated/
composition_radial_gradient_brush.rs

1// @generated by scripts/generate_composition.py — do not edit
2
3//! `CompositionRadialGradientBrush`.
4
5use bitflags::bitflags;
6use crate::RelativePoint;
7use crate::RelativeScalar;
8use crate::rendering::composition::ICompositionObjectHost;
9use crate::rendering::composition::animations::AnimationInstanceFactory;
10use crate::rendering::composition::animations::ICompositionAnimation;
11use crate::rendering::composition::expressions::ExpressionVariant;
12use crate::rendering::composition::server::CompositionProperty;
13use crate::rendering::composition::server::CompositionPropertyOf;
14use crate::rendering::composition::server::IServerAnimatedPropertyHost;
15use crate::rendering::composition::server::ServerPropertyValue;
16use crate::rendering::composition::server::props_of;
17use crate::rendering::composition::transport::BatchStreamReader;
18use crate::rendering::composition::transport::BatchStreamWriter;
19use crate::rendering::composition::transport::BatchValue;
20use crate::rendering::composition::transport::BatchValueReader;
21use std::any::Any;
22use std::any::TypeId;
23use std::cell::Cell;
24use std::sync::OnceLock;
25use std::time::Duration;
26
27bitflags! {
28    /// The fields of `CompositionRadialGradientBrush` that changed since its last serialization.
29    #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
30    pub struct CompositionRadialGradientBrushChangedFields: u8 {
31        const CENTER = 1;
32        const CENTER_ANIMATED = 2;
33        const GRADIENT_ORIGIN = 4;
34        const GRADIENT_ORIGIN_ANIMATED = 8;
35        const RADIUS_X = 16;
36        const RADIUS_X_ANIMATED = 32;
37        const RADIUS_Y = 64;
38        const RADIUS_Y_ANIMATED = 128;
39    }
40}
41
42impl BatchValue for CompositionRadialGradientBrushChangedFields {
43    #[inline]
44    fn write_to(&self, out: &mut Vec<u8>) {
45        self.bits().write_to(out);
46    }
47
48    #[inline]
49    fn read_from(input: &mut BatchValueReader<'_>) -> Self {
50        CompositionRadialGradientBrushChangedFields::from_bits_retain(u8::read_from(input))
51    }
52}
53
54/// The partial methods of `CompositionRadialGradientBrush`: implemented by the class that embeds
55/// [`CompositionRadialGradientBrushProps`]. Every hook defaults to doing nothing.
56pub trait CompositionRadialGradientBrushHooks: ICompositionObjectHost {
57    /// `base.SerializeChangesCore(writer)`: serializes the changes of the
58    /// hand-written base class `CompositionGradientBrush`.
59    fn base_serialize_changes_core(&self, writer: &mut BatchStreamWriter<'_>);
60
61    fn initialize_defaults_extra(&self) {}
62
63    fn validate_center_change(&self, _old_value: RelativePoint, _new_value: RelativePoint) {}
64    fn on_center_changed(&self) {}
65    fn on_center_changing(&self) {}
66
67    fn validate_gradient_origin_change(&self, _old_value: RelativePoint, _new_value: RelativePoint) {}
68    fn on_gradient_origin_changed(&self) {}
69    fn on_gradient_origin_changing(&self) {}
70
71    fn validate_radius_x_change(&self, _old_value: RelativeScalar, _new_value: RelativeScalar) {}
72    fn on_radius_x_changed(&self) {}
73    fn on_radius_x_changing(&self) {}
74
75    fn validate_radius_y_change(&self, _old_value: RelativeScalar, _new_value: RelativeScalar) {}
76    fn on_radius_y_changed(&self) {}
77    fn on_radius_y_changing(&self) {}
78}
79
80/// The UI-thread properties of `CompositionRadialGradientBrush`.
81pub struct CompositionRadialGradientBrushProps {
82    changed_fields_of_composition_radial_gradient_brush: Cell<CompositionRadialGradientBrushChangedFields>,
83    center: Cell<RelativePoint>,
84    gradient_origin: Cell<RelativePoint>,
85    radius_x: Cell<RelativeScalar>,
86    radius_y: Cell<RelativeScalar>,
87}
88
89impl Default for CompositionRadialGradientBrushProps {
90    fn default() -> Self {
91        Self::new()
92    }
93}
94
95impl CompositionRadialGradientBrushProps {
96    /// Creates the properties with every field at the default of its type.
97    /// The defaults of the schema are applied by
98    /// [`initialize_defaults`](Self::initialize_defaults).
99    pub fn new() -> Self {
100        Self {
101            changed_fields_of_composition_radial_gradient_brush: Cell::new(CompositionRadialGradientBrushChangedFields::empty()),
102            center: Cell::new(Default::default()),
103            gradient_origin: Cell::new(Default::default()),
104            radius_x: Cell::new(Default::default()),
105            radius_y: Cell::new(Default::default()),
106        }
107    }
108
109    /// The `InitializeDefaults` calls of the constructor chain: the base
110    /// classes first, then this class.
111    pub fn initialize_defaults(&self, host: &dyn CompositionRadialGradientBrushHooks) {
112        self.initialize_own_defaults(host);
113    }
114
115    /// `InitializeDefaults` of this class alone.
116    pub fn initialize_own_defaults(&self, host: &dyn CompositionRadialGradientBrushHooks) {
117        CompositionRadialGradientBrushHooks::initialize_defaults_extra(host);
118        self.set_radius_x(host, RelativeScalar::MIDDLE);
119        self.set_radius_y(host, RelativeScalar::MIDDLE);
120    }
121
122    /// `Center` (animated).
123    pub fn center(&self) -> RelativePoint {
124        self.center.get()
125    }
126
127    /// Sets `Center` (animated).
128    pub fn set_center(&self, host: &dyn CompositionRadialGradientBrushHooks, value: RelativePoint) {
129        let mut changed = false;
130        let old_value = self.center.get();
131        if old_value.differs(&value) {
132            CompositionRadialGradientBrushHooks::validate_center_change(host, old_value, value);
133            CompositionRadialGradientBrushHooks::on_center_changing(host);
134            changed = true;
135            // Update the backing value
136            self.center.set(value);
137            // Register object for serialization in the next batch
138            self.changed_fields_of_composition_radial_gradient_brush.set(self.changed_fields_of_composition_radial_gradient_brush.get() | CompositionRadialGradientBrushChangedFields::CENTER);
139            host.register_for_serialization();
140            // Reset previous animation if any
141            host.pending_animations().remove(ServerCompositionRadialGradientBrushProps::id_of_center_property().base());
142            self.changed_fields_of_composition_radial_gradient_brush.set(self.changed_fields_of_composition_radial_gradient_brush.get() & !CompositionRadialGradientBrushChangedFields::CENTER_ANIMATED);
143            // Check for implicit animations
144            if let Some(animation) = host.implicit_animation("Center") {
145                // Animation affects only current property
146                if let Some(a) = animation.as_composition_animation() {
147                    self.changed_fields_of_composition_radial_gradient_brush.set(self.changed_fields_of_composition_radial_gradient_brush.get() | CompositionRadialGradientBrushChangedFields::CENTER_ANIMATED);
148                    host.pending_animations().set(
149                        ServerCompositionRadialGradientBrushProps::id_of_center_property().base(),
150                        a.create_instance(host.server(), Some(ExpressionVariant::create(value))),
151                    );
152                }
153                // Animation is triggered by the current field, but does not necessary affects it
154                host.start_animation_group(&animation, "Center", ExpressionVariant::create(value));
155            }
156        }
157        self.center.set(value);
158        if changed {
159            CompositionRadialGradientBrushHooks::on_center_changed(host);
160        }
161    }
162
163    /// `GradientOrigin` (animated).
164    pub fn gradient_origin(&self) -> RelativePoint {
165        self.gradient_origin.get()
166    }
167
168    /// Sets `GradientOrigin` (animated).
169    pub fn set_gradient_origin(&self, host: &dyn CompositionRadialGradientBrushHooks, value: RelativePoint) {
170        let mut changed = false;
171        let old_value = self.gradient_origin.get();
172        if old_value.differs(&value) {
173            CompositionRadialGradientBrushHooks::validate_gradient_origin_change(host, old_value, value);
174            CompositionRadialGradientBrushHooks::on_gradient_origin_changing(host);
175            changed = true;
176            // Update the backing value
177            self.gradient_origin.set(value);
178            // Register object for serialization in the next batch
179            self.changed_fields_of_composition_radial_gradient_brush.set(self.changed_fields_of_composition_radial_gradient_brush.get() | CompositionRadialGradientBrushChangedFields::GRADIENT_ORIGIN);
180            host.register_for_serialization();
181            // Reset previous animation if any
182            host.pending_animations().remove(ServerCompositionRadialGradientBrushProps::id_of_gradient_origin_property().base());
183            self.changed_fields_of_composition_radial_gradient_brush.set(self.changed_fields_of_composition_radial_gradient_brush.get() & !CompositionRadialGradientBrushChangedFields::GRADIENT_ORIGIN_ANIMATED);
184            // Check for implicit animations
185            if let Some(animation) = host.implicit_animation("GradientOrigin") {
186                // Animation affects only current property
187                if let Some(a) = animation.as_composition_animation() {
188                    self.changed_fields_of_composition_radial_gradient_brush.set(self.changed_fields_of_composition_radial_gradient_brush.get() | CompositionRadialGradientBrushChangedFields::GRADIENT_ORIGIN_ANIMATED);
189                    host.pending_animations().set(
190                        ServerCompositionRadialGradientBrushProps::id_of_gradient_origin_property().base(),
191                        a.create_instance(host.server(), Some(ExpressionVariant::create(value))),
192                    );
193                }
194                // Animation is triggered by the current field, but does not necessary affects it
195                host.start_animation_group(&animation, "GradientOrigin", ExpressionVariant::create(value));
196            }
197        }
198        self.gradient_origin.set(value);
199        if changed {
200            CompositionRadialGradientBrushHooks::on_gradient_origin_changed(host);
201        }
202    }
203
204    /// `RadiusX` (animated, default `RelativeScalar::MIDDLE`).
205    pub fn radius_x(&self) -> RelativeScalar {
206        self.radius_x.get()
207    }
208
209    /// Sets `RadiusX` (animated, default `RelativeScalar::MIDDLE`).
210    pub fn set_radius_x(&self, host: &dyn CompositionRadialGradientBrushHooks, value: RelativeScalar) {
211        let mut changed = false;
212        let old_value = self.radius_x.get();
213        if old_value.differs(&value) {
214            CompositionRadialGradientBrushHooks::validate_radius_x_change(host, old_value, value);
215            CompositionRadialGradientBrushHooks::on_radius_x_changing(host);
216            changed = true;
217            // Update the backing value
218            self.radius_x.set(value);
219            // Register object for serialization in the next batch
220            self.changed_fields_of_composition_radial_gradient_brush.set(self.changed_fields_of_composition_radial_gradient_brush.get() | CompositionRadialGradientBrushChangedFields::RADIUS_X);
221            host.register_for_serialization();
222            // Reset previous animation if any
223            host.pending_animations().remove(ServerCompositionRadialGradientBrushProps::id_of_radius_x_property().base());
224            self.changed_fields_of_composition_radial_gradient_brush.set(self.changed_fields_of_composition_radial_gradient_brush.get() & !CompositionRadialGradientBrushChangedFields::RADIUS_X_ANIMATED);
225            // Check for implicit animations
226            if let Some(animation) = host.implicit_animation("RadiusX") {
227                // Animation affects only current property
228                if let Some(a) = animation.as_composition_animation() {
229                    self.changed_fields_of_composition_radial_gradient_brush.set(self.changed_fields_of_composition_radial_gradient_brush.get() | CompositionRadialGradientBrushChangedFields::RADIUS_X_ANIMATED);
230                    host.pending_animations().set(
231                        ServerCompositionRadialGradientBrushProps::id_of_radius_x_property().base(),
232                        a.create_instance(host.server(), Some(ExpressionVariant::create(value))),
233                    );
234                }
235                // Animation is triggered by the current field, but does not necessary affects it
236                host.start_animation_group(&animation, "RadiusX", ExpressionVariant::create(value));
237            }
238        }
239        self.radius_x.set(value);
240        if changed {
241            CompositionRadialGradientBrushHooks::on_radius_x_changed(host);
242        }
243    }
244
245    /// `RadiusY` (animated, default `RelativeScalar::MIDDLE`).
246    pub fn radius_y(&self) -> RelativeScalar {
247        self.radius_y.get()
248    }
249
250    /// Sets `RadiusY` (animated, default `RelativeScalar::MIDDLE`).
251    pub fn set_radius_y(&self, host: &dyn CompositionRadialGradientBrushHooks, value: RelativeScalar) {
252        let mut changed = false;
253        let old_value = self.radius_y.get();
254        if old_value.differs(&value) {
255            CompositionRadialGradientBrushHooks::validate_radius_y_change(host, old_value, value);
256            CompositionRadialGradientBrushHooks::on_radius_y_changing(host);
257            changed = true;
258            // Update the backing value
259            self.radius_y.set(value);
260            // Register object for serialization in the next batch
261            self.changed_fields_of_composition_radial_gradient_brush.set(self.changed_fields_of_composition_radial_gradient_brush.get() | CompositionRadialGradientBrushChangedFields::RADIUS_Y);
262            host.register_for_serialization();
263            // Reset previous animation if any
264            host.pending_animations().remove(ServerCompositionRadialGradientBrushProps::id_of_radius_y_property().base());
265            self.changed_fields_of_composition_radial_gradient_brush.set(self.changed_fields_of_composition_radial_gradient_brush.get() & !CompositionRadialGradientBrushChangedFields::RADIUS_Y_ANIMATED);
266            // Check for implicit animations
267            if let Some(animation) = host.implicit_animation("RadiusY") {
268                // Animation affects only current property
269                if let Some(a) = animation.as_composition_animation() {
270                    self.changed_fields_of_composition_radial_gradient_brush.set(self.changed_fields_of_composition_radial_gradient_brush.get() | CompositionRadialGradientBrushChangedFields::RADIUS_Y_ANIMATED);
271                    host.pending_animations().set(
272                        ServerCompositionRadialGradientBrushProps::id_of_radius_y_property().base(),
273                        a.create_instance(host.server(), Some(ExpressionVariant::create(value))),
274                    );
275                }
276                // Animation is triggered by the current field, but does not necessary affects it
277                host.start_animation_group(&animation, "RadiusY", ExpressionVariant::create(value));
278            }
279        }
280        self.radius_y.set(value);
281        if changed {
282            CompositionRadialGradientBrushHooks::on_radius_y_changed(host);
283        }
284    }
285
286    /// Connects an animation with the named property. Returns `false` when
287    /// neither this class nor its generated bases have an animated property
288    /// of that name: the caller continues with its hand-written base.
289    pub fn start_animation(
290        &self,
291        host: &dyn CompositionRadialGradientBrushHooks,
292        property_name: &str,
293        animation: &dyn ICompositionAnimation,
294        final_value: Option<ExpressionVariant>,
295    ) -> bool {
296        if property_name == "Center" {
297            let server = animation.create_instance(host.server(), final_value);
298            host.pending_animations().set(ServerCompositionRadialGradientBrushProps::id_of_center_property().base(), server);
299            self.changed_fields_of_composition_radial_gradient_brush.set(self.changed_fields_of_composition_radial_gradient_brush.get() | CompositionRadialGradientBrushChangedFields::CENTER_ANIMATED);
300            host.register_for_serialization();
301            return true;
302        }
303        if property_name == "GradientOrigin" {
304            let server = animation.create_instance(host.server(), final_value);
305            host.pending_animations().set(ServerCompositionRadialGradientBrushProps::id_of_gradient_origin_property().base(), server);
306            self.changed_fields_of_composition_radial_gradient_brush.set(self.changed_fields_of_composition_radial_gradient_brush.get() | CompositionRadialGradientBrushChangedFields::GRADIENT_ORIGIN_ANIMATED);
307            host.register_for_serialization();
308            return true;
309        }
310        if property_name == "RadiusX" {
311            let server = animation.create_instance(host.server(), final_value);
312            host.pending_animations().set(ServerCompositionRadialGradientBrushProps::id_of_radius_x_property().base(), server);
313            self.changed_fields_of_composition_radial_gradient_brush.set(self.changed_fields_of_composition_radial_gradient_brush.get() | CompositionRadialGradientBrushChangedFields::RADIUS_X_ANIMATED);
314            host.register_for_serialization();
315            return true;
316        }
317        if property_name == "RadiusY" {
318            let server = animation.create_instance(host.server(), final_value);
319            host.pending_animations().set(ServerCompositionRadialGradientBrushProps::id_of_radius_y_property().base(), server);
320            self.changed_fields_of_composition_radial_gradient_brush.set(self.changed_fields_of_composition_radial_gradient_brush.get() | CompositionRadialGradientBrushChangedFields::RADIUS_Y_ANIMATED);
321            host.register_for_serialization();
322            return true;
323        }
324        false
325    }
326
327    /// Writes the changes of the object: the base class first, then the
328    /// changed-fields mask and the changed members of this class.
329    pub fn serialize_changes_core(&self, host: &dyn CompositionRadialGradientBrushHooks, writer: &mut BatchStreamWriter<'_>) {
330        CompositionRadialGradientBrushHooks::base_serialize_changes_core(host, writer);
331        let changed = self.changed_fields_of_composition_radial_gradient_brush.get();
332        writer.write(changed);
333        if changed.contains(CompositionRadialGradientBrushChangedFields::CENTER_ANIMATED) {
334            writer.write_value(host.pending_animations().get_and_remove(ServerCompositionRadialGradientBrushProps::id_of_center_property().base()));
335        } else if changed.contains(CompositionRadialGradientBrushChangedFields::CENTER) {
336            writer.write(self.center.get());
337        }
338        if changed.contains(CompositionRadialGradientBrushChangedFields::GRADIENT_ORIGIN_ANIMATED) {
339            writer.write_value(host.pending_animations().get_and_remove(ServerCompositionRadialGradientBrushProps::id_of_gradient_origin_property().base()));
340        } else if changed.contains(CompositionRadialGradientBrushChangedFields::GRADIENT_ORIGIN) {
341            writer.write(self.gradient_origin.get());
342        }
343        if changed.contains(CompositionRadialGradientBrushChangedFields::RADIUS_X_ANIMATED) {
344            writer.write_value(host.pending_animations().get_and_remove(ServerCompositionRadialGradientBrushProps::id_of_radius_x_property().base()));
345        } else if changed.contains(CompositionRadialGradientBrushChangedFields::RADIUS_X) {
346            writer.write(self.radius_x.get());
347        }
348        if changed.contains(CompositionRadialGradientBrushChangedFields::RADIUS_Y_ANIMATED) {
349            writer.write_value(host.pending_animations().get_and_remove(ServerCompositionRadialGradientBrushProps::id_of_radius_y_property().base()));
350        } else if changed.contains(CompositionRadialGradientBrushChangedFields::RADIUS_Y) {
351            writer.write(self.radius_y.get());
352        }
353        self.changed_fields_of_composition_radial_gradient_brush.set(CompositionRadialGradientBrushChangedFields::empty());
354    }
355}
356
357/// The partial methods of `ServerCompositionRadialGradientBrush`: implemented by the class that embeds
358/// [`ServerCompositionRadialGradientBrushProps`]. Every hook defaults to doing nothing.
359pub trait ServerCompositionRadialGradientBrushHooks: IServerAnimatedPropertyHost {
360    /// `base.DeserializeChangesCore(reader, committedAt)`: reads the changes of
361    /// the hand-written base class `ServerCompositionGradientBrush`.
362    fn base_deserialize_changes_core(&self, reader: &mut BatchStreamReader<'_>, committed_at: Duration);
363
364    fn deserialize_changes_extra(&self, _reader: &mut BatchStreamReader<'_>) {}
365    fn on_fields_deserialized(&self, _changed: CompositionRadialGradientBrushChangedFields) {}
366}
367
368/// The server-side properties of `ServerCompositionRadialGradientBrush`.
369pub struct ServerCompositionRadialGradientBrushProps {
370    center: Cell<RelativePoint>,
371    gradient_origin: Cell<RelativePoint>,
372    radius_x: Cell<RelativeScalar>,
373    radius_y: Cell<RelativeScalar>,
374}
375
376impl Default for ServerCompositionRadialGradientBrushProps {
377    fn default() -> Self {
378        Self::new()
379    }
380}
381
382impl ServerCompositionRadialGradientBrushProps {
383    /// Creates the properties with every field at the default of its type; the
384    /// values of the UI thread arrive with the first batch.
385    pub fn new() -> Self {
386        Self {
387            center: Cell::new(Default::default()),
388            gradient_origin: Cell::new(Default::default()),
389            radius_x: Cell::new(Default::default()),
390            radius_y: Cell::new(Default::default()),
391        }
392    }
393
394    /// This block or the block of a base class, by type: what
395    /// `IServerObject::get_props` of the embedding class returns.
396    pub fn find_props(&self, type_id: TypeId) -> Option<&dyn Any> {
397        if type_id == TypeId::of::<Self>() {
398            return Some(self);
399        }
400        None
401    }
402
403    /// The composition property of `Center`.
404    pub fn id_of_center_property() -> &'static CompositionPropertyOf<RelativePoint> {
405        static PROPERTY: OnceLock<CompositionPropertyOf<RelativePoint>> = OnceLock::new();
406        PROPERTY.get_or_init(|| {
407            CompositionProperty::register::<ServerCompositionRadialGradientBrushProps, RelativePoint>(
408                "Center",
409                "ServerCompositionRadialGradientBrush",
410                |obj| props_of::<ServerCompositionRadialGradientBrushProps>(obj).center.get(),
411                |obj, v| props_of::<ServerCompositionRadialGradientBrushProps>(obj).center.set(v),
412                Some(|obj| ExpressionVariant::create(props_of::<ServerCompositionRadialGradientBrushProps>(obj).center.get())),
413                Some(|obj, v: ExpressionVariant| props_of::<ServerCompositionRadialGradientBrushProps>(obj).center.set(v.cast_or_default::<RelativePoint>())),
414            )
415        })
416    }
417
418    /// `Center` (animated).
419    pub fn center(&self) -> RelativePoint {
420        self.center.get()
421    }
422
423    pub fn set_center(&self, host: &dyn ServerCompositionRadialGradientBrushHooks, value: RelativePoint) {
424        self.center.set(value);
425        host.remove_animation_for_property(Self::id_of_center_property().base());
426    }
427
428    /// The composition property of `GradientOrigin`.
429    pub fn id_of_gradient_origin_property() -> &'static CompositionPropertyOf<RelativePoint> {
430        static PROPERTY: OnceLock<CompositionPropertyOf<RelativePoint>> = OnceLock::new();
431        PROPERTY.get_or_init(|| {
432            CompositionProperty::register::<ServerCompositionRadialGradientBrushProps, RelativePoint>(
433                "GradientOrigin",
434                "ServerCompositionRadialGradientBrush",
435                |obj| props_of::<ServerCompositionRadialGradientBrushProps>(obj).gradient_origin.get(),
436                |obj, v| props_of::<ServerCompositionRadialGradientBrushProps>(obj).gradient_origin.set(v),
437                Some(|obj| ExpressionVariant::create(props_of::<ServerCompositionRadialGradientBrushProps>(obj).gradient_origin.get())),
438                Some(|obj, v: ExpressionVariant| props_of::<ServerCompositionRadialGradientBrushProps>(obj).gradient_origin.set(v.cast_or_default::<RelativePoint>())),
439            )
440        })
441    }
442
443    /// `GradientOrigin` (animated).
444    pub fn gradient_origin(&self) -> RelativePoint {
445        self.gradient_origin.get()
446    }
447
448    pub fn set_gradient_origin(&self, host: &dyn ServerCompositionRadialGradientBrushHooks, value: RelativePoint) {
449        self.gradient_origin.set(value);
450        host.remove_animation_for_property(Self::id_of_gradient_origin_property().base());
451    }
452
453    /// The composition property of `RadiusX`.
454    pub fn id_of_radius_x_property() -> &'static CompositionPropertyOf<RelativeScalar> {
455        static PROPERTY: OnceLock<CompositionPropertyOf<RelativeScalar>> = OnceLock::new();
456        PROPERTY.get_or_init(|| {
457            CompositionProperty::register::<ServerCompositionRadialGradientBrushProps, RelativeScalar>(
458                "RadiusX",
459                "ServerCompositionRadialGradientBrush",
460                |obj| props_of::<ServerCompositionRadialGradientBrushProps>(obj).radius_x.get(),
461                |obj, v| props_of::<ServerCompositionRadialGradientBrushProps>(obj).radius_x.set(v),
462                Some(|obj| ExpressionVariant::create(props_of::<ServerCompositionRadialGradientBrushProps>(obj).radius_x.get())),
463                Some(|obj, v: ExpressionVariant| props_of::<ServerCompositionRadialGradientBrushProps>(obj).radius_x.set(v.cast_or_default::<RelativeScalar>())),
464            )
465        })
466    }
467
468    /// `RadiusX` (animated).
469    pub fn radius_x(&self) -> RelativeScalar {
470        self.radius_x.get()
471    }
472
473    pub fn set_radius_x(&self, host: &dyn ServerCompositionRadialGradientBrushHooks, value: RelativeScalar) {
474        self.radius_x.set(value);
475        host.remove_animation_for_property(Self::id_of_radius_x_property().base());
476    }
477
478    /// The composition property of `RadiusY`.
479    pub fn id_of_radius_y_property() -> &'static CompositionPropertyOf<RelativeScalar> {
480        static PROPERTY: OnceLock<CompositionPropertyOf<RelativeScalar>> = OnceLock::new();
481        PROPERTY.get_or_init(|| {
482            CompositionProperty::register::<ServerCompositionRadialGradientBrushProps, RelativeScalar>(
483                "RadiusY",
484                "ServerCompositionRadialGradientBrush",
485                |obj| props_of::<ServerCompositionRadialGradientBrushProps>(obj).radius_y.get(),
486                |obj, v| props_of::<ServerCompositionRadialGradientBrushProps>(obj).radius_y.set(v),
487                Some(|obj| ExpressionVariant::create(props_of::<ServerCompositionRadialGradientBrushProps>(obj).radius_y.get())),
488                Some(|obj, v: ExpressionVariant| props_of::<ServerCompositionRadialGradientBrushProps>(obj).radius_y.set(v.cast_or_default::<RelativeScalar>())),
489            )
490        })
491    }
492
493    /// `RadiusY` (animated).
494    pub fn radius_y(&self) -> RelativeScalar {
495        self.radius_y.get()
496    }
497
498    pub fn set_radius_y(&self, host: &dyn ServerCompositionRadialGradientBrushHooks, value: RelativeScalar) {
499        self.radius_y.set(value);
500        host.remove_animation_for_property(Self::id_of_radius_y_property().base());
501    }
502
503    /// Reads the changes of the object: the base class first, then the
504    /// changed-fields mask and the changed members of this class.
505    pub fn deserialize_changes_core(
506        &self,
507        host: &dyn ServerCompositionRadialGradientBrushHooks,
508        reader: &mut BatchStreamReader<'_>,
509        committed_at: Duration,
510    ) {
511        ServerCompositionRadialGradientBrushHooks::base_deserialize_changes_core(host, reader, committed_at);
512        ServerCompositionRadialGradientBrushHooks::deserialize_changes_extra(host, reader);
513        let changed = reader.read::<CompositionRadialGradientBrushChangedFields>();
514        if changed.contains(CompositionRadialGradientBrushChangedFields::CENTER_ANIMATED) {
515            let Some(animation) = reader.read_value::<AnimationInstanceFactory>().map(AnimationInstanceFactory::create) else {
516                panic!("a batch starts an animation of `Center` without an animation instance");
517            };
518            host.set_animated_value(
519                Self::id_of_center_property().base(),
520                ExpressionVariant::create(self.center.get()),
521                committed_at,
522                animation,
523            );
524        } else if changed.contains(CompositionRadialGradientBrushChangedFields::CENTER) {
525            let value = reader.read::<RelativePoint>();
526            self.set_center(host, value);
527        }
528        if changed.contains(CompositionRadialGradientBrushChangedFields::GRADIENT_ORIGIN_ANIMATED) {
529            let Some(animation) = reader.read_value::<AnimationInstanceFactory>().map(AnimationInstanceFactory::create) else {
530                panic!("a batch starts an animation of `GradientOrigin` without an animation instance");
531            };
532            host.set_animated_value(
533                Self::id_of_gradient_origin_property().base(),
534                ExpressionVariant::create(self.gradient_origin.get()),
535                committed_at,
536                animation,
537            );
538        } else if changed.contains(CompositionRadialGradientBrushChangedFields::GRADIENT_ORIGIN) {
539            let value = reader.read::<RelativePoint>();
540            self.set_gradient_origin(host, value);
541        }
542        if changed.contains(CompositionRadialGradientBrushChangedFields::RADIUS_X_ANIMATED) {
543            let Some(animation) = reader.read_value::<AnimationInstanceFactory>().map(AnimationInstanceFactory::create) else {
544                panic!("a batch starts an animation of `RadiusX` without an animation instance");
545            };
546            host.set_animated_value(
547                Self::id_of_radius_x_property().base(),
548                ExpressionVariant::create(self.radius_x.get()),
549                committed_at,
550                animation,
551            );
552        } else if changed.contains(CompositionRadialGradientBrushChangedFields::RADIUS_X) {
553            let value = reader.read::<RelativeScalar>();
554            self.set_radius_x(host, value);
555        }
556        if changed.contains(CompositionRadialGradientBrushChangedFields::RADIUS_Y_ANIMATED) {
557            let Some(animation) = reader.read_value::<AnimationInstanceFactory>().map(AnimationInstanceFactory::create) else {
558                panic!("a batch starts an animation of `RadiusY` without an animation instance");
559            };
560            host.set_animated_value(
561                Self::id_of_radius_y_property().base(),
562                ExpressionVariant::create(self.radius_y.get()),
563                committed_at,
564                animation,
565            );
566        } else if changed.contains(CompositionRadialGradientBrushChangedFields::RADIUS_Y) {
567            let value = reader.read::<RelativeScalar>();
568            self.set_radius_y(host, value);
569        }
570        ServerCompositionRadialGradientBrushHooks::on_fields_deserialized(host, changed);
571    }
572
573    /// The composition property with the given name, among the properties
574    /// of this class and of its generated bases that have a variant form.
575    pub fn get_composition_property(name: &str) -> Option<&'static CompositionProperty> {
576        if name == "Center" {
577            return Some(Self::id_of_center_property().base());
578        }
579        if name == "GradientOrigin" {
580            return Some(Self::id_of_gradient_origin_property().base());
581        }
582        if name == "RadiusX" {
583            return Some(Self::id_of_radius_x_property().base());
584        }
585        if name == "RadiusY" {
586            return Some(Self::id_of_radius_y_property().base());
587        }
588        None
589    }
590}