Struct rat_widget::table::FTableState
source · pub struct FTableState<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 base_column_areas: 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
FTable 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 per visible column, also contains the following spacer if any. The first element is at col_offset. Height is the height of the table_area.
base_column_areas: Vec<Rect>Area for each defined column without the spacer. Invisible columns have width 0. Height is the height of the table_area.
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> FTableState<Selection>
impl<Selection> FTableState<Selection>
source§impl<Selection> FTableState<Selection>
impl<Selection> FTableState<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.
See: [FTableState::scroll_to]
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> FTableState<Selection>where
Selection: TableSelection,
impl<Selection> FTableState<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 col_max_offset(&self) -> usize
pub fn col_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 col_offset(&self) -> usize
pub fn col_offset(&self) -> usize
Current horizontal offset.
sourcepub fn set_col_offset(&mut self, offset: usize) -> bool
pub fn set_col_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 col_scroll_by(&self) -> usize
pub fn col_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.
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.
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 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 FTableState<RowSelection>
impl FTableState<RowSelection>
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 select(&mut self, row: Option<usize>) -> bool
pub fn select(&mut self, row: Option<usize>) -> bool
Select the row. Limits the value to the number of rows.
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 FTableState<RowSetSelection>
impl FTableState<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 FTableState<CellSelection>
impl FTableState<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 FTableState<Selection>where
Selection: Clone,
impl<Selection> Clone for FTableState<Selection>where
Selection: Clone,
source§fn clone(&self) -> FTableState<Selection>
fn clone(&self) -> FTableState<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 FTableState<Selection>where
Selection: Debug,
impl<Selection> Debug for FTableState<Selection>where
Selection: Debug,
source§impl<Selection> Default for FTableState<Selection>where
Selection: Default,
impl<Selection> Default for FTableState<Selection>where
Selection: Default,
source§fn default() -> FTableState<Selection>
fn default() -> FTableState<Selection>
source§impl<Selection> HandleEvent<Event, DoubleClick, DoubleClickOutcome> for FTableState<Selection>
impl<Selection> HandleEvent<Event, DoubleClick, DoubleClickOutcome> for FTableState<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 FTableState<Selection>
impl<Selection> HandleEvent<Event, EditKeys, EditOutcome> for FTableState<Selection>
source§impl HandleEvent<Event, FocusKeys, Outcome> for FTableState<CellSelection>
impl HandleEvent<Event, FocusKeys, Outcome> for FTableState<CellSelection>
source§impl HandleEvent<Event, FocusKeys, Outcome> for FTableState<NoSelection>
impl HandleEvent<Event, FocusKeys, Outcome> for FTableState<NoSelection>
source§impl HandleEvent<Event, FocusKeys, Outcome> for FTableState<RowSelection>
impl HandleEvent<Event, FocusKeys, Outcome> for FTableState<RowSelection>
source§impl HandleEvent<Event, FocusKeys, Outcome> for FTableState<RowSetSelection>
impl HandleEvent<Event, FocusKeys, Outcome> for FTableState<RowSetSelection>
source§impl HandleEvent<Event, MouseOnly, Outcome> for FTableState<CellSelection>
impl HandleEvent<Event, MouseOnly, Outcome> for FTableState<CellSelection>
source§impl HandleEvent<Event, MouseOnly, Outcome> for FTableState<NoSelection>
impl HandleEvent<Event, MouseOnly, Outcome> for FTableState<NoSelection>
source§impl HandleEvent<Event, MouseOnly, Outcome> for FTableState<RowSelection>
impl HandleEvent<Event, MouseOnly, Outcome> for FTableState<RowSelection>
source§impl HandleEvent<Event, MouseOnly, Outcome> for FTableState<RowSetSelection>
impl HandleEvent<Event, MouseOnly, Outcome> for FTableState<RowSetSelection>
source§impl<Selection> HasFocusFlag for FTableState<Selection>
impl<Selection> HasFocusFlag for FTableState<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 FTableState<Selection>
impl<Selection> !RefUnwindSafe for FTableState<Selection>
impl<Selection> Send for FTableState<Selection>where
Selection: Send,
impl<Selection> !Sync for FTableState<Selection>
impl<Selection> Unpin for FTableState<Selection>where
Selection: Unpin,
impl<Selection> UnwindSafe for FTableState<Selection>where
Selection: UnwindSafe,
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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default 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