pub enum ScrollDelta {
Lines(f32, f32),
PixelDelta(Vec2),
}
Expand description
Type used by Event::Scroll
Variants§
Lines(f32, f32)
Scroll a given number of lines
Positive values indicate that the content that is being scrolled should move right and down (revealing more content left and up). Typically values are integral but this is not guaranteed.
PixelDelta(Vec2)
Scroll a given number of pixels
For a ‘natural scrolling’ touch pad (that acts like a touch screen) this means moving your fingers right and down should give positive values, and move the content right and down (to reveal more things left and up).
Implementations§
Source§impl ScrollDelta
impl ScrollDelta
Sourcepub fn is_vertical(self) -> bool
pub fn is_vertical(self) -> bool
True if the x-axis delta is zero
Sourcepub fn is_horizontal(self) -> bool
pub fn is_horizontal(self) -> bool
True if the y-axis delta is zero
Sourcepub fn as_offset(self, cx: &EventState) -> Vec2
pub fn as_offset(self, cx: &EventState) -> Vec2
Convert to a pan offset
Line deltas are converted to a distance based on scroll_distance
configuration.
Sourcepub fn as_factor(self, _: &EventState) -> f32
pub fn as_factor(self, _: &EventState) -> f32
Convert to a zoom factor
Sourcepub fn as_offset_or_factor(self, cx: &EventState) -> Result<Vec2, f32>
pub fn as_offset_or_factor(self, cx: &EventState) -> Result<Vec2, f32>
Convert to a pan offset or zoom factor
This is used for surfaces where panning/scrolling is preferred over zooming, though both are supported (for example, a web page). The Ctrl key is used to select between the two modes.
Sourcepub fn as_factor_or_offset(self, cx: &EventState) -> Result<f32, Vec2>
pub fn as_factor_or_offset(self, cx: &EventState) -> Result<f32, Vec2>
Convert to a zoom factor or pan offset
This is used for surfaces where zooming is preferred over panning, though both are supported (for example, a map view where click-and-drag may also be used to pan). Mouse wheel actions always zoom while the touchpad scrolling may cause either effect.
Sourcepub fn as_wheel_action(self, cx: &EventState) -> Option<i32>
pub fn as_wheel_action(self, cx: &EventState) -> Option<i32>
Attempt to interpret as a mouse wheel action
Infers the “scroll delta” as an integral step, if appropriate.
This may be used e.g. to change the selected value of a ComboBox
.
Positive values indicate scrolling up.
Trait Implementations§
Source§impl Clone for ScrollDelta
impl Clone for ScrollDelta
Source§fn clone(&self) -> ScrollDelta
fn clone(&self) -> ScrollDelta
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for ScrollDelta
impl Debug for ScrollDelta
Source§impl PartialEq for ScrollDelta
impl PartialEq for ScrollDelta
impl Copy for ScrollDelta
impl StructuralPartialEq for ScrollDelta
Auto Trait Implementations§
impl Freeze for ScrollDelta
impl RefUnwindSafe for ScrollDelta
impl Send for ScrollDelta
impl Sync for ScrollDelta
impl Unpin for ScrollDelta
impl UnwindSafe for ScrollDelta
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<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
Source§fn try_cast_approx(self) -> Result<T, Error>
fn try_cast_approx(self) -> Result<T, Error>
Source§fn cast_approx(self) -> T
fn cast_approx(self) -> T
Source§impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
Source§fn cast_trunc(self) -> T
fn cast_trunc(self) -> T
Source§fn cast_nearest(self) -> T
fn cast_nearest(self) -> T
Source§fn cast_floor(self) -> T
fn cast_floor(self) -> 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.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more