pub struct Core { /* private fields */ }
Expand description
Core system for scrolling views.
This is the lowest-level element handling scroll logic.
Higher-level abstractions are probably what you’re after.
In particular, see also ScrollView
.
Implementations
sourceimpl Core
impl Core
sourcepub fn sub_printer(&self, printer: &Printer<'a, 'b>) -> Printer<'a, 'b>
pub fn sub_printer(&self, printer: &Printer<'a, 'b>) -> Printer<'a, 'b>
Returns a sub-printer ready to draw the content.
sourcepub fn is_event_inside(&self, event: &mut Event) -> bool
pub fn is_event_inside(&self, event: &mut Event) -> bool
Returns true
if event
should be processed by the content.
This also updates event
so that it is relative to the content.
sourcepub fn needs_relayout(&self) -> bool
pub fn needs_relayout(&self) -> bool
Returns true
if we should relayout, no matter the content.
Even if this returns false
, the content itself might still needs to relayout.
sourcepub fn call_on_any<F>(
&mut self,
selector: &Selector<'_>,
cb: &'a mut (dyn FnMut(&mut (dyn View + 'static)) + 'a),
inner_call_on_any: F
)where
F: FnOnce(&Selector<'_>, &mut dyn FnMut(&mut (dyn View + 'static))),
pub fn call_on_any<F>(
&mut self,
selector: &Selector<'_>,
cb: &'a mut (dyn FnMut(&mut (dyn View + 'static)) + 'a),
inner_call_on_any: F
)where
F: FnOnce(&Selector<'_>, &mut dyn FnMut(&mut (dyn View + 'static))),
Performs View::call_on_any()
sourcepub fn focus_view<F>(
&mut self,
selector: &Selector<'_>,
inner_focus_view: F
) -> Result<(), ViewNotFound>where
F: FnOnce(&Selector<'_>) -> Result<(), ViewNotFound>,
pub fn focus_view<F>(
&mut self,
selector: &Selector<'_>,
inner_focus_view: F
) -> Result<(), ViewNotFound>where
F: FnOnce(&Selector<'_>) -> Result<(), ViewNotFound>,
Performs View::focus_view()
sourcepub fn content_viewport(&self) -> Rect
pub fn content_viewport(&self) -> Rect
Returns the viewport in the inner content.
sourcepub fn set_scroll_strategy(&mut self, strategy: ScrollStrategy)
pub fn set_scroll_strategy(&mut self, strategy: ScrollStrategy)
Defines the way scrolling is adjusted on content or size change.
The scroll strategy defines how the scrolling position is adjusted when the size of the view or the content change.
It is reset to ScrollStrategy::KeepRow
whenever the user scrolls
manually.
sourcepub fn scroll_strategy(self, strategy: ScrollStrategy) -> Core
pub fn scroll_strategy(self, strategy: ScrollStrategy) -> Core
Defines the way scrolling is adjusted on content or size change.
Chainable variant.
sourcepub fn set_scrollbar_padding<V>(&mut self, scrollbar_padding: V)where
V: Into<XY<usize>>,
pub fn set_scrollbar_padding<V>(&mut self, scrollbar_padding: V)where
V: Into<XY<usize>>,
Sets the padding between content and scrollbar.
sourcepub fn scrollbar_padding<V>(self, scrollbar_padding: V) -> Corewhere
V: Into<XY<usize>>,
pub fn scrollbar_padding<V>(self, scrollbar_padding: V) -> Corewhere
V: Into<XY<usize>>,
Sets the padding between content and scrollbar.
Chainable variant.
sourcepub fn get_scrollbar_padding(&self) -> XY<usize>
pub fn get_scrollbar_padding(&self) -> XY<usize>
Returns the padding between content and scrollbar.
sourcepub fn is_enabled(&self) -> XY<bool>
pub fn is_enabled(&self) -> XY<bool>
For each axis, returns true
if this view can scroll.
For example, a vertically-scrolling view will return
XY { x: false, y: true }
.
sourcepub fn set_show_scrollbars(&mut self, show_scrollbars: bool)
pub fn set_show_scrollbars(&mut self, show_scrollbars: bool)
Control whether scroll bars are visibile.
Defaults to true
.
sourcepub fn show_scrollbars(self, show_scrollbars: bool) -> Core
pub fn show_scrollbars(self, show_scrollbars: bool) -> Core
Control whether scroll bars are visibile.
Chainable variant
sourcepub fn get_show_scrollbars(&self) -> bool
pub fn get_show_scrollbars(&self) -> bool
Returns true
if we will show scrollbars when needed.
Scrollbars are always hidden when not needed.
sourcepub fn inner_size(&self) -> XY<usize>
pub fn inner_size(&self) -> XY<usize>
Returns the size given to the content on the last layout phase.
sourcepub fn set_offset<S>(&mut self, offset: S)where
S: Into<XY<usize>>,
pub fn set_offset<S>(&mut self, offset: S)where
S: Into<XY<usize>>,
Sets the scroll offset to the given value
sourcepub fn set_scroll_y(&mut self, enabled: bool)
pub fn set_scroll_y(&mut self, enabled: bool)
Controls whether this view can scroll vertically.
Defaults to true
.
sourcepub fn set_scroll_x(&mut self, enabled: bool)
pub fn set_scroll_x(&mut self, enabled: bool)
Controls whether this view can scroll horizontally.
Defaults to false
.
sourcepub fn scroll_y(self, enabled: bool) -> Core
pub fn scroll_y(self, enabled: bool) -> Core
Controls whether this view can scroll vertically.
Defaults to true
.
Chainable variant.
sourcepub fn scroll_x(self, enabled: bool) -> Core
pub fn scroll_x(self, enabled: bool) -> Core
Controls whether this view can scroll horizontally.
Defaults to false
.
Chainable variant.
sourcepub fn keep_in_view(&mut self, rect: Rect)
pub fn keep_in_view(&mut self, rect: Rect)
Try to keep the given rect
in view.
sourcepub fn scroll_to_rect(&mut self, important_area: Rect)
pub fn scroll_to_rect(&mut self, important_area: Rect)
Scrolls until the given rect is in view.
sourcepub fn scroll_to_x(&mut self, x: usize)
pub fn scroll_to_x(&mut self, x: usize)
Scroll until the given column is visible.
sourcepub fn scroll_to_y(&mut self, y: usize)
pub fn scroll_to_y(&mut self, y: usize)
Scroll until the given row is visible.
sourcepub fn scroll_left(&mut self, n: usize)
pub fn scroll_left(&mut self, n: usize)
Scroll by n
cells to the left.
sourcepub fn scroll_down(&mut self, n: usize)
pub fn scroll_down(&mut self, n: usize)
Scroll by n
cells to the bottom.
sourcepub fn scroll_right(&mut self, n: usize)
pub fn scroll_right(&mut self, n: usize)
Scroll by n
cells to the right.
sourcepub fn scroll_to_top(&mut self)
pub fn scroll_to_top(&mut self)
Programmatically scroll to the top of the view.
sourcepub fn scroll_to_bottom(&mut self)
pub fn scroll_to_bottom(&mut self)
Programmatically scroll to the bottom of the view.
sourcepub fn scroll_to_left(&mut self)
pub fn scroll_to_left(&mut self)
Programmatically scroll to the leftmost side of the view.
sourcepub fn scroll_to_right(&mut self)
pub fn scroll_to_right(&mut self)
Programmatically scroll to the rightmost side of the view.
sourcepub fn is_scrolling(&self) -> XY<bool>
pub fn is_scrolling(&self) -> XY<bool>
Returns for each axis if we are scrolling.
sourcepub fn release_grab(&mut self)
pub fn release_grab(&mut self)
Stops grabbing the scrollbar.
sourcepub fn scrollbar_size(&self) -> XY<usize>
pub fn scrollbar_size(&self) -> XY<usize>
Returns the size taken by the scrollbars.
Will be zero in axis where we’re not scrolling.
The scrollbar_size().x will be the horizontal space taken by the vertical scrollbar.
sourcepub fn last_available_size(&self) -> XY<usize>
pub fn last_available_size(&self) -> XY<usize>
Returns the last size available for the child view.
sourcepub fn last_outer_size(&self) -> XY<usize>
pub fn last_outer_size(&self) -> XY<usize>
Returns the last size given by layout
.
sourcepub fn can_scroll_up(&self) -> bool
pub fn can_scroll_up(&self) -> bool
Checks if we can scroll up.
Returns true
if vertical scrolling is enabled, and if we are not at
the top already.
sourcepub fn can_scroll_left(&self) -> bool
pub fn can_scroll_left(&self) -> bool
Checks if we can scroll to the left.
Returns true
if horizontal scrolling is enabled, and if we are not at
the left edge already.
sourcepub fn can_scroll_down(&self) -> bool
pub fn can_scroll_down(&self) -> bool
Checks if we can scroll down.
Returns true
if vertical scrolling is enabled, and if we are not at
the bottom already.
sourcepub fn can_scroll_right(&self) -> bool
pub fn can_scroll_right(&self) -> bool
Checks if we can scroll to the right.
Returns true
if horizontal scrolling is enabled, and if we are not at
the right edge already.
sourcepub fn start_drag(&mut self, position: XY<usize>) -> bool
pub fn start_drag(&mut self, position: XY<usize>) -> bool
Starts scrolling from the cursor position.
Returns true
if the event was consumed.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Core
impl Send for Core
impl Sync for Core
impl Unpin for Core
impl UnwindSafe for Core
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more