Struct ColumnDef
pub struct ColumnDef<Row> {Show 19 fields
pub key: String,
pub header: String,
pub width: ColumnWidth,
pub min_width: f32,
pub sortable: bool,
pub text_render: Option<Box<dyn Fn(&Row, &mut Scene, Affine, &mut TextRenderer, Rect, &Theme, CellState) + Send + Sync>>,
pub render_cell: Box<dyn Fn(&Row, &mut Scene, Affine, &Theme, &mut TextRenderer, Rect) + Send + Sync>,
pub widget: Option<Box<dyn FnMut(&Row, usize) -> Box<dyn Widget>>>,
pub reveal_on_hover: bool,
pub accessible_value: Option<Arc<dyn Fn(&Row) -> String + Send + Sync>>,
pub text: Option<Arc<dyn Fn(&Row) -> Option<String> + Send + Sync>>,
pub kind: TextKind,
pub absent: String,
pub max_lines: usize,
pub priority: u8,
pub badge: Option<Arc<dyn Fn(&Row) -> (String, Tone) + Send + Sync>>,
pub checked: Option<Arc<dyn Fn(&Row) -> bool + Send + Sync>>,
pub align: Option<CellAlign>,
pub compare: Option<Arc<dyn Fn(&Row, &Row) -> Ordering + Send + Sync>>,
/* private fields */
}Fields§
§key: String§header: String§width: ColumnWidth§min_width: f32Smallest readable width before optional columns hide or the table scrolls.
sortable: bool§text_render: Option<Box<dyn Fn(&Row, &mut Scene, Affine, &mut TextRenderer, Rect, &Theme, CellState) + Send + Sync>>None renders an empty cell.
render_cell: Box<dyn Fn(&Row, &mut Scene, Affine, &Theme, &mut TextRenderer, Rect) + Send + Sync>No-op by default; set via ColumnDef::with_render.
widget: Option<Box<dyn FnMut(&Row, usize) -> Box<dyn Widget>>>None by default; set via ColumnDef::with_widget.
reveal_on_hover: boolThe column’s widgets are a row’s actions: mounted only for the row
under the pointer (see ColumnDef::revealed_on_hover).
accessible_value: Option<Arc<dyn Fn(&Row) -> String + Send + Sync>>Value exposed for ready rows; set directly or by ColumnDef::with_text.
text: Option<Arc<dyn Fn(&Row) -> Option<String> + Send + Sync>>The cell text the table paints itself (set by ColumnDef::with_text
and ColumnDef::with_optional_text).
kind: TextKindWhat the column’s text is (TextKind): a numeric column’s cells
and header align to the trailing edge in tabular figures.
absent: StringWhat an absent value reads as, dimmed.
max_lines: usizeHow many lines a cell’s text may wrap to before it is elided; the row grows to hold them.
priority: u8Which columns give way first when the table is narrow: 0 never
hides, higher numbers hide before lower ones.
badge: Option<Arc<dyn Fn(&Row) -> (String, Tone) + Send + Sync>>A badge the table measures and paints in the cell.
checked: Option<Arc<dyn Fn(&Row) -> bool + Send + Sync>>A checkbox column: the box is ticked by this and toggled through the table’s checkbox callback.
align: Option<CellAlign>None follows Self::kind (see CellAlign::for_kind).
compare: Option<Arc<dyn Fn(&Row, &Row) -> Ordering + Send + Sync>>How a sortable column orders rows; None orders by the column’s
text (numerically for a numeric column), else its badge label.
Implementations§
§impl<Row> ColumnDef<Row>
impl<Row> ColumnDef<Row>
pub fn new( key: impl Into<String>, header: impl Into<String>, width: ColumnWidth, ) -> ColumnDef<Row>
pub fn checkbox(
key: impl Into<String>,
header: impl Into<String>,
checked: impl Fn(&Row) -> bool + Send + Sync + 'static,
) -> ColumnDef<Row>where
Row: 'static,
pub fn checkbox(
key: impl Into<String>,
header: impl Into<String>,
checked: impl Fn(&Row) -> bool + Send + Sync + 'static,
) -> ColumnDef<Row>where
Row: 'static,
A column of checkboxes (an enabled header, a selected file): the table
paints the box, toggles it with a pointer or Space, and reports the
row through DataTable::on_check.
pub fn wrapping(self, max_lines: usize) -> ColumnDef<Row>
pub fn wrapping(self, max_lines: usize) -> ColumnDef<Row>
Let the cell text wrap to max_lines lines before it is elided (a
message, a description); the row grows to hold them.
pub fn min_width(self, width: f32) -> ColumnDef<Row>
pub fn min_width(self, width: f32) -> ColumnDef<Row>
Keep a readable cell width while flexible columns share extra room. If the remaining columns cannot fit their minima, the table scrolls horizontally instead of squeezing their text or controls.
pub fn priority(self, priority: u8) -> ColumnDef<Row>
pub fn priority(self, priority: u8) -> ColumnDef<Row>
Hide this column when the table is too narrow for every column:
higher priorities give way first; 0 (the default) never hides.
pub fn with_badge(
self,
badge: impl Fn(&Row) -> (String, Tone) + Send + Sync + 'static,
) -> ColumnDef<Row>where
Row: 'static,
pub fn with_badge(
self,
badge: impl Fn(&Row) -> (String, Tone) + Send + Sync + 'static,
) -> ColumnDef<Row>where
Row: 'static,
A badge in each cell (a level, a status), measured and painted by the
table: badge(row) gives its label and tone; an empty label paints
none. The label is the cell’s accessible value unless the column has
text.
pub fn with_kind(self, kind: TextKind) -> ColumnDef<Row>
pub fn with_kind(self, kind: TextKind) -> ColumnDef<Row>
Say what the column’s values are: TextKind::Numeric for counts,
sizes, prices and times (cells and header then align to the trailing
edge), TextKind::Identifier for names people must not confuse,
TextKind::Secret for keys and hashes.
pub fn with_align(self, align: CellAlign) -> ColumnDef<Row>
pub fn with_align(self, align: CellAlign) -> ColumnDef<Row>
Place the column’s header and cells: CellAlign::Center for a
column of switches or short statuses that stand under their header.
pub fn sortable(self, v: bool) -> ColumnDef<Row>
pub fn sorted_by(
self,
compare: impl Fn(&Row, &Row) -> Ordering + Send + Sync + 'static,
) -> ColumnDef<Row>
pub fn sorted_by( self, compare: impl Fn(&Row, &Row) -> Ordering + Send + Sync + 'static, ) -> ColumnDef<Row>
A sortable column that orders rows by compare rather than by its
text.
pub fn with_text_render( self, f: Box<dyn Fn(&Row, &mut Scene, Affine, &mut TextRenderer, Rect, &Theme, CellState) + Send + Sync>, ) -> ColumnDef<Row>
pub fn with_text(
self,
value: impl Fn(&Row) -> String + Send + Sync + 'static,
) -> ColumnDef<Row>where
Row: 'static,
pub fn with_text(
self,
value: impl Fn(&Row) -> String + Send + Sync + 'static,
) -> ColumnDef<Row>where
Row: 'static,
Render ordinary cell text and expose the exact same string as the
accessible cell value. This is the concise default for most columns;
use Self::with_text_render plus Self::with_accessible_value when
custom drawing is required.
pub fn with_optional_text(
self,
value: impl Fn(&Row) -> Option<String> + Send + Sync + 'static,
absent: impl Into<String>,
) -> ColumnDef<Row>where
Row: 'static,
pub fn with_optional_text(
self,
value: impl Fn(&Row) -> Option<String> + Send + Sync + 'static,
absent: impl Into<String>,
) -> ColumnDef<Row>where
Row: 'static,
Cell text that may be absent (a SQL NULL): None paints absent
in tertiary ink (“NULL”, or “—” for an unset field), and is read out
as that label.
pub fn with_accessible_value(
self,
value: impl Fn(&Row) -> String + Send + Sync + 'static,
) -> ColumnDef<Row>
pub fn with_accessible_value( self, value: impl Fn(&Row) -> String + Send + Sync + 'static, ) -> ColumnDef<Row>
Expose a value for a custom-painted cell. The column header remains the cell name, while this string becomes its row-specific value.
pub fn with_render( self, f: Box<dyn Fn(&Row, &mut Scene, Affine, &Theme, &mut TextRenderer, Rect) + Send + Sync>, ) -> ColumnDef<Row>
pub fn with_widget(
self,
builder: impl FnMut(&Row, usize) -> Box<dyn Widget> + 'static,
) -> ColumnDef<Row>
pub fn with_widget( self, builder: impl FnMut(&Row, usize) -> Box<dyn Widget> + 'static, ) -> ColumnDef<Row>
Render this column with real child widgets. Only ready cells in the visible range plus overscan are built; controls participate in input, focus, animation, layout, inspection, and accessibility.
pub fn revealed_on_hover(self) -> ColumnDef<Row>
pub fn revealed_on_hover(self) -> ColumnDef<Row>
Make this column’s widgets a row’s actions: they are mounted only for
the row under the pointer, or for the selected row where nothing
hovers (touch). At rest the column paints what
Self::with_text_render draws: a row’s quiet state (a liked mark,
a progress figure), with the controls taking its place on approach.
Auto Trait Implementations§
impl<Row> Freeze for ColumnDef<Row>
impl<Row> !RefUnwindSafe for ColumnDef<Row>
impl<Row> !Send for ColumnDef<Row>
impl<Row> !Sync for ColumnDef<Row>
impl<Row> Unpin for ColumnDef<Row>
impl<Row> UnsafeUnpin for ColumnDef<Row>
impl<Row> !UnwindSafe for ColumnDef<Row>
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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