Struct ScrollBehavior

Source
pub struct ScrollBehavior {
    pub axes: ScrollAxes,
    pub line_px: f32,
}
Expand description

Wheel normalization and per-widget scroll tuning.

§Examples

use ailloli_ui_core::{ScrollAxes, ScrollBehavior};
let behavior = ScrollBehavior::new(ScrollAxes::VERTICAL);
assert_eq!(behavior.line_px, ScrollBehavior::DEFAULT_LINE_PX);

Fields§

§axes: ScrollAxes

Axes that receive normalized wheel motion.

§line_px: f32

Logical pixels represented by one platform line unit.

Implementations§

Source§

impl ScrollBehavior

Source

pub const DEFAULT_LINE_PX: f32 = 48f32

Default logical distance of one wheel line: 48 pixels.

§Examples
use ailloli_ui_core::ScrollBehavior;
assert_eq!(ScrollBehavior::DEFAULT_LINE_PX, 48.0);
Source

pub fn new(axes: ScrollAxes) -> Self

Creates behavior for axes using Self::DEFAULT_LINE_PX.

§Examples
use ailloli_ui_core::{ScrollAxes, ScrollBehavior};
assert_eq!(ScrollBehavior::new(ScrollAxes::BOTH).axes, ScrollAxes::BOTH);
Source

pub fn with_line_px(self, line_px: f32) -> Self

Sets the line distance, clamped to at least one logical pixel.

NaN and negative infinity become 1.0 through floating-point max semantics; positive infinity remains infinite.

§Examples
use ailloli_ui_core::{ScrollAxes, ScrollBehavior};
assert_eq!(ScrollBehavior::new(ScrollAxes::BOTH).with_line_px(0.0).line_px, 1.0);
Source

pub fn wheel_delta(self, delta: WheelDelta) -> Offset

Converts a platform wheel delta to a filtered logical content offset.

Line deltas are scaled by Self::line_px; pixel deltas are already in logical pixels. Both forms are negated so a positive wheel delta moves the viewed content toward its origin.

§Examples
use ailloli_ui_core::{Offset, ScrollAxes, ScrollBehavior};
use ailloli_ui_core::event::WheelDelta;
let delta = ScrollBehavior::new(ScrollAxes::VERTICAL).wheel_delta(WheelDelta::LineDelta { x: 1.0, y: -2.0 });
assert_eq!(delta, Offset::new(0.0, 96.0));
Source

pub fn wheel_delta_with_modifiers( self, delta: WheelDelta, modifiers: Modifiers, ) -> Offset

Converts wheel input while applying the framework’s Shift-axis policy.

Line values use Self::line_px and pixel values are already logical. Native horizontal movement is preserved. When Shift is held and the horizontal axis is enabled, normalized vertical movement is added to X and removed from Y. Vertical-only surfaces therefore keep scrolling vertically under Shift. Non-finite components become zero.

The provider’s precise flag is intentionally absent: line-versus-pixel already determines scaling, while precision remains event metadata and does not introduce acceleration.

§Examples
use ailloli_ui_core::{event::{Modifiers, WheelDelta}, Offset, ScrollAxes, ScrollBehavior};
let modifiers = Modifiers { shift: true, ..Modifiers::default() };
let delta = ScrollBehavior::new(ScrollAxes::BOTH).with_line_px(10.0)
    .wheel_delta_with_modifiers(WheelDelta::LineDelta { x: -1.0, y: -2.0 }, modifiers);
assert_eq!(delta, Offset::new(30.0, 0.0));

Trait Implementations§

Source§

impl Clone for ScrollBehavior

Source§

fn clone(&self) -> ScrollBehavior

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ScrollBehavior

Source§

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

Formats the value using the given formatter. Read more
Source§

impl PartialEq for ScrollBehavior

Source§

fn eq(&self, other: &ScrollBehavior) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for ScrollBehavior

Source§

impl StructuralPartialEq for ScrollBehavior

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> 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> 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> Same for T

Source§

type Output = T

Should always be Self
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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.