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: FocusFlag

Current focus state.

§area: Rect

Total area.

§inner: Rect

Area inside the border and scrollbars

§header_area: Rect

Total header area.

§table_area: Rect

Total 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.

§footer_area: Rect

Total footer area.

§rows: usize

Row count.

§_counted_rows: usize§columns: usize

Column count.

§vscroll: ScrollState

Row scrolling data.

§hscroll: ScrollState

Column scrolling data.

§selection: Selection

Selection data.

§mouse: MouseFlags

Helper for mouse interactions.

§non_exhaustive: NonExhaustive

Implementations§

source§

impl<Selection> FTableState<Selection>

source

pub fn rows(&self) -> usize

Number of rows.

source

pub fn columns(&self) -> usize

Number of columns.

source§

impl<Selection> FTableState<Selection>

source

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]

source

pub fn cell_at_clicked(&self, pos: (u16, u16)) -> Option<(usize, usize)>

Cell at given position.

source

pub fn column_at_clicked(&self, pos: (u16, u16)) -> Option<usize>

Column at given position.

source

pub fn row_at_clicked(&self, pos: (u16, u16)) -> Option<usize>

Row at given position.

source

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

source

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’.

source

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,

source

pub fn clear_offset(&mut self)

Sets both offsets to 0.

source

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.

source

pub fn row_offset(&self) -> usize

Current vertical offset.

source

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.

source

pub fn page_len(&self) -> usize

Vertical page-size at the current offset.

source

pub fn row_scroll_by(&self) -> usize

Suggested scroll per scroll-event.

source

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.

source

pub fn col_offset(&self) -> usize

Current horizontal offset.

source

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.

source

pub fn page_width(&self) -> usize

Horizontal page-size at the current offset.

source

pub fn col_scroll_by(&self) -> usize

Suggested scroll per scroll-event.

source

pub fn scroll_to_selected(&mut self) -> bool

Ensures that the selected item is visible.

source

pub fn scroll_to_row(&mut self, pos: usize) -> bool

Ensures that the given row is visible.

source

pub fn scroll_to_col(&mut self, pos: usize) -> bool

Ensures that the given column is visible.

source

pub fn scroll_up(&mut self, n: usize) -> bool

Reduce the row-offset by n.

source

pub fn scroll_down(&mut self, n: usize) -> bool

Increase the row-offset by n.

source

pub fn scroll_left(&mut self, n: usize) -> bool

Reduce the col-offset by n.

source

pub fn scroll_right(&mut self, n: usize) -> bool

Increase the col-offset by n.

source§

impl FTableState<RowSelection>

source

pub fn set_scroll_selection(&mut self, scroll: bool)

When scrolling the table, change the selection instead of the offset.

source

pub fn clear_selection(&mut self)

Clear the selection.

source

pub fn has_selection(&mut self) -> bool

Anything selected?

source

pub fn selected(&self) -> Option<usize>

Selected row.

source

pub fn select(&mut self, row: Option<usize>) -> bool

Select the row. Limits the value to the number of rows.

source

pub fn move_to(&mut self, row: usize) -> bool

Move the selection to the given row. Ensures the row is visible afterwards.

source

pub fn move_up(&mut self, n: usize) -> bool

Move the selection up n rows. Ensures the row is visible afterwards.

source

pub fn move_down(&mut self, n: usize) -> bool

Move the selection down n rows. Ensures the row is visible afterwards.

source§

impl FTableState<RowSetSelection>

source

pub fn clear_selection(&mut self)

Clear the selection.

source

pub fn has_selection(&mut self) -> bool

Anything selected?

source

pub fn selected(&self) -> HashSet<usize>

Selected rows.

source

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.

source

pub fn lead(&self) -> Option<usize>

Current lead.

source

pub fn anchor(&self) -> Option<usize>

Current anchor.

source

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.

source

pub fn add_selected(&mut self, idx: usize)

Add to selection. Only works for retired selections, not for the active anchor-lead range.

source

pub fn remove_selected(&mut self, idx: usize)

Remove from selection. Only works for retired selections, not for the active anchor-lead range.

source

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

pub fn move_up(&mut self, n: usize, extend: bool) -> bool

Move the selection up n rows. Ensures the row is visible afterwards.

source

pub fn move_down(&mut self, n: usize, extend: bool) -> bool

Move the selection down n rows. Ensures the row is visible afterwards.

