Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

TableRow

Layer: cell · Path: src/cells/table_row.rs · Exports: table_row::TableRow

The row model for the Table organism: a Vec of TableCells plus row-level state (selected / selectable / key). It is a descriptor, not a rendererTableRow has no show. The Table organism lays the cells out across the column widths (via egui_extras) and reads this state to drive selection. Carries lifetime 'a from its cells (a custom cell may borrow).

Design

  • Purpose / when to use — Always paired with Table: construct one TableRow per data row and pass the collection to Table::rows(...).

  • Anatomy — Fields (crate-visible, consumed by the organism): cells: Vec<TableCell<'a>>, selected: bool, selectable: bool (default true), key: Option<u64>.

  • Variants / states

    ModifierEffect
    selected(true)row highlighted by the Table organism
    selectable(false)row cannot be selected (default is selectable)
    key(u64)stable identity for selection / tree operations
  • Tokens / layout consumed — None directly; the organism applies row height (layout::TABLE_ROW_HEIGHT, 28px, or a size variant) and selection styling. See layout tokens.

API

MethodSignatureEffect
newnew(cells: impl IntoIterator<Item = TableCell<'a>>) -> SelfBuild a row from its cells; selected=false, selectable=true, key=None.
selectedselected(self, selected: bool) -> SelfMark the row selected (highlighted by the organism).
selectableselectable(self, selectable: bool) -> SelfWhether the row may be selected (default true).
keykey(self, key: u64) -> SelfStable identity for selection / tree operations.

There is no showTableRow is consumed by Table::rows(...), not rendered standalone.

Usage

#![allow(unused)]
fn main() {
use ouroboros_ui::cells::{TableRow, TableCell};

TableRow::new([
    TableCell::text("width"),
    TableCell::text("1920").end(),
]);
}
#![allow(unused)]
fn main() {
// realistic — feeding the Table organism with selection
use ouroboros_ui::cells::{TableRow, TableCell};
use ouroboros_ui::organisms::{Table, Column};

let rows = data.iter().enumerate().map(|(i, d)| {
    TableRow::new([
        TableCell::text(&d.name),
        TableCell::text(&d.size).end(),
        TableCell::text(&d.status).status(d.color),
    ])
    .key(i as u64)
    .selected(selected == Some(i as u64))
});

Table::new()
    .columns([Column::auto(), Column::auto().end(), Column::remainder()])
    .rows(rows)
    .show(ui);
}

Composition

Composes TableCells only and holds plain state. It paints nothing and renders nothing on its own — rendering is the Table organism’s job. Consistent with the cells rule enforced by tests/no_painter_in_molecules.rs.

Notes

  • Pure data: the cells are stored, not drawn, until the organism iterates them across columns.
  • Provide a stable key when the table supports selection or tree state so identity survives reordering.
  • The 'a lifetime flows from TableCell<'a> (a custom cell may borrow); keep borrowed data alive until the table is shown.