Skip to main content

TableVecState

Struct TableVecState 

Source
pub struct TableVecState<T, Selection = RowSelection> {
    pub table: TableState<Selection>,
    pub data: Vec<T>,
    pub non_exhaustive: NonExhaustive,
}
Expand description

State for TableVec.

Fields§

§table: TableState<Selection>§data: Vec<T>§non_exhaustive: NonExhaustive

Implementations§

Source§

impl<T, Selection> TableVecState<T, Selection>
where Selection: Default,

Source

pub fn new() -> TableVecState<T, Selection>

Source

pub fn named(name: &str) -> TableVecState<T, Selection>

Source

pub fn with( self, data: impl IntoIterator<Item = T>, ) -> TableVecState<T, Selection>

Populate the table-data.

Source§

impl<T, Selection> TableVecState<T, Selection>

Source

pub fn rows(&self) -> usize

Number of rows.

Source

pub fn columns(&self) -> usize

Number of columns.

Source§

impl<T, Selection> TableVecState<T, 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.

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<T, Selection> TableVecState<T, 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. The offset may be beyond the number of rows.

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

Source

pub fn x_offset(&self) -> usize

Current horizontal offset.

Source

pub fn set_x_offset(&mut self, offset: usize) -> bool

Change the horizontal offset. The offset may be beyond the table-width.

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 x_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. Caveat: This doesn’t work nicely if you have varying row-heights. Caveat: Number of rows needs to be correct.

Source

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. Caveat: Number of rows needs to be correct.

Source

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

Ensures that the given column is completely visible.

Source

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

Ensures that the given position 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<T, Selection> TableVecState<T, Selection>
where Selection: TableSelection,

Source

pub fn clear_selection(&mut self)

Clear the selection.

Source§

impl<T, Selection> TableVecState<T, Selection>
where Selection: TableSelection,

Source

pub fn clear(&mut self)

Clear

Source

pub fn rows_changed(&mut self)

Data-vec changed.

Source

pub fn set_value(&mut self, data: Vec<T>)

Set the data-vec.

Source

pub fn value(&self) -> &Vec<T>

Get the table data.

Source

pub fn append_row(&mut self, value: T)

Add a row to the internal data-vec.

Source

pub fn insert_row(&mut self, row: usize, value: T)

Insert a row to the internal data-vec.

Source

pub fn remove_row(&mut self, row: usize) -> T

Remove a row from the internal data-vec.

Source§

impl<T> TableVecState<T>

Source

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

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

Source

pub fn has_selection(&mut self) -> bool

Anything selected?

Source

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

Selected row. The selected row is not constrained by the row-count.

Source

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

Return the selected row and ensure it is in the range 0..rows.

Source

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

Select the row. The selection is not constrained by the row-count.

Source

pub fn move_deselect(&mut self) -> bool

Set the selection to None and set the offset to 0

Source

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

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

Source

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

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

Source

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

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

Source§

impl<T> TableVecState<T, RowSetSelection>

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.

To be sure call retire_selection first.

Source

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

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

To be sure call retire_selection first.

Source

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

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

Source

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

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

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<T> TableVecState<T, CellSelection>

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<T, Selection> Clone for TableVecState<T, Selection>
where T: Clone, Selection: Clone,

Source§

fn clone(&self) -> TableVecState<T, Selection>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T, Selection> Default for TableVecState<T, Selection>
where Selection: Default,

Source§

fn default() -> TableVecState<T, Selection>

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

impl<T, Selection> HandleEvent<Event, DoubleClick, DoubleClickOutcome> for TableVecState<T, Selection>

Source§

fn handle(&mut self, event: &Event, _keymap: DoubleClick) -> DoubleClickOutcome

Handles double-click events on the table.

Source§

impl<T> HandleEvent<Event, MouseOnly, TableOutcome> for TableVecState<T, CellSelection>

Source§

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

Handle an event. Read more
Source§

impl<T> HandleEvent<Event, MouseOnly, TableOutcome> for TableVecState<T, NoSelection>

Source§

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

Handle an event. Read more
Source§

impl<T> HandleEvent<Event, MouseOnly, TableOutcome> for TableVecState<T>

