From df6701433e9f575b737be59dbff5b0115a7c2703 Mon Sep 17 00:00:00 2001 From: rhysd Date: Mon, 16 Oct 2023 00:06:37 +0900 Subject: [PATCH 1/3] feat(macOS): Add 'Bring All to Front' predefined menu item on macOS Signed-off-by: rhysd --- .changes/front-menu-item.md | 5 +++++ examples/tao.rs | 1 + examples/winit.rs | 1 + examples/wry.rs | 1 + src/items/predefined.rs | 11 +++++++++++ src/platform_impl/macos/mod.rs | 1 + 6 files changed, 20 insertions(+) create mode 100644 .changes/front-menu-item.md diff --git a/.changes/front-menu-item.md b/.changes/front-menu-item.md new file mode 100644 index 00000000..83ddcefd --- /dev/null +++ b/.changes/front-menu-item.md @@ -0,0 +1,5 @@ +--- +"muda": "patch" +--- + +Add `PredefinedMenuItem::front` for 'Bring All to Front' menu item on macOS. diff --git a/examples/tao.rs b/examples/tao.rs index 8153eedf..1a77c829 100644 --- a/examples/tao.rs +++ b/examples/tao.rs @@ -119,6 +119,7 @@ fn main() { &PredefinedMenuItem::maximize(None), &PredefinedMenuItem::close_window(Some("Close")), &PredefinedMenuItem::fullscreen(None), + &PredefinedMenuItem::front(None), &PredefinedMenuItem::about( None, Some(AboutMetadata { diff --git a/examples/winit.rs b/examples/winit.rs index b950066b..45967f10 100644 --- a/examples/winit.rs +++ b/examples/winit.rs @@ -109,6 +109,7 @@ fn main() { &PredefinedMenuItem::maximize(None), &PredefinedMenuItem::close_window(Some("Close")), &PredefinedMenuItem::fullscreen(None), + &PredefinedMenuItem::front(None), &PredefinedMenuItem::about( None, Some(AboutMetadata { diff --git a/examples/wry.rs b/examples/wry.rs index 635755cd..ff0cdd75 100644 --- a/examples/wry.rs +++ b/examples/wry.rs @@ -123,6 +123,7 @@ fn main() -> wry::Result<()> { &PredefinedMenuItem::maximize(None), &PredefinedMenuItem::close_window(Some("Close")), &PredefinedMenuItem::fullscreen(None), + &PredefinedMenuItem::front(None), &PredefinedMenuItem::about( None, Some(AboutMetadata { diff --git a/src/items/predefined.rs b/src/items/predefined.rs index 0574bcaf..ad0bae71 100644 --- a/src/items/predefined.rs +++ b/src/items/predefined.rs @@ -162,6 +162,15 @@ impl PredefinedMenuItem { PredefinedMenuItem::new(PredefinedMenuItemType::Services, text) } + /// 'Bring all windows in front' menu item + /// + /// ## Platform-specific: + /// + /// - **Windows / Linux:** Unsupported. + pub fn front(text: Option<&str>) -> PredefinedMenuItem { + PredefinedMenuItem::new(PredefinedMenuItemType::Front, text) + } + fn new>(item: PredefinedMenuItemType, text: Option) -> Self { let item = crate::platform_impl::MenuChild::new_predefined( item, @@ -250,6 +259,7 @@ pub(crate) enum PredefinedMenuItemType { Quit, About(Option), Services, + Front, None, } @@ -288,6 +298,7 @@ impl PredefinedMenuItemType { PredefinedMenuItemType::Quit => "&Quit", PredefinedMenuItemType::About(_) => "&About", PredefinedMenuItemType::Services => "Services", + PredefinedMenuItemType::Front => "Bring All to Front", PredefinedMenuItemType::None => "", } } diff --git a/src/platform_impl/macos/mod.rs b/src/platform_impl/macos/mod.rs index 44164b1d..eefb8a51 100644 --- a/src/platform_impl/macos/mod.rs +++ b/src/platform_impl/macos/mod.rs @@ -873,6 +873,7 @@ impl PredefinedMenuItemType { // manual implementation in `fire_menu_item_click` PredefinedMenuItemType::About(_) => Some(selector("fireMenuItemAction:")), PredefinedMenuItemType::Services => None, + PredefinedMenuItemType::Front => Some(selector("arrangeInFront:")), PredefinedMenuItemType::None => None, } } From dfb0f41e6797bd18a6939c9639062fabbfc828cf Mon Sep 17 00:00:00 2001 From: rhysd Date: Mon, 16 Oct 2023 23:48:17 +0900 Subject: [PATCH 2/3] Rename `front` to `bring_all_to_front` Signed-off-by: rhysd --- .changes/bring-all-to-front.md | 5 +++++ .changes/front-menu-item.md | 5 ----- src/items/predefined.rs | 10 +++++----- src/platform_impl/macos/mod.rs | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) create mode 100644 .changes/bring-all-to-front.md delete mode 100644 .changes/front-menu-item.md diff --git a/.changes/bring-all-to-front.md b/.changes/bring-all-to-front.md new file mode 100644 index 00000000..f3e1a4f3 --- /dev/null +++ b/.changes/bring-all-to-front.md @@ -0,0 +1,5 @@ +--- +"muda": "patch" +--- + +Add `PredefinedMenuItem::bring_all_to_front` for 'Bring All to Front' menu item on macOS. diff --git a/.changes/front-menu-item.md b/.changes/front-menu-item.md deleted file mode 100644 index 83ddcefd..00000000 --- a/.changes/front-menu-item.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"muda": "patch" ---- - -Add `PredefinedMenuItem::front` for 'Bring All to Front' menu item on macOS. diff --git a/src/items/predefined.rs b/src/items/predefined.rs index ad0bae71..8ed4a342 100644 --- a/src/items/predefined.rs +++ b/src/items/predefined.rs @@ -162,13 +162,13 @@ impl PredefinedMenuItem { PredefinedMenuItem::new(PredefinedMenuItemType::Services, text) } - /// 'Bring all windows in front' menu item + /// 'Bring all to front' menu item /// /// ## Platform-specific: /// /// - **Windows / Linux:** Unsupported. - pub fn front(text: Option<&str>) -> PredefinedMenuItem { - PredefinedMenuItem::new(PredefinedMenuItemType::Front, text) + pub fn bring_all_to_front(text: Option<&str>) -> PredefinedMenuItem { + PredefinedMenuItem::new(PredefinedMenuItemType::BringAllToFront, text) } fn new>(item: PredefinedMenuItemType, text: Option) -> Self { @@ -259,7 +259,7 @@ pub(crate) enum PredefinedMenuItemType { Quit, About(Option), Services, - Front, + BringAllToFront, None, } @@ -298,7 +298,7 @@ impl PredefinedMenuItemType { PredefinedMenuItemType::Quit => "&Quit", PredefinedMenuItemType::About(_) => "&About", PredefinedMenuItemType::Services => "Services", - PredefinedMenuItemType::Front => "Bring All to Front", + PredefinedMenuItemType::BringAllToFront => "Bring All to Front", PredefinedMenuItemType::None => "", } } diff --git a/src/platform_impl/macos/mod.rs b/src/platform_impl/macos/mod.rs index eefb8a51..7ea03a4b 100644 --- a/src/platform_impl/macos/mod.rs +++ b/src/platform_impl/macos/mod.rs @@ -873,7 +873,7 @@ impl PredefinedMenuItemType { // manual implementation in `fire_menu_item_click` PredefinedMenuItemType::About(_) => Some(selector("fireMenuItemAction:")), PredefinedMenuItemType::Services => None, - PredefinedMenuItemType::Front => Some(selector("arrangeInFront:")), + PredefinedMenuItemType::BringAllToFront => Some(selector("arrangeInFront:")), PredefinedMenuItemType::None => None, } } From 56403fc056049d3b675f32049447786a9801ed4b Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Mon, 16 Oct 2023 18:38:41 +0300 Subject: [PATCH 3/3] Apply suggestions from code review --- examples/tao.rs | 2 +- examples/winit.rs | 2 +- examples/wry.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/tao.rs b/examples/tao.rs index 1a77c829..c2d8e1bb 100644 --- a/examples/tao.rs +++ b/examples/tao.rs @@ -119,7 +119,7 @@ fn main() { &PredefinedMenuItem::maximize(None), &PredefinedMenuItem::close_window(Some("Close")), &PredefinedMenuItem::fullscreen(None), - &PredefinedMenuItem::front(None), + &PredefinedMenuItem::bring_all_to_front(None), &PredefinedMenuItem::about( None, Some(AboutMetadata { diff --git a/examples/winit.rs b/examples/winit.rs index 45967f10..702e891a 100644 --- a/examples/winit.rs +++ b/examples/winit.rs @@ -109,7 +109,7 @@ fn main() { &PredefinedMenuItem::maximize(None), &PredefinedMenuItem::close_window(Some("Close")), &PredefinedMenuItem::fullscreen(None), - &PredefinedMenuItem::front(None), + &PredefinedMenuItem::bring_all_to_front(None), &PredefinedMenuItem::about( None, Some(AboutMetadata { diff --git a/examples/wry.rs b/examples/wry.rs index ff0cdd75..7added7d 100644 --- a/examples/wry.rs +++ b/examples/wry.rs @@ -123,7 +123,7 @@ fn main() -> wry::Result<()> { &PredefinedMenuItem::maximize(None), &PredefinedMenuItem::close_window(Some("Close")), &PredefinedMenuItem::fullscreen(None), - &PredefinedMenuItem::front(None), + &PredefinedMenuItem::bring_all_to_front(None), &PredefinedMenuItem::about( None, Some(AboutMetadata {