pub struct ListView<'t, T> {
pub area: Area,
pub skin: &'t MadSkin,
/* private fields */
}
Expand description
A filterable list whose columns can be automatically resized.
Notes:
- another version will allow more than one style per cell (i.e. make the cells composites rather than compounds). Shout out if you need that now.
- this version doesn’t allow cell wrapping
Fields§
§area: Area
§skin: &'t MadSkin
Implementations§
source§impl<'t, T> ListView<'t, T>
impl<'t, T> ListView<'t, T>
sourcepub fn new(
area: Area,
columns: Vec<ListViewColumn<'t, T>>,
skin: &'t MadSkin,
) -> Self
pub fn new( area: Area, columns: Vec<ListViewColumn<'t, T>>, skin: &'t MadSkin, ) -> Self
Create a new list view with the passed columns.
The columns can’t be changed afterwards but the area can be modified. When two columns have the same title, those titles are merged (but the columns below stay separated).
sourcepub const fn tbody_height(&self) -> u16
pub const fn tbody_height(&self) -> u16
return the height which is available for rows
sourcepub fn scrollbar(&self) -> Option<(u16, u16)>
pub fn scrollbar(&self) -> Option<(u16, u16)>
return an option which when filled contains a tupple with the top and bottom of the vertical scrollbar. Return none when the content fits the available space.
pub fn add_row(&mut self, data: T)
sourcepub fn clear_rows(&mut self)
pub fn clear_rows(&mut self)
remove all rows (and selection).
Keep the columns and the sort function, if any.
sourcepub fn row_counts(&self) -> (usize, usize)
pub fn row_counts(&self) -> (usize, usize)
return both the number of displayed rows and the total number
sourcepub fn update_dimensions(&mut self)
pub fn update_dimensions(&mut self)
recompute the widths of all columns. This should be called when the area size is modified
pub fn set_filter(&mut self, filter: Box<dyn Fn(&T) -> bool>)
pub fn remove_filter(&mut self)
sourcepub fn write_on<W>(&self, w: &mut W) -> Result<(), Error>where
W: Write,
pub fn write_on<W>(&self, w: &mut W) -> Result<(), Error>where
W: Write,
write the list view on the given writer
sourcepub const fn do_scroll_show_bottom(&self) -> bool
pub const fn do_scroll_show_bottom(&self) -> bool
return true if the last line of the list is visible
sourcepub fn scroll_to_bottom(&mut self)
pub fn scroll_to_bottom(&mut self)
ensure the last line is visible
sourcepub fn try_scroll_lines(&mut self, lines_count: i32)
pub fn try_scroll_lines(&mut self, lines_count: i32)
set the scroll amount. lines_count can be negative
sourcepub fn try_scroll_pages(&mut self, pages_count: i32)
pub fn try_scroll_pages(&mut self, pages_count: i32)
set the scroll amount. pages_count can be negative
sourcepub fn try_select_next(&mut self, up: bool)
pub fn try_select_next(&mut self, up: bool)
try to select the next visible line
sourcepub fn select_first_line(&mut self)
pub fn select_first_line(&mut self)
select the first visible line (unless there’s nothing).
sourcepub fn select_last_line(&mut self)
pub fn select_last_line(&mut self)
select the last visible line (unless there’s nothing).
sourcepub fn make_selection_visible(&mut self)
pub fn make_selection_visible(&mut self)
scroll to ensure the selected line (if any) is visible.
This is automatically called by try_scroll and try select functions