Skip to content

Commit

Permalink
Set the sizing_pass flag in first frame of egui_extras::Table (em…
Browse files Browse the repository at this point in the history
…ilk#4613)

* Closes emilk#4535

This should improve the auto-sizing of columns when nesting expanding
widgets (e.g. `Separator`), or centered or justified layouts.
  • Loading branch information
emilk authored and hacknus committed Oct 30, 2024
1 parent b4d6a7c commit 03e39f0
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions crates/egui_extras/src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Response> = None;
add_header_row(TableRow {
Expand Down Expand Up @@ -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::<usize>(hovered_row_index_id));
Expand Down

0 comments on commit 03e39f0

Please sign in to comment.