Struct prototty_elements::menu::MenuInstance
[−]
[src]
pub struct MenuInstance<T: Copy> { /* fields omitted */ }
An instance of a menu, with a selected entry.
A MenuInstance
can be run using a MenuRunner
,
and a selection finalised. When a MenuInstance
is rendered, the currently-selected entry is
rendered using the Menu
's selected_info
.
Methods
impl<T: Copy> MenuInstance<T>
[src]
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.
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()
.
fn index(&self) -> usize
[src]
Returns the current index
fn set_index(&mut self, index: usize)
[src]
Sets the index, if the specified index < menu.entries.len()
fn up(&mut self)
[src]
Select the entry above the current selection, unless the first entry is currently selected.
fn down(&mut self)
[src]
Select the entry below the current selection, unless the last entry is currently selected.
fn selected(&self) -> T
[src]
Returns a copy of the currently selected entry's value.
[src]
Consumes self, returning the menu
Trait Implementations
impl<T: Debug + Copy> Debug for MenuInstance<T>
[src]
impl<T: Clone + Copy> Clone for MenuInstance<T>
[src]
fn clone(&self) -> MenuInstance<T>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T: Copy> View for MenuInstance<T>
[src]
fn view<G: ViewGrid>(&self, offset: Vector2<i16>, depth: i16, grid: &mut G)
[src]
Update the cells in grid
to describe how a type should be rendered. Implementations of view
for low level ui components will typically involve updating cells directly. Implementations for higer level components, such as an entire application's ui, will typically call the view
methed of lower level components which make up the ui. Read more