Struct cursive::view::ScrollBase [−][src]
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>,
}
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
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
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.
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
Returns the “default value” for a type. Read more