ferroui_native/
mac_os_native_menu_commands.rs1use crate::helpers::ComResultExt;
2use crate::interop::*;
3use ferroui_base::{ferro_property, AttachedProperty, FerroProperty, StaticType, TypeInfo};
4use ferroui_controls::platform::INativeApplicationCommands;
5use ferroui_controls::NativeMenu;
6use ferroui_microcom::ComPtr;
7
8pub struct MacOSNativeMenuCommands {
10 commands: ComPtr<IFrnApplicationCommands>,
11}
12
13impl StaticType for MacOSNativeMenuCommands {
14 const TYPE: &'static TypeInfo = {
15 static TYPE: TypeInfo = TypeInfo::new("MacOSNativeMenuCommands", None);
16 &TYPE
17 };
18}
19
20impl MacOSNativeMenuCommands {
21 ferro_property!(
22 pub fn is_services_submenu_property() -> AttachedProperty<bool> {
25 FerroProperty::register_attached::<MacOSNativeMenuCommands, NativeMenu, _>("IsServicesSubmenu", false)
26 }
27 );
28
29 pub(crate) fn new(commands: ComPtr<IFrnApplicationCommands>) -> Self {
30 Self { commands }
31 }
32}
33
34impl INativeApplicationCommands for MacOSNativeMenuCommands {
35 fn show_app(&self) {
36 self.commands.unhide_app().check();
37 }
38
39 fn hide_app(&self) {
40 self.commands.hide_app().check();
41 }
42
43 fn show_all(&self) {
44 self.commands.show_all().check();
45 }
46
47 fn hide_others(&self) {
48 self.commands.hide_others().check();
49 }
50}