diff --git a/.changes/maximize-hide.md b/.changes/maximize-hide.md new file mode 100644 index 0000000..14ea545 --- /dev/null +++ b/.changes/maximize-hide.md @@ -0,0 +1,5 @@ +--- +"muda": "patch" +--- + +Implement `PredefinedMenuItemm::maximize` and `PredefinedMenuItemm::hide` on Windows. diff --git a/.changes/predefined-menu-item-docs.md b/.changes/predefined-menu-item-docs.md new file mode 100644 index 0000000..9fb3bfa --- /dev/null +++ b/.changes/predefined-menu-item-docs.md @@ -0,0 +1,5 @@ +--- +"muda": "patch" +--- + +Add docs for predefined menu items diff --git a/src/platform_impl/windows/mod.rs b/src/platform_impl/windows/mod.rs index 2323c3a..b5f1126 100644 --- a/src/platform_impl/windows/mod.rs +++ b/src/platform_impl/windows/mod.rs @@ -30,8 +30,8 @@ use windows_sys::Win32::{ SetMenuItemInfoW, ShowWindow, TrackPopupMenu, HACCEL, HMENU, MB_ICONINFORMATION, MENUITEMINFOW, MFS_CHECKED, MFS_DISABLED, MF_BYCOMMAND, MF_BYPOSITION, MF_CHECKED, MF_DISABLED, MF_ENABLED, MF_GRAYED, MF_POPUP, MF_SEPARATOR, MF_STRING, MF_UNCHECKED, - MIIM_BITMAP, MIIM_STATE, MIIM_STRING, SW_MINIMIZE, TPM_LEFTALIGN, WM_COMMAND, - WM_DESTROY, + MIIM_BITMAP, MIIM_STATE, MIIM_STRING, SW_HIDE, SW_MAXIMIZE, SW_MINIMIZE, TPM_LEFTALIGN, + WM_COMMAND, WM_DESTROY, }, }, }; @@ -1099,6 +1099,12 @@ unsafe extern "system" fn menu_subclass_proc( PredfinedMenuItemType::Minimize => { ShowWindow(hwnd, SW_MINIMIZE); } + PredfinedMenuItemType::Maximize => { + ShowWindow(hwnd, SW_MAXIMIZE); + } + PredfinedMenuItemType::Hide => { + ShowWindow(hwnd, SW_HIDE); + } PredfinedMenuItemType::CloseWindow => { DestroyWindow(hwnd); } diff --git a/src/predefined.rs b/src/predefined.rs index 6370ce8..60e8152 100644 --- a/src/predefined.rs +++ b/src/predefined.rs @@ -27,73 +27,134 @@ unsafe impl MenuItemExt for PredefinedMenuItem { } impl PredefinedMenuItem { + /// Separator menu item pub fn separator() -> PredefinedMenuItem { PredefinedMenuItem::new::<&str>(PredfinedMenuItemType::Separator, None) } + /// Copy menu item pub fn copy(text: Option<&str>) -> PredefinedMenuItem { PredefinedMenuItem::new(PredfinedMenuItemType::Copy, text) } + /// Cut menu item pub fn cut(text: Option<&str>) -> PredefinedMenuItem { PredefinedMenuItem::new(PredfinedMenuItemType::Cut, text) } + /// Paste menu item pub fn paste(text: Option<&str>) -> PredefinedMenuItem { PredefinedMenuItem::new(PredfinedMenuItemType::Paste, text) } + /// SelectAll menu item pub fn select_all(text: Option<&str>) -> PredefinedMenuItem { PredefinedMenuItem::new(PredfinedMenuItemType::SelectAll, text) } + /// Undo menu item + /// + /// ## Platform-specific: + /// + /// - **Windows / Linux:** Unsupported. pub fn undo(text: Option<&str>) -> PredefinedMenuItem { PredefinedMenuItem::new(PredfinedMenuItemType::Undo, text) } - + /// Redo menu item + /// + /// ## Platform-specific: + /// + /// - **Windows / Linux:** Unsupported. pub fn redo(text: Option<&str>) -> PredefinedMenuItem { PredefinedMenuItem::new(PredfinedMenuItemType::Redo, text) } + /// Minimize window menu item + /// + /// ## Platform-specific: + /// + /// - **Linux:** Unsupported. pub fn minimize(text: Option<&str>) -> PredefinedMenuItem { PredefinedMenuItem::new(PredfinedMenuItemType::Minimize, text) } + /// Maximize window menu item + /// + /// ## Platform-specific: + /// + /// - **Linux:** Unsupported. pub fn maximize(text: Option<&str>) -> PredefinedMenuItem { PredefinedMenuItem::new(PredfinedMenuItemType::Maximize, text) } + /// Fullscreen menu item + /// + /// ## Platform-specific: + /// + /// - **Windows / Linux:** Unsupported. pub fn fullscreen(text: Option<&str>) -> PredefinedMenuItem { PredefinedMenuItem::new(PredfinedMenuItemType::Fullscreen, text) } + /// Hide window menu item + /// + /// ## Platform-specific: + /// + /// - **Linux:** Unsupported. pub fn hide(text: Option<&str>) -> PredefinedMenuItem { PredefinedMenuItem::new(PredfinedMenuItemType::Hide, text) } + /// Hide other windows menu item + /// + /// ## Platform-specific: + /// + /// - **Linux:** Unsupported. pub fn hide_others(text: Option<&str>) -> PredefinedMenuItem { PredefinedMenuItem::new(PredfinedMenuItemType::HideOthers, text) } + /// Show all app windows menu item + /// + /// ## Platform-specific: + /// + /// - **Windows / Linux:** Unsupported. pub fn show_all(text: Option<&str>) -> PredefinedMenuItem { PredefinedMenuItem::new(PredfinedMenuItemType::ShowAll, text) } + /// Close window menu item + /// + /// ## Platform-specific: + /// + /// - **Linux:** Unsupported. pub fn close_window(text: Option<&str>) -> PredefinedMenuItem { PredefinedMenuItem::new(PredfinedMenuItemType::CloseWindow, text) } + /// Quit app menu item + /// + /// ## Platform-specific: + /// + /// - **Linux:** Unsupported. pub fn quit(text: Option<&str>) -> PredefinedMenuItem { PredefinedMenuItem::new(PredfinedMenuItemType::Quit, text) } + /// About app menu item pub fn about(text: Option<&str>, metadata: Option) -> PredefinedMenuItem { PredefinedMenuItem::new(PredfinedMenuItemType::About(metadata), text) } + /// Services menu item + /// + /// ## Platform-specific: + /// + /// - **Windows / Linux:** Unsupported. pub fn services(text: Option<&str>) -> PredefinedMenuItem { PredefinedMenuItem::new(PredfinedMenuItemType::Services, text) } + fn new>(item: PredfinedMenuItemType, text: Option) -> Self { Self(crate::platform_impl::PredefinedMenuItem::new( item, @@ -184,9 +245,9 @@ impl PredfinedMenuItemType { #[cfg(target_os = "macos")] PredfinedMenuItemType::Maximize => "Zoom", #[cfg(not(target_os = "macos"))] - PredfinedMenuItemType::Maximize => "Maximize", + PredfinedMenuItemType::Maximize => "Ma&ximize", PredfinedMenuItemType::Fullscreen => "Toggle Full Screen", - PredfinedMenuItemType::Hide => "Hide", + PredfinedMenuItemType::Hide => "&Hide", PredfinedMenuItemType::HideOthers => "Hide Others", PredfinedMenuItemType::ShowAll => "Show All", #[cfg(windows)]