Skip to main content

Menu

Struct Menu 

Source
pub struct Menu {
    pub style: Style,
    pub item_style: Style,
    pub selected_color: Color,
    pub header_color: Color,
    pub text_color: Color,
    pub separator_color: Color,
    /* private fields */
}
Expand description

Multi-page hierarchical navigation surface (LPAR-13 §5.E).

Stores all page data and item strings as owned values.

Fields§

§style: Style

Background / border style for the full widget (Part::MAIN).

§item_style: Style

Style applied to item rows (Part::ITEMS).

§selected_color: Color

Highlight color for the focused item (Part::SELECTED).

§header_color: Color

Background color for the header bar.

§text_color: Color

Color for all text labels.

§separator_color: Color

Color for separator rules.

Implementations§

Source§

impl Menu

Source

pub fn new(bounds: Rect) -> Self

Create a Menu widget occupying bounds with no pages.

Source

pub fn set_font(&mut self, font: &'static dyn FontMetrics)

Assign the font used to render this widget (FONT-00 §5); resolves to FONT_6X10 when unset.

Source

pub fn add_page(&mut self, title: &str) -> MenuPageId

Create a new page with the given title and return its id.

Source

pub fn set_root_page(&mut self, id: MenuPageId)

Set the root (initial) page displayed when the stack is empty.

Source

pub fn add_item(&mut self, page: MenuPageId, item: MenuItem) -> MenuItemId

Append item to page and return its id within that page.

The item string data is owned by the widget.

Source

pub fn set_page(&mut self, id: MenuPageId)

Navigate directly to id, pushing it onto the stack.

If id is already in the stack, pops back to that position.

Source

pub fn back(&mut self)

Pop the current page from the stack.

No-op when already at the root page (i.e. active_page() == root_page and the stack is empty or has the root page at position 0).

Source

pub fn active_page(&self) -> MenuPageId

Return the id of the currently displayed page.

Source

pub fn set_header_mode(&mut self, mode: MenuHeaderMode)

Set the position of the header bar.

Source

pub fn header_mode(&self) -> MenuHeaderMode

Return the current header mode.

Source

pub fn set_root_back_button(&mut self, enable: bool)

Enable or disable the back button when on the root page.

Source

pub fn root_back_button(&self) -> bool

Return whether the root back button is enabled.

Source

pub fn navigate_next(&mut self)

Move the highlight to the next navigable item on the current page, wrapping at the end.

Wire to ObjectEvent::Key(Key::ArrowDown).

Source

pub fn navigate_prev(&mut self)

Move the highlight to the previous navigable item on the current page, wrapping at the start.

Wire to ObjectEvent::Key(Key::ArrowUp).

Source

pub fn activate_selected(&mut self)

Activate the currently highlighted item.

Wire to ObjectEvent::Key(Key::Enter).

Trait Implementations§

Source§

impl Widget for Menu

Source§

fn bounds(&self) -> Rect

Return the area this widget occupies relative to its parent.
Source§

fn widget_font_mut(&mut self) -> Option<&mut WidgetFont>

Expose this widget’s font slot for cascade-driven font resolution (FONT-05 §5.B). Read more
Source§

fn set_bounds(&mut self, bounds: Rect)

Called by the LPAR-10 layout pass to notify this widget of its layout-computed bounds. Read more
Source§

fn draw(&self, renderer: &mut dyn Renderer)

Render the widget using the provided Renderer.
Source§

fn handle_event(&mut self, event: &Event) -> bool

Handle an event and return true if it was consumed. Read more
Source§

fn clear_region(&mut self) -> Option<Rect>

Return a region (in draw/landscape coordinates) that should be restored from the pristine background copy, or None. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Menu

§

impl !Send for Menu

§

impl !Sync for Menu

§

impl !UnwindSafe for Menu

§

impl Freeze for Menu

§

impl Unpin for Menu

§

impl UnsafeUnpin for Menu

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.