Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions demo/src/table_demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,11 @@ impl TableDemo {
egui_table::AutoSizeMode::OnParentResize,
"OnParentResize",
);
ui.radio_value(
&mut self.auto_size_mode,
egui_table::AutoSizeMode::Fill,
"Fill",
);
});
ui.end_row();
});
Expand Down
6 changes: 6 additions & 0 deletions egui_table/src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@

/// Auto-size the columns if the parents' width changes
OnParentResize,

/// Auto-size the columns only if the parents' width is greater than the minimum width
Fill,
}

#[derive(Clone, Debug, Default, serde::Deserialize, serde::Serialize)]
Expand Down Expand Up @@ -375,6 +378,9 @@
AutoSizeMode::Never => false,
AutoSizeMode::Always => true,
AutoSizeMode::OnParentResize => state.parent_width != Some(parent_width),
AutoSizeMode::Fill => state.parent_width.map_or(true, |w| {

Check failure on line 381 in egui_table/src/table.rs

View workflow job for this annotation

GitHub Actions / Rust

this `map_or` can be simplified

Check failure on line 381 in egui_table/src/table.rs

View workflow job for this annotation

GitHub Actions / Check wasm32

this `map_or` can be simplified
w > self.columns.iter().map(|col| col.current).sum()
}),
};
if auto_size {
Column::auto_size(&mut self.columns, parent_width);
Expand Down
Loading