Skip to main content

Menu

Struct Menu 

Source
pub struct Menu<T: Clone, S = ()> { /* private fields */ }

Implementations§

Source§

impl<T: Clone, S> Menu<T, S>

Source

pub fn up(&mut self)

Source

pub fn down(&mut self)

Source

pub fn set_index(&mut self, index: usize)

Source

pub fn index(&self) -> usize

Source

pub fn selected(&self) -> &T

Source

pub fn choose(&mut self, ctx: Ctx<'_>, input: Input) -> Option<T>

Trait Implementations§

Source§

impl<T: Clone, S> Component for Menu<T, S>

Source§

type State = S

The type of the external state of this component. This allows multiple different components to share the same piece of state. For components whose entire state is contained within the component itself, set this to ().
Source§

type Output = Option<T>

The type yielded by the component in response to an event. Typical components only yield meaningful results when certain conditions have been met (e.g. an item is chosen from a menu), thus it’s common for this type to be Option<_>.
Source§

fn render(&self, state: &S, ctx: Ctx<'_>, fb: &mut FrameBuffer)

Render the component to a frame buffer
Source§

fn update(&mut self, state: &mut S, ctx: Ctx<'_>, event: Event) -> Self::Output

Update the internal and extnal state of this component in response to an event, and yield a value.
Source§

fn size(&self, state: &S, ctx: Ctx<'_>) -> UCoord

Return the current size (in cells) of this component. This allows decorators to account for the size of the components they decorate (e.g. when drawing a border around a component, its size must be known).

Auto Trait Implementations§

§

impl<T, S> Freeze for Menu<T, S>

§

impl<T, S = ()> !RefUnwindSafe for Menu<T, S>

§

impl<T, S = ()> !Send for Menu<T, S>

§

impl<T, S = ()> !Sync for Menu<T, S>

§

impl<T, S> Unpin for Menu<T, S>
where T: Unpin,

§

impl<T, S = ()> !UnwindSafe for Menu<T, S>

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.