Skip to main content

TouchPad

Struct TouchPad 

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

The virtual stick and its tap buttons, pushing into the kit’s action sink.

Owned by the app for the life of the game, like the games’ own touch state: the pad holds the finger that is down, its origin and the gate.

Implementations§

Source§

impl<A: UiAction> TouchPad<A>

Source

pub fn new(kit: Kit<A>) -> Self

A pad sharing kit’s sink, palette and scale.

Source

pub fn with_zone(self, fraction: f32) -> Result<Self, TouchError>

Cover a different fraction of the viewport width with the stick’s zone.

Source

pub fn kit(&self) -> &Kit<A>

Source

pub fn enabled(&self) -> bool

Whether the pad is taking pointers this frame.

Source

pub fn active(&self) -> bool

Whether a finger is on the stick.

Source

pub fn stick(&self) -> Vec2

The stick’s value: dead-zoned, clamped to the unit disc, y down.

Poll it where the game already combines its move axes; it is not an action because movement is a level, not an edge.

Source

pub fn begin_frame(&self, flow: FlowState)

Per-frame gate: the pad takes pointers only while the game owns input.

Call before composing (or before the sim step) with the same FlowState the gameplay systems read. Closing the gate releases a finger that is still down, so the game cannot keep moving under a modal.

Source

pub fn begin_frame_in(&self, world: &World)

Per-frame gate read straight from the sim world.

A world where the flow was never installed reads as FlowState::CLOSED, so the overlay is closed rather than live.

Source

pub fn release(&self)

Forget the stick without touching the gate.

Source

pub fn view(&self, viewport: [f32; 2]) -> View

The stick’s touch zone and ring, to be composed over the game.

Nothing is composed while the gate is closed.

Source

pub fn tap( &self, viewport: [f32; 2], glyph: &str, at: [f32; 2], radius: f32, action: A, ) -> View

A round tap button at a design-space point, pushing action on release.

Sized like the glyph buttons and placed absolutely, so it can sit under the thumb. Touch buttons stay out of keyboard traversal: a finger is not a focus.

Source

pub fn driver(&self) -> NavDriver

The traversal driver for the pad’s controls, when a game wants a panel’s buttons reachable from a stick as well as from a finger: a touch stick is a pointer, so this is only for a game that also reads it as a directional axis.

Trait Implementations§

Source§

impl<A: Clone + UiAction> Clone for TouchPad<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 TouchPad<A>

§

impl<A> !Send for TouchPad<A>

§

impl<A> !Sync for TouchPad<A>

§

impl<A> !UnwindSafe for TouchPad<A>

§

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

§

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

§

impl<A> UnsafeUnpin for TouchPad<A>
where Kit<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.