pub struct ArrayView<T, H> { /* private fields */ }Expand description
View to display a 2D array with row and column headers.
Implementations§
Source§impl<T, H> ArrayView<T, H>
impl<T, H> ArrayView<T, H>
Sourcepub fn set_items_stable(&mut self, items: Vec<T>)
pub fn set_items_stable(&mut self, items: Vec<T>)
Sets the contained items of the array.
The current selection will be preserved when possible.
(But this is only available for T: PartialEq.)
Source§impl<T, H> ArrayView<T, H>
impl<T, H> ArrayView<T, H>
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new empty ArrayView without any columns.
An ArrayView should be accompanied by an enum of type H representing
the array columns.
Sourcepub fn row_header<C: FnOnce(ArrayRowHeader) -> ArrayRowHeader>(
self,
callback: C,
) -> Self
pub fn row_header<C: FnOnce(ArrayRowHeader) -> ArrayRowHeader>( self, callback: C, ) -> Self
Configures the row header column.
Row header values are read from ArrayViewItem::to_row.
The top-left corner text is set via ArrayView::array_name.
Chainable variant.
Sourcepub fn array_name<S: Into<String>>(self, name: S) -> Self
pub fn array_name<S: Into<String>>(self, name: S) -> Self
Sets the text shown in the top-left corner.
Chainable variant.
Sourcepub fn set_array_name<S: Into<String>>(&mut self, name: S)
pub fn set_array_name<S: Into<String>>(&mut self, name: S)
Sets the text shown in the top-left corner.
Sourcepub fn set_row_header<C: FnOnce(ArrayRowHeader) -> ArrayRowHeader>(
&mut self,
callback: C,
)
pub fn set_row_header<C: FnOnce(ArrayRowHeader) -> ArrayRowHeader>( &mut self, callback: C, )
Configures the row header column.
Row header values are read from ArrayViewItem::to_row.
The top-left corner text is set via ArrayView::array_name.
Sourcepub fn column<S: Into<String>, C: FnOnce(TableColumn<H>) -> TableColumn<H>>(
self,
column: H,
title: S,
callback: C,
) -> Self
pub fn column<S: Into<String>, C: FnOnce(TableColumn<H>) -> TableColumn<H>>( self, column: H, title: S, callback: C, ) -> Self
Adds a column for the specified array column from type H along with
a title for its visual display.
The provided callback can be used to further configure the
created TableColumn.
Sourcepub fn add_column<S: Into<String>, C: FnOnce(TableColumn<H>) -> TableColumn<H>>(
&mut self,
column: H,
title: S,
callback: C,
)
pub fn add_column<S: Into<String>, C: FnOnce(TableColumn<H>) -> TableColumn<H>>( &mut self, column: H, title: S, callback: C, )
Adds a column for the specified array column from type H along with
a title for its visual display.
The provided callback can be used to further configure the
created TableColumn.
Sourcepub fn remove_column(&mut self, i: usize)
pub fn remove_column(&mut self, i: usize)
Remove a column.
Sourcepub fn insert_column<S: Into<String>, C: FnOnce(TableColumn<H>) -> TableColumn<H>>(
&mut self,
i: usize,
column: H,
title: S,
callback: C,
)
pub fn insert_column<S: Into<String>, C: FnOnce(TableColumn<H>) -> TableColumn<H>>( &mut self, i: usize, column: H, title: S, callback: C, )
Adds a column for the specified array column from type H along with
a title for its visual display.
The provided callback can be used to further configure the
created TableColumn.
Sourcepub fn set_enabled(&mut self, enabled: bool)
pub fn set_enabled(&mut self, enabled: bool)
Enable or disable this view.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Returns true if this view is enabled.
Sourcepub fn set_on_submit<F>(&mut self, cb: F)
pub fn set_on_submit<F>(&mut self, cb: F)
Sets a callback to be used when <Enter> is pressed while a cell
is selected.
Both the currently selected row and column will be given to the callback.
§Example
array.set_on_submit(|_siv: &mut Cursive, _row: usize, _column: ArrayColumn| {
});Sourcepub fn on_submit<F>(self, cb: F) -> Self
pub fn on_submit<F>(self, cb: F) -> Self
Sets a callback to be used when <Enter> is pressed while a cell
is selected.
Chainable variant.
§Example
let _array = array.on_submit(|_siv: &mut Cursive, _row: usize, _column: ArrayColumn| {});Sourcepub fn set_on_select<F>(&mut self, cb: F)
pub fn set_on_select<F>(&mut self, cb: F)
Sets a callback to be used when a cell is selected.
Both the currently selected row and column will be given to the callback.
§Example
array.set_on_select(|_siv: &mut Cursive, _row: usize, _column: ArrayColumn| {
});Sourcepub fn on_select<F>(self, cb: F) -> Self
pub fn on_select<F>(self, cb: F) -> Self
Sets a callback to be used when a cell is selected.
Chainable variant.
§Example
let _array = array.on_select(|_siv: &mut Cursive, _row: usize, _column: ArrayColumn| {});Sourcepub fn set_selected_row(&mut self, row_index: usize)
pub fn set_selected_row(&mut self, row_index: usize)
Selects the row at the specified index.
Sourcepub fn selected_row(self, row_index: usize) -> Self
pub fn selected_row(self, row_index: usize) -> Self
Selects the row at the specified index.
Chainable variant.
Sourcepub fn items(self, items: Vec<T>) -> Self
pub fn items(self, items: Vec<T>) -> Self
Sets the contained items of the array.
Chainable variant.
Sourcepub fn borrow_item(&self, index: usize) -> Option<&T>
pub fn borrow_item(&self, index: usize) -> Option<&T>
Returns an immutable reference to the item at the specified index within the underlying storage vector.
Sourcepub fn borrow_item_mut(&mut self, index: usize) -> Option<&mut T>
pub fn borrow_item_mut(&mut self, index: usize) -> Option<&mut T>
Returns a mutable reference to the item at the specified index within the underlying storage vector.
Sourcepub fn borrow_items(&self) -> &[T]
pub fn borrow_items(&self) -> &[T]
Returns an immutable reference to the items contained within the array.
Sourcepub fn borrow_items_mut(&mut self) -> &mut [T]
pub fn borrow_items_mut(&mut self) -> &mut [T]
Returns a mutable reference to the items contained within the array.
Can be used to modify the items in place.
Sourcepub fn item(&self) -> Option<usize>
pub fn item(&self) -> Option<usize>
Returns the index of the currently selected item within the underlying storage vector.
Sourcepub fn set_selected_item(&mut self, item_index: usize)
pub fn set_selected_item(&mut self, item_index: usize)
Selects the item at the specified index within the underlying storage vector.
Sourcepub fn selected_item(self, item_index: usize) -> Self
pub fn selected_item(self, item_index: usize) -> Self
Selects the item at the specified index within the underlying storage vector.
Chainable variant.
Sourcepub fn insert_item(&mut self, item: T)
pub fn insert_item(&mut self, item: T)
Inserts a new item into the array.
The item will be added to the end of the array.
Sourcepub fn insert_item_at(&mut self, index: usize, item: T)
pub fn insert_item_at(&mut self, index: usize, item: T)
Inserts a new item into the array.
The item will be inserted at the given index.
§Panics
If index > self.len().
Sourcepub fn remove_item(&mut self, item_index: usize) -> Option<T>
pub fn remove_item(&mut self, item_index: usize) -> Option<T>
Removes the item at the specified index within the underlying storage vector and returns it.
Sourcepub fn take_items(&mut self) -> Vec<T>
pub fn take_items(&mut self) -> Vec<T>
Removes all items from the underlying storage and returns them.
Trait Implementations§
Source§impl<T, H> Default for ArrayView<T, H>
impl<T, H> Default for ArrayView<T, H>
Source§fn default() -> Self
fn default() -> Self
Creates a new empty ArrayView without any columns.
See ArrayView::new().
Source§impl<T, H> Scroller for ArrayView<T, H>
impl<T, H> Scroller for ArrayView<T, H>
Source§fn get_scroller_mut(&mut self) -> &mut Core
fn get_scroller_mut(&mut self) -> &mut Core
Source§fn get_scroller(&self) -> &Core
fn get_scroller(&self) -> &Core
Source§impl<T, H> View for ArrayView<T, H>
impl<T, H> View for ArrayView<T, H>
Source§fn required_size(&mut self, req: Vec2) -> Vec2
fn required_size(&mut self, req: Vec2) -> Vec2
Source§fn draw(&self, printer: &Printer<'_, '_>)
fn draw(&self, printer: &Printer<'_, '_>)
Source§fn layout(&mut self, size: Vec2)
fn layout(&mut self, size: Vec2)
Source§fn take_focus(&mut self, _: Direction) -> Result<EventResult, CannotFocus>
fn take_focus(&mut self, _: Direction) -> Result<EventResult, CannotFocus>
Source§fn on_event(&mut self, event: Event) -> EventResult
fn on_event(&mut self, event: Event) -> EventResult
Source§fn important_area(&self, size: Vec2) -> Rect
fn important_area(&self, size: Vec2) -> Rect
Source§fn needs_relayout(&self) -> bool
fn needs_relayout(&self) -> bool
Source§fn call_on_any(
&mut self,
_: &Selector<'_>,
_: &mut dyn FnMut(&mut (dyn View + 'static)),
)
fn call_on_any( &mut self, _: &Selector<'_>, _: &mut dyn FnMut(&mut (dyn View + 'static)), )
Source§fn focus_view(&mut self, _: &Selector<'_>) -> Result<EventResult, ViewNotFound>
fn focus_view(&mut self, _: &Selector<'_>) -> Result<EventResult, ViewNotFound>
Auto Trait Implementations§
impl<T, H> Freeze for ArrayView<T, H>
impl<T, H> !RefUnwindSafe for ArrayView<T, H>
impl<T, H> Send for ArrayView<T, H>
impl<T, H> Sync for ArrayView<T, H>
impl<T, H> Unpin for ArrayView<T, H>
impl<T, H> !UnwindSafe for ArrayView<T, H>
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> Finder for Twhere
T: View,
impl<T> Finder for Twhere
T: View,
Source§fn call_on_all<V, F>(&mut self, sel: &Selector<'_>, callback: F)
fn call_on_all<V, F>(&mut self, sel: &Selector<'_>, callback: F)
sel. Read moreSource§fn call_on<V, F, R>(&mut self, sel: &Selector<'_>, callback: F) -> Option<R>
fn call_on<V, F, R>(&mut self, sel: &Selector<'_>, callback: F) -> Option<R>
sel. Read moreSource§fn call_on_name<V, F, R>(&mut self, name: &str, callback: F) -> Option<R>
fn call_on_name<V, F, R>(&mut self, name: &str, callback: F) -> Option<R>
call_on with a view::Selector::Name.Source§impl<T> IntoBoxedView for Twhere
T: View,
impl<T> IntoBoxedView for Twhere
T: View,
Source§fn into_boxed_view(self) -> Box<dyn View>
fn into_boxed_view(self) -> Box<dyn View>
Box<View>.Source§impl<T> Resizable for Twhere
T: View,
impl<T> Resizable for Twhere
T: View,
Source§fn resized(
self,
width: SizeConstraint,
height: SizeConstraint,
) -> ResizedView<Self>
fn resized( self, width: SizeConstraint, height: SizeConstraint, ) -> ResizedView<Self>
self in a ResizedView with the given size constraints.Source§fn fixed_size<S>(self, size: S) -> ResizedView<Self>
fn fixed_size<S>(self, size: S) -> ResizedView<Self>
self into a fixed-size ResizedView.Source§fn fixed_width(self, width: usize) -> ResizedView<Self>
fn fixed_width(self, width: usize) -> ResizedView<Self>
self into a fixed-width ResizedView.Source§fn fixed_height(self, height: usize) -> ResizedView<Self>
fn fixed_height(self, height: usize) -> ResizedView<Self>
self into a fixed-width ResizedView.Source§fn full_screen(self) -> ResizedView<Self>
fn full_screen(self) -> ResizedView<Self>
self into a full-screen ResizedView.Source§fn full_width(self) -> ResizedView<Self>
fn full_width(self) -> ResizedView<Self>
self into a full-width ResizedView.Source§fn full_height(self) -> ResizedView<Self>
fn full_height(self) -> ResizedView<Self>
self into a full-height ResizedView.Source§fn max_size<S>(self, size: S) -> ResizedView<Self>
fn max_size<S>(self, size: S) -> ResizedView<Self>
self into a limited-size ResizedView.Source§fn max_width(self, max_width: usize) -> ResizedView<Self>
fn max_width(self, max_width: usize) -> ResizedView<Self>
self into a limited-width ResizedView.Source§fn max_height(self, max_height: usize) -> ResizedView<Self>
fn max_height(self, max_height: usize) -> ResizedView<Self>
self into a limited-height ResizedView.Source§fn min_size<S>(self, size: S) -> ResizedView<Self>
fn min_size<S>(self, size: S) -> ResizedView<Self>
self into a ResizedView at least sized size.Source§fn min_width(self, min_width: usize) -> ResizedView<Self>
fn min_width(self, min_width: usize) -> ResizedView<Self>
self in a ResizedView at least min_width wide.Source§fn min_height(self, min_height: usize) -> ResizedView<Self>
fn min_height(self, min_height: usize) -> ResizedView<Self>
self in a ResizedView at least min_height tall.Source§impl<T> Scrollable for Twhere
T: View,
impl<T> Scrollable for Twhere
T: View,
Source§fn scrollable(self) -> ScrollView<Self>
fn scrollable(self) -> ScrollView<Self>
self in a ScrollView.