[−][src]Struct prototty_common::MenuInstance
An instance of a menu, with a selected entry.
When a MenuInstance
is rendered, the
currently-selected entry is rendered using
the Menu
's selected_info
.
Methods
impl<T: Copy> MenuInstance<T>
[src]
pub fn new(menu: Menu<T>) -> Option<Self>
[src]
Create a new MenuInstance
with the first entry selected.
Returns None
if the Menu
has 0 elements.
pub fn with_index(menu: Menu<T>, index: usize) -> Option<Self>
[src]
Create a new MenuInstance
with the given index selected.
Returns None
if index >= menu.entries.len()
.
pub fn menu(&self) -> &Menu<T>
[src]
Returns a reference to the internal menu
pub fn into_menu(self) -> Menu<T>
[src]
Consumes the instance, returning its menu
pub fn index(&self) -> usize
[src]
Returns the current index
pub fn set_index(&mut self, index: usize)
[src]
Sets the index, if the specified index < menu.entries.len()
pub fn up(&mut self)
[src]
Select the entry above the current selection, unless the first entry is currently selected.
pub fn down(&mut self)
[src]
Select the entry below the current selection, unless the last entry is currently selected.
pub fn selected(&self) -> T
[src]
Returns a copy of the currently selected entry's value.
pub fn tick<I>(&mut self, inputs: I) -> Option<MenuOutput<T>> where
I: IntoIterator<Item = Input>,
[src]
I: IntoIterator<Item = Input>,
Feed input into the menu instance, possibly changing the selected entry, cancelling the menu, attempting to exit the program, or finalising the selection.
pub fn tick_with_mouse<'a, I, M>(
&mut self,
inputs: I,
view: &'a M
) -> Option<MenuOutput<T>> where
I: IntoIterator<Item = Input>,
M: MenuIndexFromScreenCoord,
[src]
&mut self,
inputs: I,
view: &'a M
) -> Option<MenuOutput<T>> where
I: IntoIterator<Item = Input>,
M: MenuIndexFromScreenCoord,
Trait Implementations
impl<T: Clone + Copy> Clone for MenuInstance<T>
[src]
fn clone(&self) -> MenuInstance<T>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T: Debug + Copy> Debug for MenuInstance<T>
[src]
impl<T: Copy> View<MenuInstance<T>> for DefaultMenuInstanceView
[src]
fn view<G: ViewGrid>(
&mut self,
value: &MenuInstance<T>,
offset: Coord,
depth: i32,
grid: &mut G
)
[src]
&mut self,
value: &MenuInstance<T>,
offset: Coord,
depth: i32,
grid: &mut G
)
impl<T: Copy> ViewSize<MenuInstance<T>> for DefaultMenuInstanceView
[src]
fn size(&mut self, data: &MenuInstance<T>) -> Size
[src]
Auto Trait Implementations
impl<T> Send for MenuInstance<T> where
T: Send,
T: Send,
impl<T> Sync for MenuInstance<T> where
T: Sync,
T: Sync,
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,