Struct egui::menu::MenuState

source ·
pub(crate) struct MenuState {
    sub_menu: Option<(Id, Arc<RwLock<MenuState>>)>,
    pub rect: Rect,
    pub response: MenuResponse,
    entry_count: usize,
}

Fields§

§sub_menu: Option<(Id, Arc<RwLock<MenuState>>)>

The opened sub-menu and its Id

§rect: Rect

Bounding box of this menu (without the sub-menu)

§response: MenuResponse

Used to check if any menu in the tree wants to close

§entry_count: usize

Used to hash different Ids for sub-menus

Implementations§

source§

impl MenuState

source

pub fn new(position: Pos2) -> Self

source

pub fn close(&mut self)

Close menu hierarchy.

source

pub fn show<R>( ctx: &Context, menu_state: &Arc<RwLock<Self>>, id: Id, add_contents: impl FnOnce(&mut Ui) -> R ) -> InnerResponse<R>

source

fn show_submenu<R>( &mut self, ctx: &Context, id: Id, add_contents: impl FnOnce(&mut Ui) -> R ) -> Option<R>

source

pub fn area_contains(&self, pos: Pos2) -> bool

Check if position is in the menu hierarchy’s area.

source

fn next_entry_index(&mut self) -> usize

source

fn submenu_button_interaction(&mut self, ui: &Ui, sub_id: Id, button: &Response)

Sense button interaction opening and closing submenu.

source

fn points_at_left_of_rect(pos: Pos2, dir: Vec2, rect: Rect) -> bool

Check if dir points from pos towards left side of rect.

source

fn moving_towards_current_submenu(&self, pointer: &PointerState) -> bool

Check if pointer is moving towards current submenu.

source

fn cascade_close_response(&mut self, response: MenuResponse)

Cascade close response to menu root.

source

fn is_open(&self, id: Id) -> bool

source

fn sub_id(&self) -> Option<Id>

source

fn current_submenu(&self) -> Option<&Arc<RwLock<Self>>>

source

fn submenu(&mut self, id: Id) -> Option<&Arc<RwLock<Self>>>

source

fn open_submenu(&mut self, id: Id, pos: Pos2)

Open submenu at position, if not already open.

Auto Trait Implementations§

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>,

§

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>,

§

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.