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§
pub fn new() -> Self
Sourcepub fn begin_frame(&self)
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.
Sourcepub fn register(
&self,
requester: &FocusRequester,
group: Option<GroupId>,
) -> bool
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.
Sourcepub fn mark(&self, id: u64, group: Option<GroupId>, requester: FocusRequester)
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.
Sourcepub fn place(
&self,
requester: &FocusRequester,
rect: Rect,
group: Option<GroupId>,
) -> bool
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.
Sourcepub fn active(&self) -> Vec<NavEntry>
pub fn active(&self) -> Vec<NavEntry>
Controls composed and laid out this frame, in composition order.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn request(&self, id: u64) -> bool
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).
Sourcepub fn capture(&self, id: u64) -> bool
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.
Sourcepub fn release(&self, id: u64) -> bool
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.
Trait Implementations§
Auto Trait Implementations§
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
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>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> FromTemplate for T
impl<T> FromTemplate for T
Source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
Source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self using default().
Source§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
Source§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
Source§impl<T> Template for T
impl<T> Template for T
Source§fn build_template(
&self,
_context: &mut TemplateContext<'_, '_>,
) -> Result<<T as Template>::Output, BevyError>
fn build_template( &self, _context: &mut TemplateContext<'_, '_>, ) -> Result<<T as Template>::Output, BevyError>
entity context to produce a Template::Output.Source§fn clone_template(&self) -> T
fn clone_template(&self) -> T
Clone.