Struct AutoScroll

Source
pub struct AutoScroll {
    pub scroll_offset: f32,
    pub enabled: bool,
    pub distance_from_min: f32,
    pub distance_from_max: f32,
    pub max_speed: f32,
}
Expand description

Handles automatic scrolling when dragging items near the edges of the table’s view.

The AutoScroll struct allows the table to automatically scroll when the user drags items near the top or bottom edge of the view. It provides configurable parameters such as the speed of scrolling and the distances from the edges at which scrolling is triggered.

Fields§

§scroll_offset: f32

The current vertical scroll offset.

§enabled: bool

Whether auto-scrolling is enabled or disabled.

§distance_from_min: f32

The minimum distance from the top edge before auto-scrolling starts. Extra space due to the header being in the way. Default: 200.0

§distance_from_max: f32

The minimum distance from the bottom edge before auto-scrolling starts. Default: 120.0

§max_speed: f32

The maximum speed at which auto-scrolling occurs. Default: 30.0

Implementations§

Source§

impl AutoScroll

Source

pub fn new(enabled: bool) -> Self

Creates a new instance of AutoScroll with the option to enable or disable auto-scrolling.

§Parameters:
  • enabled: Whether auto-scrolling should be enabled.
§Example:
let auto_scroll = AutoScroll::new(true); // Enables auto-scrolling
Source

pub const fn distance_from_min(self, distance: f32) -> Self

Sets the minimum distance from the top edge at which auto-scrolling is triggered.

§Parameters:
  • distance: The distance from the top edge in pixels.
§Returns:

An updated instance of AutoScroll with the specified distance_from_min value.

§Considerations:
  • Add some extra distance due to the header being in the way of selection
§Example:
let auto_scroll = AutoScroll::new(true).distance_from_min(100.0); // Auto-scrolls when 100 pixels from top
Source

pub const fn distance_from_max(self, distance: f32) -> Self

Sets the minimum distance from the bottom edge at which auto-scrolling is triggered.

§Parameters:
  • distance: The distance from the bottom edge in pixels.
§Returns:

An updated instance of AutoScroll with the specified distance_from_max value.

§Example:
let auto_scroll = AutoScroll::new(true).distance_from_max(80.0); // Auto-scrolls when 80 pixels from bottom
Source

pub const fn max_speed(self, speed: f32) -> Self

Sets the maximum scroll speed when auto-scrolling is triggered.

§Parameters:
  • speed: The maximum scroll speed
§Returns:

An updated instance of AutoScroll with the specified max_speed.

§Example:
let auto_scroll = AutoScroll::new(true).max_speed(50.0); // Sets the max scroll speed to 50.0

Trait Implementations§

Source§

impl Default for AutoScroll

Source§

fn default() -> Self

Returns the “default value” for a type. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.