Struct ScrollRegion
pub struct ScrollRegion { /* private fields */ }Expand description
See the module docs.
Implementations§
§impl ScrollRegion
impl ScrollRegion
pub fn new(axis: ScrollAxis) -> ScrollRegion
pub fn vertical() -> ScrollRegion
pub fn vertical() -> ScrollRegion
A region that scrolls up and down.
pub fn horizontal() -> ScrollRegion
pub fn horizontal() -> ScrollRegion
A region that scrolls sideways.
pub fn with_persisted_offset(self, cell: Rc<Cell<(f32, f32)>>) -> ScrollRegion
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
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)
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)
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
pub fn overflows_vertically(&self) -> bool
Whether the content is taller than the region.
pub fn overflows_horizontally(&self) -> bool
pub fn overflows_horizontally(&self) -> bool
Whether the content is wider than the region.
pub fn content_rect(&self) -> Rect
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 set_offset(&mut self, offset: Vec2)
pub fn set_offset(&mut self, offset: Vec2)
Scroll to offset (clamped).
pub fn scroll_into_view(&mut self, rect: Rect)
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
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
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
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
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)
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>)
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>) -> boolwhere
T: ?Sized,
pub fn offer_copy<T>(&self, owner: &T, regions: &mut Vec<Rect>) -> boolwhere
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)
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),
)
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)
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
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>
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)
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
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
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
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>
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
pub fn apply_primary_vertical_scroll( &mut self, action: PrimaryScrollAction, ) -> PrimaryScrollResult
Apply an accessible scroll action: forward
Widget::apply_primary_vertical_scroll.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ScrollRegion
impl !RefUnwindSafe for ScrollRegion
impl !Send for ScrollRegion
impl !Sync for ScrollRegion
impl Unpin for ScrollRegion
impl UnsafeUnpin for ScrollRegion
impl !UnwindSafe for ScrollRegion
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
§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.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 more