use super::composition_object_impls::composition_object_impls;
use super::generated::{CompositionViewBoxHooks, CompositionViewBoxProps, ServerCompositionViewBoxProps};
use super::server::{ServerCompositionViewBox, ServerObjectId};
use super::{CompositionObject, CompositionStretch, Compositor};
use crate::Vector;
use std::rc::{Rc, Weak};
pub struct CompositionViewBox {
this: Weak<CompositionViewBox>,
object: CompositionObject,
props: CompositionViewBoxProps,
}
impl CompositionViewBox {
pub(crate) fn new(compositor: &Rc<Compositor>) -> Rc<CompositionViewBox> {
let server = compositor.create_server_object(|compositor, _| ServerCompositionViewBox::new(compositor));
let view_box = Rc::new_cyclic(|this: &Weak<CompositionViewBox>| CompositionViewBox {
this: this.clone(),
object: CompositionObject::new(compositor, Some(server)),
props: CompositionViewBoxProps::new(),
});
view_box.props.initialize_defaults(&*view_box);
view_box
}
pub fn compositor(&self) -> &Rc<Compositor> {
self.object.compositor()
}
pub fn object(&self) -> &CompositionObject {
&self.object
}
pub fn server(&self) -> ServerObjectId {
self.object.required_server()
}
pub fn is_disposed(&self) -> bool {
self.object.is_disposed()
}
pub fn dispose(&self) {
self.object.dispose();
}
pub fn props(&self) -> &CompositionViewBoxProps {
&self.props
}
pub fn horizontal_alignment_ratio(&self) -> f32 {
self.props.horizontal_alignment_ratio()
}
pub fn set_horizontal_alignment_ratio(&self, value: f32) {
self.props.set_horizontal_alignment_ratio(self, value)
}
pub fn offset(&self) -> Vector {
self.props.offset()
}
pub fn set_offset(&self, value: Vector) {
self.props.set_offset(self, value)
}
pub fn size(&self) -> Vector {
self.props.size()
}
pub fn set_size(&self, value: Vector) {
self.props.set_size(self, value)
}
pub fn stretch(&self) -> CompositionStretch {
self.props.stretch()
}
pub fn set_stretch(&self, value: CompositionStretch) {
self.props.set_stretch(self, value)
}
pub fn vertical_alignment_ratio(&self) -> f32 {
self.props.vertical_alignment_ratio()
}
pub fn set_vertical_alignment_ratio(&self, value: f32) {
self.props.set_vertical_alignment_ratio(self, value)
}
}
impl CompositionViewBoxHooks for CompositionViewBox {}
composition_object_impls!(
CompositionViewBox, "CompositionViewBox",
serialize: |this, writer| this.props.serialize_changes_core(this, writer),
start_animation: |this, name, animation, final_value| this.props.start_animation(this, name, animation, final_value),
composition_property: |_this, name| ServerCompositionViewBoxProps::get_composition_property(name),
);