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 with Self::id_salt
.
§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>
impl<'a> TableBuilder<'a>
pub fn new(ui: &'a mut Ui) -> Self
Sourcepub fn striped(self, striped: bool) -> Self
pub fn striped(self, striped: bool) -> Self
Enable striped row background for improved readability.
Default is whatever is in egui::Visuals::striped
.
Sourcepub fn sense(self, sense: Sense) -> Self
pub fn sense(self, sense: Sense) -> Self
What should table cells sense for? (default: egui::Sense::hover()
).
Sourcepub fn resizable(self, resizable: bool) -> Self
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
.
Sourcepub fn drag_to_scroll(self, drag_to_scroll: bool) -> Self
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.
Sourcepub fn stick_to_bottom(self, stick: bool) -> Self
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
.
Sourcepub fn scroll_to_row(self, row: usize, align: Option<Align>) -> Self
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
.
Sourcepub fn vertical_scroll_offset(self, offset: f32) -> Self
pub fn vertical_scroll_offset(self, offset: f32) -> Self
Set the vertical scroll offset position, in points.
See also: Self::scroll_to_row
.
Sourcepub fn min_scrolled_height(self, min_scrolled_height: f32) -> Self
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
.
Sourcepub fn max_scroll_height(self, max_scroll_height: f32) -> Self
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
.
Sourcepub fn auto_shrink(self, auto_shrink: impl Into<Vec2b>) -> Self
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.
Sourcepub fn scroll_bar_visibility(
self,
scroll_bar_visibility: ScrollBarVisibility,
) -> Self
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.
Sourcepub fn animate_scrolling(self, animated: bool) -> Self
pub fn animate_scrolling(self, animated: bool) -> Self
Should the scroll area animate scroll_to_*
functions?
Default: true
.
Sourcepub fn cell_layout(self, cell_layout: Layout) -> Self
pub fn cell_layout(self, cell_layout: Layout) -> Self
What layout should we use for the individual cells?
Sourcepub fn columns(self, column: Column, count: usize) -> Self
pub fn columns(self, column: Column, count: usize) -> Self
Allocate space for several columns at once.