Skip to main content

GestureArena

Struct GestureArena 

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

多个识别器竞争同一指针:

  1. 每个识别器初始 Possible
  2. 事件喂给所有未决识别器
  3. 第一个返回 Accepted 的胜出,其余 dispose(强制 Rejected)
  4. 胜出者独占后续事件,直到 PointerUp(手势结束,重置)

Implementations§

Source§

impl GestureArena

Source

pub fn new(recognizers: Vec<Box<dyn GestureRecognizer>>) -> Self

Source

pub fn adopt_callbacks(&mut self, fresh: GestureArena)

用 fresh 竞技场(从新 widget 构建)刷新回调,保留识别器状态。

识别器按 build_arena 的确定性顺序 index 对齐。识别器集合大小变化 (手势配置改变,如摘掉 on_pan_update)时无法对应 → 整场替换(状态作废)。

Source

pub fn is_empty(&self) -> bool

Source

pub fn has_winner(&self) -> bool

竞技场是否有已胜出的持续型手势(外部仲裁查询用)

Source

pub fn add_pointer(&mut self, event: &WidgetEvent)

喂指针事件:胜者独占;无胜者全员参与,然后仲裁

Source

pub fn poll(&mut self)

时钟推进(每帧由 GestureDetectorState::tick 调)。 长按等“按住超时“类手势没有事件流驱动,靠这里到时触发; 仲裁规则与 add_pointer 相同(第一个 Accepted 胜出,其余 dispose)。

Source

pub fn dispose_all(&mut self)

外部否决(竞争失败):全部强制放弃

Trait Implementations§

Source§

impl Debug for GestureArena

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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