Skip to main content

ColumnDef

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: f32

Smallest 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: bool

The 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: TextKind

What the column’s text is (TextKind): a numeric column’s cells and header align to the trailing edge in tabular figures.

§absent: String

What an absent value reads as, dimmed.

§max_lines: usize

How many lines a cell’s text may wrap to before it is elided; the row grows to hold them.

§priority: u8

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

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,

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>

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>

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>

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,

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>

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>

Place the column’s header and cells: CellAlign::Center for a column of switches or short statuses that stand under their header.

pub fn alignment(&self) -> CellAlign

Where the column’s header and cells sit.

pub fn sortable(self, v: bool) -> 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,

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,

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>

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>

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>

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

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

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

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

Source§

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

Source§

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

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

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,