pub struct MenuBar {
pub items: Vec<MenuItem>,
pub area: Option<Rect>,
pub normal_style: Style,
pub selected_style: Style,
pub hover_style: Style,
pub selected_hover_style: Style,
}Available on crate feature
menu only.Expand description
A horizontal menu bar with selectable items
Fields§
§items: Vec<MenuItem>§area: Option<Rect>§normal_style: Style§selected_style: Style§hover_style: Style§selected_hover_style: StyleImplementations§
Source§impl MenuBar
impl MenuBar
Sourcepub fn with_selected(self, index: usize) -> Self
pub fn with_selected(self, index: usize) -> Self
Set initial selected button (by index)
Sourcepub fn normal_style(self, style: Style) -> Self
pub fn normal_style(self, style: Style) -> Self
Set custom normal style
Sourcepub fn selected_style(self, style: Style) -> Self
pub fn selected_style(self, style: Style) -> Self
Set custom selected style
Sourcepub fn hover_style(self, style: Style) -> Self
pub fn hover_style(self, style: Style) -> Self
Set custom hover style
Sourcepub fn selected_hover_style(self, style: Style) -> Self
pub fn selected_hover_style(self, style: Style) -> Self
Set custom selected hover style
Sourcepub fn update_hover(&mut self, column: u16, row: u16)
pub fn update_hover(&mut self, column: u16, row: u16)
Update hover state based on mouse position
Sourcepub fn handle_click(&mut self, column: u16, row: u16) -> Option<usize>
pub fn handle_click(&mut self, column: u16, row: u16) -> Option<usize>
Handle click at position, returns the index of clicked menu item if any
Sourcepub fn render(&mut self, frame: &mut Frame<'_>, area: Rect)
pub fn render(&mut self, frame: &mut Frame<'_>, area: Rect)
Render the menu bar as a connected series of items with rounded border
Sourcepub fn render_with_offset(
&mut self,
frame: &mut Frame<'_>,
area: Rect,
left_offset: u16,
)
pub fn render_with_offset( &mut self, frame: &mut Frame<'_>, area: Rect, left_offset: u16, )
Render the menu bar with a left offset to make room for other components
Sourcepub fn render_centered(&mut self, frame: &mut Frame<'_>, area: Rect)
pub fn render_centered(&mut self, frame: &mut Frame<'_>, area: Rect)
Render with a centered layout (useful for menu bars)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MenuBar
impl RefUnwindSafe for MenuBar
impl Send for MenuBar
impl Sync for MenuBar
impl Unpin for MenuBar
impl UnwindSafe for MenuBar
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more