Skip to main content

Table

Struct Table 

Source
pub struct Table {
    pub style: Style,
    pub cell_bg_color: Color,
    pub selected_color: Color,
    pub text_color: Color,
    pub grid_color: Color,
    /* private fields */
}
Expand description

LVGL-parity table widget.

Stores cells as a flat row-major Vec; column widths as a Vec<i32>. Row heights are computed dynamically from the cell content using the LPAR-08 shared wrap_greedy_ltr measurement.

Fields§

§style: Style

Background and outer border style.

§cell_bg_color: Color

Color for cell background and grid lines.

§selected_color: Color

Color for the selected cell background.

§text_color: Color

Text color.

§grid_color: Color

Grid line color.

Implementations§

Source§

impl Table

Source

pub fn new(bounds: Rect) -> Self

Create an empty table at bounds with 0 rows and 0 columns.

Source

pub fn set_font(&mut self, font: &'static dyn FontMetrics)

Assign the font used to render this widget (FONT-00 §5); resolves to FONT_6X10 when unset.

Source

pub fn row_count(&self) -> usize

Return the number of rows.

Source

pub fn column_count(&self) -> usize

Return the number of columns.

Source

pub fn set_row_count(&mut self, rows: usize)

Set the number of rows, extending or truncating the cell vector.

Source

pub fn set_column_count(&mut self, cols: usize)

Set the number of columns, extending or truncating; preserves existing cell content where indices overlap.

Source

pub fn set_cell_value(&mut self, row: usize, col: usize, text: &str)

Set the text value of a cell.

Out-of-bounds indices are silently ignored (matching LVGL behavior).

Source

pub fn cell_value(&self, row: usize, col: usize) -> Option<&str>

Return the text value of a cell, or None if empty or out of bounds.

Source

pub fn set_cell_ctrl(&mut self, row: usize, col: usize, ctrl: CellCtrl)

Set control flags for a cell.

Source

pub fn cell_ctrl(&self, row: usize, col: usize) -> CellCtrl

Return control flags for a cell.

Source

pub fn set_cell_align(&mut self, row: usize, col: usize, align: CellAlign)

Set horizontal alignment for a cell.

Source

pub fn set_column_width(&mut self, col: usize, width: i32)

Set the pixel width of column col.

A width of 0 means “auto” — the column participates in the remaining width distribution.

Source

pub fn column_width(&self, col: usize) -> i32

Return the stored column width (0 = auto).

Source

pub fn set_selected_cell(&mut self, row: usize, col: usize)

Set the selected cell. Out-of-bounds is silently ignored.

Source

pub fn selected_cell(&self) -> Option<(usize, usize)>

Return the selected cell (row, col), or None if nothing is selected.

Source

pub fn navigate_next(&mut self)

Move selection to the next cell (right then down; wraps at the last cell to the first).

Wire to ObjectEvent::Key(Key::ArrowRight) or Key::Tab in a node handler.

Source

pub fn navigate_prev(&mut self)

Move selection to the previous cell (left then up; wraps at the first cell to the last).

Wire to ObjectEvent::Key(Key::ArrowLeft) or Key::BackTab.

Source

pub fn navigate_up(&mut self)

Move selection one row up.

Wire to ObjectEvent::Key(Key::ArrowUp) in a node handler.

Source

pub fn navigate_down(&mut self)

Move selection one row down.

Wire to ObjectEvent::Key(Key::ArrowDown) in a node handler.

Source

pub fn activate_selected(&mut self)

Activate the selected cell and record it in the poll slot.

Wire to ObjectEvent::Key(Key::Enter) in a node handler.

Source

pub fn last_activated(&mut self) -> Option<(usize, usize)>

Drain the activation poll slot.

Trait Implementations§

Source§

impl Widget for Table

Source§

fn bounds(&self) -> Rect

Return the area this widget occupies relative to its parent.
Source§

fn widget_font_mut(&mut self) -> Option<&mut WidgetFont>

Expose this widget’s font slot for cascade-driven font resolution (FONT-05 §5.B). Read more
Source§

fn set_bounds(&mut self, bounds: Rect)

Called by the LPAR-10 layout pass to notify this widget of its layout-computed bounds. Read more
Source§

fn draw(&self, renderer: &mut dyn Renderer)

Render the widget using the provided Renderer.
Source§

fn handle_event(&mut self, _event: &Event) -> bool

Handle an event and return true if it was consumed. Read more
Source§

fn clear_region(&mut self) -> Option<Rect>

Return a region (in draw/landscape coordinates) that should be restored from the pristine background copy, or None. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Table

§

impl !Send for Table

§

impl !Sync for Table

§

impl !UnwindSafe for Table

§

impl Freeze for Table

§

impl Unpin for Table

§

impl UnsafeUnpin for Table

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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