Source§

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

Handle an event. Read more
Source§

impl<T> HandleEvent<Event, MouseOnly, TableOutcome> for TableVecState<T, RowSetSelection>

Source§

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

Handle an event. Read more
Source§

impl<T> HandleEvent<Event, Regular, TableOutcome> for TableVecState<T, CellSelection>

Source§

fn handle(&mut self, event: &Event, _: Regular) -> TableOutcome

Handle an event. Read more
Source§

impl<T> HandleEvent<Event, Regular, TableOutcome> for TableVecState<T, NoSelection>

Source§

fn handle(&mut self, event: &Event, _: Regular) -> TableOutcome

Handle an event. Read more
Source§

impl<T> HandleEvent<Event, Regular, TableOutcome> for TableVecState<T>

Source§

fn handle(&mut self, event: &Event, _: Regular) -> TableOutcome

Handle an event. Read more
Source§

impl<T> HandleEvent<Event, Regular, TableOutcome> for TableVecState<T, RowSetSelection>

Source§

fn handle(&mut self, event: &Event, _: Regular) -> TableOutcome

Handle an event. Read more
Source§

impl<T, Selection> HasFocus for TableVecState<T, Selection>

Source§

fn build(&self, builder: &mut FocusBuilder)

Build the focus-structure for the container/widget.
Source§

fn focus(&self) -> FocusFlag

Access to the focus flag.
Source§

fn area(&self) -> Rect

Area for mouse focus. Read more
Source§

fn build_nav(&self, navigable: Navigation, builder: &mut FocusBuilder)

Build the focus-structure for the container/widget. Read more
Source§

fn id(&self) -> usize

Provide a unique id for the widget.
Source§

fn area_z(&self) -> u16

Z-value for the area. Read more
Source§

fn navigable(&self) -> Navigation

Declares how the widget interacts with focus. Read more
Source§

fn is_focused(&self) -> bool

Does this widget have the focus or if the flag is used for a container, does any of widgets inside the container have the focus. Read more
Source§

fn lost_focus(&self) -> bool

This widget just lost the focus. Read more
Source§

fn gained_focus(&self) -> bool

This widget just gained the focus. Read more
Source§

fn is_obscured(&self) -> bool

This widget is not beneath the mouse-cursor. Read more
Source§

impl<T, Selection> HasScreenCursor for TableVecState<T, Selection>

Source§

fn screen_cursor(&self) -> Option<(u16, u16)>

This returns the cursor position if Read more
Source§

impl<T, Selection> RelocatableState for TableVecState<T, Selection>

Source§

fn relocate(&mut self, shift: (i16, i16), clip: Rect)

Relocate the areas in this widgets state. Read more
Source§

fn relocate_popup(&mut self, shift: (i16, i16), clip: Rect)

Relocate only popup areas. As rendering the popups is a separate render, this has to be separate too.
Source§

fn relocate_popup_hidden(&mut self)

Relocate all popup areas to a clip-rect (0,0+0x0).
Source§

fn relocate_hidden(&mut self)

Relocate all areas to a clip-rect (0,0+0x0).

Auto Trait Implementations§

§

impl<T, Selection = RowSelection> !Freeze for TableVecState<T, Selection>

§

impl<T, Selection = RowSelection> !RefUnwindSafe for TableVecState<T, Selection>

§

impl<T, Selection = RowSelection> !Send for TableVecState<T, Selection>

§

impl<T, Selection = RowSelection> !Sync for TableVecState<T, Selection>

§

impl<T, Selection = RowSelection> !UnwindSafe for TableVecState<T, Selection>

§

impl<T, Selection> Forget for TableVecState<T, Selection>

§

impl<T, Selection> Move for TableVecState<T, Selection>

§

impl<T, Selection> Unpin for TableVecState<T, Selection>
where TableState<Selection>: Unpin, Vec<T>: Unpin,

§

impl<T, Selection> UnsafeUnpin for TableVecState<T, Selection>
where TableState<Selection>: UnsafeUnpin, Vec<T>: UnsafeUnpin,

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§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

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

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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,

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.