Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
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 @@ pub enum AutoSizeMode {

/// 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 @@ impl Table {
AutoSizeMode::Never => false,
AutoSizeMode::Always => true,
AutoSizeMode::OnParentResize => state.parent_width.map_or(true, |w| w != parent_width),
AutoSizeMode::Fill => state.parent_width.map_or(true, |w| {
w > self.columns.iter().map(|col| col.current).sum()
}),
};
if auto_size {
Column::auto_size(&mut self.columns, parent_width);
Expand Down