pub struct DragTrack {
pub inset: f32,
pub mirrored: bool,
pub mode: DragMode,
}Expand description
Where a drag lands along a widget that takes one: see Widget::drag_track.
Fields§
§inset: f32How far in from each end the travel starts, in logical pixels.
mirrored: boolWhether the travel runs from the right in a right-to-left reading direction.
mode: DragModeHow a press and a slide move the value (milestone 650).
Implementations§
Source§impl DragTrack
impl DragTrack
Sourcepub const WHOLE: Self
pub const WHOLE: Self
The whole width, left to right, following the pointer: what a widget with no opinion answers.
Sourcepub fn fraction(self, rect: Rect, x: f32, rtl: bool) -> f32
pub fn fraction(self, rect: Rect, x: f32, rtl: bool) -> f32
Where x falls along rect’s travel, as a fraction 0..=1, for a reading
direction that is right to left when rtl.
One function, used by a drag’s start, every move and its end alike: three copies of this arithmetic would agree on every slider until one of them did not.
Sourcepub fn engages(self, rect: Rect, x: f32, rtl: bool) -> bool
pub fn engages(self, rect: Rect, x: f32, rtl: bool) -> bool
Whether a press at x starts anything at all: always, but for
DragMode::SlideThumb, which wants the press on its thumb.
Sourcepub fn value_at(
self,
rect: Rect,
press_x: f32,
x: f32,
moved: bool,
rtl: bool,
) -> Option<f32>
pub fn value_at( self, rect: Rect, press_x: f32, x: f32, moved: bool, rtl: bool, ) -> Option<f32>
The value a drag pressed at press_x and now at x stands for, as a fraction of
the travel; None when this moment changes nothing. moved is false for the
press itself and true for every movement after it — and for the release, which
is where the slide ended.
A slide that started from the value moves it by the pointer’s movement, as the reference’s does, so a thumb grabbed off its centre does not jump to the pointer.
Sourcepub fn pick_thumb(
self,
rect: Rect,
press_x: f32,
dx: f32,
rtl: bool,
) -> Option<usize>
pub fn pick_thumb( self, rect: Rect, press_x: f32, dx: f32, rtl: bool, ) -> Option<usize>
Which thumb a press at press_x takes on a DragMode::Thumbs track, 0 for
the start and 1 for the end, the movement since the press being dx — the
reference’s _defaultRangeThumbSelector. The nearer thumb, unless the press is on
both, when the first movement decides: towards the start takes the start. None
while that is undecided, or on a track without thumbs.