Skip to content

Commit

Permalink
Add docstring example for TableBody::rows
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Apr 9, 2022
1 parent cd0fb1f commit bdfc512
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion egui_extras/src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ impl<'a> TableBody<'a> {

// calculate height below the visible table range
for (_, _, height) in striped_heights {
height_below_visible += height as f64
height_below_visible += height as f64;
}

// if height below visible is > 0 here then we need to add a buffer to allow the table to
Expand All @@ -466,6 +466,24 @@ impl<'a> TableBody<'a> {
/// Add rows with same height.
///
/// Is a lot more performant than adding each individual row as non visible rows must not be rendered
///
/// ### Example
/// ```
/// # egui::__run_test_ui(|ui| {
/// use egui_extras::{TableBuilder, Size};
/// TableBuilder::new(ui)
/// .column(Size::remainder().at_least(100.0))
/// .body(|mut body| {
/// let row_height = 18.0;
/// let num_rows = 10_000;
/// body.rows(row_height, num_rows, |row_index, mut row| {
/// row.col(|ui| {
/// ui.label("First column");
/// });
/// });
/// });
/// # });
/// ```
pub fn rows(mut self, height: f32, rows: usize, mut row: impl FnMut(usize, TableRow<'_, '_>)) {
let y_progress = self.y_progress();
let mut start = 0;
Expand Down

0 comments on commit bdfc512

Please sign in to comment.