Skip to main content

Kit

Struct Kit 

Source
pub struct Kit<A: UiAction> { /* private fields */ }
Expand description

The scale, tokens, sink and nav map a panel’s controls are built from.

Build one per game and clone it into whatever composes: the scale cell, the sink and the nav map are shared behind Rc/Arc, so every clone sees the same frame. A kit rebuilt every frame would start from an empty nav map, whose one-frame rectangle binding would never complete and whose controls could never be reached.

Implementations§

Source§

impl<A: UiAction> Kit<A>

Source

pub fn new(scale: Scale, tokens: Tokens, sink: Sink<A>) -> Self

A kit drawing with tokens, pushing into sink and registering in a fresh nav map.

Source

pub fn with_map( scale: Scale, tokens: Tokens, sink: Sink<A>, nav: NavMap, ) -> Self

A kit wrapping an existing nav map, so a game that keeps its own map still shares it with the controls.

Source

pub fn set_scale(&self, scale: Scale)

This frame’s viewport scale. All clones of the kit see it.

Source

pub fn scale(&self) -> Scale

Source

pub fn tokens(&self) -> Tokens

Source

pub fn with_tokens(self, tokens: Tokens) -> Self

Replace the palette. Returns the re-skinned kit.

Source

pub fn with_wrap(self, wrap: Wrap) -> Self

Edge behaviour for directional traversal.

Source

pub fn sink(&self) -> &Sink<A>

Source

pub fn nav_map(&self) -> &NavMap

Source

pub fn driver(&self) -> NavDriver

Traversal over this kit’s controls.

Source

pub fn begin_frame(&self)

Retire the controls that are no longer composed: call once per frame, before composing panels.

Source

pub fn button(&self, text: impl Into<String>, action: A) -> Button<A>

A chunky text button that pushes action and takes focus.

Source

pub fn icon_button(&self, glyph: impl Into<String>, action: A) -> Button<A>

A square glyph button (play, pause, home) that pushes action.

Source

pub fn chip(&self, text: impl Into<String>, face: Color) -> View

An information chip: a HUD counter, score or timer face.

Source

pub fn panel( &self, viewport: [f32; 2], anchor: [f32; 4], offset: [f32; 4], face: Color, ) -> View

A card: the panel body, placed by viewport anchor and design-unit offset, stacking its children in a column with the default gap.

Add children to the returned view; they are centred as a column, which is what every template menu is.

Source

pub fn scrim(&self) -> View

The dim behind a modal panel: full-bleed, and it blocks pointer input so a click cannot reach the game underneath. It stays out of the focus chain.

Source

pub fn label( &self, modifier: Modifier, text: &str, size: f32, fill: Color, ) -> View

Outlined text: labels that must read over game art.

Source

pub fn label_plain( &self, modifier: Modifier, text: &str, size: f32, fill: Color, ) -> View

Plain text: numbers and button captions, no outline.

Source

pub fn display( &self, modifier: Modifier, text: &str, size: f32, fill: Color, ) -> View

Display text: tighter tracking and a heavier faux-bold, for titles.

Source

pub fn icon(&self, glyph: &str, size: f32, fill: Color) -> View

A Material Symbols glyph.

Source

pub fn disc( &self, viewport: [f32; 2], at: [f32; 2], radius: f32, color: Color, ) -> View

A filled circle in design space.

Source

pub fn ring( &self, viewport: [f32; 2], at: [f32; 2], radius: f32, width: f32, color: Color, ) -> View

An unfilled circle in design space.

Source

pub fn place( &self, viewport: [f32; 2], anchor: [f32; 4], offset: [f32; 4], ) -> Modifier

The rect(vp, s, anchor, offset) placement helper, with this kit’s scale.

Source

pub fn touch_pad(&self) -> TouchPad<A>

The virtual stick and tap buttons, pushing into the same sink.

Build the pad once and keep it in the app, like the game’s own input state: a pad built per frame forgets the finger that is down.

Trait Implementations§

Source§

impl<A: Clone + UiAction> Clone for Kit<A>

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

Auto Trait Implementations§

§

impl<A> !RefUnwindSafe for Kit<A>

§

impl<A> !Send for Kit<A>

§

impl<A> !Sync for Kit<A>

§

impl<A> !UnwindSafe for Kit<A>

§

impl<A> Freeze for Kit<A>
where Sink<A>: Freeze,

§

impl<A> Unpin for Kit<A>
where Sink<A>: Unpin,

§

impl<A> UnsafeUnpin for Kit<A>
where Sink<A>: UnsafeUnpin,

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