Skip to main content

ScrollRegion

Struct ScrollRegion 

pub struct ScrollRegion { /* private fields */ }
Expand description

See the module docs.

Implementations§

§

impl ScrollRegion

pub fn new(axis: ScrollAxis) -> ScrollRegion

pub fn vertical() -> ScrollRegion

A region that scrolls up and down.

pub fn horizontal() -> ScrollRegion

A region that scrolls sideways.

pub fn with_persisted_offset(self, cell: Rc<Cell<(f32, f32)>>) -> ScrollRegion

Keep the offset in cell across rebuilds of the host; it is clamped to the content once both sizes are known.

pub fn with_edge_fade(self) -> ScrollRegion

Fade the content out at an edge more of it can scroll in from, like Scrollable::with_edge_fade.

pub fn set_viewport(&mut self, viewport: Rect, theme: &Theme)

The region’s rect (bar lanes included) for this layout, and the theme its lanes and steps come from.

pub fn set_content_size(&mut self, width: f64, height: f64)

How big the content is, in the host’s content coordinates.

pub fn overflows_vertically(&self) -> bool

Whether the content is taller than the region.

pub fn overflows_horizontally(&self) -> bool

Whether the content is wider than the region.

pub fn content_rect(&self) -> Rect

The part of the region the content shows in: the region less the bar lanes while the content overflows. Lay the content out to this width.

pub fn offset(&self) -> Vec2

The current offset (how far the content is scrolled).

pub fn scroll_by(&mut self, delta: Vec2) -> bool

Scroll by delta; returns whether the offset moved.

pub fn set_offset(&mut self, offset: Vec2)

Scroll to offset (clamped).

pub fn scroll_into_view(&mut self, rect: Rect)

Scroll the least that shows rect (in content coordinates).

pub fn content_transform(&self, transform: Affine) -> Affine

The transform the host draws its content with: the region’s own transform, moved to the content’s origin and by the offset.

pub fn to_content(&self, point: Point) -> Point

Where a point in the window falls in the content, for hit-testing.

pub fn visible_content(&self) -> Rect

The part of the content in view, in content coordinates (cull what lies outside it).

pub fn is_dragging(&self) -> bool

Whether a bar’s thumb is being dragged: the host keeps the pointer captured until it is released (Widget::wants_pointer_capture).

pub fn note_shown(&self, transform: Affine, theme: &Theme)

Note what the frame being drawn shows, for a host that clips and draws its content itself (with Self::paint_bars) and offers its scrolls as copies (Self::offer_copy); Self::paint notes it.

pub fn damage_changed_bars(&self, regions: &mut Vec<Rect>)

From the host’s collect_damage, on a frame whose content and offset are as on screen: add the bars’ tracks to regions when what the bars paint changed since the frame on screen (a thumb fading out or lighting up under the pointer). Without both frames noted, every track either knows is added.

pub fn offer_copy<T>(&self, owner: &T, regions: &mut Vec<Rect>) -> bool
where T: ?Sized,

From the host’s collect_damage, when nothing it paints in the region changed since the frame on screen but the offset: offer the scroll to a host that copies what stays on screen (crate::scroll_copy::offer), and add the bars’ tracks, where the thumbs moved, to regions. false when the host does not copy, or the frame shows the content in another clip or under another transform, or the offset did not move: the host then damages the region as it would without copies.

pub fn mark_presented(&mut self)

From the host’s mark_drawn: the frame just drawn is on screen. Not drawn this frame, the region’s content is not known to be there, and its next scroll repaints.

pub fn paint( &self, scene: &mut Scene, transform: Affine, theme: &Theme, draw: impl FnOnce(&mut Scene, Affine), )

Paint the content with draw (handed the scene and the content transform), clipped to the region, then the edge fades and the bars.

pub fn paint_bars(&self, scene: &mut Scene, transform: Affine, theme: &Theme)

Paint the bars alone, for a host that clips and draws its content itself.

pub fn needs_animation_frame(&self, theme: &Theme) -> bool

Whether the bar’s fade needs frames now.

pub fn next_wake_deadline(&self, theme: &Theme) -> Option<Instant>

When the bar starts to fade, for the host’s next_wake_deadline.

pub fn set_focused(&mut self, focused: bool)

Follow the host’s keyboard focus: a focused region scrolls with the keyboard and keeps its bar shown.

pub fn handle_event( &mut self, event: &WindowEvent, ctx: &mut EventCtx<'_>, theme: &Theme, ) -> bool

Wheel and touchpad scrolling over the region, dragging and paging with its bars, and Page Up/Down, Home/End and the arrows while the host holds focus. Marks the event handled when it scrolled. Returns whether the offset or the bars changed.

pub fn cancel_interaction(&mut self) -> bool

Retire a captured scrollbar gesture and its transient pointer feedback.

pub fn handle_window_event( &mut self, event: &WindowEvent, scale_factor: f64, modifiers: ModifiersState, handled: &mut bool, theme: &Theme, ) -> bool

The same input path for painted hosts without a retained widget tree.

pub fn primary_vertical_scroll(&self) -> Option<PrimaryScrollRegion>

The region as the host’s primary vertical scroll, for assistive technology and agents: forward Widget::primary_vertical_scroll.

pub fn apply_primary_vertical_scroll( &mut self, action: PrimaryScrollAction, ) -> PrimaryScrollResult

Apply an accessible scroll action: forward Widget::apply_primary_vertical_scroll.

Trait Implementations§

§

impl Debug for ScrollRegion

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. 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
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

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.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,