Struct rat_ftable::FTableState

source ·
pub struct FTableState<Selection> {
Show 19 fields pub area: 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 row_offset: usize, pub col_offset: usize, pub row_page_len: usize, pub col_page_len: usize, pub max_row_offset: usize, pub max_col_offset: usize, pub selection: Selection, pub mouse: MouseFlags, pub non_exhaustive: NonExhaustive,
}
Expand description

FTable state.

Fields§

§area: Rect

Total area.

§header_area: Rect

Total header area.

§table_area: Rect

Total table area.

§row_areas: Vec<Rect>

Area per visible row.

§column_areas: Vec<Rect>

Area per visible column, also contains the following spacer if any. Good for click-hit checks.

§base_column_areas: Vec<Rect>

Area for each defined column without the spacer. Columns not visible will have width 0.

§footer_area: Rect

Total footer area.

§rows: usize

Row count.

§_counted_rows: usize§columns: usize

Column count.

§row_offset: usize

Current row offset. Automatically capped at rows-1.

§col_offset: usize

Current column offset. Automatically capped at columns-1.

§row_page_len: usize

Current page len as items.

§col_page_len: usize

Current page width as columns.

§max_row_offset: usize

Maximum offset for row-scrolling. Can be set higher, but this offset guarantees a full page display.

§max_col_offset: usize

Maximum offset for column-scrolling. Can be set higher, but this offset guarantees a full page display.

§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

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: Position) -> Option<(usize, usize)>

Cell at given position.

source

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

Column at given position.

source

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

Row at given position.

source

pub fn cell_at_drag(&self, pos: Position) -> (usize, usize)

Cell when dragging. Can go outside the area.

source

pub fn row_at_drag(&self, pos: Position) -> usize

Row when dragging. Can go outside the area.

source

pub fn column_at_drag(&self, pos: Position) -> usize

Column when dragging. Can go outside the area.

source

pub fn clear_offset(&mut self)

Sets both offsets to 0.

source§

impl<Selection: TableSelection> FTableState<Selection>

source

pub fn scroll_to_selected(&mut self)

Scroll to selected.

source

pub fn scroll_to(&mut self, pos: (usize, usize))

Scroll to position.

source§

impl<Selection: TableSelection> FTableState<Selection>

source

pub fn vertical_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 vertical_offset(&self) -> usize

Current vertical offset.

source

pub fn vertical_page(&self) -> usize

Vertical page-size at the current offset.

source

pub fn vertical_scroll(&self) -> usize

Suggested scroll per scroll-event.

source

pub fn horizontal_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 horizontal_offset(&self) -> usize

Current horizontal offset.

source

pub fn horizontal_page(&self) -> usize

Horizontal page-size at the current offset.

source

pub fn horizontal_scroll(&self) -> usize

Suggested scroll per scroll-event.

source

pub fn set_vertical_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 set_horizontal_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 scroll_up(&mut self, n: usize) -> bool

Scroll up by n items. The widget returns true if the offset changed at all.

source

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

Scroll down by n items. The widget returns true if the offset changed at all.

source

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

Scroll up by n items. The widget returns true if the offset changed at all.

source

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

Scroll down by n items. The widget returns true if the offset changed at all.

source§

impl FTableState<RowSelection>

source

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

Scroll selection instead of offset.

source

pub fn scroll_selection(&self) -> bool

Scroll selection instead of offset.

source

pub fn clear(&mut self)

Clear offsets and selection.

source

pub fn clear_selection(&mut self)

source

pub fn has_selection(&mut self) -> bool

source

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

source

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

source

pub fn select_clamped(&mut self, select: usize, maximum: usize)

Select a row, clamp between 0 and maximum.

source§

impl FTableState<RowSetSelection>

source

pub fn clear(&mut self)

Clear offsets and selection.

source

pub fn clear_selection(&mut self)

Clear the selection.

source

pub fn has_selection(&mut self) -> bool

source

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

source

pub fn set_lead(&mut self, lead: Option<usize>, extend: bool)

source

pub fn set_lead_clamped(&mut self, lead: usize, max: usize, extend: bool)

Set a new lead, at the same time limit the lead to max.

source

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

Current lead.

source

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

Current anchor.

source

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

Add to selection.

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§

impl FTableState<CellSelection>

source

pub fn clear(&mut self)

Clear offsets and selection.

source

pub fn clear_selection(&mut self)

source

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

Selected cell.

source

pub fn has_selection(&mut self) -> bool

source

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

Select a cell.

source

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

Select a row. Column stays the same.

source

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

Select a column, row stays the same.

source

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

Select a cell, clamp between 0 and maximum.

Trait Implementations§

source§

impl<Selection: Clone> Clone for FTableState<Selection>

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> Debug for FTableState<Selection>

source§

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

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

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

source§

fn default() -> Self

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: TableSelection> HandleEvent<Event, EditKeys, EditOutcome> for FTableState<Selection>

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

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