pub trait RowViewer<R>: 'static {
Show 23 methods
// Required methods
fn num_columns(&mut self) -> usize;
fn show_cell_view(&mut self, ui: &mut Ui, row: &R, column: usize);
fn show_cell_editor(
&mut self,
ui: &mut Ui,
row: &mut R,
column: usize,
) -> Option<Response>;
fn set_cell_value(&mut self, src: &R, dst: &mut R, column: usize);
fn new_empty_row(&mut self) -> R;
// Provided methods
fn column_name(&mut self, column: usize) -> Cow<'static, str> { ... }
fn try_create_codec(
&mut self,
is_encoding: bool,
) -> Option<impl RowCodec<R>> { ... }
fn column_render_config(&mut self, column: usize) -> TableColumnConfig { ... }
fn is_sortable_column(&mut self, column: usize) -> bool { ... }
fn compare_cell(&self, row_a: &R, row_b: &R, column: usize) -> Ordering { ... }
fn row_filter_hash(&mut self) -> &impl Hash { ... }
fn filter_row(&mut self, row: &R) -> bool { ... }
fn on_cell_view_response(
&mut self,
row: &R,
column: usize,
resp: &Response,
) -> Option<Box<R>> { ... }
fn confirm_cell_write_by_ui(
&mut self,
current: &R,
next: &R,
column: usize,
context: CellWriteContext,
) -> bool { ... }
fn confirm_row_deletion_by_ui(&mut self, row: &R) -> bool { ... }
fn new_empty_row_for(&mut self, context: EmptyRowCreateContext) -> R { ... }
fn clone_row(&mut self, row: &R) -> R { ... }
fn clone_row_for_insertion(&mut self, row: &R) -> R { ... }
fn clone_row_as_copied_base(&mut self, row: &R) -> R { ... }
fn on_highlight_cell(&mut self, row: &R, column: usize) { ... }
fn hotkeys(
&mut self,
context: &UiActionContext,
) -> Vec<(KeyboardShortcut, UiAction)> { ... }
fn trivial_config(&mut self) -> TrivialConfig { ... }
fn persist_ui_state(&self) -> bool { ... }
}
Expand description
The primary trait for the spreadsheet viewer.
Required Methods§
Sourcefn num_columns(&mut self) -> usize
fn num_columns(&mut self) -> usize
Number of columns. Changing this will invalidate the table rendering status totally(including undo histories), therefore frequently changing this value is discouraged.
Sourcefn show_cell_view(&mut self, ui: &mut Ui, row: &R, column: usize)
fn show_cell_view(&mut self, ui: &mut Ui, row: &R, column: usize)
Display values of the cell. Any input will be consumed before table renderer; therefore any widget rendered inside here is read-only.
To deal with input, use cell_edit
method. If you need to deal with drag/drop,
see RowViewer::on_cell_view_response
which delivers resulting response of
containing cell.
Sourcefn show_cell_editor(
&mut self,
ui: &mut Ui,
row: &mut R,
column: usize,
) -> Option<Response>
fn show_cell_editor( &mut self, ui: &mut Ui, row: &mut R, column: usize, ) -> Option<Response>
Edit values of the cell.
Sourcefn set_cell_value(&mut self, src: &R, dst: &mut R, column: usize)
fn set_cell_value(&mut self, src: &R, dst: &mut R, column: usize)
Set the value of a column in a row.
Sourcefn new_empty_row(&mut self) -> R
fn new_empty_row(&mut self) -> R
Create a new empty row.
Provided Methods§
Sourcefn column_name(&mut self, column: usize) -> Cow<'static, str>
fn column_name(&mut self, column: usize) -> Cow<'static, str>
Name of the column. This can be dynamically changed.
Sourcefn try_create_codec(&mut self, is_encoding: bool) -> Option<impl RowCodec<R>>
fn try_create_codec(&mut self, is_encoding: bool) -> Option<impl RowCodec<R>>
Tries to create a codec for the row (de)serialization. If this returns Some
, it’ll use
the system clipboard for copy/paste operations.
is_encoding
parameter is provided to determine if we’re creating the codec as encoding
mode or decoding mode.
It is just okay to choose not to implement both encoding and decoding; returning None
conditionally based on is_encoding
parameter is also valid. It is guaranteed that created
codec will be used only for the same mode during its lifetime.
Sourcefn column_render_config(&mut self, column: usize) -> TableColumnConfig
fn column_render_config(&mut self, column: usize) -> TableColumnConfig
Returns the rendering configuration for the column.
Sourcefn is_sortable_column(&mut self, column: usize) -> bool
fn is_sortable_column(&mut self, column: usize) -> bool
Returns if given column is ‘sortable’
Sourcefn compare_cell(&self, row_a: &R, row_b: &R, column: usize) -> Ordering
fn compare_cell(&self, row_a: &R, row_b: &R, column: usize) -> Ordering
Compare two column contents for sort.
Sourcefn row_filter_hash(&mut self) -> &impl Hash
fn row_filter_hash(&mut self) -> &impl Hash
Get hash value of a filter. This is used to determine if the filter has changed.
Sourcefn filter_row(&mut self, row: &R) -> bool
fn filter_row(&mut self, row: &R) -> bool
Filter single row. If this returns false, the row will be hidden.
Sourcefn on_cell_view_response(
&mut self,
row: &R,
column: usize,
resp: &Response,
) -> Option<Box<R>>
fn on_cell_view_response( &mut self, row: &R, column: usize, resp: &Response, ) -> Option<Box<R>>
Use this to check if given cell is going to take any dropped payload / use as drag source.
Sourcefn confirm_cell_write_by_ui(
&mut self,
current: &R,
next: &R,
column: usize,
context: CellWriteContext,
) -> bool
fn confirm_cell_write_by_ui( &mut self, current: &R, next: &R, column: usize, context: CellWriteContext, ) -> bool
In the write context that happens outside of show_cell_editor
, this method is
called on every cell value editions.
Sourcefn confirm_row_deletion_by_ui(&mut self, row: &R) -> bool
fn confirm_row_deletion_by_ui(&mut self, row: &R) -> bool
Before removing each row, this method is called to confirm the deletion from the viewer. This won’t be called during the undo/redo operation!
Sourcefn new_empty_row_for(&mut self, context: EmptyRowCreateContext) -> R
fn new_empty_row_for(&mut self, context: EmptyRowCreateContext) -> R
Create a new empty row under the given context.
Sourcefn clone_row(&mut self, row: &R) -> R
fn clone_row(&mut self, row: &R) -> R
Create duplication of existing row.
You may want to override this method for more efficient duplication.
Sourcefn clone_row_for_insertion(&mut self, row: &R) -> R
fn clone_row_for_insertion(&mut self, row: &R) -> R
Create duplication of existing row for insertion.
Sourcefn clone_row_as_copied_base(&mut self, row: &R) -> R
fn clone_row_as_copied_base(&mut self, row: &R) -> R
Create duplication of existing row for clipboard. Useful when you need to specify different behavior for clipboard duplication. (e.g. unset transient flag)
Sourcefn on_highlight_cell(&mut self, row: &R, column: usize)
fn on_highlight_cell(&mut self, row: &R, column: usize)
Called when a cell is selected/highlighted.
Sourcefn hotkeys(
&mut self,
context: &UiActionContext,
) -> Vec<(KeyboardShortcut, UiAction)>
fn hotkeys( &mut self, context: &UiActionContext, ) -> Vec<(KeyboardShortcut, UiAction)>
Return hotkeys for the current context.
Sourcefn trivial_config(&mut self) -> TrivialConfig
fn trivial_config(&mut self) -> TrivialConfig
Get trivial configurations for renderer.
Sourcefn persist_ui_state(&self) -> bool
fn persist_ui_state(&self) -> bool
If you want to keep UI state on storage(i.e. persist over sessions), return true from this function.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.