Skip to main content

ferroui_base/rendering/composition/generated/
composition_nine_grid_brush.rs

1// @generated by scripts/generate_composition.py — do not edit
2
3//! `CompositionNineGridBrush`.
4//!
5//! Defined by the FerroUI overlay (scripts/composition-schema-winui.xml).
6
7use bitflags::bitflags;
8use crate::rendering::composition::ICompositionObject;
9use crate::rendering::composition::animations::AnimationInstanceFactory;
10use crate::rendering::composition::animations::ICompositionAnimation;
11use crate::rendering::composition::expressions::ExpressionVariant;
12use crate::rendering::composition::server::AsServerRenderResource;
13use crate::rendering::composition::server::CompositionProperty;
14use crate::rendering::composition::server::CompositionPropertyOf;
15use crate::rendering::composition::server::IServerObject;
16use crate::rendering::composition::server::ServerPropertyValue;
17use crate::rendering::composition::server::ServerValueChange;
18use crate::rendering::composition::server::props_of;
19use crate::rendering::composition::server::read_server_object;
20use crate::rendering::composition::transport::BatchStreamReader;
21use crate::rendering::composition::transport::BatchStreamWriter;
22use crate::rendering::composition::transport::BatchValue;
23use crate::rendering::composition::transport::BatchValueReader;
24use std::any::Any;
25use std::any::TypeId;
26use std::cell::Cell;
27use std::cell::RefCell;
28use std::rc::Rc;
29use std::sync::OnceLock;
30use std::time::Duration;
31use super::CompositionBrushHooks;
32use super::CompositionBrushProps;
33use super::ServerCompositionBrushHooks;
34use super::ServerCompositionBrushProps;
35
36bitflags! {
37    /// The fields of `CompositionNineGridBrush` that changed since its last serialization.
38    #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
39    pub struct CompositionNineGridBrushChangedFields: u32 {
40        const SOURCE = 1;
41        const LEFT_INSET = 2;
42        const LEFT_INSET_ANIMATED = 4;
43        const TOP_INSET = 8;
44        const TOP_INSET_ANIMATED = 16;
45        const RIGHT_INSET = 32;
46        const RIGHT_INSET_ANIMATED = 64;
47        const BOTTOM_INSET = 128;
48        const BOTTOM_INSET_ANIMATED = 256;
49        const LEFT_INSET_SCALE = 512;
50        const LEFT_INSET_SCALE_ANIMATED = 1024;
51        const TOP_INSET_SCALE = 2048;
52        const TOP_INSET_SCALE_ANIMATED = 4096;
53        const RIGHT_INSET_SCALE = 8192;
54        const RIGHT_INSET_SCALE_ANIMATED = 16384;
55        const BOTTOM_INSET_SCALE = 32768;
56        const BOTTOM_INSET_SCALE_ANIMATED = 65536;
57        const IS_CENTER_HOLLOW = 131072;
58    }
59}
60
61impl BatchValue for CompositionNineGridBrushChangedFields {
62    #[inline]
63    fn write_to(&self, out: &mut Vec<u8>) {
64        self.bits().write_to(out);
65    }
66
67    #[inline]
68    fn read_from(input: &mut BatchValueReader<'_>) -> Self {
69        CompositionNineGridBrushChangedFields::from_bits_retain(u32::read_from(input))
70    }
71}
72
73/// The partial methods of `CompositionNineGridBrush`: implemented by the class that embeds
74/// [`CompositionNineGridBrushProps`]. Every hook defaults to doing nothing.
75pub trait CompositionNineGridBrushHooks: CompositionBrushHooks {
76    fn initialize_defaults_extra(&self) {}
77
78    fn validate_source_change(&self, _old_value: &Option<Rc<dyn ICompositionObject>>, _new_value: &Option<Rc<dyn ICompositionObject>>) {}
79    fn on_source_changed(&self) {}
80    fn on_source_changing(&self) {}
81
82    fn validate_left_inset_change(&self, _old_value: f32, _new_value: f32) {}
83    fn on_left_inset_changed(&self) {}
84    fn on_left_inset_changing(&self) {}
85
86    fn validate_top_inset_change(&self, _old_value: f32, _new_value: f32) {}
87    fn on_top_inset_changed(&self) {}
88    fn on_top_inset_changing(&self) {}
89
90    fn validate_right_inset_change(&self, _old_value: f32, _new_value: f32) {}
91    fn on_right_inset_changed(&self) {}
92    fn on_right_inset_changing(&self) {}
93
94    fn validate_bottom_inset_change(&self, _old_value: f32, _new_value: f32) {}
95    fn on_bottom_inset_changed(&self) {}
96    fn on_bottom_inset_changing(&self) {}
97
98    fn validate_left_inset_scale_change(&self, _old_value: f32, _new_value: f32) {}
99    fn on_left_inset_scale_changed(&self) {}
100    fn on_left_inset_scale_changing(&self) {}
101
102    fn validate_top_inset_scale_change(&self, _old_value: f32, _new_value: f32) {}
103    fn on_top_inset_scale_changed(&self) {}
104    fn on_top_inset_scale_changing(&self) {}
105
106    fn validate_right_inset_scale_change(&self, _old_value: f32, _new_value: f32) {}
107    fn on_right_inset_scale_changed(&self) {}
108    fn on_right_inset_scale_changing(&self) {}
109
110    fn validate_bottom_inset_scale_change(&self, _old_value: f32, _new_value: f32) {}
111    fn on_bottom_inset_scale_changed(&self) {}
112    fn on_bottom_inset_scale_changing(&self) {}
113
114    fn validate_is_center_hollow_change(&self, _old_value: bool, _new_value: bool) {}
115    fn on_is_center_hollow_changed(&self) {}
116    fn on_is_center_hollow_changing(&self) {}
117}
118
119/// The UI-thread properties of `CompositionNineGridBrush`.
120pub struct CompositionNineGridBrushProps {
121    base: CompositionBrushProps,
122    changed_fields_of_composition_nine_grid_brush: Cell<CompositionNineGridBrushChangedFields>,
123    source: RefCell<Option<Rc<dyn ICompositionObject>>>,
124    left_inset: Cell<f32>,
125    top_inset: Cell<f32>,
126    right_inset: Cell<f32>,
127    bottom_inset: Cell<f32>,
128    left_inset_scale: Cell<f32>,
129    top_inset_scale: Cell<f32>,
130    right_inset_scale: Cell<f32>,
131    bottom_inset_scale: Cell<f32>,
132    is_center_hollow: Cell<bool>,
133}
134
135impl Default for CompositionNineGridBrushProps {
136    fn default() -> Self {
137        Self::new()
138    }
139}
140
141impl CompositionNineGridBrushProps {
142    /// Creates the properties with every field at the default of its type.
143    /// The defaults of the schema are applied by
144    /// [`initialize_defaults`](Self::initialize_defaults).
145    pub fn new() -> Self {
146        Self {
147            base: CompositionBrushProps::new(),
148            changed_fields_of_composition_nine_grid_brush: Cell::new(CompositionNineGridBrushChangedFields::empty()),
149            source: RefCell::new(None),
150            left_inset: Cell::new(Default::default()),
151            top_inset: Cell::new(Default::default()),
152            right_inset: Cell::new(Default::default()),
153            bottom_inset: Cell::new(Default::default()),
154            left_inset_scale: Cell::new(Default::default()),
155            top_inset_scale: Cell::new(Default::default()),
156            right_inset_scale: Cell::new(Default::default()),
157            bottom_inset_scale: Cell::new(Default::default()),
158            is_center_hollow: Cell::new(Default::default()),
159        }
160    }
161
162    /// The properties of the base class.
163    pub fn base(&self) -> &CompositionBrushProps {
164        &self.base
165    }
166
167    /// The `InitializeDefaults` calls of the constructor chain: the base
168    /// classes first, then this class.
169    pub fn initialize_defaults(&self, host: &dyn CompositionNineGridBrushHooks) {
170        self.base.initialize_defaults(host);
171        self.initialize_own_defaults(host);
172    }
173
174    /// `InitializeDefaults` of this class alone.
175    pub fn initialize_own_defaults(&self, host: &dyn CompositionNineGridBrushHooks) {
176        CompositionNineGridBrushHooks::initialize_defaults_extra(host);
177        self.set_left_inset_scale(host, 1.0);
178        self.set_top_inset_scale(host, 1.0);
179        self.set_right_inset_scale(host, 1.0);
180        self.set_bottom_inset_scale(host, 1.0);
181    }
182
183    /// `Source` (FerroUI overlay).
184    pub fn source(&self) -> Option<Rc<dyn ICompositionObject>> {
185        self.source.borrow().clone()
186    }
187
188    /// Sets `Source` (FerroUI overlay).
189    pub fn set_source(&self, host: &dyn CompositionNineGridBrushHooks, value: Option<Rc<dyn ICompositionObject>>) {
190        let mut changed = false;
191        let old_value = self.source.borrow().clone();
192        if old_value.differs(&value) {
193            CompositionNineGridBrushHooks::validate_source_change(host, &old_value, &value);
194            CompositionNineGridBrushHooks::on_source_changing(host);
195            changed = true;
196            // Update the backing value
197            *self.source.borrow_mut() = value.clone();
198            // Register object for serialization in the next batch
199            self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::SOURCE);
200            host.register_for_serialization();
201        }
202        *self.source.borrow_mut() = value;
203        if changed {
204            CompositionNineGridBrushHooks::on_source_changed(host);
205        }
206    }
207
208    /// `LeftInset` (animated, FerroUI overlay).
209    pub fn left_inset(&self) -> f32 {
210        self.left_inset.get()
211    }
212
213    /// Sets `LeftInset` (animated, FerroUI overlay).
214    pub fn set_left_inset(&self, host: &dyn CompositionNineGridBrushHooks, value: f32) {
215        let mut changed = false;
216        let old_value = self.left_inset.get();
217        if old_value.differs(&value) {
218            CompositionNineGridBrushHooks::validate_left_inset_change(host, old_value, value);
219            CompositionNineGridBrushHooks::on_left_inset_changing(host);
220            changed = true;
221            // Update the backing value
222            self.left_inset.set(value);
223            // Register object for serialization in the next batch
224            self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::LEFT_INSET);
225            host.register_for_serialization();
226            // Reset previous animation if any
227            host.pending_animations().remove(ServerCompositionNineGridBrushProps::id_of_left_inset_property().base());
228            self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() & !CompositionNineGridBrushChangedFields::LEFT_INSET_ANIMATED);
229            // Check for implicit animations
230            if let Some(animation) = host.implicit_animation("LeftInset") {
231                // Animation affects only current property
232                if let Some(a) = animation.as_composition_animation() {
233                    self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::LEFT_INSET_ANIMATED);
234                    host.pending_animations().set(
235                        ServerCompositionNineGridBrushProps::id_of_left_inset_property().base(),
236                        a.create_instance(host.server(), Some(ExpressionVariant::create(value))),
237                    );
238                }
239                // Animation is triggered by the current field, but does not necessary affects it
240                host.start_animation_group(&animation, "LeftInset", ExpressionVariant::create(value));
241            }
242        }
243        self.left_inset.set(value);
244        if changed {
245            CompositionNineGridBrushHooks::on_left_inset_changed(host);
246        }
247    }
248
249    /// `TopInset` (animated, FerroUI overlay).
250    pub fn top_inset(&self) -> f32 {
251        self.top_inset.get()
252    }
253
254    /// Sets `TopInset` (animated, FerroUI overlay).
255    pub fn set_top_inset(&self, host: &dyn CompositionNineGridBrushHooks, value: f32) {
256        let mut changed = false;
257        let old_value = self.top_inset.get();
258        if old_value.differs(&value) {
259            CompositionNineGridBrushHooks::validate_top_inset_change(host, old_value, value);
260            CompositionNineGridBrushHooks::on_top_inset_changing(host);
261            changed = true;
262            // Update the backing value
263            self.top_inset.set(value);
264            // Register object for serialization in the next batch
265            self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::TOP_INSET);
266            host.register_for_serialization();
267            // Reset previous animation if any
268            host.pending_animations().remove(ServerCompositionNineGridBrushProps::id_of_top_inset_property().base());
269            self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() & !CompositionNineGridBrushChangedFields::TOP_INSET_ANIMATED);
270            // Check for implicit animations
271            if let Some(animation) = host.implicit_animation("TopInset") {
272                // Animation affects only current property
273                if let Some(a) = animation.as_composition_animation() {
274                    self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::TOP_INSET_ANIMATED);
275                    host.pending_animations().set(
276                        ServerCompositionNineGridBrushProps::id_of_top_inset_property().base(),
277                        a.create_instance(host.server(), Some(ExpressionVariant::create(value))),
278                    );
279                }
280                // Animation is triggered by the current field, but does not necessary affects it
281                host.start_animation_group(&animation, "TopInset", ExpressionVariant::create(value));
282            }
283        }
284        self.top_inset.set(value);
285        if changed {
286            CompositionNineGridBrushHooks::on_top_inset_changed(host);
287        }
288    }
289
290    /// `RightInset` (animated, FerroUI overlay).
291    pub fn right_inset(&self) -> f32 {
292        self.right_inset.get()
293    }
294
295    /// Sets `RightInset` (animated, FerroUI overlay).
296    pub fn set_right_inset(&self, host: &dyn CompositionNineGridBrushHooks, value: f32) {
297        let mut changed = false;
298        let old_value = self.right_inset.get();
299        if old_value.differs(&value) {
300            CompositionNineGridBrushHooks::validate_right_inset_change(host, old_value, value);
301            CompositionNineGridBrushHooks::on_right_inset_changing(host);
302            changed = true;
303            // Update the backing value
304            self.right_inset.set(value);
305            // Register object for serialization in the next batch
306            self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::RIGHT_INSET);
307            host.register_for_serialization();
308            // Reset previous animation if any
309            host.pending_animations().remove(ServerCompositionNineGridBrushProps::id_of_right_inset_property().base());
310            self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() & !CompositionNineGridBrushChangedFields::RIGHT_INSET_ANIMATED);
311            // Check for implicit animations
312            if let Some(animation) = host.implicit_animation("RightInset") {
313                // Animation affects only current property
314                if let Some(a) = animation.as_composition_animation() {
315                    self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::RIGHT_INSET_ANIMATED);
316                    host.pending_animations().set(
317                        ServerCompositionNineGridBrushProps::id_of_right_inset_property().base(),
318                        a.create_instance(host.server(), Some(ExpressionVariant::create(value))),
319                    );
320                }
321                // Animation is triggered by the current field, but does not necessary affects it
322                host.start_animation_group(&animation, "RightInset", ExpressionVariant::create(value));
323            }
324        }
325        self.right_inset.set(value);
326        if changed {
327            CompositionNineGridBrushHooks::on_right_inset_changed(host);
328        }
329    }
330
331    /// `BottomInset` (animated, FerroUI overlay).
332    pub fn bottom_inset(&self) -> f32 {
333        self.bottom_inset.get()
334    }
335
336    /// Sets `BottomInset` (animated, FerroUI overlay).
337    pub fn set_bottom_inset(&self, host: &dyn CompositionNineGridBrushHooks, value: f32) {
338        let mut changed = false;
339        let old_value = self.bottom_inset.get();
340        if old_value.differs(&value) {
341            CompositionNineGridBrushHooks::validate_bottom_inset_change(host, old_value, value);
342            CompositionNineGridBrushHooks::on_bottom_inset_changing(host);
343            changed = true;
344            // Update the backing value
345            self.bottom_inset.set(value);
346            // Register object for serialization in the next batch
347            self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::BOTTOM_INSET);
348            host.register_for_serialization();
349            // Reset previous animation if any
350            host.pending_animations().remove(ServerCompositionNineGridBrushProps::id_of_bottom_inset_property().base());
351            self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() & !CompositionNineGridBrushChangedFields::BOTTOM_INSET_ANIMATED);
352            // Check for implicit animations
353            if let Some(animation) = host.implicit_animation("BottomInset") {
354                // Animation affects only current property
355                if let Some(a) = animation.as_composition_animation() {
356                    self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::BOTTOM_INSET_ANIMATED);
357                    host.pending_animations().set(
358                        ServerCompositionNineGridBrushProps::id_of_bottom_inset_property().base(),
359                        a.create_instance(host.server(), Some(ExpressionVariant::create(value))),
360                    );
361                }
362                // Animation is triggered by the current field, but does not necessary affects it
363                host.start_animation_group(&animation, "BottomInset", ExpressionVariant::create(value));
364            }
365        }
366        self.bottom_inset.set(value);
367        if changed {
368            CompositionNineGridBrushHooks::on_bottom_inset_changed(host);
369        }
370    }
371
372    /// `LeftInsetScale` (animated, default `1.0`, FerroUI overlay).
373    pub fn left_inset_scale(&self) -> f32 {
374        self.left_inset_scale.get()
375    }
376
377    /// Sets `LeftInsetScale` (animated, default `1.0`, FerroUI overlay).
378    pub fn set_left_inset_scale(&self, host: &dyn CompositionNineGridBrushHooks, value: f32) {
379        let mut changed = false;
380        let old_value = self.left_inset_scale.get();
381        if old_value.differs(&value) {
382            CompositionNineGridBrushHooks::validate_left_inset_scale_change(host, old_value, value);
383            CompositionNineGridBrushHooks::on_left_inset_scale_changing(host);
384            changed = true;
385            // Update the backing value
386            self.left_inset_scale.set(value);
387            // Register object for serialization in the next batch
388            self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::LEFT_INSET_SCALE);
389            host.register_for_serialization();
390            // Reset previous animation if any
391            host.pending_animations().remove(ServerCompositionNineGridBrushProps::id_of_left_inset_scale_property().base());
392            self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() & !CompositionNineGridBrushChangedFields::LEFT_INSET_SCALE_ANIMATED);
393            // Check for implicit animations
394            if let Some(animation) = host.implicit_animation("LeftInsetScale") {
395                // Animation affects only current property
396                if let Some(a) = animation.as_composition_animation() {
397                    self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::LEFT_INSET_SCALE_ANIMATED);
398                    host.pending_animations().set(
399                        ServerCompositionNineGridBrushProps::id_of_left_inset_scale_property().base(),
400                        a.create_instance(host.server(), Some(ExpressionVariant::create(value))),
401                    );
402                }
403                // Animation is triggered by the current field, but does not necessary affects it
404                host.start_animation_group(&animation, "LeftInsetScale", ExpressionVariant::create(value));
405            }
406        }
407        self.left_inset_scale.set(value);
408        if changed {
409            CompositionNineGridBrushHooks::on_left_inset_scale_changed(host);
410        }
411    }
412
413    /// `TopInsetScale` (animated, default `1.0`, FerroUI overlay).
414    pub fn top_inset_scale(&self) -> f32 {
415        self.top_inset_scale.get()
416    }
417
418    /// Sets `TopInsetScale` (animated, default `1.0`, FerroUI overlay).
419    pub fn set_top_inset_scale(&self, host: &dyn CompositionNineGridBrushHooks, value: f32) {
420        let mut changed = false;
421        let old_value = self.top_inset_scale.get();
422        if old_value.differs(&value) {
423            CompositionNineGridBrushHooks::validate_top_inset_scale_change(host, old_value, value);
424            CompositionNineGridBrushHooks::on_top_inset_scale_changing(host);
425            changed = true;
426            // Update the backing value
427            self.top_inset_scale.set(value);
428            // Register object for serialization in the next batch
429            self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::TOP_INSET_SCALE);
430            host.register_for_serialization();
431            // Reset previous animation if any
432            host.pending_animations().remove(ServerCompositionNineGridBrushProps::id_of_top_inset_scale_property().base());
433            self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() & !CompositionNineGridBrushChangedFields::TOP_INSET_SCALE_ANIMATED);
434            // Check for implicit animations
435            if let Some(animation) = host.implicit_animation("TopInsetScale") {
436                // Animation affects only current property
437                if let Some(a) = animation.as_composition_animation() {
438                    self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::TOP_INSET_SCALE_ANIMATED);
439                    host.pending_animations().set(
440                        ServerCompositionNineGridBrushProps::id_of_top_inset_scale_property().base(),
441                        a.create_instance(host.server(), Some(ExpressionVariant::create(value))),
442                    );
443                }
444                // Animation is triggered by the current field, but does not necessary affects it
445                host.start_animation_group(&animation, "TopInsetScale", ExpressionVariant::create(value));
446            }
447        }
448        self.top_inset_scale.set(value);
449        if changed {
450            CompositionNineGridBrushHooks::on_top_inset_scale_changed(host);
451        }
452    }
453
454    /// `RightInsetScale` (animated, default `1.0`, FerroUI overlay).
455    pub fn right_inset_scale(&self) -> f32 {
456        self.right_inset_scale.get()
457    }
458
459    /// Sets `RightInsetScale` (animated, default `1.0`, FerroUI overlay).
460    pub fn set_right_inset_scale(&self, host: &dyn CompositionNineGridBrushHooks, value: f32) {
461        let mut changed = false;
462        let old_value = self.right_inset_scale.get();
463        if old_value.differs(&value) {
464            CompositionNineGridBrushHooks::validate_right_inset_scale_change(host, old_value, value);
465            CompositionNineGridBrushHooks::on_right_inset_scale_changing(host);
466            changed = true;
467            // Update the backing value
468            self.right_inset_scale.set(value);
469            // Register object for serialization in the next batch
470            self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::RIGHT_INSET_SCALE);
471            host.register_for_serialization();
472            // Reset previous animation if any
473            host.pending_animations().remove(ServerCompositionNineGridBrushProps::id_of_right_inset_scale_property().base());
474            self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() & !CompositionNineGridBrushChangedFields::RIGHT_INSET_SCALE_ANIMATED);
475            // Check for implicit animations
476            if let Some(animation) = host.implicit_animation("RightInsetScale") {
477                // Animation affects only current property
478                if let Some(a) = animation.as_composition_animation() {
479                    self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::RIGHT_INSET_SCALE_ANIMATED);
480                    host.pending_animations().set(
481                        ServerCompositionNineGridBrushProps::id_of_right_inset_scale_property().base(),
482                        a.create_instance(host.server(), Some(ExpressionVariant::create(value))),
483                    );
484                }
485                // Animation is triggered by the current field, but does not necessary affects it
486                host.start_animation_group(&animation, "RightInsetScale", ExpressionVariant::create(value));
487            }
488        }
489        self.right_inset_scale.set(value);
490        if changed {
491            CompositionNineGridBrushHooks::on_right_inset_scale_changed(host);
492        }
493    }
494
495    /// `BottomInsetScale` (animated, default `1.0`, FerroUI overlay).
496    pub fn bottom_inset_scale(&self) -> f32 {
497        self.bottom_inset_scale.get()
498    }
499
500    /// Sets `BottomInsetScale` (animated, default `1.0`, FerroUI overlay).
501    pub fn set_bottom_inset_scale(&self, host: &dyn CompositionNineGridBrushHooks, value: f32) {
502        let mut changed = false;
503        let old_value = self.bottom_inset_scale.get();
504        if old_value.differs(&value) {
505            CompositionNineGridBrushHooks::validate_bottom_inset_scale_change(host, old_value, value);
506            CompositionNineGridBrushHooks::on_bottom_inset_scale_changing(host);
507            changed = true;
508            // Update the backing value
509            self.bottom_inset_scale.set(value);
510            // Register object for serialization in the next batch
511            self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::BOTTOM_INSET_SCALE);
512            host.register_for_serialization();
513            // Reset previous animation if any
514            host.pending_animations().remove(ServerCompositionNineGridBrushProps::id_of_bottom_inset_scale_property().base());
515            self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() & !CompositionNineGridBrushChangedFields::BOTTOM_INSET_SCALE_ANIMATED);
516            // Check for implicit animations
517            if let Some(animation) = host.implicit_animation("BottomInsetScale") {
518                // Animation affects only current property
519                if let Some(a) = animation.as_composition_animation() {
520                    self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::BOTTOM_INSET_SCALE_ANIMATED);
521                    host.pending_animations().set(
522                        ServerCompositionNineGridBrushProps::id_of_bottom_inset_scale_property().base(),
523                        a.create_instance(host.server(), Some(ExpressionVariant::create(value))),
524                    );
525                }
526                // Animation is triggered by the current field, but does not necessary affects it
527                host.start_animation_group(&animation, "BottomInsetScale", ExpressionVariant::create(value));
528            }
529        }
530        self.bottom_inset_scale.set(value);
531        if changed {
532            CompositionNineGridBrushHooks::on_bottom_inset_scale_changed(host);
533        }
534    }
535
536    /// `IsCenterHollow` (FerroUI overlay).
537    pub fn is_center_hollow(&self) -> bool {
538        self.is_center_hollow.get()
539    }
540
541    /// Sets `IsCenterHollow` (FerroUI overlay).
542    pub fn set_is_center_hollow(&self, host: &dyn CompositionNineGridBrushHooks, value: bool) {
543        let mut changed = false;
544        let old_value = self.is_center_hollow.get();
545        if old_value.differs(&value) {
546            CompositionNineGridBrushHooks::validate_is_center_hollow_change(host, old_value, value);
547            CompositionNineGridBrushHooks::on_is_center_hollow_changing(host);
548            changed = true;
549            // Update the backing value
550            self.is_center_hollow.set(value);
551            // Register object for serialization in the next batch
552            self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::IS_CENTER_HOLLOW);
553            host.register_for_serialization();
554        }
555        self.is_center_hollow.set(value);
556        if changed {
557            CompositionNineGridBrushHooks::on_is_center_hollow_changed(host);
558        }
559    }
560
561    /// Connects an animation with the named property. Returns `false` when
562    /// neither this class nor its generated bases have an animated property
563    /// of that name: the caller continues with its hand-written base.
564    pub fn start_animation(
565        &self,
566        host: &dyn CompositionNineGridBrushHooks,
567        property_name: &str,
568        animation: &dyn ICompositionAnimation,
569        final_value: Option<ExpressionVariant>,
570    ) -> bool {
571        if property_name == "LeftInset" {
572            let server = animation.create_instance(host.server(), final_value);
573            host.pending_animations().set(ServerCompositionNineGridBrushProps::id_of_left_inset_property().base(), server);
574            self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::LEFT_INSET_ANIMATED);
575            host.register_for_serialization();
576            return true;
577        }
578        if property_name == "TopInset" {
579            let server = animation.create_instance(host.server(), final_value);
580            host.pending_animations().set(ServerCompositionNineGridBrushProps::id_of_top_inset_property().base(), server);
581            self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::TOP_INSET_ANIMATED);
582            host.register_for_serialization();
583            return true;
584        }
585        if property_name == "RightInset" {
586            let server = animation.create_instance(host.server(), final_value);
587            host.pending_animations().set(ServerCompositionNineGridBrushProps::id_of_right_inset_property().base(), server);
588            self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::RIGHT_INSET_ANIMATED);
589            host.register_for_serialization();
590            return true;
591        }
592        if property_name == "BottomInset" {
593            let server = animation.create_instance(host.server(), final_value);
594            host.pending_animations().set(ServerCompositionNineGridBrushProps::id_of_bottom_inset_property().base(), server);
595            self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::BOTTOM_INSET_ANIMATED);
596            host.register_for_serialization();
597            return true;
598        }
599        if property_name == "LeftInsetScale" {
600            let server = animation.create_instance(host.server(), final_value);
601            host.pending_animations().set(ServerCompositionNineGridBrushProps::id_of_left_inset_scale_property().base(), server);
602            self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::LEFT_INSET_SCALE_ANIMATED);
603            host.register_for_serialization();
604            return true;
605        }
606        if property_name == "TopInsetScale" {
607            let server = animation.create_instance(host.server(), final_value);
608            host.pending_animations().set(ServerCompositionNineGridBrushProps::id_of_top_inset_scale_property().base(), server);
609            self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::TOP_INSET_SCALE_ANIMATED);
610            host.register_for_serialization();
611            return true;
612        }
613        if property_name == "RightInsetScale" {
614            let server = animation.create_instance(host.server(), final_value);
615            host.pending_animations().set(ServerCompositionNineGridBrushProps::id_of_right_inset_scale_property().base(), server);
616            self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::RIGHT_INSET_SCALE_ANIMATED);
617            host.register_for_serialization();
618            return true;
619        }
620        if property_name == "BottomInsetScale" {
621            let server = animation.create_instance(host.server(), final_value);
622            host.pending_animations().set(ServerCompositionNineGridBrushProps::id_of_bottom_inset_scale_property().base(), server);
623            self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::BOTTOM_INSET_SCALE_ANIMATED);
624            host.register_for_serialization();
625            return true;
626        }
627        self.base.start_animation(host, property_name, animation, final_value)
628    }
629
630    /// Writes the changes of the object: the base class first, then the
631    /// changed-fields mask and the changed members of this class.
632    pub fn serialize_changes_core(&self, host: &dyn CompositionNineGridBrushHooks, writer: &mut BatchStreamWriter<'_>) {
633        self.base.serialize_changes_core(host, writer);
634        let changed = self.changed_fields_of_composition_nine_grid_brush.get();
635        writer.write(changed);
636        if changed.contains(CompositionNineGridBrushChangedFields::SOURCE) {
637            writer.write_server_object(self.source.borrow().clone().map(|o| o.server()));
638        }
639        if changed.contains(CompositionNineGridBrushChangedFields::LEFT_INSET_ANIMATED) {
640            writer.write_value(host.pending_animations().get_and_remove(ServerCompositionNineGridBrushProps::id_of_left_inset_property().base()));
641        } else if changed.contains(CompositionNineGridBrushChangedFields::LEFT_INSET) {
642            writer.write(self.left_inset.get());
643        }
644        if changed.contains(CompositionNineGridBrushChangedFields::TOP_INSET_ANIMATED) {
645            writer.write_value(host.pending_animations().get_and_remove(ServerCompositionNineGridBrushProps::id_of_top_inset_property().base()));
646        } else if changed.contains(CompositionNineGridBrushChangedFields::TOP_INSET) {
647            writer.write(self.top_inset.get());
648        }
649        if changed.contains(CompositionNineGridBrushChangedFields::RIGHT_INSET_ANIMATED) {
650            writer.write_value(host.pending_animations().get_and_remove(ServerCompositionNineGridBrushProps::id_of_right_inset_property().base()));
651        } else if changed.contains(CompositionNineGridBrushChangedFields::RIGHT_INSET) {
652            writer.write(self.right_inset.get());
653        }
654        if changed.contains(CompositionNineGridBrushChangedFields::BOTTOM_INSET_ANIMATED) {
655            writer.write_value(host.pending_animations().get_and_remove(ServerCompositionNineGridBrushProps::id_of_bottom_inset_property().base()));
656        } else if changed.contains(CompositionNineGridBrushChangedFields::BOTTOM_INSET) {
657            writer.write(self.bottom_inset.get());
658        }
659        if changed.contains(CompositionNineGridBrushChangedFields::LEFT_INSET_SCALE_ANIMATED) {
660            writer.write_value(host.pending_animations().get_and_remove(ServerCompositionNineGridBrushProps::id_of_left_inset_scale_property().base()));
661        } else if changed.contains(CompositionNineGridBrushChangedFields::LEFT_INSET_SCALE) {
662            writer.write(self.left_inset_scale.get());
663        }
664        if changed.contains(CompositionNineGridBrushChangedFields::TOP_INSET_SCALE_ANIMATED) {
665            writer.write_value(host.pending_animations().get_and_remove(ServerCompositionNineGridBrushProps::id_of_top_inset_scale_property().base()));
666        } else if changed.contains(CompositionNineGridBrushChangedFields::TOP_INSET_SCALE) {
667            writer.write(self.top_inset_scale.get());
668        }
669        if changed.contains(CompositionNineGridBrushChangedFields::RIGHT_INSET_SCALE_ANIMATED) {
670            writer.write_value(host.pending_animations().get_and_remove(ServerCompositionNineGridBrushProps::id_of_right_inset_scale_property().base()));
671        } else if changed.contains(CompositionNineGridBrushChangedFields::RIGHT_INSET_SCALE) {
672            writer.write(self.right_inset_scale.get());
673        }
674        if changed.contains(CompositionNineGridBrushChangedFields::BOTTOM_INSET_SCALE_ANIMATED) {
675            writer.write_value(host.pending_animations().get_and_remove(ServerCompositionNineGridBrushProps::id_of_bottom_inset_scale_property().base()));
676        } else if changed.contains(CompositionNineGridBrushChangedFields::BOTTOM_INSET_SCALE) {
677            writer.write(self.bottom_inset_scale.get());
678        }
679        if changed.contains(CompositionNineGridBrushChangedFields::IS_CENTER_HOLLOW) {
680            writer.write(self.is_center_hollow.get());
681        }
682        self.changed_fields_of_composition_nine_grid_brush.set(CompositionNineGridBrushChangedFields::empty());
683    }
684}
685
686/// The partial methods of `ServerCompositionNineGridBrush`: implemented by the class that embeds
687/// [`ServerCompositionNineGridBrushProps`]. Every hook defaults to doing nothing.
688pub trait ServerCompositionNineGridBrushHooks: ServerCompositionBrushHooks {
689    fn deserialize_changes_extra(&self, _reader: &mut BatchStreamReader<'_>) {}
690    fn on_fields_deserialized(&self, _changed: CompositionNineGridBrushChangedFields) {}
691
692    fn on_source_changed(&self) {}
693    fn on_source_changing(&self) {}
694
695    fn on_is_center_hollow_changed(&self) {}
696    fn on_is_center_hollow_changing(&self) {}
697}
698
699/// The server-side properties of `ServerCompositionNineGridBrush`.
700pub struct ServerCompositionNineGridBrushProps {
701    base: ServerCompositionBrushProps,
702    source: RefCell<Option<Rc<dyn IServerObject>>>,
703    left_inset: Cell<f32>,
704    top_inset: Cell<f32>,
705    right_inset: Cell<f32>,
706    bottom_inset: Cell<f32>,
707    left_inset_scale: Cell<f32>,
708    top_inset_scale: Cell<f32>,
709    right_inset_scale: Cell<f32>,
710    bottom_inset_scale: Cell<f32>,
711    is_center_hollow: Cell<bool>,
712}
713
714impl Default for ServerCompositionNineGridBrushProps {
715    fn default() -> Self {
716        Self::new()
717    }
718}
719
720impl ServerCompositionNineGridBrushProps {
721    /// Creates the properties with every field at the default of its type; the
722    /// values of the UI thread arrive with the first batch.
723    pub fn new() -> Self {
724        Self {
725            base: ServerCompositionBrushProps::new(),
726            source: RefCell::new(None),
727            left_inset: Cell::new(Default::default()),
728            top_inset: Cell::new(Default::default()),
729            right_inset: Cell::new(Default::default()),
730            bottom_inset: Cell::new(Default::default()),
731            left_inset_scale: Cell::new(Default::default()),
732            top_inset_scale: Cell::new(Default::default()),
733            right_inset_scale: Cell::new(Default::default()),
734            bottom_inset_scale: Cell::new(Default::default()),
735            is_center_hollow: Cell::new(Default::default()),
736        }
737    }
738
739    /// The properties of the base class.
740    pub fn base(&self) -> &ServerCompositionBrushProps {
741        &self.base
742    }
743
744    /// This block or the block of a base class, by type: what
745    /// `IServerObject::get_props` of the embedding class returns.
746    pub fn find_props(&self, type_id: TypeId) -> Option<&dyn Any> {
747        if type_id == TypeId::of::<Self>() {
748            return Some(self);
749        }
750        self.base.find_props(type_id)
751    }
752
753    /// The composition property of `Source`.
754    pub fn id_of_source_property() -> &'static CompositionPropertyOf<Option<Rc<dyn IServerObject>>> {
755        static PROPERTY: OnceLock<CompositionPropertyOf<Option<Rc<dyn IServerObject>>>> = OnceLock::new();
756        PROPERTY.get_or_init(|| {
757            CompositionProperty::register::<ServerCompositionNineGridBrushProps, Option<Rc<dyn IServerObject>>>(
758                "Source",
759                "ServerCompositionNineGridBrush",
760                |obj| props_of::<ServerCompositionNineGridBrushProps>(obj).source.borrow().clone(),
761                |obj, v| *props_of::<ServerCompositionNineGridBrushProps>(obj).source.borrow_mut() = v,
762                None,
763                None,
764            )
765        })
766    }
767
768    /// `Source`.
769    pub fn source(&self) -> Option<Rc<dyn IServerObject>> {
770        self.source.borrow().clone()
771    }
772
773    pub fn set_source(&self, host: &dyn ServerCompositionNineGridBrushHooks, value: Option<Rc<dyn IServerObject>>) {
774        let old_value = self.source.borrow().clone();
775        let mut changed = false;
776        if old_value.differs(&value) {
777            ServerCompositionNineGridBrushHooks::on_source_changing(host);
778            changed = true;
779        }
780        host.set_value(
781            Self::id_of_source_property().base(),
782            ServerValueChange {
783                equal: old_value.default_equals(&value),
784                old_resource: old_value.as_server_render_resource(),
785                new_resource: value.as_server_render_resource(),
786                assign: &mut || *self.source.borrow_mut() = value.clone(),
787            },
788        );
789        if changed {
790            ServerCompositionNineGridBrushHooks::on_source_changed(host);
791        }
792    }
793
794    /// The composition property of `LeftInset`.
795    pub fn id_of_left_inset_property() -> &'static CompositionPropertyOf<f32> {
796        static PROPERTY: OnceLock<CompositionPropertyOf<f32>> = OnceLock::new();
797        PROPERTY.get_or_init(|| {
798            CompositionProperty::register::<ServerCompositionNineGridBrushProps, f32>(
799                "LeftInset",
800                "ServerCompositionNineGridBrush",
801                |obj| props_of::<ServerCompositionNineGridBrushProps>(obj).left_inset.get(),
802                |obj, v| props_of::<ServerCompositionNineGridBrushProps>(obj).left_inset.set(v),
803                Some(|obj| ExpressionVariant::create(props_of::<ServerCompositionNineGridBrushProps>(obj).left_inset.get())),
804                Some(|obj, v: ExpressionVariant| props_of::<ServerCompositionNineGridBrushProps>(obj).left_inset.set(v.cast_or_default::<f32>())),
805            )
806        })
807    }
808
809    /// `LeftInset` (animated).
810    pub fn left_inset(&self) -> f32 {
811        self.left_inset.get()
812    }
813
814    pub fn set_left_inset(&self, host: &dyn ServerCompositionNineGridBrushHooks, value: f32) {
815        self.left_inset.set(value);
816        host.remove_animation_for_property(Self::id_of_left_inset_property().base());
817    }
818
819    /// The composition property of `TopInset`.
820    pub fn id_of_top_inset_property() -> &'static CompositionPropertyOf<f32> {
821        static PROPERTY: OnceLock<CompositionPropertyOf<f32>> = OnceLock::new();
822        PROPERTY.get_or_init(|| {
823            CompositionProperty::register::<ServerCompositionNineGridBrushProps, f32>(
824                "TopInset",
825                "ServerCompositionNineGridBrush",
826                |obj| props_of::<ServerCompositionNineGridBrushProps>(obj).top_inset.get(),
827                |obj, v| props_of::<ServerCompositionNineGridBrushProps>(obj).top_inset.set(v),
828                Some(|obj| ExpressionVariant::create(props_of::<ServerCompositionNineGridBrushProps>(obj).top_inset.get())),
829                Some(|obj, v: ExpressionVariant| props_of::<ServerCompositionNineGridBrushProps>(obj).top_inset.set(v.cast_or_default::<f32>())),
830            )
831        })
832    }
833
834    /// `TopInset` (animated).
835    pub fn top_inset(&self) -> f32 {
836        self.top_inset.get()
837    }
838
839    pub fn set_top_inset(&self, host: &dyn ServerCompositionNineGridBrushHooks, value: f32) {
840        self.top_inset.set(value);
841        host.remove_animation_for_property(Self::id_of_top_inset_property().base());
842    }
843
844    /// The composition property of `RightInset`.
845    pub fn id_of_right_inset_property() -> &'static CompositionPropertyOf<f32> {
846        static PROPERTY: OnceLock<CompositionPropertyOf<f32>> = OnceLock::new();
847        PROPERTY.get_or_init(|| {
848            CompositionProperty::register::<ServerCompositionNineGridBrushProps, f32>(
849                "RightInset",
850                "ServerCompositionNineGridBrush",
851                |obj| props_of::<ServerCompositionNineGridBrushProps>(obj).right_inset.get(),
852                |obj, v| props_of::<ServerCompositionNineGridBrushProps>(obj).right_inset.set(v),
853                Some(|obj| ExpressionVariant::create(props_of::<ServerCompositionNineGridBrushProps>(obj).right_inset.get())),
854                Some(|obj, v: ExpressionVariant| props_of::<ServerCompositionNineGridBrushProps>(obj).right_inset.set(v.cast_or_default::<f32>())),
855            )
856        })
857    }
858
859    /// `RightInset` (animated).
860    pub fn right_inset(&self) -> f32 {
861        self.right_inset.get()
862    }
863
864    pub fn set_right_inset(&self, host: &dyn ServerCompositionNineGridBrushHooks, value: f32) {
865        self.right_inset.set(value);
866        host.remove_animation_for_property(Self::id_of_right_inset_property().base());
867    }
868
869    /// The composition property of `BottomInset`.
870    pub fn id_of_bottom_inset_property() -> &'static CompositionPropertyOf<f32> {
871        static PROPERTY: OnceLock<CompositionPropertyOf<f32>> = OnceLock::new();
872        PROPERTY.get_or_init(|| {
873            CompositionProperty::register::<ServerCompositionNineGridBrushProps, f32>(
874                "BottomInset",
875                "ServerCompositionNineGridBrush",
876                |obj| props_of::<ServerCompositionNineGridBrushProps>(obj).bottom_inset.get(),
877                |obj, v| props_of::<ServerCompositionNineGridBrushProps>(obj).bottom_inset.set(v),
878                Some(|obj| ExpressionVariant::create(props_of::<ServerCompositionNineGridBrushProps>(obj).bottom_inset.get())),
879                Some(|obj, v: ExpressionVariant| props_of::<ServerCompositionNineGridBrushProps>(obj).bottom_inset.set(v.cast_or_default::<f32>())),
880            )
881        })
882    }
883
884    /// `BottomInset` (animated).
885    pub fn bottom_inset(&self) -> f32 {
886        self.bottom_inset.get()
887    }
888
889    pub fn set_bottom_inset(&self, host: &dyn ServerCompositionNineGridBrushHooks, value: f32) {
890        self.bottom_inset.set(value);
891        host.remove_animation_for_property(Self::id_of_bottom_inset_property().base());
892    }
893
894    /// The composition property of `LeftInsetScale`.
895    pub fn id_of_left_inset_scale_property() -> &'static CompositionPropertyOf<f32> {
896        static PROPERTY: OnceLock<CompositionPropertyOf<f32>> = OnceLock::new();
897        PROPERTY.get_or_init(|| {
898            CompositionProperty::register::<ServerCompositionNineGridBrushProps, f32>(
899                "LeftInsetScale",
900                "ServerCompositionNineGridBrush",
901                |obj| props_of::<ServerCompositionNineGridBrushProps>(obj).left_inset_scale.get(),
902                |obj, v| props_of::<ServerCompositionNineGridBrushProps>(obj).left_inset_scale.set(v),
903                Some(|obj| ExpressionVariant::create(props_of::<ServerCompositionNineGridBrushProps>(obj).left_inset_scale.get())),
904                Some(|obj, v: ExpressionVariant| props_of::<ServerCompositionNineGridBrushProps>(obj).left_inset_scale.set(v.cast_or_default::<f32>())),
905            )
906        })
907    }
908
909    /// `LeftInsetScale` (animated).
910    pub fn left_inset_scale(&self) -> f32 {
911        self.left_inset_scale.get()
912    }
913
914    pub fn set_left_inset_scale(&self, host: &dyn ServerCompositionNineGridBrushHooks, value: f32) {
915        self.left_inset_scale.set(value);
916        host.remove_animation_for_property(Self::id_of_left_inset_scale_property().base());
917    }
918
919    /// The composition property of `TopInsetScale`.
920    pub fn id_of_top_inset_scale_property() -> &'static CompositionPropertyOf<f32> {
921        static PROPERTY: OnceLock<CompositionPropertyOf<f32>> = OnceLock::new();
922        PROPERTY.get_or_init(|| {
923            CompositionProperty::register::<ServerCompositionNineGridBrushProps, f32>(
924                "TopInsetScale",
925                "ServerCompositionNineGridBrush",
926                |obj| props_of::<ServerCompositionNineGridBrushProps>(obj).top_inset_scale.get(),
927                |obj, v| props_of::<ServerCompositionNineGridBrushProps>(obj).top_inset_scale.set(v),
928                Some(|obj| ExpressionVariant::create(props_of::<ServerCompositionNineGridBrushProps>(obj).top_inset_scale.get())),
929                Some(|obj, v: ExpressionVariant| props_of::<ServerCompositionNineGridBrushProps>(obj).top_inset_scale.set(v.cast_or_default::<f32>())),
930            )
931        })
932    }
933
934    /// `TopInsetScale` (animated).
935    pub fn top_inset_scale(&self) -> f32 {
936        self.top_inset_scale.get()
937    }
938
939    pub fn set_top_inset_scale(&self, host: &dyn ServerCompositionNineGridBrushHooks, value: f32) {
940        self.top_inset_scale.set(value);
941        host.remove_animation_for_property(Self::id_of_top_inset_scale_property().base());
942    }
943
944    /// The composition property of `RightInsetScale`.
945    pub fn id_of_right_inset_scale_property() -> &'static CompositionPropertyOf<f32> {
946        static PROPERTY: OnceLock<CompositionPropertyOf<f32>> = OnceLock::new();
947        PROPERTY.get_or_init(|| {
948            CompositionProperty::register::<ServerCompositionNineGridBrushProps, f32>(
949                "RightInsetScale",
950                "ServerCompositionNineGridBrush",
951                |obj| props_of::<ServerCompositionNineGridBrushProps>(obj).right_inset_scale.get(),
952                |obj, v| props_of::<ServerCompositionNineGridBrushProps>(obj).right_inset_scale.set(v),
953                Some(|obj| ExpressionVariant::create(props_of::<ServerCompositionNineGridBrushProps>(obj).right_inset_scale.get())),
954                Some(|obj, v: ExpressionVariant| props_of::<ServerCompositionNineGridBrushProps>(obj).right_inset_scale.set(v.cast_or_default::<f32>())),
955            )
956        })
957    }
958
959    /// `RightInsetScale` (animated).
960    pub fn right_inset_scale(&self) -> f32 {
961        self.right_inset_scale.get()
962    }
963
964    pub fn set_right_inset_scale(&self, host: &dyn ServerCompositionNineGridBrushHooks, value: f32) {
965        self.right_inset_scale.set(value);
966        host.remove_animation_for_property(Self::id_of_right_inset_scale_property().base());
967    }
968
969    /// The composition property of `BottomInsetScale`.
970    pub fn id_of_bottom_inset_scale_property() -> &'static CompositionPropertyOf<f32> {
971        static PROPERTY: OnceLock<CompositionPropertyOf<f32>> = OnceLock::new();
972        PROPERTY.get_or_init(|| {
973            CompositionProperty::register::<ServerCompositionNineGridBrushProps, f32>(
974                "BottomInsetScale",
975                "ServerCompositionNineGridBrush",
976                |obj| props_of::<ServerCompositionNineGridBrushProps>(obj).bottom_inset_scale.get(),
977                |obj, v| props_of::<ServerCompositionNineGridBrushProps>(obj).bottom_inset_scale.set(v),
978                Some(|obj| ExpressionVariant::create(props_of::<ServerCompositionNineGridBrushProps>(obj).bottom_inset_scale.get())),
979                Some(|obj, v: ExpressionVariant| props_of::<ServerCompositionNineGridBrushProps>(obj).bottom_inset_scale.set(v.cast_or_default::<f32>())),
980            )
981        })
982    }
983
984    /// `BottomInsetScale` (animated).
985    pub fn bottom_inset_scale(&self) -> f32 {
986        self.bottom_inset_scale.get()
987    }
988
989    pub fn set_bottom_inset_scale(&self, host: &dyn ServerCompositionNineGridBrushHooks, value: f32) {
990        self.bottom_inset_scale.set(value);
991        host.remove_animation_for_property(Self::id_of_bottom_inset_scale_property().base());
992    }
993
994    /// The composition property of `IsCenterHollow`.
995    pub fn id_of_is_center_hollow_property() -> &'static CompositionPropertyOf<bool> {
996        static PROPERTY: OnceLock<CompositionPropertyOf<bool>> = OnceLock::new();
997        PROPERTY.get_or_init(|| {
998            CompositionProperty::register::<ServerCompositionNineGridBrushProps, bool>(
999                "IsCenterHollow",
1000                "ServerCompositionNineGridBrush",
1001                |obj| props_of::<ServerCompositionNineGridBrushProps>(obj).is_center_hollow.get(),
1002                |obj, v| props_of::<ServerCompositionNineGridBrushProps>(obj).is_center_hollow.set(v),
1003                Some(|obj| ExpressionVariant::create(props_of::<ServerCompositionNineGridBrushProps>(obj).is_center_hollow.get())),
1004                None,
1005            )
1006        })
1007    }
1008
1009    /// `IsCenterHollow`.
1010    pub fn is_center_hollow(&self) -> bool {
1011        self.is_center_hollow.get()
1012    }
1013
1014    pub fn set_is_center_hollow(&self, host: &dyn ServerCompositionNineGridBrushHooks, value: bool) {
1015        let old_value = self.is_center_hollow.get();
1016        let mut changed = false;
1017        if old_value.differs(&value) {
1018            ServerCompositionNineGridBrushHooks::on_is_center_hollow_changing(host);
1019            changed = true;
1020        }
1021        host.set_value(
1022            Self::id_of_is_center_hollow_property().base(),
1023            ServerValueChange {
1024                equal: old_value.default_equals(&value),
1025                old_resource: None,
1026                new_resource: None,
1027                assign: &mut || self.is_center_hollow.set(value),
1028            },
1029        );
1030        if changed {
1031            ServerCompositionNineGridBrushHooks::on_is_center_hollow_changed(host);
1032        }
1033    }
1034
1035    /// Reads the changes of the object: the base class first, then the
1036    /// changed-fields mask and the changed members of this class.
1037    pub fn deserialize_changes_core(
1038        &self,
1039        host: &dyn ServerCompositionNineGridBrushHooks,
1040        reader: &mut BatchStreamReader<'_>,
1041        committed_at: Duration,
1042    ) {
1043        let compositor = host.server_compositor();
1044        self.base.deserialize_changes_core(host, reader, committed_at);
1045        ServerCompositionNineGridBrushHooks::deserialize_changes_extra(host, reader);
1046        let changed = reader.read::<CompositionNineGridBrushChangedFields>();
1047        if changed.contains(CompositionNineGridBrushChangedFields::SOURCE) {
1048            let value = read_server_object(reader, compositor.as_ref());
1049            self.set_source(host, value);
1050        }
1051        if changed.contains(CompositionNineGridBrushChangedFields::LEFT_INSET_ANIMATED) {
1052            let Some(animation) = reader.read_value::<AnimationInstanceFactory>().map(AnimationInstanceFactory::create) else {
1053                panic!("a batch starts an animation of `LeftInset` without an animation instance");
1054            };
1055            host.set_animated_value(
1056                Self::id_of_left_inset_property().base(),
1057                ExpressionVariant::create(self.left_inset.get()),
1058                committed_at,
1059                animation,
1060            );
1061        } else if changed.contains(CompositionNineGridBrushChangedFields::LEFT_INSET) {
1062            let value = reader.read::<f32>();
1063            self.set_left_inset(host, value);
1064        }
1065        if changed.contains(CompositionNineGridBrushChangedFields::TOP_INSET_ANIMATED) {
1066            let Some(animation) = reader.read_value::<AnimationInstanceFactory>().map(AnimationInstanceFactory::create) else {
1067                panic!("a batch starts an animation of `TopInset` without an animation instance");
1068            };
1069            host.set_animated_value(
1070                Self::id_of_top_inset_property().base(),
1071                ExpressionVariant::create(self.top_inset.get()),
1072                committed_at,
1073                animation,
1074            );
1075        } else if changed.contains(CompositionNineGridBrushChangedFields::TOP_INSET) {
1076            let value = reader.read::<f32>();
1077            self.set_top_inset(host, value);
1078        }
1079        if changed.contains(CompositionNineGridBrushChangedFields::RIGHT_INSET_ANIMATED) {
1080            let Some(animation) = reader.read_value::<AnimationInstanceFactory>().map(AnimationInstanceFactory::create) else {
1081                panic!("a batch starts an animation of `RightInset` without an animation instance");
1082            };
1083            host.set_animated_value(
1084                Self::id_of_right_inset_property().base(),
1085                ExpressionVariant::create(self.right_inset.get()),
1086                committed_at,
1087                animation,
1088            );
1089        } else if changed.contains(CompositionNineGridBrushChangedFields::RIGHT_INSET) {
1090            let value = reader.read::<f32>();
1091            self.set_right_inset(host, value);
1092        }
1093        if changed.contains(CompositionNineGridBrushChangedFields::BOTTOM_INSET_ANIMATED) {
1094            let Some(animation) = reader.read_value::<AnimationInstanceFactory>().map(AnimationInstanceFactory::create) else {
1095                panic!("a batch starts an animation of `BottomInset` without an animation instance");
1096            };
1097            host.set_animated_value(
1098                Self::id_of_bottom_inset_property().base(),
1099                ExpressionVariant::create(self.bottom_inset.get()),
1100                committed_at,
1101                animation,
1102            );
1103        } else if changed.contains(CompositionNineGridBrushChangedFields::BOTTOM_INSET) {
1104            let value = reader.read::<f32>();
1105            self.set_bottom_inset(host, value);
1106        }
1107        if changed.contains(CompositionNineGridBrushChangedFields::LEFT_INSET_SCALE_ANIMATED) {
1108            let Some(animation) = reader.read_value::<AnimationInstanceFactory>().map(AnimationInstanceFactory::create) else {
1109                panic!("a batch starts an animation of `LeftInsetScale` without an animation instance");
1110            };
1111            host.set_animated_value(
1112                Self::id_of_left_inset_scale_property().base(),
1113                ExpressionVariant::create(self.left_inset_scale.get()),
1114                committed_at,
1115                animation,
1116            );
1117        } else if changed.contains(CompositionNineGridBrushChangedFields::LEFT_INSET_SCALE) {
1118            let value = reader.read::<f32>();
1119            self.set_left_inset_scale(host, value);
1120        }
1121        if changed.contains(CompositionNineGridBrushChangedFields::TOP_INSET_SCALE_ANIMATED) {
1122            let Some(animation) = reader.read_value::<AnimationInstanceFactory>().map(AnimationInstanceFactory::create) else {
1123                panic!("a batch starts an animation of `TopInsetScale` without an animation instance");
1124            };
1125            host.set_animated_value(
1126                Self::id_of_top_inset_scale_property().base(),
1127                ExpressionVariant::create(self.top_inset_scale.get()),
1128                committed_at,
1129                animation,
1130            );
1131        } else if changed.contains(CompositionNineGridBrushChangedFields::TOP_INSET_SCALE) {
1132            let value = reader.read::<f32>();
1133            self.set_top_inset_scale(host, value);
1134        }
1135        if changed.contains(CompositionNineGridBrushChangedFields::RIGHT_INSET_SCALE_ANIMATED) {
1136            let Some(animation) = reader.read_value::<AnimationInstanceFactory>().map(AnimationInstanceFactory::create) else {
1137                panic!("a batch starts an animation of `RightInsetScale` without an animation instance");
1138            };
1139            host.set_animated_value(
1140                Self::id_of_right_inset_scale_property().base(),
1141                ExpressionVariant::create(self.right_inset_scale.get()),
1142                committed_at,
1143                animation,
1144            );
1145        } else if changed.contains(CompositionNineGridBrushChangedFields::RIGHT_INSET_SCALE) {
1146            let value = reader.read::<f32>();
1147            self.set_right_inset_scale(host, value);
1148        }
1149        if changed.contains(CompositionNineGridBrushChangedFields::BOTTOM_INSET_SCALE_ANIMATED) {
1150            let Some(animation) = reader.read_value::<AnimationInstanceFactory>().map(AnimationInstanceFactory::create) else {
1151                panic!("a batch starts an animation of `BottomInsetScale` without an animation instance");
1152            };
1153            host.set_animated_value(
1154                Self::id_of_bottom_inset_scale_property().base(),
1155                ExpressionVariant::create(self.bottom_inset_scale.get()),
1156                committed_at,
1157                animation,
1158            );
1159        } else if changed.contains(CompositionNineGridBrushChangedFields::BOTTOM_INSET_SCALE) {
1160            let value = reader.read::<f32>();
1161            self.set_bottom_inset_scale(host, value);
1162        }
1163        if changed.contains(CompositionNineGridBrushChangedFields::IS_CENTER_HOLLOW) {
1164            let value = reader.read::<bool>();
1165            self.set_is_center_hollow(host, value);
1166        }
1167        ServerCompositionNineGridBrushHooks::on_fields_deserialized(host, changed);
1168    }
1169
1170    /// The composition property with the given name, among the properties
1171    /// of this class and of its generated bases that have a variant form.
1172    pub fn get_composition_property(name: &str) -> Option<&'static CompositionProperty> {
1173        if name == "LeftInset" {
1174            return Some(Self::id_of_left_inset_property().base());
1175        }
1176        if name == "TopInset" {
1177            return Some(Self::id_of_top_inset_property().base());
1178        }
1179        if name == "RightInset" {
1180            return Some(Self::id_of_right_inset_property().base());
1181        }
1182        if name == "BottomInset" {
1183            return Some(Self::id_of_bottom_inset_property().base());
1184        }
1185        if name == "LeftInsetScale" {
1186            return Some(Self::id_of_left_inset_scale_property().base());
1187        }
1188        if name == "TopInsetScale" {
1189            return Some(Self::id_of_top_inset_scale_property().base());
1190        }
1191        if name == "RightInsetScale" {
1192            return Some(Self::id_of_right_inset_scale_property().base());
1193        }
1194        if name == "BottomInsetScale" {
1195            return Some(Self::id_of_bottom_inset_scale_property().base());
1196        }
1197        if name == "IsCenterHollow" {
1198            return Some(Self::id_of_is_center_hollow_property().base());
1199        }
1200        ServerCompositionBrushProps::get_composition_property(name)
1201    }
1202}