ferroui-base 0.3.0

The base library of FerroUI: the property system, layout, input, styling, media, text, animation, data binding and the compositor
Documentation
use crate::media::{Geometry, GeometryImpl};
use crate::platform::IGeometryImpl;
use crate::{ferro_class, ferro_impl_classes, instantiate, FerroObjectImpl, Ref};
use std::sync::Arc;

/// A geometry with a fixed platform implementation.
#[repr(C)]
pub struct ImmutableGeometry {
    base: Geometry,
}

ferro_class!(ImmutableGeometry: Geometry);
ferro_impl_classes!(ImmutableGeometry: FerroObjectImpl);

impl GeometryImpl for ImmutableGeometry {
    fn clone_geometry(this: &Self) -> Ref<Geometry> {
        ImmutableGeometry::new(this.platform_impl()).upcast()
    }

    fn create_defining_geometry(this: &Self) -> Option<Arc<dyn IGeometryImpl>> {
        this.platform_impl()
    }
}

impl ImmutableGeometry {
    pub fn new(platform_impl: Option<Arc<dyn IGeometryImpl>>) -> Ref<Self> {
        instantiate(Self { base: Geometry::construct_with_impl(platform_impl) })
    }
}