Menu

Struct Menu 

Source
pub struct Menu<'a, 'b, T, Message, Theme = Theme, Renderer = Renderer>
where Theme: Catalog, Renderer: Renderer, 'b: 'a,
{ /* private fields */ }
Expand description

A list of selectable options.

Implementations§

Source§

impl<'a, 'b, T, Message, Theme, Renderer> Menu<'a, 'b, T, Message, Theme, Renderer>
where T: ToString + Clone, Message: 'a, Theme: Catalog + 'a, Renderer: Renderer + 'a, 'b: 'a,

Source

pub fn new( state: &'a mut State, options: &'a [T], hovered_option: &'a mut Option<usize>, on_selected: impl FnMut(T) -> Message + 'a, on_option_hovered: Option<&'a dyn Fn(T) -> Message>, class: &'a <Theme as Catalog>::Class<'b>, ) -> Self

Creates a new Menu with the given State, a list of options, the message to produced when an option is selected, and its Style.

Source

pub fn width(self, width: f32) -> Self

Sets the width of the Menu.

Source

pub fn padding<P: Into<Padding>>(self, padding: P) -> Self

Sets the Padding of the Menu.

Source

pub fn text_size(self, text_size: impl Into<Pixels>) -> Self

Sets the text size of the Menu.

Source

pub fn text_line_height(self, line_height: impl Into<LineHeight>) -> Self

Sets the text text::LineHeight of the Menu.

Source

pub fn text_shaping(self, shaping: Shaping) -> Self

Sets the text::Shaping strategy of the Menu.

Source

pub fn font(self, font: impl Into<Renderer::Font>) -> Self

Sets the font of the Menu.

Source

pub fn overlay( self, position: Point, viewport: Rectangle, target_height: f32, menu_height: Length, ) -> Element<'a, Message, Theme, Renderer>

Turns the Menu into an overlay Element at the given target position.

The target_height will be used to display the menu either on top of the target or under it, depending on the screen position and the dimensions of the Menu.

Auto Trait Implementations§

§

impl<'a, 'b, T, Message, Theme, Renderer> Freeze for Menu<'a, 'b, T, Message, Theme, Renderer>
where <Renderer as Renderer>::Font: Freeze,

§

impl<'a, 'b, T, Message, Theme = Theme, Renderer = Renderer> !RefUnwindSafe for Menu<'a, 'b, T, Message, Theme, Renderer>

§

impl<'a, 'b, T, Message, Theme = Theme, Renderer = Renderer> !Send for Menu<'a, 'b, T, Message, Theme, Renderer>

§

impl<'a, 'b, T, Message, Theme = Theme, Renderer = Renderer> !Sync for Menu<'a, 'b, T, Message, Theme, Renderer>

§

impl<'a, 'b, T, Message, Theme, Renderer> Unpin for Menu<'a, 'b, T, Message, Theme, Renderer>
where <Renderer as Renderer>::Font: Unpin,

§

impl<'a, 'b, T, Message, Theme = Theme, Renderer = Renderer> !UnwindSafe for Menu<'a, 'b, T, Message, Theme, Renderer>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.