Struct rat_widget::table::TableState
source · pub struct TableState<Selection> {Show 17 fields
pub focus: FocusFlag,
pub area: Rect,
pub inner: Rect,
pub header_area: Rect,
pub table_area: Rect,
pub row_areas: Vec<Rect>,
pub column_areas: Vec<Rect>,
pub column_layout: Vec<Rect>,
pub footer_area: Rect,
pub rows: usize,
pub _counted_rows: usize,
pub columns: usize,
pub vscroll: ScrollState,
pub hscroll: ScrollState,
pub selection: Selection,
pub mouse: MouseFlags,
pub non_exhaustive: NonExhaustive,
}Expand description
Table state.
Fields§
§focus: FocusFlagCurrent focus state.
area: RectTotal area.
inner: RectArea inside the border and scrollbars
header_area: RectTotal header area.
table_area: RectTotal table area.
row_areas: Vec<Rect>Area per visible row. The first element is at row_offset.
column_areas: Vec<Rect>Area for each column plus the following spacer if any. Invisible columns have width 0, height is the height of the table_area.
column_layout: Vec<Rect>Layout areas for each column plus the following spacer if any. Positions are 0-based, y and height are 0.
Total footer area.
rows: usizeRow count.
_counted_rows: usize§columns: usizeColumn count.
vscroll: ScrollStateRow scrolling data.
hscroll: ScrollStateColumn scrolling data.
selection: SelectionSelection data.
mouse: MouseFlagsHelper for mouse interactions.
non_exhaustive: NonExhaustiveImplementations§
source§impl<Selection> TableState<Selection>where
Selection: Default,
impl<Selection> TableState<Selection>where
Selection: Default,
pub fn new() -> TableState<Selection>
pub fn named(name: &str) -> TableState<Selection>
source§impl<Selection> TableState<Selection>
impl<Selection> TableState<Selection>
source§impl<Selection> TableState<Selection>
impl<Selection> TableState<Selection>
sourcepub fn row_cells(&self, row: usize) -> Option<(Rect, Vec<Rect>)>
pub fn row_cells(&self, row: usize) -> Option<(Rect, Vec<Rect>)>
Returns the whole row-area and the cell-areas for the given row, if it is visible.
Attention: These areas might be 0-length if the column is scrolled beyond the table-area.
sourcepub fn cell_at_clicked(&self, pos: (u16, u16)) -> Option<(usize, usize)>
pub fn cell_at_clicked(&self, pos: (u16, u16)) -> Option<(usize, usize)>
Cell at given position.
sourcepub fn cell_at_drag(&self, pos: (u16, u16)) -> (usize, usize)
pub fn cell_at_drag(&self, pos: (u16, u16)) -> (usize, usize)
Cell when dragging. Position can be outside the table area. See row_at_drag, col_at_drag
sourcepub fn row_at_drag(&self, pos: (u16, u16)) -> usize
pub fn row_at_drag(&self, pos: (u16, u16)) -> usize
Row when dragging. Position can be outside the table area. If the position is above the table-area this returns offset - #rows. If the position is below the table-area this returns offset + page_len + #rows.
This doesn’t account for the row-height of the actual rows outside the table area, just assumes ‘1’.
sourcepub fn column_at_drag(&self, pos: (u16, u16)) -> usize
pub fn column_at_drag(&self, pos: (u16, u16)) -> usize
Column when dragging. Position can be outside the table area. If the position is left of the table area this returns offset - 1. If the position is right of the table area this returns offset + page_width + 1.
source§impl<Selection> TableState<Selection>where
Selection: TableSelection,
impl<Selection> TableState<Selection>where
Selection: TableSelection,
sourcepub fn clear_offset(&mut self)
pub fn clear_offset(&mut self)
Sets both offsets to 0.
sourcepub fn row_max_offset(&self) -> usize
pub fn row_max_offset(&self) -> usize
Maximum offset that is accessible with scrolling.
This is shorter than the length by whatever fills the last page. This is the base for the scrollbar content_length.
sourcepub fn row_offset(&self) -> usize
pub fn row_offset(&self) -> usize
Current vertical offset.
sourcepub fn set_row_offset(&mut self, offset: usize) -> bool
pub fn set_row_offset(&mut self, offset: usize) -> bool
Change the vertical offset.
Due to overscroll it’s possible that this is an invalid offset for the widget. The widget must deal with this situation.
The widget returns true if the offset changed at all.
sourcepub fn row_scroll_by(&self) -> usize
pub fn row_scroll_by(&self) -> usize
Suggested scroll per scroll-event.
sourcepub fn x_max_offset(&self) -> usize
pub fn x_max_offset(&self) -> usize
Maximum offset that is accessible with scrolling.
This is shorter than the length of the content by whatever fills the last page. This is the base for the scrollbar content_length.
sourcepub fn set_x_offset(&mut self, offset: usize) -> bool
pub fn set_x_offset(&mut self, offset: usize) -> bool
Change the horizontal offset.
Due to overscroll it’s possible that this is an invalid offset for the widget. The widget must deal with this situation.
The widget returns true if the offset changed at all.
sourcepub fn page_width(&self) -> usize
pub fn page_width(&self) -> usize
Horizontal page-size at the current offset.
sourcepub fn x_scroll_by(&self) -> usize
pub fn x_scroll_by(&self) -> usize
Suggested scroll per scroll-event.
sourcepub fn scroll_to_selected(&mut self) -> bool
pub fn scroll_to_selected(&mut self) -> bool
Ensures that the selected item is visible. Caveat: This doesn’t work nicely if you have varying row-heights.
sourcepub fn scroll_to_row(&mut self, pos: usize) -> bool
pub fn scroll_to_row(&mut self, pos: usize) -> bool
Ensures that the given row is visible. Caveat: This doesn’t work nicely if you have varying row-heights.
sourcepub fn scroll_to_col(&mut self, pos: usize) -> bool
pub fn scroll_to_col(&mut self, pos: usize) -> bool
Ensures that the given column is completely visible.
sourcepub fn scroll_to_x(&mut self, pos: usize) -> bool
pub fn scroll_to_x(&mut self, pos: usize) -> bool
Ensures that the given cell is visible.
sourcepub fn scroll_down(&mut self, n: usize) -> bool
pub fn scroll_down(&mut self, n: usize) -> bool
Increase the row-offset by n.
sourcepub fn scroll_left(&mut self, n: usize) -> bool
pub fn scroll_left(&mut self, n: usize) -> bool
Reduce the col-offset by n.
sourcepub fn scroll_right(&mut self, n: usize) -> bool
pub fn scroll_right(&mut self, n: usize) -> bool
Increase the col-offset by n.
source§impl TableState<RowSelection>
impl TableState<RowSelection>
sourcepub fn items_added(&mut self, pos: usize, n: usize)
pub fn items_added(&mut self, pos: usize, n: usize)
Update the state to match adding items. This corrects the number of rows, offset and selection.
sourcepub fn items_removed(&mut self, pos: usize, n: usize)
pub fn items_removed(&mut self, pos: usize, n: usize)
Update the state to match removing items. This corrects the number of rows, offset and selection.
sourcepub fn set_scroll_selection(&mut self, scroll: bool)
pub fn set_scroll_selection(&mut self, scroll: bool)
When scrolling the table, change the selection instead of the offset.
sourcepub fn clear_selection(&mut self)
pub fn clear_selection(&mut self)
Clear the selection.
sourcepub fn has_selection(&mut self) -> bool
pub fn has_selection(&mut self) -> bool
Anything selected?
sourcepub fn move_to(&mut self, row: usize) -> bool
pub fn move_to(&mut self, row: usize) -> bool
Move the selection to the given row. Ensures the row is visible afterwards.
source§impl TableState<RowSetSelection>
impl TableState<RowSetSelection>
sourcepub fn clear_selection(&mut self)
pub fn clear_selection(&mut self)
Clear the selection.
sourcepub fn has_selection(&mut self) -> bool
pub fn has_selection(&mut self) -> bool
Anything selected?
sourcepub fn set_lead(&mut self, row: Option<usize>, extend: bool) -> bool
pub fn set_lead(&mut self, row: Option<usize>, extend: bool) -> bool
Change the lead-selection. Limits the value to the number of rows.
If extend is false the current selection is cleared and both lead and
anchor are set to the given value.
If extend is true, the anchor is kept where it is and lead is changed.
Everything in the range anchor..lead is selected. It doesn’t matter
if anchor < lead.
sourcepub fn retire_selection(&mut self)
pub fn retire_selection(&mut self)
Retire the current anchor/lead selection to the set of selected rows. Resets lead and anchor and starts a new selection round.
sourcepub fn add_selected(&mut self, idx: usize)
pub fn add_selected(&mut self, idx: usize)
Add to selection. Only works for retired selections, not for the active anchor-lead range.
sourcepub fn remove_selected(&mut self, idx: usize)
pub fn remove_selected(&mut self, idx: usize)
Remove from selection. Only works for retired selections, not for the active anchor-lead range.
sourcepub fn move_to(&mut self, row: usize, extend: bool) -> bool
pub fn move_to(&mut self, row: usize, extend: bool) -> bool
Move the selection to the given row. Ensures the row is visible afterwards.
source§impl TableState<CellSelection>
impl TableState<CellSelection>
pub fn clear_selection(&mut self)
pub fn has_selection(&mut self) -> bool
sourcepub fn select_row(&mut self, row: Option<usize>) -> bool
pub fn select_row(&mut self, row: Option<usize>) -> bool
Select a row. Column stays the same.
sourcepub fn select_column(&mut self, column: Option<usize>) -> bool
pub fn select_column(&mut self, column: Option<usize>) -> bool
Select a column, row stays the same.
sourcepub fn move_to_row(&mut self, row: usize) -> bool
pub fn move_to_row(&mut self, row: usize) -> bool
Select a row, limit to maximum.
sourcepub fn move_to_col(&mut self, col: usize) -> bool
pub fn move_to_col(&mut self, col: usize) -> bool
Select a cell, clamp between 0 and maximum.
sourcepub fn move_up(&mut self, n: usize) -> bool
pub fn move_up(&mut self, n: usize) -> bool
Move the selection up n rows. Ensures the row is visible afterwards.
sourcepub fn move_down(&mut self, n: usize) -> bool
pub fn move_down(&mut self, n: usize) -> bool
Move the selection down n rows. Ensures the row is visible afterwards.
sourcepub fn move_left(&mut self, n: usize) -> bool
pub fn move_left(&mut self, n: usize) -> bool
Move the selection left n columns. Ensures the row is visible afterwards.
sourcepub fn move_right(&mut self, n: usize) -> bool
pub fn move_right(&mut self, n: usize) -> bool
Move the selection right n columns. Ensures the row is visible afterwards.
Trait Implementations§
source§impl<Selection> Clone for TableState<Selection>where
Selection: Clone,
impl<Selection> Clone for TableState<Selection>where
Selection: Clone,
source§fn clone(&self) -> TableState<Selection>
fn clone(&self) -> TableState<Selection>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl<Selection> Debug for TableState<Selection>where
Selection: Debug,
impl<Selection> Debug for TableState<Selection>where
Selection: Debug,
source§impl<Selection> Default for TableState<Selection>where
Selection: Default,
impl<Selection> Default for TableState<Selection>where
Selection: Default,
source§fn default() -> TableState<Selection>
fn default() -> TableState<Selection>
source§impl<Selection> HandleEvent<Event, DoubleClick, DoubleClickOutcome> for TableState<Selection>
impl<Selection> HandleEvent<Event, DoubleClick, DoubleClickOutcome> for TableState<Selection>
source§fn handle(&mut self, event: &Event, _keymap: DoubleClick) -> DoubleClickOutcome
fn handle(&mut self, event: &Event, _keymap: DoubleClick) -> DoubleClickOutcome
Handles double-click events on the table.
source§impl<Selection> HandleEvent<Event, EditKeys, EditOutcome> for TableState<Selection>
impl<Selection> HandleEvent<Event, EditKeys, EditOutcome> for TableState<Selection>
source§impl HandleEvent<Event, MouseOnly, Outcome> for TableState<CellSelection>
impl HandleEvent<Event, MouseOnly, Outcome> for TableState<CellSelection>
source§impl HandleEvent<Event, MouseOnly, Outcome> for TableState<NoSelection>
impl HandleEvent<Event, MouseOnly, Outcome> for TableState<NoSelection>
source§impl HandleEvent<Event, MouseOnly, Outcome> for TableState<RowSelection>
impl HandleEvent<Event, MouseOnly, Outcome> for TableState<RowSelection>
source§impl HandleEvent<Event, MouseOnly, Outcome> for TableState<RowSetSelection>
impl HandleEvent<Event, MouseOnly, Outcome> for TableState<RowSetSelection>
source§impl HandleEvent<Event, Regular, Outcome> for TableState<CellSelection>
impl HandleEvent<Event, Regular, Outcome> for TableState<CellSelection>
source§impl HandleEvent<Event, Regular, Outcome> for TableState<NoSelection>
impl HandleEvent<Event, Regular, Outcome> for TableState<NoSelection>
source§impl HandleEvent<Event, Regular, Outcome> for TableState<RowSelection>
impl HandleEvent<Event, Regular, Outcome> for TableState<RowSelection>
source§impl HandleEvent<Event, Regular, Outcome> for TableState<RowSetSelection>
impl HandleEvent<Event, Regular, Outcome> for TableState<RowSetSelection>
source§impl<Selection> HasFocusFlag for TableState<Selection>
impl<Selection> HasFocusFlag for TableState<Selection>
source§fn z_areas(&self) -> &[ZRect]
fn z_areas(&self) -> &[ZRect]
source§fn is_focused(&self) -> bool
fn is_focused(&self) -> bool
source§fn lost_focus(&self) -> bool
fn lost_focus(&self) -> bool
source§fn gained_focus(&self) -> bool
fn gained_focus(&self) -> bool
Auto Trait Implementations§
impl<Selection> !Freeze for TableState<Selection>
impl<Selection> !RefUnwindSafe for TableState<Selection>
impl<Selection> !Send for TableState<Selection>
impl<Selection> !Sync for TableState<Selection>
impl<Selection> Unpin for TableState<Selection>where
Selection: Unpin,
impl<Selection> !UnwindSafe for TableState<Selection>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more