pub struct ScrollComponent { /* private fields */ }
Expand description
Logic for a scroll region
This struct handles some scroll logic. It does not provide scroll bars.
Implementations§
Source§impl ScrollComponent
impl ScrollComponent
Sourcepub fn is_gliding(&self) -> bool
pub fn is_gliding(&self) -> bool
True if momentum scrolling is active
Sourcepub fn max_offset(&self) -> Offset
pub fn max_offset(&self) -> Offset
Get the maximum offset
Note: the minimum offset is always zero.
Sourcepub fn offset(&self) -> Offset
pub fn offset(&self) -> Offset
Get the current offset
To translate a coordinate from the outer region to a coordinate of the scrolled region, add this offset.
Sourcepub fn set_sizes(&mut self, window_size: Size, content_size: Size) -> Action
pub fn set_sizes(&mut self, window_size: Size, content_size: Size) -> Action
Set sizes:
window_size
: size of scroll region on the outsidecontent_size
: size of scroll region on the inside (usually larger)
Like Self::set_offset
this generates a Action
due to potential
change in offset. In practice the caller will likely be performing all
required updates regardless and the return value can be safely ignored.
Sourcepub fn set_offset(&mut self, offset: Offset) -> Action
pub fn set_offset(&mut self, offset: Offset) -> Action
Set the scroll offset
The offset is clamped to the available scroll range.
Returns Action::empty()
if the offset is identical to the old offset,
or Action::REGION_MOVED
if the offset changes.
Also cancels any momentum scrolling, but only if offset
is not equal
to the current offset.
Sourcepub fn focus_rect(
&mut self,
cx: &mut EventCx<'_>,
rect: Rect,
window_rect: Rect,
) -> Action
pub fn focus_rect( &mut self, cx: &mut EventCx<'_>, rect: Rect, window_rect: Rect, ) -> Action
Scroll to make the given rect
visible
Inputs:
rect
: the rect to focus in child’s coordinate spacewindow_rect
: the rect of the scroll window
Sets Scroll::Rect
to ensure correct scrolling of parents.
Returns Action::REGION_MOVED
when the scroll offset changes.
Sourcepub fn scroll(
&mut self,
cx: &mut EventCx<'_>,
window_rect: Rect,
scroll: Scroll,
) -> Action
pub fn scroll( &mut self, cx: &mut EventCx<'_>, window_rect: Rect, scroll: Scroll, ) -> Action
Handle a Scroll
action
Sourcepub fn scroll_by_event(
&mut self,
cx: &mut EventCx<'_>,
event: Event,
id: Id,
window_rect: Rect,
) -> (bool, IsUsed)
pub fn scroll_by_event( &mut self, cx: &mut EventCx<'_>, event: Event, id: Id, window_rect: Rect, ) -> (bool, IsUsed)
Use an event to scroll, if possible
Consumes the following events: Command
, Scroll
, PressStart
,
PressMove
, PressEnd
, Timer(pl)
where pl == (1<<60) + 1
.
May request timer updates.
Implements scroll by Home/End, Page Up/Down and arrow keys, by mouse wheel and touchpad.
PressStart
is consumed only if the maximum scroll offset is non-zero
and event configuration enables panning for this press source
(may
depend on modifiers), and if so grabs press events from this source
.
PressMove
is used to scroll by the motion delta and to track speed;
PressEnd
initiates momentum-scrolling if the speed is high enough.
Returns (moved, is_used)
where moved
means this component
scrolled (scrolling of a parent is possible even if !moved
).
Trait Implementations§
Source§impl Clone for ScrollComponent
impl Clone for ScrollComponent
Source§fn clone(&self) -> ScrollComponent
fn clone(&self) -> ScrollComponent
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for ScrollComponent
impl Debug for ScrollComponent
Source§impl Default for ScrollComponent
impl Default for ScrollComponent
Source§fn default() -> ScrollComponent
fn default() -> ScrollComponent
Auto Trait Implementations§
impl Freeze for ScrollComponent
impl RefUnwindSafe for ScrollComponent
impl Send for ScrollComponent
impl Sync for ScrollComponent
impl Unpin for ScrollComponent
impl UnwindSafe for ScrollComponent
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian()
.