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>
impl<A: UiAction> Kit<A>
Sourcepub fn new(scale: Scale, tokens: Tokens, sink: Sink<A>) -> Self
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.
Sourcepub fn with_map(
scale: Scale,
tokens: Tokens,
sink: Sink<A>,
nav: NavMap,
) -> Self
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.
Sourcepub fn set_scale(&self, scale: Scale)
pub fn set_scale(&self, scale: Scale)
This frame’s viewport scale. All clones of the kit see it.
pub fn scale(&self) -> Scale
pub fn tokens(&self) -> Tokens
Sourcepub fn with_tokens(self, tokens: Tokens) -> Self
pub fn with_tokens(self, tokens: Tokens) -> Self
Replace the palette. Returns the re-skinned kit.
pub fn sink(&self) -> &Sink<A>
Sourcepub fn begin_frame(&self)
pub fn begin_frame(&self)
Retire the controls that are no longer composed: call once per frame, before composing panels.
A chunky text button that pushes action and takes focus.
A square glyph button (play, pause, home) that pushes action.
Sourcepub fn chip(&self, text: impl Into<String>, face: Color) -> View
pub fn chip(&self, text: impl Into<String>, face: Color) -> View
An information chip: a HUD counter, score or timer face.
Sourcepub fn panel(
&self,
viewport: [f32; 2],
anchor: [f32; 4],
offset: [f32; 4],
face: Color,
) -> View
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.
Sourcepub fn scrim(&self) -> View
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.
Sourcepub fn label(
&self,
modifier: Modifier,
text: &str,
size: f32,
fill: Color,
) -> View
pub fn label( &self, modifier: Modifier, text: &str, size: f32, fill: Color, ) -> View
Outlined text: labels that must read over game art.
Sourcepub fn label_plain(
&self,
modifier: Modifier,
text: &str,
size: f32,
fill: Color,
) -> View
pub fn label_plain( &self, modifier: Modifier, text: &str, size: f32, fill: Color, ) -> View
Plain text: numbers and button captions, no outline.
Sourcepub fn display(
&self,
modifier: Modifier,
text: &str,
size: f32,
fill: Color,
) -> View
pub fn display( &self, modifier: Modifier, text: &str, size: f32, fill: Color, ) -> View
Display text: tighter tracking and a heavier faux-bold, for titles.
Sourcepub fn disc(
&self,
viewport: [f32; 2],
at: [f32; 2],
radius: f32,
color: Color,
) -> View
pub fn disc( &self, viewport: [f32; 2], at: [f32; 2], radius: f32, color: Color, ) -> View
A filled circle in design space.
Sourcepub fn ring(
&self,
viewport: [f32; 2],
at: [f32; 2],
radius: f32,
width: f32,
color: Color,
) -> View
pub fn ring( &self, viewport: [f32; 2], at: [f32; 2], radius: f32, width: f32, color: Color, ) -> View
An unfilled circle in design space.
Trait Implementations§
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>
impl<A> Unpin for Kit<A>
impl<A> UnsafeUnpin for Kit<A>where
Sink<A>: UnsafeUnpin,
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> 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.