pub struct TableBuilder<'a> { /* private fields */ }
Expand description

Builder for a Table with (optional) fixed header and scrolling body.

You must pre-allocate all columns with Self::column/Self::columns.

If you have multiple Table:s in the same Ui you will need to give them unique id:s by surrounding them with Ui::push_id.

§Example

use egui_extras::{TableBuilder, Column};
TableBuilder::new(ui)
    .column(Column::auto().resizable(true))
    .column(Column::remainder())
    .header(20.0, |mut header| {
        header.col(|ui| {
            ui.heading("First column");
        });
        header.col(|ui| {
            ui.heading("Second column");
        });
    })
    .body(|mut body| {
        body.row(30.0, |mut row| {
            row.col(|ui| {
                ui.label("Hello");
            });
            row.col(|ui| {
                ui.button("world!");
            });
        });
    });

Implementations§

source§

impl<'a> TableBuilder<'a>

source

pub fn new(ui: &'a mut Ui) -> Self

source

pub fn striped(self, striped: bool) -> Self

Enable striped row background for improved readability.

Default is whatever is in egui::Visuals::striped.

source

pub fn sense(self, sense: Sense) -> Self

What should table cells sense for? (default: egui::Sense::hover()).

source

pub fn resizable(self, resizable: bool) -> Self

Make the columns resizable by dragging.

You can set this for individual columns with Column::resizable. Self::resizable is used as a fallback for any column for which you don’t call Column::resizable.

If the last column is Column::remainder, then it won’t be resizable (and instead use up the remainder).

Default is false.

source

pub fn vscroll(self, vscroll: bool) -> Self

Enable vertical scrolling in body (default: true)

source

pub fn drag_to_scroll(self, drag_to_scroll: bool) -> Self

Enables scrolling the table’s contents using mouse drag (default: true).

See ScrollArea::drag_to_scroll for more.

source

pub fn stick_to_bottom(self, stick: bool) -> Self

Should the scroll handle stick to the bottom position even as the content size changes dynamically? The scroll handle remains stuck until manually changed, and will become stuck once again when repositioned to the bottom. Default: false.

source

pub fn scroll_to_row(self, row: usize, align: Option<Align>) -> Self

Set a row to scroll to.

align specifies if the row should be positioned in the top, center, or bottom of the view (using Align::TOP, Align::Center or Align::BOTTOM). If align is None, the table will scroll just enough to bring the cursor into view.

See also: Self::vertical_scroll_offset.

source

pub fn vertical_scroll_offset(self, offset: f32) -> Self

Set the vertical scroll offset position, in points.

See also: Self::scroll_to_row.

source

pub fn min_scrolled_height(self, min_scrolled_height: f32) -> Self

The minimum height of a vertical scroll area which requires scroll bars.

The scroll area will only become smaller than this if the content is smaller than this (and so we don’t require scroll bars).

Default: 200.0.

source

pub fn max_scroll_height(self, max_scroll_height: f32) -> Self

Don’t make the scroll area higher than this (add scroll-bars instead!).

In other words: add scroll-bars when this height is reached. Default: 800.0.

source

pub fn auto_shrink(self, auto_shrink: impl Into<Vec2b>) -> Self

For each axis (x,y):

  • If true, add blank space outside the table, keeping the table small.
  • If false, add blank space inside the table, expanding the table to fit the containing ui.

Default: true.

See ScrollArea::auto_shrink for more.

source

pub fn scroll_bar_visibility( self, scroll_bar_visibility: ScrollBarVisibility ) -> Self

Set the visibility of both horizontal and vertical scroll bars.

With ScrollBarVisibility::VisibleWhenNeeded (default), the scroll bar will be visible only when needed.

source

pub fn cell_layout(self, cell_layout: Layout) -> Self

What layout should we use for the individual cells?

source

pub fn column(self, column: Column) -> Self

Allocate space for one column.

source

pub fn columns(self, column: Column, count: usize) -> Self

Allocate space for several columns at once.

source

pub fn header( self, height: f32, add_header_row: impl FnOnce(TableRow<'_, '_>) ) -> Table<'a>

Create a header row which always stays visible and at the top

source

pub fn body<F>(self, add_body_contents: F)
where F: for<'b> FnOnce(TableBody<'b>),

Create table body without a header row

Auto Trait Implementations§

§

impl<'a> Freeze for TableBuilder<'a>

§

impl<'a> !RefUnwindSafe for TableBuilder<'a>

§

impl<'a> Send for TableBuilder<'a>

§

impl<'a> Sync for TableBuilder<'a>

§

impl<'a> Unpin for TableBuilder<'a>

§

impl<'a> !UnwindSafe for TableBuilder<'a>

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

§

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

§

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.