mirror of
https://github.com/italicsjenga/muda.git
synced 2025-01-11 04:11:32 +11:00
docs: add docs for PredefinedMenuItem
(#51)
This commit is contained in:
parent
74801f238a
commit
d2bd85bf7e
5
.changes/maximize-hide.md
Normal file
5
.changes/maximize-hide.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"muda": "patch"
|
||||
---
|
||||
|
||||
Implement `PredefinedMenuItemm::maximize` and `PredefinedMenuItemm::hide` on Windows.
|
5
.changes/predefined-menu-item-docs.md
Normal file
5
.changes/predefined-menu-item-docs.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"muda": "patch"
|
||||
---
|
||||
|
||||
Add docs for predefined menu items
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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<AboutMetadata>) -> 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<S: AsRef<str>>(item: PredfinedMenuItemType, text: Option<S>) -> 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)]
|
||||
|
|
Loading…
Reference in a new issue