use bitflags::bitflags;
use crate::rendering::composition::ICompositionObject;
use crate::rendering::composition::animations::AnimationInstanceFactory;
use crate::rendering::composition::animations::ICompositionAnimation;
use crate::rendering::composition::expressions::ExpressionVariant;
use crate::rendering::composition::server::AsServerRenderResource;
use crate::rendering::composition::server::CompositionProperty;
use crate::rendering::composition::server::CompositionPropertyOf;
use crate::rendering::composition::server::IServerObject;
use crate::rendering::composition::server::ServerPropertyValue;
use crate::rendering::composition::server::ServerValueChange;
use crate::rendering::composition::server::props_of;
use crate::rendering::composition::server::read_server_object;
use crate::rendering::composition::transport::BatchStreamReader;
use crate::rendering::composition::transport::BatchStreamWriter;
use crate::rendering::composition::transport::BatchValue;
use crate::rendering::composition::transport::BatchValueReader;
use std::any::Any;
use std::any::TypeId;
use std::cell::Cell;
use std::cell::RefCell;
use std::rc::Rc;
use std::sync::OnceLock;
use std::time::Duration;
use super::CompositionBrushHooks;
use super::CompositionBrushProps;
use super::ServerCompositionBrushHooks;
use super::ServerCompositionBrushProps;
bitflags! {
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct CompositionNineGridBrushChangedFields: u32 {
const SOURCE = 1;
const LEFT_INSET = 2;
const LEFT_INSET_ANIMATED = 4;
const TOP_INSET = 8;
const TOP_INSET_ANIMATED = 16;
const RIGHT_INSET = 32;
const RIGHT_INSET_ANIMATED = 64;
const BOTTOM_INSET = 128;
const BOTTOM_INSET_ANIMATED = 256;
const LEFT_INSET_SCALE = 512;
const LEFT_INSET_SCALE_ANIMATED = 1024;
const TOP_INSET_SCALE = 2048;
const TOP_INSET_SCALE_ANIMATED = 4096;
const RIGHT_INSET_SCALE = 8192;
const RIGHT_INSET_SCALE_ANIMATED = 16384;
const BOTTOM_INSET_SCALE = 32768;
const BOTTOM_INSET_SCALE_ANIMATED = 65536;
const IS_CENTER_HOLLOW = 131072;
}
}
impl BatchValue for CompositionNineGridBrushChangedFields {
#[inline]
fn write_to(&self, out: &mut Vec<u8>) {
self.bits().write_to(out);
}
#[inline]
fn read_from(input: &mut BatchValueReader<'_>) -> Self {
CompositionNineGridBrushChangedFields::from_bits_retain(u32::read_from(input))
}
}
pub trait CompositionNineGridBrushHooks: CompositionBrushHooks {
fn initialize_defaults_extra(&self) {}
fn validate_source_change(&self, _old_value: &Option<Rc<dyn ICompositionObject>>, _new_value: &Option<Rc<dyn ICompositionObject>>) {}
fn on_source_changed(&self) {}
fn on_source_changing(&self) {}
fn validate_left_inset_change(&self, _old_value: f32, _new_value: f32) {}
fn on_left_inset_changed(&self) {}
fn on_left_inset_changing(&self) {}
fn validate_top_inset_change(&self, _old_value: f32, _new_value: f32) {}
fn on_top_inset_changed(&self) {}
fn on_top_inset_changing(&self) {}
fn validate_right_inset_change(&self, _old_value: f32, _new_value: f32) {}
fn on_right_inset_changed(&self) {}
fn on_right_inset_changing(&self) {}
fn validate_bottom_inset_change(&self, _old_value: f32, _new_value: f32) {}
fn on_bottom_inset_changed(&self) {}
fn on_bottom_inset_changing(&self) {}
fn validate_left_inset_scale_change(&self, _old_value: f32, _new_value: f32) {}
fn on_left_inset_scale_changed(&self) {}
fn on_left_inset_scale_changing(&self) {}
fn validate_top_inset_scale_change(&self, _old_value: f32, _new_value: f32) {}
fn on_top_inset_scale_changed(&self) {}
fn on_top_inset_scale_changing(&self) {}
fn validate_right_inset_scale_change(&self, _old_value: f32, _new_value: f32) {}
fn on_right_inset_scale_changed(&self) {}
fn on_right_inset_scale_changing(&self) {}
fn validate_bottom_inset_scale_change(&self, _old_value: f32, _new_value: f32) {}
fn on_bottom_inset_scale_changed(&self) {}
fn on_bottom_inset_scale_changing(&self) {}
fn validate_is_center_hollow_change(&self, _old_value: bool, _new_value: bool) {}
fn on_is_center_hollow_changed(&self) {}
fn on_is_center_hollow_changing(&self) {}
}
pub struct CompositionNineGridBrushProps {
base: CompositionBrushProps,
changed_fields_of_composition_nine_grid_brush: Cell<CompositionNineGridBrushChangedFields>,
source: RefCell<Option<Rc<dyn ICompositionObject>>>,
left_inset: Cell<f32>,
top_inset: Cell<f32>,
right_inset: Cell<f32>,
bottom_inset: Cell<f32>,
left_inset_scale: Cell<f32>,
top_inset_scale: Cell<f32>,
right_inset_scale: Cell<f32>,
bottom_inset_scale: Cell<f32>,
is_center_hollow: Cell<bool>,
}
impl Default for CompositionNineGridBrushProps {
fn default() -> Self {
Self::new()
}
}
impl CompositionNineGridBrushProps {
pub fn new() -> Self {
Self {
base: CompositionBrushProps::new(),
changed_fields_of_composition_nine_grid_brush: Cell::new(CompositionNineGridBrushChangedFields::empty()),
source: RefCell::new(None),
left_inset: Cell::new(Default::default()),
top_inset: Cell::new(Default::default()),
right_inset: Cell::new(Default::default()),
bottom_inset: Cell::new(Default::default()),
left_inset_scale: Cell::new(Default::default()),
top_inset_scale: Cell::new(Default::default()),
right_inset_scale: Cell::new(Default::default()),
bottom_inset_scale: Cell::new(Default::default()),
is_center_hollow: Cell::new(Default::default()),
}
}
pub fn base(&self) -> &CompositionBrushProps {
&self.base
}
pub fn initialize_defaults(&self, host: &dyn CompositionNineGridBrushHooks) {
self.base.initialize_defaults(host);
self.initialize_own_defaults(host);
}
pub fn initialize_own_defaults(&self, host: &dyn CompositionNineGridBrushHooks) {
CompositionNineGridBrushHooks::initialize_defaults_extra(host);
self.set_left_inset_scale(host, 1.0);
self.set_top_inset_scale(host, 1.0);
self.set_right_inset_scale(host, 1.0);
self.set_bottom_inset_scale(host, 1.0);
}
pub fn source(&self) -> Option<Rc<dyn ICompositionObject>> {
self.source.borrow().clone()
}
pub fn set_source(&self, host: &dyn CompositionNineGridBrushHooks, value: Option<Rc<dyn ICompositionObject>>) {
let mut changed = false;
let old_value = self.source.borrow().clone();
if old_value.differs(&value) {
CompositionNineGridBrushHooks::validate_source_change(host, &old_value, &value);
CompositionNineGridBrushHooks::on_source_changing(host);
changed = true;
*self.source.borrow_mut() = value.clone();
self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::SOURCE);
host.register_for_serialization();
}
*self.source.borrow_mut() = value;
if changed {
CompositionNineGridBrushHooks::on_source_changed(host);
}
}
pub fn left_inset(&self) -> f32 {
self.left_inset.get()
}
pub fn set_left_inset(&self, host: &dyn CompositionNineGridBrushHooks, value: f32) {
let mut changed = false;
let old_value = self.left_inset.get();
if old_value.differs(&value) {
CompositionNineGridBrushHooks::validate_left_inset_change(host, old_value, value);
CompositionNineGridBrushHooks::on_left_inset_changing(host);
changed = true;
self.left_inset.set(value);
self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::LEFT_INSET);
host.register_for_serialization();
host.pending_animations().remove(ServerCompositionNineGridBrushProps::id_of_left_inset_property().base());
self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() & !CompositionNineGridBrushChangedFields::LEFT_INSET_ANIMATED);
if let Some(animation) = host.implicit_animation("LeftInset") {
if let Some(a) = animation.as_composition_animation() {
self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::LEFT_INSET_ANIMATED);
host.pending_animations().set(
ServerCompositionNineGridBrushProps::id_of_left_inset_property().base(),
a.create_instance(host.server(), Some(ExpressionVariant::create(value))),
);
}
host.start_animation_group(&animation, "LeftInset", ExpressionVariant::create(value));
}
}
self.left_inset.set(value);
if changed {
CompositionNineGridBrushHooks::on_left_inset_changed(host);
}
}
pub fn top_inset(&self) -> f32 {
self.top_inset.get()
}
pub fn set_top_inset(&self, host: &dyn CompositionNineGridBrushHooks, value: f32) {
let mut changed = false;
let old_value = self.top_inset.get();
if old_value.differs(&value) {
CompositionNineGridBrushHooks::validate_top_inset_change(host, old_value, value);
CompositionNineGridBrushHooks::on_top_inset_changing(host);
changed = true;
self.top_inset.set(value);
self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::TOP_INSET);
host.register_for_serialization();
host.pending_animations().remove(ServerCompositionNineGridBrushProps::id_of_top_inset_property().base());
self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() & !CompositionNineGridBrushChangedFields::TOP_INSET_ANIMATED);
if let Some(animation) = host.implicit_animation("TopInset") {
if let Some(a) = animation.as_composition_animation() {
self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::TOP_INSET_ANIMATED);
host.pending_animations().set(
ServerCompositionNineGridBrushProps::id_of_top_inset_property().base(),
a.create_instance(host.server(), Some(ExpressionVariant::create(value))),
);
}
host.start_animation_group(&animation, "TopInset", ExpressionVariant::create(value));
}
}
self.top_inset.set(value);
if changed {
CompositionNineGridBrushHooks::on_top_inset_changed(host);
}
}
pub fn right_inset(&self) -> f32 {
self.right_inset.get()
}
pub fn set_right_inset(&self, host: &dyn CompositionNineGridBrushHooks, value: f32) {
let mut changed = false;
let old_value = self.right_inset.get();
if old_value.differs(&value) {
CompositionNineGridBrushHooks::validate_right_inset_change(host, old_value, value);
CompositionNineGridBrushHooks::on_right_inset_changing(host);
changed = true;
self.right_inset.set(value);
self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::RIGHT_INSET);
host.register_for_serialization();
host.pending_animations().remove(ServerCompositionNineGridBrushProps::id_of_right_inset_property().base());
self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() & !CompositionNineGridBrushChangedFields::RIGHT_INSET_ANIMATED);
if let Some(animation) = host.implicit_animation("RightInset") {
if let Some(a) = animation.as_composition_animation() {
self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::RIGHT_INSET_ANIMATED);
host.pending_animations().set(
ServerCompositionNineGridBrushProps::id_of_right_inset_property().base(),
a.create_instance(host.server(), Some(ExpressionVariant::create(value))),
);
}
host.start_animation_group(&animation, "RightInset", ExpressionVariant::create(value));
}
}
self.right_inset.set(value);
if changed {
CompositionNineGridBrushHooks::on_right_inset_changed(host);
}
}
pub fn bottom_inset(&self) -> f32 {
self.bottom_inset.get()
}
pub fn set_bottom_inset(&self, host: &dyn CompositionNineGridBrushHooks, value: f32) {
let mut changed = false;
let old_value = self.bottom_inset.get();
if old_value.differs(&value) {
CompositionNineGridBrushHooks::validate_bottom_inset_change(host, old_value, value);
CompositionNineGridBrushHooks::on_bottom_inset_changing(host);
changed = true;
self.bottom_inset.set(value);
self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::BOTTOM_INSET);
host.register_for_serialization();
host.pending_animations().remove(ServerCompositionNineGridBrushProps::id_of_bottom_inset_property().base());
self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() & !CompositionNineGridBrushChangedFields::BOTTOM_INSET_ANIMATED);
if let Some(animation) = host.implicit_animation("BottomInset") {
if let Some(a) = animation.as_composition_animation() {
self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::BOTTOM_INSET_ANIMATED);
host.pending_animations().set(
ServerCompositionNineGridBrushProps::id_of_bottom_inset_property().base(),
a.create_instance(host.server(), Some(ExpressionVariant::create(value))),
);
}
host.start_animation_group(&animation, "BottomInset", ExpressionVariant::create(value));
}
}
self.bottom_inset.set(value);
if changed {
CompositionNineGridBrushHooks::on_bottom_inset_changed(host);
}
}
pub fn left_inset_scale(&self) -> f32 {
self.left_inset_scale.get()
}
pub fn set_left_inset_scale(&self, host: &dyn CompositionNineGridBrushHooks, value: f32) {
let mut changed = false;
let old_value = self.left_inset_scale.get();
if old_value.differs(&value) {
CompositionNineGridBrushHooks::validate_left_inset_scale_change(host, old_value, value);
CompositionNineGridBrushHooks::on_left_inset_scale_changing(host);
changed = true;
self.left_inset_scale.set(value);
self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::LEFT_INSET_SCALE);
host.register_for_serialization();
host.pending_animations().remove(ServerCompositionNineGridBrushProps::id_of_left_inset_scale_property().base());
self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() & !CompositionNineGridBrushChangedFields::LEFT_INSET_SCALE_ANIMATED);
if let Some(animation) = host.implicit_animation("LeftInsetScale") {
if let Some(a) = animation.as_composition_animation() {
self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::LEFT_INSET_SCALE_ANIMATED);
host.pending_animations().set(
ServerCompositionNineGridBrushProps::id_of_left_inset_scale_property().base(),
a.create_instance(host.server(), Some(ExpressionVariant::create(value))),
);
}
host.start_animation_group(&animation, "LeftInsetScale", ExpressionVariant::create(value));
}
}
self.left_inset_scale.set(value);
if changed {
CompositionNineGridBrushHooks::on_left_inset_scale_changed(host);
}
}
pub fn top_inset_scale(&self) -> f32 {
self.top_inset_scale.get()
}
pub fn set_top_inset_scale(&self, host: &dyn CompositionNineGridBrushHooks, value: f32) {
let mut changed = false;
let old_value = self.top_inset_scale.get();
if old_value.differs(&value) {
CompositionNineGridBrushHooks::validate_top_inset_scale_change(host, old_value, value);
CompositionNineGridBrushHooks::on_top_inset_scale_changing(host);
changed = true;
self.top_inset_scale.set(value);
self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::TOP_INSET_SCALE);
host.register_for_serialization();
host.pending_animations().remove(ServerCompositionNineGridBrushProps::id_of_top_inset_scale_property().base());
self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() & !CompositionNineGridBrushChangedFields::TOP_INSET_SCALE_ANIMATED);
if let Some(animation) = host.implicit_animation("TopInsetScale") {
if let Some(a) = animation.as_composition_animation() {
self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::TOP_INSET_SCALE_ANIMATED);
host.pending_animations().set(
ServerCompositionNineGridBrushProps::id_of_top_inset_scale_property().base(),
a.create_instance(host.server(), Some(ExpressionVariant::create(value))),
);
}
host.start_animation_group(&animation, "TopInsetScale", ExpressionVariant::create(value));
}
}
self.top_inset_scale.set(value);
if changed {
CompositionNineGridBrushHooks::on_top_inset_scale_changed(host);
}
}
pub fn right_inset_scale(&self) -> f32 {
self.right_inset_scale.get()
}
pub fn set_right_inset_scale(&self, host: &dyn CompositionNineGridBrushHooks, value: f32) {
let mut changed = false;
let old_value = self.right_inset_scale.get();
if old_value.differs(&value) {
CompositionNineGridBrushHooks::validate_right_inset_scale_change(host, old_value, value);
CompositionNineGridBrushHooks::on_right_inset_scale_changing(host);
changed = true;
self.right_inset_scale.set(value);
self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::RIGHT_INSET_SCALE);
host.register_for_serialization();
host.pending_animations().remove(ServerCompositionNineGridBrushProps::id_of_right_inset_scale_property().base());
self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() & !CompositionNineGridBrushChangedFields::RIGHT_INSET_SCALE_ANIMATED);
if let Some(animation) = host.implicit_animation("RightInsetScale") {
if let Some(a) = animation.as_composition_animation() {
self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::RIGHT_INSET_SCALE_ANIMATED);
host.pending_animations().set(
ServerCompositionNineGridBrushProps::id_of_right_inset_scale_property().base(),
a.create_instance(host.server(), Some(ExpressionVariant::create(value))),
);
}
host.start_animation_group(&animation, "RightInsetScale", ExpressionVariant::create(value));
}
}
self.right_inset_scale.set(value);
if changed {
CompositionNineGridBrushHooks::on_right_inset_scale_changed(host);
}
}
pub fn bottom_inset_scale(&self) -> f32 {
self.bottom_inset_scale.get()
}
pub fn set_bottom_inset_scale(&self, host: &dyn CompositionNineGridBrushHooks, value: f32) {
let mut changed = false;
let old_value = self.bottom_inset_scale.get();
if old_value.differs(&value) {
CompositionNineGridBrushHooks::validate_bottom_inset_scale_change(host, old_value, value);
CompositionNineGridBrushHooks::on_bottom_inset_scale_changing(host);
changed = true;
self.bottom_inset_scale.set(value);
self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::BOTTOM_INSET_SCALE);
host.register_for_serialization();
host.pending_animations().remove(ServerCompositionNineGridBrushProps::id_of_bottom_inset_scale_property().base());
self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() & !CompositionNineGridBrushChangedFields::BOTTOM_INSET_SCALE_ANIMATED);
if let Some(animation) = host.implicit_animation("BottomInsetScale") {
if let Some(a) = animation.as_composition_animation() {
self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::BOTTOM_INSET_SCALE_ANIMATED);
host.pending_animations().set(
ServerCompositionNineGridBrushProps::id_of_bottom_inset_scale_property().base(),
a.create_instance(host.server(), Some(ExpressionVariant::create(value))),
);
}
host.start_animation_group(&animation, "BottomInsetScale", ExpressionVariant::create(value));
}
}
self.bottom_inset_scale.set(value);
if changed {
CompositionNineGridBrushHooks::on_bottom_inset_scale_changed(host);
}
}
pub fn is_center_hollow(&self) -> bool {
self.is_center_hollow.get()
}
pub fn set_is_center_hollow(&self, host: &dyn CompositionNineGridBrushHooks, value: bool) {
let mut changed = false;
let old_value = self.is_center_hollow.get();
if old_value.differs(&value) {
CompositionNineGridBrushHooks::validate_is_center_hollow_change(host, old_value, value);
CompositionNineGridBrushHooks::on_is_center_hollow_changing(host);
changed = true;
self.is_center_hollow.set(value);
self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::IS_CENTER_HOLLOW);
host.register_for_serialization();
}
self.is_center_hollow.set(value);
if changed {
CompositionNineGridBrushHooks::on_is_center_hollow_changed(host);
}
}
pub fn start_animation(
&self,
host: &dyn CompositionNineGridBrushHooks,
property_name: &str,
animation: &dyn ICompositionAnimation,
final_value: Option<ExpressionVariant>,
) -> bool {
if property_name == "LeftInset" {
let server = animation.create_instance(host.server(), final_value);
host.pending_animations().set(ServerCompositionNineGridBrushProps::id_of_left_inset_property().base(), server);
self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::LEFT_INSET_ANIMATED);
host.register_for_serialization();
return true;
}
if property_name == "TopInset" {
let server = animation.create_instance(host.server(), final_value);
host.pending_animations().set(ServerCompositionNineGridBrushProps::id_of_top_inset_property().base(), server);
self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::TOP_INSET_ANIMATED);
host.register_for_serialization();
return true;
}
if property_name == "RightInset" {
let server = animation.create_instance(host.server(), final_value);
host.pending_animations().set(ServerCompositionNineGridBrushProps::id_of_right_inset_property().base(), server);
self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::RIGHT_INSET_ANIMATED);
host.register_for_serialization();
return true;
}
if property_name == "BottomInset" {
let server = animation.create_instance(host.server(), final_value);
host.pending_animations().set(ServerCompositionNineGridBrushProps::id_of_bottom_inset_property().base(), server);
self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::BOTTOM_INSET_ANIMATED);
host.register_for_serialization();
return true;
}
if property_name == "LeftInsetScale" {
let server = animation.create_instance(host.server(), final_value);
host.pending_animations().set(ServerCompositionNineGridBrushProps::id_of_left_inset_scale_property().base(), server);
self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::LEFT_INSET_SCALE_ANIMATED);
host.register_for_serialization();
return true;
}
if property_name == "TopInsetScale" {
let server = animation.create_instance(host.server(), final_value);
host.pending_animations().set(ServerCompositionNineGridBrushProps::id_of_top_inset_scale_property().base(), server);
self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::TOP_INSET_SCALE_ANIMATED);
host.register_for_serialization();
return true;
}
if property_name == "RightInsetScale" {
let server = animation.create_instance(host.server(), final_value);
host.pending_animations().set(ServerCompositionNineGridBrushProps::id_of_right_inset_scale_property().base(), server);
self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::RIGHT_INSET_SCALE_ANIMATED);
host.register_for_serialization();
return true;
}
if property_name == "BottomInsetScale" {
let server = animation.create_instance(host.server(), final_value);
host.pending_animations().set(ServerCompositionNineGridBrushProps::id_of_bottom_inset_scale_property().base(), server);
self.changed_fields_of_composition_nine_grid_brush.set(self.changed_fields_of_composition_nine_grid_brush.get() | CompositionNineGridBrushChangedFields::BOTTOM_INSET_SCALE_ANIMATED);
host.register_for_serialization();
return true;
}
self.base.start_animation(host, property_name, animation, final_value)
}
pub fn serialize_changes_core(&self, host: &dyn CompositionNineGridBrushHooks, writer: &mut BatchStreamWriter<'_>) {
self.base.serialize_changes_core(host, writer);
let changed = self.changed_fields_of_composition_nine_grid_brush.get();
writer.write(changed);
if changed.contains(CompositionNineGridBrushChangedFields::SOURCE) {
writer.write_server_object(self.source.borrow().clone().map(|o| o.server()));
}
if changed.contains(CompositionNineGridBrushChangedFields::LEFT_INSET_ANIMATED) {
writer.write_value(host.pending_animations().get_and_remove(ServerCompositionNineGridBrushProps::id_of_left_inset_property().base()));
} else if changed.contains(CompositionNineGridBrushChangedFields::LEFT_INSET) {
writer.write(self.left_inset.get());
}
if changed.contains(CompositionNineGridBrushChangedFields::TOP_INSET_ANIMATED) {
writer.write_value(host.pending_animations().get_and_remove(ServerCompositionNineGridBrushProps::id_of_top_inset_property().base()));
} else if changed.contains(CompositionNineGridBrushChangedFields::TOP_INSET) {
writer.write(self.top_inset.get());
}
if changed.contains(CompositionNineGridBrushChangedFields::RIGHT_INSET_ANIMATED) {
writer.write_value(host.pending_animations().get_and_remove(ServerCompositionNineGridBrushProps::id_of_right_inset_property().base()));
} else if changed.contains(CompositionNineGridBrushChangedFields::RIGHT_INSET) {
writer.write(self.right_inset.get());
}
if changed.contains(CompositionNineGridBrushChangedFields::BOTTOM_INSET_ANIMATED) {
writer.write_value(host.pending_animations().get_and_remove(ServerCompositionNineGridBrushProps::id_of_bottom_inset_property().base()));
} else if changed.contains(CompositionNineGridBrushChangedFields::BOTTOM_INSET) {
writer.write(self.bottom_inset.get());
}
if changed.contains(CompositionNineGridBrushChangedFields::LEFT_INSET_SCALE_ANIMATED) {
writer.write_value(host.pending_animations().get_and_remove(ServerCompositionNineGridBrushProps::id_of_left_inset_scale_property().base()));
} else if changed.contains(CompositionNineGridBrushChangedFields::LEFT_INSET_SCALE) {
writer.write(self.left_inset_scale.get());
}
if changed.contains(CompositionNineGridBrushChangedFields::TOP_INSET_SCALE_ANIMATED) {
writer.write_value(host.pending_animations().get_and_remove(ServerCompositionNineGridBrushProps::id_of_top_inset_scale_property().base()));
} else if changed.contains(CompositionNineGridBrushChangedFields::TOP_INSET_SCALE) {
writer.write(self.top_inset_scale.get());
}
if changed.contains(CompositionNineGridBrushChangedFields::RIGHT_INSET_SCALE_ANIMATED) {
writer.write_value(host.pending_animations().get_and_remove(ServerCompositionNineGridBrushProps::id_of_right_inset_scale_property().base()));
} else if changed.contains(CompositionNineGridBrushChangedFields::RIGHT_INSET_SCALE) {
writer.write(self.right_inset_scale.get());
}
if changed.contains(CompositionNineGridBrushChangedFields::BOTTOM_INSET_SCALE_ANIMATED) {
writer.write_value(host.pending_animations().get_and_remove(ServerCompositionNineGridBrushProps::id_of_bottom_inset_scale_property().base()));
} else if changed.contains(CompositionNineGridBrushChangedFields::BOTTOM_INSET_SCALE) {
writer.write(self.bottom_inset_scale.get());
}
if changed.contains(CompositionNineGridBrushChangedFields::IS_CENTER_HOLLOW) {
writer.write(self.is_center_hollow.get());
}
self.changed_fields_of_composition_nine_grid_brush.set(CompositionNineGridBrushChangedFields::empty());
}
}
pub trait ServerCompositionNineGridBrushHooks: ServerCompositionBrushHooks {
fn deserialize_changes_extra(&self, _reader: &mut BatchStreamReader<'_>) {}
fn on_fields_deserialized(&self, _changed: CompositionNineGridBrushChangedFields) {}
fn on_source_changed(&self) {}
fn on_source_changing(&self) {}
fn on_is_center_hollow_changed(&self) {}
fn on_is_center_hollow_changing(&self) {}
}
pub struct ServerCompositionNineGridBrushProps {
base: ServerCompositionBrushProps,
source: RefCell<Option<Rc<dyn IServerObject>>>,
left_inset: Cell<f32>,
top_inset: Cell<f32>,
right_inset: Cell<f32>,
bottom_inset: Cell<f32>,
left_inset_scale: Cell<f32>,
top_inset_scale: Cell<f32>,
right_inset_scale: Cell<f32>,
bottom_inset_scale: Cell<f32>,
is_center_hollow: Cell<bool>,
}
impl Default for ServerCompositionNineGridBrushProps {
fn default() -> Self {
Self::new()
}
}
impl ServerCompositionNineGridBrushProps {
pub fn new() -> Self {
Self {
base: ServerCompositionBrushProps::new(),
source: RefCell::new(None),
left_inset: Cell::new(Default::default()),
top_inset: Cell::new(Default::default()),
right_inset: Cell::new(Default::default()),
bottom_inset: Cell::new(Default::default()),
left_inset_scale: Cell::new(Default::default()),
top_inset_scale: Cell::new(Default::default()),
right_inset_scale: Cell::new(Default::default()),
bottom_inset_scale: Cell::new(Default::default()),
is_center_hollow: Cell::new(Default::default()),
}
}
pub fn base(&self) -> &ServerCompositionBrushProps {
&self.base
}
pub fn find_props(&self, type_id: TypeId) -> Option<&dyn Any> {
if type_id == TypeId::of::<Self>() {
return Some(self);
}
self.base.find_props(type_id)
}
pub fn id_of_source_property() -> &'static CompositionPropertyOf<Option<Rc<dyn IServerObject>>> {
static PROPERTY: OnceLock<CompositionPropertyOf<Option<Rc<dyn IServerObject>>>> = OnceLock::new();
PROPERTY.get_or_init(|| {
CompositionProperty::register::<ServerCompositionNineGridBrushProps, Option<Rc<dyn IServerObject>>>(
"Source",
"ServerCompositionNineGridBrush",
|obj| props_of::<ServerCompositionNineGridBrushProps>(obj).source.borrow().clone(),
|obj, v| *props_of::<ServerCompositionNineGridBrushProps>(obj).source.borrow_mut() = v,
None,
None,
)
})
}
pub fn source(&self) -> Option<Rc<dyn IServerObject>> {
self.source.borrow().clone()
}
pub fn set_source(&self, host: &dyn ServerCompositionNineGridBrushHooks, value: Option<Rc<dyn IServerObject>>) {
let old_value = self.source.borrow().clone();
let mut changed = false;
if old_value.differs(&value) {
ServerCompositionNineGridBrushHooks::on_source_changing(host);
changed = true;
}
host.set_value(
Self::id_of_source_property().base(),
ServerValueChange {
equal: old_value.default_equals(&value),
old_resource: old_value.as_server_render_resource(),
new_resource: value.as_server_render_resource(),
assign: &mut || *self.source.borrow_mut() = value.clone(),
},
);
if changed {
ServerCompositionNineGridBrushHooks::on_source_changed(host);
}
}
pub fn id_of_left_inset_property() -> &'static CompositionPropertyOf<f32> {
static PROPERTY: OnceLock<CompositionPropertyOf<f32>> = OnceLock::new();
PROPERTY.get_or_init(|| {
CompositionProperty::register::<ServerCompositionNineGridBrushProps, f32>(
"LeftInset",
"ServerCompositionNineGridBrush",
|obj| props_of::<ServerCompositionNineGridBrushProps>(obj).left_inset.get(),
|obj, v| props_of::<ServerCompositionNineGridBrushProps>(obj).left_inset.set(v),
Some(|obj| ExpressionVariant::create(props_of::<ServerCompositionNineGridBrushProps>(obj).left_inset.get())),
Some(|obj, v: ExpressionVariant| props_of::<ServerCompositionNineGridBrushProps>(obj).left_inset.set(v.cast_or_default::<f32>())),
)
})
}
pub fn left_inset(&self) -> f32 {
self.left_inset.get()
}
pub fn set_left_inset(&self, host: &dyn ServerCompositionNineGridBrushHooks, value: f32) {
self.left_inset.set(value);
host.remove_animation_for_property(Self::id_of_left_inset_property().base());
}
pub fn id_of_top_inset_property() -> &'static CompositionPropertyOf<f32> {
static PROPERTY: OnceLock<CompositionPropertyOf<f32>> = OnceLock::new();
PROPERTY.get_or_init(|| {
CompositionProperty::register::<ServerCompositionNineGridBrushProps, f32>(
"TopInset",
"ServerCompositionNineGridBrush",
|obj| props_of::<ServerCompositionNineGridBrushProps>(obj).top_inset.get(),
|obj, v| props_of::<ServerCompositionNineGridBrushProps>(obj).top_inset.set(v),
Some(|obj| ExpressionVariant::create(props_of::<ServerCompositionNineGridBrushProps>(obj).top_inset.get())),
Some(|obj, v: ExpressionVariant| props_of::<ServerCompositionNineGridBrushProps>(obj).top_inset.set(v.cast_or_default::<f32>())),
)
})
}
pub fn top_inset(&self) -> f32 {
self.top_inset.get()
}
pub fn set_top_inset(&self, host: &dyn ServerCompositionNineGridBrushHooks, value: f32) {
self.top_inset.set(value);
host.remove_animation_for_property(Self::id_of_top_inset_property().base());
}
pub fn id_of_right_inset_property() -> &'static CompositionPropertyOf<f32> {
static PROPERTY: OnceLock<CompositionPropertyOf<f32>> = OnceLock::new();
PROPERTY.get_or_init(|| {
CompositionProperty::register::<ServerCompositionNineGridBrushProps, f32>(
"RightInset",
"ServerCompositionNineGridBrush",
|obj| props_of::<ServerCompositionNineGridBrushProps>(obj).right_inset.get(),
|obj, v| props_of::<ServerCompositionNineGridBrushProps>(obj).right_inset.set(v),
Some(|obj| ExpressionVariant::create(props_of::<ServerCompositionNineGridBrushProps>(obj).right_inset.get())),
Some(|obj, v: ExpressionVariant| props_of::<ServerCompositionNineGridBrushProps>(obj).right_inset.set(v.cast_or_default::<f32>())),
)
})
}
pub fn right_inset(&self) -> f32 {
self.right_inset.get()
}
pub fn set_right_inset(&self, host: &dyn ServerCompositionNineGridBrushHooks, value: f32) {
self.right_inset.set(value);
host.remove_animation_for_property(Self::id_of_right_inset_property().base());
}
pub fn id_of_bottom_inset_property() -> &'static CompositionPropertyOf<f32> {
static PROPERTY: OnceLock<CompositionPropertyOf<f32>> = OnceLock::new();
PROPERTY.get_or_init(|| {
CompositionProperty::register::<ServerCompositionNineGridBrushProps, f32>(
"BottomInset",
"ServerCompositionNineGridBrush",
|obj| props_of::<ServerCompositionNineGridBrushProps>(obj).bottom_inset.get(),
|obj, v| props_of::<ServerCompositionNineGridBrushProps>(obj).bottom_inset.set(v),
Some(|obj| ExpressionVariant::create(props_of::<ServerCompositionNineGridBrushProps>(obj).bottom_inset.get())),
Some(|obj, v: ExpressionVariant| props_of::<ServerCompositionNineGridBrushProps>(obj).bottom_inset.set(v.cast_or_default::<f32>())),
)
})
}
pub fn bottom_inset(&self) -> f32 {
self.bottom_inset.get()
}
pub fn set_bottom_inset(&self, host: &dyn ServerCompositionNineGridBrushHooks, value: f32) {
self.bottom_inset.set(value);
host.remove_animation_for_property(Self::id_of_bottom_inset_property().base());
}
pub fn id_of_left_inset_scale_property() -> &'static CompositionPropertyOf<f32> {
static PROPERTY: OnceLock<CompositionPropertyOf<f32>> = OnceLock::new();
PROPERTY.get_or_init(|| {
CompositionProperty::register::<ServerCompositionNineGridBrushProps, f32>(
"LeftInsetScale",
"ServerCompositionNineGridBrush",
|obj| props_of::<ServerCompositionNineGridBrushProps>(obj).left_inset_scale.get(),
|obj, v| props_of::<ServerCompositionNineGridBrushProps>(obj).left_inset_scale.set(v),
Some(|obj| ExpressionVariant::create(props_of::<ServerCompositionNineGridBrushProps>(obj).left_inset_scale.get())),
Some(|obj, v: ExpressionVariant| props_of::<ServerCompositionNineGridBrushProps>(obj).left_inset_scale.set(v.cast_or_default::<f32>())),
)
})
}
pub fn left_inset_scale(&self) -> f32 {
self.left_inset_scale.get()
}
pub fn set_left_inset_scale(&self, host: &dyn ServerCompositionNineGridBrushHooks, value: f32) {
self.left_inset_scale.set(value);
host.remove_animation_for_property(Self::id_of_left_inset_scale_property().base());
}
pub fn id_of_top_inset_scale_property() -> &'static CompositionPropertyOf<f32> {
static PROPERTY: OnceLock<CompositionPropertyOf<f32>> = OnceLock::new();
PROPERTY.get_or_init(|| {
CompositionProperty::register::<ServerCompositionNineGridBrushProps, f32>(
"TopInsetScale",
"ServerCompositionNineGridBrush",
|obj| props_of::<ServerCompositionNineGridBrushProps>(obj).top_inset_scale.get(),
|obj, v| props_of::<ServerCompositionNineGridBrushProps>(obj).top_inset_scale.set(v),
Some(|obj| ExpressionVariant::create(props_of::<ServerCompositionNineGridBrushProps>(obj).top_inset_scale.get())),
Some(|obj, v: ExpressionVariant| props_of::<ServerCompositionNineGridBrushProps>(obj).top_inset_scale.set(v.cast_or_default::<f32>())),
)
})
}
pub fn top_inset_scale(&self) -> f32 {
self.top_inset_scale.get()
}
pub fn set_top_inset_scale(&self, host: &dyn ServerCompositionNineGridBrushHooks, value: f32) {
self.top_inset_scale.set(value);
host.remove_animation_for_property(Self::id_of_top_inset_scale_property().base());
}
pub fn id_of_right_inset_scale_property() -> &'static CompositionPropertyOf<f32> {
static PROPERTY: OnceLock<CompositionPropertyOf<f32>> = OnceLock::new();
PROPERTY.get_or_init(|| {
CompositionProperty::register::<ServerCompositionNineGridBrushProps, f32>(
"RightInsetScale",
"ServerCompositionNineGridBrush",
|obj| props_of::<ServerCompositionNineGridBrushProps>(obj).right_inset_scale.get(),
|obj, v| props_of::<ServerCompositionNineGridBrushProps>(obj).right_inset_scale.set(v),
Some(|obj| ExpressionVariant::create(props_of::<ServerCompositionNineGridBrushProps>(obj).right_inset_scale.get())),
Some(|obj, v: ExpressionVariant| props_of::<ServerCompositionNineGridBrushProps>(obj).right_inset_scale.set(v.cast_or_default::<f32>())),
)
})
}
pub fn right_inset_scale(&self) -> f32 {
self.right_inset_scale.get()
}
pub fn set_right_inset_scale(&self, host: &dyn ServerCompositionNineGridBrushHooks, value: f32) {
self.right_inset_scale.set(value);
host.remove_animation_for_property(Self::id_of_right_inset_scale_property().base());
}
pub fn id_of_bottom_inset_scale_property() -> &'static CompositionPropertyOf<f32> {
static PROPERTY: OnceLock<CompositionPropertyOf<f32>> = OnceLock::new();
PROPERTY.get_or_init(|| {
CompositionProperty::register::<ServerCompositionNineGridBrushProps, f32>(
"BottomInsetScale",
"ServerCompositionNineGridBrush",
|obj| props_of::<ServerCompositionNineGridBrushProps>(obj).bottom_inset_scale.get(),
|obj, v| props_of::<ServerCompositionNineGridBrushProps>(obj).bottom_inset_scale.set(v),
Some(|obj| ExpressionVariant::create(props_of::<ServerCompositionNineGridBrushProps>(obj).bottom_inset_scale.get())),
Some(|obj, v: ExpressionVariant| props_of::<ServerCompositionNineGridBrushProps>(obj).bottom_inset_scale.set(v.cast_or_default::<f32>())),
)
})
}
pub fn bottom_inset_scale(&self) -> f32 {
self.bottom_inset_scale.get()
}
pub fn set_bottom_inset_scale(&self, host: &dyn ServerCompositionNineGridBrushHooks, value: f32) {
self.bottom_inset_scale.set(value);
host.remove_animation_for_property(Self::id_of_bottom_inset_scale_property().base());
}
pub fn id_of_is_center_hollow_property() -> &'static CompositionPropertyOf<bool> {
static PROPERTY: OnceLock<CompositionPropertyOf<bool>> = OnceLock::new();
PROPERTY.get_or_init(|| {
CompositionProperty::register::<ServerCompositionNineGridBrushProps, bool>(
"IsCenterHollow",
"ServerCompositionNineGridBrush",
|obj| props_of::<ServerCompositionNineGridBrushProps>(obj).is_center_hollow.get(),
|obj, v| props_of::<ServerCompositionNineGridBrushProps>(obj).is_center_hollow.set(v),
Some(|obj| ExpressionVariant::create(props_of::<ServerCompositionNineGridBrushProps>(obj).is_center_hollow.get())),
None,
)
})
}
pub fn is_center_hollow(&self) -> bool {
self.is_center_hollow.get()
}
pub fn set_is_center_hollow(&self, host: &dyn ServerCompositionNineGridBrushHooks, value: bool) {
let old_value = self.is_center_hollow.get();
let mut changed = false;
if old_value.differs(&value) {
ServerCompositionNineGridBrushHooks::on_is_center_hollow_changing(host);
changed = true;
}
host.set_value(
Self::id_of_is_center_hollow_property().base(),
ServerValueChange {
equal: old_value.default_equals(&value),
old_resource: None,
new_resource: None,
assign: &mut || self.is_center_hollow.set(value),
},
);
if changed {
ServerCompositionNineGridBrushHooks::on_is_center_hollow_changed(host);
}
}
pub fn deserialize_changes_core(
&self,
host: &dyn ServerCompositionNineGridBrushHooks,
reader: &mut BatchStreamReader<'_>,
committed_at: Duration,
) {
let compositor = host.server_compositor();
self.base.deserialize_changes_core(host, reader, committed_at);
ServerCompositionNineGridBrushHooks::deserialize_changes_extra(host, reader);
let changed = reader.read::<CompositionNineGridBrushChangedFields>();
if changed.contains(CompositionNineGridBrushChangedFields::SOURCE) {
let value = read_server_object(reader, compositor.as_ref());
self.set_source(host, value);
}
if changed.contains(CompositionNineGridBrushChangedFields::LEFT_INSET_ANIMATED) {
let Some(animation) = reader.read_value::<AnimationInstanceFactory>().map(AnimationInstanceFactory::create) else {
panic!("a batch starts an animation of `LeftInset` without an animation instance");
};
host.set_animated_value(
Self::id_of_left_inset_property().base(),
ExpressionVariant::create(self.left_inset.get()),
committed_at,
animation,
);
} else if changed.contains(CompositionNineGridBrushChangedFields::LEFT_INSET) {
let value = reader.read::<f32>();
self.set_left_inset(host, value);
}
if changed.contains(CompositionNineGridBrushChangedFields::TOP_INSET_ANIMATED) {
let Some(animation) = reader.read_value::<AnimationInstanceFactory>().map(AnimationInstanceFactory::create) else {
panic!("a batch starts an animation of `TopInset` without an animation instance");
};
host.set_animated_value(
Self::id_of_top_inset_property().base(),
ExpressionVariant::create(self.top_inset.get()),
committed_at,
animation,
);
} else if changed.contains(CompositionNineGridBrushChangedFields::TOP_INSET) {
let value = reader.read::<f32>();
self.set_top_inset(host, value);
}
if changed.contains(CompositionNineGridBrushChangedFields::RIGHT_INSET_ANIMATED) {
let Some(animation) = reader.read_value::<AnimationInstanceFactory>().map(AnimationInstanceFactory::create) else {
panic!("a batch starts an animation of `RightInset` without an animation instance");
};
host.set_animated_value(
Self::id_of_right_inset_property().base(),
ExpressionVariant::create(self.right_inset.get()),
committed_at,
animation,
);
} else if changed.contains(CompositionNineGridBrushChangedFields::RIGHT_INSET) {
let value = reader.read::<f32>();
self.set_right_inset(host, value);
}
if changed.contains(CompositionNineGridBrushChangedFields::BOTTOM_INSET_ANIMATED) {
let Some(animation) = reader.read_value::<AnimationInstanceFactory>().map(AnimationInstanceFactory::create) else {
panic!("a batch starts an animation of `BottomInset` without an animation instance");
};
host.set_animated_value(
Self::id_of_bottom_inset_property().base(),
ExpressionVariant::create(self.bottom_inset.get()),
committed_at,
animation,
);
} else if changed.contains(CompositionNineGridBrushChangedFields::BOTTOM_INSET) {
let value = reader.read::<f32>();
self.set_bottom_inset(host, value);
}
if changed.contains(CompositionNineGridBrushChangedFields::LEFT_INSET_SCALE_ANIMATED) {
let Some(animation) = reader.read_value::<AnimationInstanceFactory>().map(AnimationInstanceFactory::create) else {
panic!("a batch starts an animation of `LeftInsetScale` without an animation instance");
};
host.set_animated_value(
Self::id_of_left_inset_scale_property().base(),
ExpressionVariant::create(self.left_inset_scale.get()),
committed_at,
animation,
);
} else if changed.contains(CompositionNineGridBrushChangedFields::LEFT_INSET_SCALE) {
let value = reader.read::<f32>();
self.set_left_inset_scale(host, value);
}
if changed.contains(CompositionNineGridBrushChangedFields::TOP_INSET_SCALE_ANIMATED) {
let Some(animation) = reader.read_value::<AnimationInstanceFactory>().map(AnimationInstanceFactory::create) else {
panic!("a batch starts an animation of `TopInsetScale` without an animation instance");
};
host.set_animated_value(
Self::id_of_top_inset_scale_property().base(),
ExpressionVariant::create(self.top_inset_scale.get()),
committed_at,
animation,
);
} else if changed.contains(CompositionNineGridBrushChangedFields::TOP_INSET_SCALE) {
let value = reader.read::<f32>();
self.set_top_inset_scale(host, value);
}
if changed.contains(CompositionNineGridBrushChangedFields::RIGHT_INSET_SCALE_ANIMATED) {
let Some(animation) = reader.read_value::<AnimationInstanceFactory>().map(AnimationInstanceFactory::create) else {
panic!("a batch starts an animation of `RightInsetScale` without an animation instance");
};
host.set_animated_value(
Self::id_of_right_inset_scale_property().base(),
ExpressionVariant::create(self.right_inset_scale.get()),
committed_at,
animation,
);
} else if changed.contains(CompositionNineGridBrushChangedFields::RIGHT_INSET_SCALE) {
let value = reader.read::<f32>();
self.set_right_inset_scale(host, value);
}
if changed.contains(CompositionNineGridBrushChangedFields::BOTTOM_INSET_SCALE_ANIMATED) {
let Some(animation) = reader.read_value::<AnimationInstanceFactory>().map(AnimationInstanceFactory::create) else {
panic!("a batch starts an animation of `BottomInsetScale` without an animation instance");
};
host.set_animated_value(
Self::id_of_bottom_inset_scale_property().base(),
ExpressionVariant::create(self.bottom_inset_scale.get()),
committed_at,
animation,
);
} else if changed.contains(CompositionNineGridBrushChangedFields::BOTTOM_INSET_SCALE) {
let value = reader.read::<f32>();
self.set_bottom_inset_scale(host, value);
}
if changed.contains(CompositionNineGridBrushChangedFields::IS_CENTER_HOLLOW) {
let value = reader.read::<bool>();
self.set_is_center_hollow(host, value);
}
ServerCompositionNineGridBrushHooks::on_fields_deserialized(host, changed);
}
pub fn get_composition_property(name: &str) -> Option<&'static CompositionProperty> {
if name == "LeftInset" {
return Some(Self::id_of_left_inset_property().base());
}
if name == "TopInset" {
return Some(Self::id_of_top_inset_property().base());
}
if name == "RightInset" {
return Some(Self::id_of_right_inset_property().base());
}
if name == "BottomInset" {
return Some(Self::id_of_bottom_inset_property().base());
}
if name == "LeftInsetScale" {
return Some(Self::id_of_left_inset_scale_property().base());
}
if name == "TopInsetScale" {
return Some(Self::id_of_top_inset_scale_property().base());
}
if name == "RightInsetScale" {
return Some(Self::id_of_right_inset_scale_property().base());
}
if name == "BottomInsetScale" {
return Some(Self::id_of_bottom_inset_scale_property().base());
}
if name == "IsCenterHollow" {
return Some(Self::id_of_is_center_hollow_property().base());
}
ServerCompositionBrushProps::get_composition_property(name)
}
}