pub struct RotaryScrollEvent {
pub vertical_scroll_pixels: f32,
pub horizontal_scroll_pixels: f32,
pub uptime_millis: u64,
}Expand description
Re-export the UI crate so applications can depend on a single crate. A rotary scroll event produced by a Wear OS crown or rotating bezel.
Field-for-field equivalent to Compose’s
androidx.compose.ui.input.rotary.RotaryScrollEvent. The scroll amounts are
in pixels, not detents: the platform layer has already multiplied the
raw axis value by the system scroll factor.
This type is Copy and contains no heap data, so dispatching one allocates
nothing.
Fields§
§vertical_scroll_pixels: f32How far to scroll (in pixels) in a container that scrolls vertically.
Negative when the user turned the crown “up”/away (positive
AXIS_SCROLL on Android); see the module docs for the
derivation.
horizontal_scroll_pixels: f32How far to scroll (in pixels) in a container that scrolls horizontally.
uptime_millis: u64Time in milliseconds at which the event occurred. The zero point is platform-dependent (Android’s uptime clock, the process start elsewhere), so only differences between events are meaningful.
Implementations§
Source§impl RotaryScrollEvent
impl RotaryScrollEvent
Sourcepub const fn new(
vertical_scroll_pixels: f32,
horizontal_scroll_pixels: f32,
uptime_millis: u64,
) -> RotaryScrollEvent
pub const fn new( vertical_scroll_pixels: f32, horizontal_scroll_pixels: f32, uptime_millis: u64, ) -> RotaryScrollEvent
Creates a rotary event from scroll amounts that are already in pixels.
Sourcepub fn from_detents(
detents: f32,
vertical_scroll_factor: f32,
horizontal_scroll_factor: f32,
uptime_millis: u64,
) -> RotaryScrollEvent
pub fn from_detents( detents: f32, vertical_scroll_factor: f32, horizontal_scroll_factor: f32, uptime_millis: u64, ) -> RotaryScrollEvent
Builds a rotary event from a raw Android AXIS_SCROLL value in detents.
detents is the value straight out of
AMotionEvent_getAxisValue(event, AMOTION_EVENT_AXIS_SCROLL, 0); the
scroll factors are ViewConfiguration.getScaledVerticalScrollFactor()
and getScaledHorizontalScrollFactor().
The detent value is negated exactly once, matching Compose (see the module docs), and the same negated value feeds both axes.
Sourcepub fn from_wheel_pixels(
vertical: f32,
horizontal: f32,
uptime_millis: u64,
) -> RotaryScrollEvent
pub fn from_wheel_pixels( vertical: f32, horizontal: f32, uptime_millis: u64, ) -> RotaryScrollEvent
Builds a rotary event from a mouse-wheel / trackpad sample already in logical pixels.
The final target for rotary input is a Wear OS crown, but the machines
it is developed on have wheels, so every desktop-class host offers its
wheel to the rotary handlers first. vertical and horizontal are in
the shell’s wheel convention — positive when the content should move
down and right, the direction a wheel turned up produces — which is
the same physical direction as a positive Android detent. Both are
therefore negated exactly once, like from_detents,
so a wheel turned up and a crown turned up land on the same negative
vertical_scroll_pixels.
Unlike the detent path, a wheel really does have two axes, so each one is carried through on its own rather than fanned out from a single value.
Trait Implementations§
Source§impl Clone for RotaryScrollEvent
impl Clone for RotaryScrollEvent
Source§fn clone(&self) -> RotaryScrollEvent
fn clone(&self) -> RotaryScrollEvent
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for RotaryScrollEvent
Source§impl Debug for RotaryScrollEvent
impl Debug for RotaryScrollEvent
Source§impl Default for RotaryScrollEvent
impl Default for RotaryScrollEvent
Source§fn default() -> RotaryScrollEvent
fn default() -> RotaryScrollEvent
Source§impl PartialEq for RotaryScrollEvent
impl PartialEq for RotaryScrollEvent
impl StructuralPartialEq for RotaryScrollEvent
Auto Trait Implementations§
impl Freeze for RotaryScrollEvent
impl RefUnwindSafe for RotaryScrollEvent
impl Send for RotaryScrollEvent
impl Sync for RotaryScrollEvent
impl Unpin for RotaryScrollEvent
impl UnsafeUnpin for RotaryScrollEvent
impl UnwindSafe for RotaryScrollEvent
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>. Box<dyn Any> can
then be further downcast into Box<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>. Rc<Any> 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.