ferroui_controls/shapes/
path.rs1use super::{Shape, ShapeImpl};
2use crate::ControlImpl;
3use ferroui_base::input::InputElementImpl;
4use ferroui_base::interactivity::InteractiveImpl;
5use ferroui_base::layout::LayoutableImpl;
6use ferroui_base::media::Geometry;
7use ferroui_base::{
8 ferro_class, ferro_impl_classes, ferro_property, instantiate, FerroObjectImpl, FerroProperty,
9 Nullable, Ref, StyledElementImpl, StyledProperty, VisualImpl,
10};
11
12#[repr(C)]
14pub struct Path {
15 base: Shape,
16}
17
18ferro_class!(Path: Shape);
19ferroui_base::ferro_class_info!(Path { new: Path::new });
20ferro_impl_classes!(
21 Path: StyledElementImpl,
22 VisualImpl,
23 LayoutableImpl,
24 InteractiveImpl,
25 InputElementImpl,
26 ControlImpl
27);
28
29ferroui_base::ferro_impl_classes!(Path: FerroObjectImpl);
30
31impl ShapeImpl for Path {
32 fn create_defining_geometry(this: &Self) -> Option<Ref<Geometry>> {
33 this.data()
34 }
35}
36
37ferroui_base::ferro_properties! { impl Path {
38 ferro_property!(
39 pub fn data_property() -> StyledProperty<Option<Ref<Geometry>>> {
41 FerroProperty::register::<Path, _>("Data", None)
42 }
43 );
44} }
45
46impl Path {
47 fn static_constructor() {
48 Shape::affects_geometry::<Path>(&[Self::data_property().as_property()]);
49 }
50
51 pub fn construct() -> Self {
53 Self { base: Shape::construct() }
54 }
55
56 pub fn new() -> Ref<Self> {
57 instantiate(Self::construct())
58 }
59
60 pub fn data(&self) -> Option<Ref<Geometry>> {
62 self.get_value(Self::data_property())
63 }
64
65 pub fn set_data(&self, value: impl Into<Nullable<Geometry>>) {
66 self.set_value(Self::data_property(), value.into().0)
67 }
68}