Skip to main content

ferroui_base/media/
platform_geometry.rs

1use crate::media::{Geometry, GeometryImpl};
2use crate::platform::IGeometryImpl;
3use crate::{ferro_class, ferro_impl_classes, instantiate, FerroObjectImpl, Ref};
4use std::sync::Arc;
5
6/// A geometry that wraps a platform implementation.
7#[repr(C)]
8pub struct PlatformGeometry {
9    base: Geometry,
10    geometry_impl: Arc<dyn IGeometryImpl>,
11}
12
13ferro_class!(PlatformGeometry: Geometry);
14ferro_impl_classes!(PlatformGeometry: FerroObjectImpl);
15
16impl GeometryImpl for PlatformGeometry {
17    fn clone_geometry(this: &Self) -> Ref<Geometry> {
18        PlatformGeometry::new(this.geometry_impl.clone()).upcast()
19    }
20
21    fn create_defining_geometry(this: &Self) -> Option<Arc<dyn IGeometryImpl>> {
22        Some(this.geometry_impl.clone())
23    }
24}
25
26impl PlatformGeometry {
27    pub fn new(geometry_impl: Arc<dyn IGeometryImpl>) -> Ref<Self> {
28        instantiate(Self { base: Geometry::construct(), geometry_impl })
29    }
30}