pub struct Table<'a, C: PixelColor, M: Clone> { /* private fields */ }Expand description
Vertically scrollable table of borrowed text cells with an optional header.
Build it with Table::new, set columns/data with Table::rows or
Table::row, optionally add a Table::header, then enable scrolling
with the same builders Column exposes. A tapped body cell emits the
Table::on_select message carrying (row, col).
Implementations§
Source§impl<'a, C: PixelColor + 'a, M: Clone + 'a> Table<'a, C, M>
impl<'a, C: PixelColor + 'a, M: Clone + 'a> Table<'a, C, M>
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new empty table. Position and size are assigned by the parent
via arrange.
Sourcepub fn id(self, id: WidgetId) -> Self
pub fn id(self, id: WidgetId) -> Self
Set a stable base id so body cells can participate in focus traversal.
Sourcepub fn header(self, cells: &'a [&'a str]) -> Self
pub fn header(self, cells: &'a [&'a str]) -> Self
The header row, drawn above (and outside) the scrolling body.
Sourcepub fn rows(self, rows: &'a [&'a [&'a str]]) -> Self
pub fn rows(self, rows: &'a [&'a [&'a str]]) -> Self
Replace all body rows at once from a borrowed 2-D slice.
Sourcepub fn columns(self, columns: usize) -> Self
pub fn columns(self, columns: usize) -> Self
Explicit column count. Overrides the auto-derived width; useful when some rows are short.
Sourcepub fn selected(self, row: usize, col: usize) -> Self
pub fn selected(self, row: usize, col: usize) -> Self
(row, col) of the cell to render highlighted. Host-driven —
typically the value the last Table::on_select set.
Sourcepub fn on_select<F>(self, f: F) -> Self
pub fn on_select<F>(self, f: F) -> Self
Callback invoked with a tapped body cell’s (row, col).
Without it the body cells are inert.
Sourcepub fn scrollable(self, dir: ScrollDirection) -> Self
pub fn scrollable(self, dir: ScrollDirection) -> Self
Make this table scrollable on dir. Tables scroll
vertically, so ScrollDirection::Vertical is the usual choice.
Sourcepub fn scroll_state(self, state: &ScrollState) -> Self
pub fn scroll_state(self, state: &ScrollState) -> Self
Supply the host-owned ScrollState read this frame.
Implies scrolling (vertical by default).
Sourcepub fn scrollbar(self, mode: ScrollbarMode) -> Self
pub fn scrollbar(self, mode: ScrollbarMode) -> Self
When the scrollbar is drawn.
Trait Implementations§
Source§impl<'a, C: PixelColor + 'a, M: Clone + 'a> Widget<C, M> for Table<'a, C, M>
impl<'a, C: PixelColor + 'a, M: Clone + 'a> Widget<C, M> for Table<'a, C, M>
Source§fn measure(&mut self, constraints: Constraints) -> Size
fn measure(&mut self, constraints: Constraints) -> Size
constraints.Source§fn preferred_size(&self) -> (Length, Length)
fn preferred_size(&self) -> (Length, Length)
.width(...) / .height(...).
Containers consult this during layout to allocate fixed slots,
query intrinsic sizes, and split residual space among
Fill / FillPortion children. Default is Length::Fill on
both axes.Source§fn arrange(&mut self, rect: Rectangle)
fn arrange(&mut self, rect: Rectangle)
Source§fn handle_touch(&mut self, point: Point, phase: TouchPhase) -> Option<M>
fn handle_touch(&mut self, point: Point, phase: TouchPhase) -> Option<M>
Source§fn mark_pressed(&mut self, point: Point)
fn mark_pressed(&mut self, point: Point)
point hits. No message emit.
Containers forward to children. Default no-op.Source§fn collect_focusable(&self, out: &mut Vec<WidgetId>)
fn collect_focusable(&self, out: &mut Vec<WidgetId>)
Source§fn sync_focus(&mut self, focused: Option<WidgetId>)
fn sync_focus(&mut self, focused: Option<WidgetId>)
Source§fn route_action(&mut self, target: WidgetId, action: UiAction) -> Option<M>
fn route_action(&mut self, target: WidgetId, action: UiAction) -> Option<M>
target.target for directional actions.Source§fn focus_rect(&self, target: WidgetId) -> Option<Rectangle>
fn focus_rect(&self, target: WidgetId) -> Option<Rectangle>
Source§fn draw<'t>(
&self,
renderer: &mut dyn Renderer<C>,
theme: &Theme<'t, C>,
) -> Result<(), RenderError>
fn draw<'t>( &self, renderer: &mut dyn Renderer<C>, theme: &Theme<'t, C>, ) -> Result<(), RenderError>
renderer at rect.Source§fn widget_id(&self) -> Option<WidgetId>
fn widget_id(&self) -> Option<WidgetId>
Source§fn is_focusable(&self) -> bool
fn is_focusable(&self) -> bool
Source§fn handle_action(&mut self, action: UiAction) -> Option<M>
fn handle_action(&mut self, action: UiAction) -> Option<M>
Auto Trait Implementations§
impl<'a, C, M> Freeze for Table<'a, C, M>
impl<'a, C, M> !RefUnwindSafe for Table<'a, C, M>
impl<'a, C, M> !Send for Table<'a, C, M>
impl<'a, C, M> !Sync for Table<'a, C, M>
impl<'a, C, M> Unpin for Table<'a, C, M>
impl<'a, C, M> UnsafeUnpin for Table<'a, C, M>
impl<'a, C, M> !UnwindSafe for Table<'a, C, M>
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> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<'a, C, M, W> IntoElement<'a, C, M> for W
impl<'a, C, M, W> IntoElement<'a, C, M> for W
Source§fn into_element(self) -> Element<'a, C, M>
fn into_element(self) -> Element<'a, C, M>
self.