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,
|
SetMenuItemInfoW, ShowWindow, TrackPopupMenu, HACCEL, HMENU, MB_ICONINFORMATION,
|
||||||
MENUITEMINFOW, MFS_CHECKED, MFS_DISABLED, MF_BYCOMMAND, MF_BYPOSITION, MF_CHECKED,
|
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,
|
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,
|
MIIM_BITMAP, MIIM_STATE, MIIM_STRING, SW_HIDE, SW_MAXIMIZE, SW_MINIMIZE, TPM_LEFTALIGN,
|
||||||
WM_DESTROY,
|
WM_COMMAND, WM_DESTROY,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -1099,6 +1099,12 @@ unsafe extern "system" fn menu_subclass_proc(
|
||||||
PredfinedMenuItemType::Minimize => {
|
PredfinedMenuItemType::Minimize => {
|
||||||
ShowWindow(hwnd, SW_MINIMIZE);
|
ShowWindow(hwnd, SW_MINIMIZE);
|
||||||
}
|
}
|
||||||
|
PredfinedMenuItemType::Maximize => {
|
||||||
|
ShowWindow(hwnd, SW_MAXIMIZE);
|
||||||
|
}
|
||||||
|
PredfinedMenuItemType::Hide => {
|
||||||
|
ShowWindow(hwnd, SW_HIDE);
|
||||||
|
}
|
||||||
PredfinedMenuItemType::CloseWindow => {
|
PredfinedMenuItemType::CloseWindow => {
|
||||||
DestroyWindow(hwnd);
|
DestroyWindow(hwnd);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,73 +27,134 @@ unsafe impl MenuItemExt for PredefinedMenuItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PredefinedMenuItem {
|
impl PredefinedMenuItem {
|
||||||
|
/// Separator menu item
|
||||||
pub fn separator() -> PredefinedMenuItem {
|
pub fn separator() -> PredefinedMenuItem {
|
||||||
PredefinedMenuItem::new::<&str>(PredfinedMenuItemType::Separator, None)
|
PredefinedMenuItem::new::<&str>(PredfinedMenuItemType::Separator, None)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Copy menu item
|
||||||
pub fn copy(text: Option<&str>) -> PredefinedMenuItem {
|
pub fn copy(text: Option<&str>) -> PredefinedMenuItem {
|
||||||
PredefinedMenuItem::new(PredfinedMenuItemType::Copy, text)
|
PredefinedMenuItem::new(PredfinedMenuItemType::Copy, text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Cut menu item
|
||||||
pub fn cut(text: Option<&str>) -> PredefinedMenuItem {
|
pub fn cut(text: Option<&str>) -> PredefinedMenuItem {
|
||||||
PredefinedMenuItem::new(PredfinedMenuItemType::Cut, text)
|
PredefinedMenuItem::new(PredfinedMenuItemType::Cut, text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Paste menu item
|
||||||
pub fn paste(text: Option<&str>) -> PredefinedMenuItem {
|
pub fn paste(text: Option<&str>) -> PredefinedMenuItem {
|
||||||
PredefinedMenuItem::new(PredfinedMenuItemType::Paste, text)
|
PredefinedMenuItem::new(PredfinedMenuItemType::Paste, text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// SelectAll menu item
|
||||||
pub fn select_all(text: Option<&str>) -> PredefinedMenuItem {
|
pub fn select_all(text: Option<&str>) -> PredefinedMenuItem {
|
||||||
PredefinedMenuItem::new(PredfinedMenuItemType::SelectAll, text)
|
PredefinedMenuItem::new(PredfinedMenuItemType::SelectAll, text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Undo menu item
|
||||||
|
///
|
||||||
|
/// ## Platform-specific:
|
||||||
|
///
|
||||||
|
/// - **Windows / Linux:** Unsupported.
|
||||||
pub fn undo(text: Option<&str>) -> PredefinedMenuItem {
|
pub fn undo(text: Option<&str>) -> PredefinedMenuItem {
|
||||||
PredefinedMenuItem::new(PredfinedMenuItemType::Undo, text)
|
PredefinedMenuItem::new(PredfinedMenuItemType::Undo, text)
|
||||||
}
|
}
|
||||||
|
/// Redo menu item
|
||||||
|
///
|
||||||
|
/// ## Platform-specific:
|
||||||
|
///
|
||||||
|
/// - **Windows / Linux:** Unsupported.
|
||||||
pub fn redo(text: Option<&str>) -> PredefinedMenuItem {
|
pub fn redo(text: Option<&str>) -> PredefinedMenuItem {
|
||||||
PredefinedMenuItem::new(PredfinedMenuItemType::Redo, text)
|
PredefinedMenuItem::new(PredfinedMenuItemType::Redo, text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Minimize window menu item
|
||||||
|
///
|
||||||
|
/// ## Platform-specific:
|
||||||
|
///
|
||||||
|
/// - **Linux:** Unsupported.
|
||||||
pub fn minimize(text: Option<&str>) -> PredefinedMenuItem {
|
pub fn minimize(text: Option<&str>) -> PredefinedMenuItem {
|
||||||
PredefinedMenuItem::new(PredfinedMenuItemType::Minimize, text)
|
PredefinedMenuItem::new(PredfinedMenuItemType::Minimize, text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Maximize window menu item
|
||||||
|
///
|
||||||
|
/// ## Platform-specific:
|
||||||
|
///
|
||||||
|
/// - **Linux:** Unsupported.
|
||||||
pub fn maximize(text: Option<&str>) -> PredefinedMenuItem {
|
pub fn maximize(text: Option<&str>) -> PredefinedMenuItem {
|
||||||
PredefinedMenuItem::new(PredfinedMenuItemType::Maximize, text)
|
PredefinedMenuItem::new(PredfinedMenuItemType::Maximize, text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Fullscreen menu item
|
||||||
|
///
|
||||||
|
/// ## Platform-specific:
|
||||||
|
///
|
||||||
|
/// - **Windows / Linux:** Unsupported.
|
||||||
pub fn fullscreen(text: Option<&str>) -> PredefinedMenuItem {
|
pub fn fullscreen(text: Option<&str>) -> PredefinedMenuItem {
|
||||||
PredefinedMenuItem::new(PredfinedMenuItemType::Fullscreen, text)
|
PredefinedMenuItem::new(PredfinedMenuItemType::Fullscreen, text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Hide window menu item
|
||||||
|
///
|
||||||
|
/// ## Platform-specific:
|
||||||
|
///
|
||||||
|
/// - **Linux:** Unsupported.
|
||||||
pub fn hide(text: Option<&str>) -> PredefinedMenuItem {
|
pub fn hide(text: Option<&str>) -> PredefinedMenuItem {
|
||||||
PredefinedMenuItem::new(PredfinedMenuItemType::Hide, text)
|
PredefinedMenuItem::new(PredfinedMenuItemType::Hide, text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Hide other windows menu item
|
||||||
|
///
|
||||||
|
/// ## Platform-specific:
|
||||||
|
///
|
||||||
|
/// - **Linux:** Unsupported.
|
||||||
pub fn hide_others(text: Option<&str>) -> PredefinedMenuItem {
|
pub fn hide_others(text: Option<&str>) -> PredefinedMenuItem {
|
||||||
PredefinedMenuItem::new(PredfinedMenuItemType::HideOthers, text)
|
PredefinedMenuItem::new(PredfinedMenuItemType::HideOthers, text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Show all app windows menu item
|
||||||
|
///
|
||||||
|
/// ## Platform-specific:
|
||||||
|
///
|
||||||
|
/// - **Windows / Linux:** Unsupported.
|
||||||
pub fn show_all(text: Option<&str>) -> PredefinedMenuItem {
|
pub fn show_all(text: Option<&str>) -> PredefinedMenuItem {
|
||||||
PredefinedMenuItem::new(PredfinedMenuItemType::ShowAll, text)
|
PredefinedMenuItem::new(PredfinedMenuItemType::ShowAll, text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Close window menu item
|
||||||
|
///
|
||||||
|
/// ## Platform-specific:
|
||||||
|
///
|
||||||
|
/// - **Linux:** Unsupported.
|
||||||
pub fn close_window(text: Option<&str>) -> PredefinedMenuItem {
|
pub fn close_window(text: Option<&str>) -> PredefinedMenuItem {
|
||||||
PredefinedMenuItem::new(PredfinedMenuItemType::CloseWindow, text)
|
PredefinedMenuItem::new(PredfinedMenuItemType::CloseWindow, text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Quit app menu item
|
||||||
|
///
|
||||||
|
/// ## Platform-specific:
|
||||||
|
///
|
||||||
|
/// - **Linux:** Unsupported.
|
||||||
pub fn quit(text: Option<&str>) -> PredefinedMenuItem {
|
pub fn quit(text: Option<&str>) -> PredefinedMenuItem {
|
||||||
PredefinedMenuItem::new(PredfinedMenuItemType::Quit, text)
|
PredefinedMenuItem::new(PredfinedMenuItemType::Quit, text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// About app menu item
|
||||||
pub fn about(text: Option<&str>, metadata: Option<AboutMetadata>) -> PredefinedMenuItem {
|
pub fn about(text: Option<&str>, metadata: Option<AboutMetadata>) -> PredefinedMenuItem {
|
||||||
PredefinedMenuItem::new(PredfinedMenuItemType::About(metadata), text)
|
PredefinedMenuItem::new(PredfinedMenuItemType::About(metadata), text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Services menu item
|
||||||
|
///
|
||||||
|
/// ## Platform-specific:
|
||||||
|
///
|
||||||
|
/// - **Windows / Linux:** Unsupported.
|
||||||
pub fn services(text: Option<&str>) -> PredefinedMenuItem {
|
pub fn services(text: Option<&str>) -> PredefinedMenuItem {
|
||||||
PredefinedMenuItem::new(PredfinedMenuItemType::Services, text)
|
PredefinedMenuItem::new(PredfinedMenuItemType::Services, text)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new<S: AsRef<str>>(item: PredfinedMenuItemType, text: Option<S>) -> Self {
|
fn new<S: AsRef<str>>(item: PredfinedMenuItemType, text: Option<S>) -> Self {
|
||||||
Self(crate::platform_impl::PredefinedMenuItem::new(
|
Self(crate::platform_impl::PredefinedMenuItem::new(
|
||||||
item,
|
item,
|
||||||
|
@ -184,9 +245,9 @@ impl PredfinedMenuItemType {
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
PredfinedMenuItemType::Maximize => "Zoom",
|
PredfinedMenuItemType::Maximize => "Zoom",
|
||||||
#[cfg(not(target_os = "macos"))]
|
#[cfg(not(target_os = "macos"))]
|
||||||
PredfinedMenuItemType::Maximize => "Maximize",
|
PredfinedMenuItemType::Maximize => "Ma&ximize",
|
||||||
PredfinedMenuItemType::Fullscreen => "Toggle Full Screen",
|
PredfinedMenuItemType::Fullscreen => "Toggle Full Screen",
|
||||||
PredfinedMenuItemType::Hide => "Hide",
|
PredfinedMenuItemType::Hide => "&Hide",
|
||||||
PredfinedMenuItemType::HideOthers => "Hide Others",
|
PredfinedMenuItemType::HideOthers => "Hide Others",
|
||||||
PredfinedMenuItemType::ShowAll => "Show All",
|
PredfinedMenuItemType::ShowAll => "Show All",
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
|
|
Loading…
Reference in a new issue