Skip to main content

ferroui_controls/
native_dock.rs

1use crate::NativeMenu;
2use ferroui_base::{ferro_properties, ferro_static_type, AttachedProperty, FerroObject, FerroProperty, Ref};
3
4/// Allows native menu support on platforms where a [`NativeMenu`] can be
5/// attached to the dock.
6pub struct NativeDock;
7
8ferro_static_type!(NativeDock);
9
10ferro_properties! {
11    impl NativeDock {
12        /// Defines the Menu attached property.
13        pub fn menu_property() -> AttachedProperty<Option<Ref<NativeMenu>>> {
14            FerroProperty::register_attached::<NativeDock, FerroObject, _>("Menu", None)
15        }
16    }
17}
18
19impl NativeDock {
20    /// Sets the value of the attached [`menu_property`](Self::menu_property).
21    pub fn set_menu(o: &FerroObject, menu: Option<Ref<NativeMenu>>) {
22        o.set_value(Self::menu_property(), menu)
23    }
24
25    /// Gets the value of the attached [`menu_property`](Self::menu_property).
26    pub fn get_menu(o: &FerroObject) -> Option<Ref<NativeMenu>> {
27        o.get_value(Self::menu_property())
28    }
29}