[][src]Struct druid::MenuDesc

pub struct MenuDesc<T> { /* fields omitted */ }

A platform-agnostic description of an application, window, or context menu.

Implementations

impl<T: Data> MenuDesc<T>[src]

pub fn empty() -> Self[src]

Create a new, empty menu.

pub fn new(title: LocalizedString<T>) -> Self[src]

Create a new menu with the given title.

pub fn platform_default() -> Option<MenuDesc<T>>[src]

If this platform always expects windows to have a menu by default, returns a menu. Otherwise returns None.

pub fn append_iter<I: Iterator<Item = MenuItem<T>>>(
    self,
    f: impl FnOnce() -> I
) -> Self
[src]

Given a function that produces an iterator, appends that iterator's items to this menu.

Examples

use druid::{Command, LocalizedString, MenuDesc, MenuItem, Selector};

let num_items: usize = 4;
const MENU_COUNT_ACTION: Selector<usize> = Selector::new("menu-count-action");

let my_menu: MenuDesc<u32> = MenuDesc::empty()
    .append_iter(|| (0..num_items).map(|i| {
        MenuItem::new(
            LocalizedString::new("hello-counter").with_arg("count", move |_, _| i.into()),
            Command::new(MENU_COUNT_ACTION, i),
       )
    })
);

assert_eq!(my_menu.len(), 4);

pub fn append(self, item: impl Into<MenuEntry<T>>) -> Self[src]

Append an item to this menu.

pub fn append_if(
    self,
    item: impl Into<MenuEntry<T>>,
    p: impl FnMut() -> bool
) -> Self
[src]

Append an item to this menu if the predicate is matched.

pub fn append_separator(self) -> Self[src]

Append a separator.

pub fn len(&self) -> usize[src]

The number of items in the menu.

pub fn is_empty(&self) -> bool[src]

Returns true if the menu contains no items.

Trait Implementations

impl<T: Clone> Clone for MenuDesc<T>[src]

impl<T> Debug for MenuDesc<T>[src]

Auto Trait Implementations

impl<T> !RefUnwindSafe for MenuDesc<T>

impl<T> !Send for MenuDesc<T>

impl<T> !Sync for MenuDesc<T>

impl<T> Unpin for MenuDesc<T>

impl<T> !UnwindSafe for MenuDesc<T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> RoundFrom<T> for T

impl<T, U> RoundInto<U> for T where
    U: RoundFrom<T>, 

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.