source§

impl FTableState<CellSelection>

source

pub fn clear_selection(&mut self)

source

pub fn has_selection(&mut self) -> bool

source

pub fn selected(&self) -> Option<(usize, usize)>

Selected cell.

source

pub fn select_cell(&mut self, select: Option<(usize, usize)>) -> bool

Select a cell.

source

pub fn select_row(&mut self, row: Option<usize>) -> bool

Select a row. Column stays the same.

source

pub fn select_column(&mut self, column: Option<usize>) -> bool

Select a column, row stays the same.

source

pub fn move_to(&mut self, select: (usize, usize)) -> bool

Select a cell, limit to maximum.

source

pub fn move_to_row(&mut self, row: usize) -> bool

Select a row, limit to maximum.

source

pub fn move_to_col(&mut self, col: usize) -> bool

Select a cell, clamp between 0 and maximum.

source

pub fn move_up(&mut self, n: usize) -> bool

Move the selection up n rows. Ensures the row is visible afterwards.

source

pub fn move_down(&mut self, n: usize) -> bool

Move the selection down n rows. Ensures the row is visible afterwards.

source

pub fn move_left(&mut self, n: usize) -> bool

Move the selection left n columns. Ensures the row is visible afterwards.

source

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,

source§

fn clone(&self) -> FTableState<Selection>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<Selection> Debug for FTableState<Selection>
where Selection: Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl<Selection> Default for FTableState<Selection>
where Selection: Default,

source§

fn default() -> FTableState<Selection>

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

impl<Selection> HandleEvent<Event, DoubleClick, DoubleClickOutcome> for FTableState<Selection>

source§

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>
where Selection: TableSelection, FTableState<Selection>: HandleEvent<Event, FocusKeys, Outcome>,

source§

fn handle(&mut self, event: &Event, _keymap: EditKeys) -> EditOutcome

Handle an event. Read more
source§

impl HandleEvent<Event, FocusKeys, Outcome> for FTableState<CellSelection>

source§

fn handle(&mut self, event: &Event, _keymap: FocusKeys) -> Outcome

Handle an event. Read more
source§

impl HandleEvent<Event, FocusKeys, Outcome> for FTableState<NoSelection>

source§

fn handle(&mut self, event: &Event, _keymap: FocusKeys) -> Outcome

Handle an event. Read more
source§

impl HandleEvent<Event, FocusKeys, Outcome> for FTableState<RowSelection>

source§

fn handle(&mut self, event: &Event, _keymap: FocusKeys) -> Outcome

Handle an event. Read more
source§

impl HandleEvent<Event, FocusKeys, Outcome> for FTableState<RowSetSelection>

source§

fn handle(&mut self, event: &Event, _: FocusKeys) -> Outcome

Handle an event. Read more
source§

impl HandleEvent<Event, MouseOnly, Outcome> for FTableState<CellSelection>

source§

fn handle(&mut self, event: &Event, _keymap: MouseOnly) -> Outcome

Handle an event. Read more
source§

impl HandleEvent<Event, MouseOnly, Outcome> for FTableState<NoSelection>

source§

fn handle(&mut self, event: &Event, _keymap: MouseOnly) -> Outcome

Handle an event. Read more
source§

impl HandleEvent<Event, MouseOnly, Outcome> for FTableState<RowSelection>

source§

fn handle(&mut self, event: &Event, _keymap: MouseOnly) -> Outcome

Handle an event. Read more
source§

impl HandleEvent<Event, MouseOnly, Outcome> for FTableState<RowSetSelection>

source§

fn handle(&mut self, event: &Event, _: MouseOnly) -> Outcome

Handle an event. Read more
source§

impl<Selection> HasFocusFlag for FTableState<Selection>

source§

fn focus(&self) -> &FocusFlag

Access to the flag for the rest.
source§

fn area(&self) -> Rect

Access the area for mouse focus.
source§

fn z_areas(&self) -> &[ZRect]

The widget might have several disjointed areas. This is the case if it is showing a popup, but there might be other causes. Read more
source§

fn navigable(&self) -> bool

If the widget is focusable, but doesn’t want to partake in keyboard navigation it returns false here. Read more
source§

fn is_focused(&self) -> bool

Focused?
source§

fn lost_focus(&self) -> bool

Just lost focus.
source§

fn gained_focus(&self) -> bool

Just gained focus.

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.