Struct kas_core::event::components::ScrollComponent
source · 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 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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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.§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.§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.§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.