[−][src]Struct cursive::view::ScrollBase
ScrollBase
is being deprecated in favor of the view::scroll module.
Provide scrolling functionalities to a view.
This is a legacy helper utility to define scrollable views.
The scroll
module is the preferred way to achieve that.
Fields
start_line: usize
ScrollBase
is being deprecated in favor of the view::scroll module.
First line visible
content_height: usize
ScrollBase
is being deprecated in favor of the view::scroll module.
Content height
view_height: usize
ScrollBase
is being deprecated in favor of the view::scroll module.
Number of lines displayed
scrollbar_offset: usize
ScrollBase
is being deprecated in favor of the view::scroll module.
Padding for the scrollbar
If present, the scrollbar will be shifted
scrollbar_offset
columns to the left.
(Useful when each item includes its own side borders, to draw the scrollbar inside.)
right_padding: usize
ScrollBase
is being deprecated in favor of the view::scroll module.
Blank between the text and the scrollbar.
thumb_grab: Option<usize>
ScrollBase
is being deprecated in favor of the view::scroll module.
Initial position of the cursor when dragging.
Implementations
impl ScrollBase
[src]
pub fn new() -> ScrollBase
[src]
Creates a new, uninitialized scrollbar.
pub fn scrollbar_offset(self, offset: usize) -> ScrollBase
[src]
Shifts the scrollbar toward the inside of the view.
Used by views that draw their side borders in the children. Pushing the scrollbar to the left allows it to stay inside the borders.
pub fn right_padding(self, padding: usize) -> ScrollBase
[src]
Sets the number of blank cells between the text and the scrollbar.
Defaults to 1.
pub fn set_heights(&mut self, view_height: usize, content_height: usize)
[src]
Call this method whem the content or the view changes.
pub fn scrollable(&self) -> bool
[src]
Returns TRUE
if the view needs to scroll.
pub fn can_scroll_up(&self) -> bool
[src]
Returns TRUE
unless we are at the top.
pub fn can_scroll_down(&self) -> bool
[src]
Returns TRUE
unless we are at the bottom.
pub fn scroll_top(&mut self)
[src]
Scroll to the top of the view.
pub fn scroll_to(&mut self, y: usize)
[src]
Makes sure that the given line is visible, scrolling if needed.
pub fn scroll_bottom(&mut self)
[src]
Scroll to the bottom of the view.
pub fn scroll_down(&mut self, n: usize)
[src]
Scroll down by the given number of line.
Never further than the bottom of the view.
pub fn scroll_to_thumb(&mut self, thumb_y: usize, thumb_height: usize)
[src]
Scrolls down until the scrollbar thumb is at the given location.
pub fn scroll_up(&mut self, n: usize)
[src]
Scroll up by the given number of lines.
Never above the top of the view.
pub fn start_drag(&mut self, position: XY<usize>, width: usize) -> bool
[src]
Starts scrolling from the given cursor position.
pub fn drag(&mut self, position: XY<usize>)
[src]
Keeps scrolling by dragging the cursor.
pub fn is_dragging(&self) -> bool
[src]
Returns true
if we are in the process of dragging the scroll thumb.
pub fn release_grab(&mut self)
[src]
Stops grabbing the scrollbar.
pub fn draw<F>(&self, printer: &Printer<'_, '_>, line_drawer: F) where
F: Fn(&Printer<'_, '_>, usize),
[src]
F: Fn(&Printer<'_, '_>, usize),
Draws the scroll bar and the content using the given drawer.
line_drawer
will be called once for each line that needs to be drawn.
It will be given the absolute ID of the item to draw..
It will also be given a printer with the correct offset,
so it should only print on the first line.
Examples
let lines = ["Line 1", "Line number 2"]; scrollbase.draw(printer, |printer, i| { printer.print((0, 0), lines[i]); });
pub fn scrollbar_x(&self, total_size: usize) -> usize
[src]
Returns the X position of the scrollbar, given the size available.
Note that this does not depend whether or not a scrollbar will actually be present.
pub fn scrollbar_thumb_height(&self) -> usize
[src]
Returns the height of the scrollbar thumb.
pub fn scrollbar_thumb_y(&self, scrollbar_thumb_height: usize) -> usize
[src]
Returns the y position of the scrollbar thumb.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for ScrollBase
[src]
impl Send for ScrollBase
[src]
impl Sync for ScrollBase
[src]
impl Unpin for ScrollBase
[src]
impl UnwindSafe for ScrollBase
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Erased for T
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> With for T
[src]
pub fn wrap_with<U, F>(self, f: F) -> U where
F: FnOnce(Self) -> U,
[src]
F: FnOnce(Self) -> U,
pub fn with<F>(self, f: F) -> Self where
F: FnOnce(&mut Self),
[src]
F: FnOnce(&mut Self),
pub fn try_with<E, F>(self, f: F) -> Result<Self, E> where
F: FnOnce(&mut Self) -> Result<(), E>,
[src]
F: FnOnce(&mut Self) -> Result<(), E>,
pub fn with_if<F>(self, condition: bool, f: F) -> Self where
F: FnOnce(&mut Self),
[src]
F: FnOnce(&mut Self),