From 03e39f075a0ccff58056a5073ba21a1b518bafac Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Wed, 5 Jun 2024 12:17:15 +0200 Subject: [PATCH] Set the `sizing_pass` flag in first frame of `egui_extras::Table` (#4613) * Closes https://github.com/emilk/egui/issues/4535 This should improve the auto-sizing of columns when nesting expanding widgets (e.g. `Separator`), or centered or justified layouts. --- crates/egui_extras/src/table.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/crates/egui_extras/src/table.rs b/crates/egui_extras/src/table.rs index cfcc0c9dd2a..c6b203aab36 100644 --- a/crates/egui_extras/src/table.rs +++ b/crates/egui_extras/src/table.rs @@ -437,8 +437,11 @@ impl<'a> TableBuilder<'a> { let table_top = ui.cursor().top(); - // Hide first-frame-jitters when auto-sizing. - ui.add_visible_ui(!first_frame_auto_size_columns, |ui| { + ui.scope(|ui| { + if first_frame_auto_size_columns { + // Hide first-frame-jitters when auto-sizing. + ui.set_sizing_pass(); + } let mut layout = StripLayout::new(ui, CellDirection::Horizontal, cell_layout, sense); let mut response: Option = None; add_header_row(TableRow { @@ -648,7 +651,11 @@ impl<'a> Table<'a> { let clip_rect = ui.clip_rect(); // Hide first-frame-jitters when auto-sizing. - ui.add_visible_ui(!first_frame_auto_size_columns, |ui| { + ui.scope(|ui| { + if first_frame_auto_size_columns { + ui.set_sizing_pass(); + } + let hovered_row_index_id = self.state_id.with("__table_hovered_row"); let hovered_row_index = ui.data_mut(|data| data.remove_temp::(hovered_row_index_id));