pub struct ScrollBase {
    pub start_line: usize,
    pub content_height: usize,
    pub view_height: usize,
    pub scrollbar_offset: usize,
    pub right_padding: usize,
    pub thumb_grab: Option<usize>,
}
👎Deprecated since 0.16.0:

ScrollBase is being deprecated in favor of the view::scroll module.

Expand description

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
👎Deprecated since 0.16.0:

ScrollBase is being deprecated in favor of the view::scroll module.

First line visible

content_height: usize
👎Deprecated since 0.16.0:

ScrollBase is being deprecated in favor of the view::scroll module.

Content height

view_height: usize
👎Deprecated since 0.16.0:

ScrollBase is being deprecated in favor of the view::scroll module.

Number of lines displayed

scrollbar_offset: usize
👎Deprecated since 0.16.0:

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
👎Deprecated since 0.16.0:

ScrollBase is being deprecated in favor of the view::scroll module.

Blank between the text and the scrollbar.

thumb_grab: Option<usize>
👎Deprecated since 0.16.0:

ScrollBase is being deprecated in favor of the view::scroll module.

Initial position of the cursor when dragging.

Implementations

Creates a new, uninitialized scrollbar.

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.

Sets the number of blank cells between the text and the scrollbar.

Defaults to 1.

Call this method whem the content or the view changes.

Returns TRUE if the view needs to scroll.

Returns TRUE unless we are at the top.

Returns TRUE unless we are at the bottom.

Scroll to the top of the view.

Makes sure that the given line is visible, scrolling if needed.

Scroll to the bottom of the view.

Scroll down by the given number of line.

Never further than the bottom of the view.

Scrolls down until the scrollbar thumb is at the given location.

Scroll up by the given number of lines.

Never above the top of the view.

Starts scrolling from the given cursor position.

Keeps scrolling by dragging the cursor.

Returns true if we are in the process of dragging the scroll thumb.

Stops grabbing the scrollbar.

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]);
});

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.

Returns the height of the scrollbar thumb.

Returns the y position of the scrollbar thumb.

Trait Implementations

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Calls the given closure and return the result. Read more

Calls the given closure on self.

Calls the given closure on self.

Calls the given closure if condition == true.