Skip to main content

ferroui_controls/split_view/
split_view_template_settings.rs

1use crate::GridLength;
2use ferroui_base::{
3    ferro_class, ferro_class_info, ferro_properties, instantiate, FerroObject, FerroObjectImpl, FerroProperty, Ref,
4    StyledProperty,
5};
6
7/// Provides calculated values for use with the control theme or template of
8/// the [`SplitView`](crate::SplitView).
9///
10/// This class is NOT intended for general use outside of control templates.
11#[repr(C)]
12pub struct SplitViewTemplateSettings {
13    base: FerroObject,
14}
15
16ferro_class!(SplitViewTemplateSettings: FerroObject);
17// The constructor is internal upstream: no default constructor is declared.
18ferro_class_info!(SplitViewTemplateSettings {});
19
20ferroui_base::ferro_impl_classes!(SplitViewTemplateSettings: FerroObjectImpl);
21
22ferro_properties! {
23    impl SplitViewTemplateSettings {
24        /// Defines the `ClosedPaneWidth` property.
25        pub fn closed_pane_width_property() -> StyledProperty<f64> {
26            FerroProperty::register::<SplitViewTemplateSettings, _>("ClosedPaneWidth", 0.0)
27        }
28
29        /// Defines the `PaneColumnGridLength` property.
30        pub fn pane_column_grid_length_property() -> StyledProperty<GridLength> {
31            FerroProperty::register::<SplitViewTemplateSettings, _>("PaneColumnGridLength", GridLength::default())
32        }
33
34        /// Defines the `ClosedPaneHeight` property.
35        pub fn closed_pane_height_property() -> StyledProperty<f64> {
36            FerroProperty::register::<SplitViewTemplateSettings, _>("ClosedPaneHeight", 0.0)
37        }
38
39        /// Defines the `PaneRowGridLength` property.
40        pub fn pane_row_grid_length_property() -> StyledProperty<GridLength> {
41            FerroProperty::register::<SplitViewTemplateSettings, _>("PaneRowGridLength", GridLength::default())
42        }
43    }
44}
45
46impl SplitViewTemplateSettings {
47    /// Creates the settings. Only the split view creates them.
48    pub(crate) fn new() -> Ref<Self> {
49        instantiate(Self { base: FerroObject::construct() })
50    }
51
52    /// The width of the pane when it is closed.
53    pub fn closed_pane_width(&self) -> f64 {
54        self.get_value(Self::closed_pane_width_property())
55    }
56
57    pub(crate) fn set_closed_pane_width(&self, value: f64) {
58        self.set_value(Self::closed_pane_width_property(), value)
59    }
60
61    /// The length of the grid column of the pane.
62    pub fn pane_column_grid_length(&self) -> GridLength {
63        self.get_value(Self::pane_column_grid_length_property())
64    }
65
66    pub(crate) fn set_pane_column_grid_length(&self, value: GridLength) {
67        self.set_value(Self::pane_column_grid_length_property(), value)
68    }
69
70    /// The height of the pane when it is closed.
71    pub fn closed_pane_height(&self) -> f64 {
72        self.get_value(Self::closed_pane_height_property())
73    }
74
75    pub(crate) fn set_closed_pane_height(&self, value: f64) {
76        self.set_value(Self::closed_pane_height_property(), value)
77    }
78
79    /// The length of the grid row of the pane.
80    pub fn pane_row_grid_length(&self) -> GridLength {
81        self.get_value(Self::pane_row_grid_length_property())
82    }
83
84    pub(crate) fn set_pane_row_grid_length(&self, value: GridLength) {
85        self.set_value(Self::pane_row_grid_length_property(), value)
86    }
87}