Skip to main content

NavMap

Struct NavMap 

Source
pub struct NavMap { /* private fields */ }
Expand description

The controls the kit composed this frame, with their laid-out rectangles.

Clone the map into every control: it is one shared registry behind an Rc. The game calls NavMap::begin_frame once per frame before composing, which retires controls that were not recomposed: a panel stays navigable through the frame after its last composition, so traversal made before composing still finds the layout the player was looking at, and leaves the map at the begin_frame after that.

A control registers itself while composing (NavMap::register) and reports its rectangle from the layout callback (NavMap::place). Traversal resolves against whatever is registered.

Implementations§

Source§

impl NavMap

Source

pub fn new() -> Self

Source

pub fn begin_frame(&self)

Start a frame: every control must be marked or placed again to stay in the map. Call before composing the panel.

Source

pub fn clear(&self)

Forget every control, including the ones marked this frame.

Source

pub fn register( &self, requester: &FocusRequester, group: Option<GroupId>, ) -> bool

Register a control for this frame, deriving its view id from its focus requester.

This is what a kit control calls while composing. It returns false on the control’s first frame, before the first layout pass has assigned the id; the rectangle that layout reported is kept until the control registers with an id, so a control becomes navigable as soon as its id arrives, whether or not the panel composed in the frames between.

Source

pub fn mark(&self, id: u64, group: Option<GroupId>, requester: FocusRequester)

Mark a control whose view id the caller already has.

Kit controls go through register; this is for a game that composes its own control and reads the id from the layout.

Source

pub fn place( &self, requester: &FocusRequester, rect: Rect, group: Option<GroupId>, ) -> bool

Record a control’s laid-out rectangle, from Modifier::on_globally_positioned.

A rectangle that arrives before the control’s view id is known is held for it until the control registers with that id; after that, the callback only fires when the rectangle changes, so this is a cheap update. A group of None leaves the group the control already has alone: a caller that only knows the rectangle must not clear a modal trap. Returns whether the rectangle was recorded against a control.

Source

pub fn active(&self) -> Vec<NavEntry>

Controls composed and laid out this frame, in composition order.

Source

pub fn first(&self) -> Option<u64>

The first control in composition order.

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn contains(&self, id: u64) -> bool

Whether id is a control on screen this frame.

Source

pub fn request(&self, id: u64) -> bool

Ask the platform to focus id. false when there is no such control or the request was refused (captured focus, not laid out yet).

Source

pub fn capture(&self, id: u64) -> bool

Pin focus to id until release: what a modal panel does when it opens, so traversal cannot escape to what is underneath.

The requester is remembered with the capture, so the release does not depend on the control still being in the map.

Source

pub fn release(&self, id: u64) -> bool

Release a capture taken by capture.

Focus is cleared, so the caller asks for the next panel’s focus with NavDriver::enter once the modal is gone. A capture the map took is freed even after its control left the map, because the platform’s lock would otherwise pin focus to an id nothing can request again.

Source

pub fn resolve(&self, from: Option<u64>, dir: NavDir, wrap: Wrap) -> NavStep

Resolve one traversal request.

Trait Implementations§

Source§

impl Clone for NavMap

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for NavMap

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for NavMap

§

impl !Send for NavMap

§

impl !Sync for NavMap

§

impl !UnwindSafe for NavMap

§

impl Freeze for NavMap

§

impl Unpin for NavMap

§

impl UnsafeUnpin for NavMap

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &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)

Converts &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> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromTemplate for T
where T: Clone + Default + Unpin,

Source§

type Template = T

The Template for this type.
Source§

impl<T> FromWorld for T
where T: Default,

Source§

fn from_world(_world: &mut World) -> T

Creates Self using default().

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> IntoResult<T> for T

Source§

fn into_result(self) -> Result<T, RunSystemError>

Converts this type into the system output type.
Source§

impl<A> Is for A
where A: Any,

Source§

fn is<T>() -> bool
where T: Any,

Checks if the current type “is” another type, using a TypeId equality comparison. This is most useful in the context of generic logic. Read more
Source§

impl<T> Template for T
where T: Clone + Unpin,

Source§

type Output = T

The type of value produced by this Template.
Source§

fn build_template( &self, _context: &mut TemplateContext<'_, '_>, ) -> Result<<T as Template>::Output, BevyError>

Uses this template and the given entity context to produce a Template::Output.
Source§

fn clone_template(&self) -> T

Clones this template. See Clone.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.