pub struct ScrollbarDrag {
pub axis: ScrollbarAxis,
pub grab_offset: f32,
}Expand description
Pointer-relative state retained while dragging one scrollbar thumb.
§Examples
use ailloli_ui_core::ScrollbarAxis;
assert_eq!(format!("{:?}", ScrollbarAxis::Horizontal), "Horizontal");Fields§
§axis: ScrollbarAxisAxis captured when the drag began.
grab_offset: f32Logical-pixel distance from the thumb start to the pressed point.
Implementations§
Source§impl ScrollbarDrag
impl ScrollbarDrag
Sourcepub fn target_offset(self, point: Point, geometry: ScrollbarGeometry) -> f32
pub fn target_offset(self, point: Point, geometry: ScrollbarGeometry) -> f32
Maps the current pointer position to a clamped logical content offset.
A geometry for another axis or a track with no thumb travel returns zero. Movement outside the track is accepted and clamped.
§Examples
use ailloli_ui_core::{Point, Rect, ScrollMetrics, ScrollState, ScrollbarAxis, ScrollbarGeometrySpec, Size};
let geometry = ScrollbarGeometrySpec::new(
ScrollbarAxis::Horizontal,
Rect::new(0.0, 0.0, 100.0, 60.0),
ScrollMetrics::new(Size::new(100.0, 60.0), Size::new(300.0, 60.0)),
ScrollState::new(),
).resolve().unwrap();
let drag = geometry.begin_drag(Point::new(geometry.thumb.x, geometry.thumb.y)).unwrap();
assert_eq!(drag.target_offset(Point::new(10_000.0, 0.0), geometry), geometry.max_offset);Trait Implementations§
Source§impl Clone for ScrollbarDrag
impl Clone for ScrollbarDrag
Source§fn clone(&self) -> ScrollbarDrag
fn clone(&self) -> ScrollbarDrag
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ScrollbarDrag
impl Debug for ScrollbarDrag
Source§impl PartialEq for ScrollbarDrag
impl PartialEq for ScrollbarDrag
impl Copy for ScrollbarDrag
impl StructuralPartialEq for ScrollbarDrag
Auto Trait Implementations§
impl Freeze for ScrollbarDrag
impl RefUnwindSafe for ScrollbarDrag
impl Send for ScrollbarDrag
impl Sync for ScrollbarDrag
impl Unpin for ScrollbarDrag
impl UnwindSafe for ScrollbarDrag
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
Mutably borrows from an owned value. Read more