egui: Problem with `Table` from egui_extras

Describe the bug

I recently changed to latest version of egui 0.20.1 from 0.19 in one of my projects. the problem that I noticed so far is the Table wont work as it use to work in version 0.19, when trying to resize or make the windows full screen the table layout will fill up the entire Panel and push out anything that is beside it.

it would be better to show the problem with a video, I will attach some video in screenshot section.

To Reproduce

here is the an example source code, just compile and try to resize it…

use eframe::{NativeOptions, epaint::{Vec2, text::{LayoutJob, LayoutSection, TextWrapping}}, run_native, App, egui::{CentralPanel, Direction, Layout, TextFormat, SidePanel}, emath::Align};
use egui_extras::{TableBuilder, Column};

struct Test {
	test_data: Vec<[String; 3]>,
}

impl Default for Test {
    fn default() -> Self {
		let mut test_data = Vec::with_capacity(1000);

		for i in 0..1000 {
			test_data.push([
				"First one".to_owned(),
				"Second one".to_owned(),
				format!("{i}: The last one that should be looooooooooooooooooooooooooooooooooooong"),
			]);
		}

        Self { test_data }
    }
}

impl App for Test {
    fn update(&mut self, ctx: &eframe::egui::Context, _frame: &mut eframe::Frame) {
		SidePanel::right("side_panel")
			.default_width(225.0)
			.max_width(225.0)
			.resizable(false)
			.show(ctx, |ui| {
				ui.label("just a simple side panel");
			});

        CentralPanel::default().show(ctx, |ui| {
			TableBuilder::new(ui)
				.striped(true)
				.column(Column::initial(50.0).at_least(50.0).at_most(50.0))
				.column(Column::initial(150.0).at_least(50.0).at_most(160.))
				.column(Column::remainder().at_least(60.0))
				.cell_layout(Layout::centered_and_justified(Direction::LeftToRight))
				.resizable(true)
				.header(20.0, |mut header| {
					for text in ["One", "Two", "Long Text"] {
						header.col(|ui| {
							ui.heading(text);
						});
					}
				})
				.body(|body| {
					body.rows(25.0, 1000, |row_idx, mut row| {
						row.col(|ui| {
							ui.label(&self.test_data[row_idx][0]);
						});
						row.col(|ui| {
							ui.label(&self.test_data[row_idx][1]);
						});
						row.col(|ui| {
							let job = LayoutJob {
								text: self.test_data[row_idx][2].clone(),
								sections: vec![LayoutSection {
									leading_space: 0.0,
									byte_range: 0..self.test_data[row_idx][2].len(),
									format: TextFormat::default(),
								}],
								wrap: TextWrapping {
									max_rows: 1,
									break_anywhere: true,
									overflow_character: Some('…'),
									..Default::default()
								},
								break_on_newline: true,
								halign: Align::Center,
								..Default::default()
							};
							
							ui.centered_and_justified(|ui| {
								ui.label(job);
							});
						});
					})
				})
		});
    }
}

fn main() {
    let options = NativeOptions {
        initial_window_size: Some(Vec2::new(680., 535.)),
        min_window_size: Some(Vec2::new(680., 535.)),
        ..Default::default()
    };

	run_native(
		"Test",
		options,
		Box::new(|_| Box::new(Test::default())));
}

(for version 0.19.0 just changing Column to Size is enough.

Expected behavior

I believe it should work as it been working in version 0.19.0

Screenshots and Videos

version 0.19

https://user-images.githubusercontent.com/18105381/206941941-046ba4a0-74ca-4155-a1f3-6da2da3f982c.mp4

here is the same program in version 0.20.1

https://user-images.githubusercontent.com/18105381/206942039-2bbcd901-a598-4586-b2a3-cc358f0693aa.mp4

Desktop (please complete the following information):

  • OS: Windows
  • Version: 10 (21H2)

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (6 by maintainers)

Commits related to this issue

Most upvoted comments

Any plan for fixing this? its really a big problem…

I don’t have time to dig into this right now, but feel free to investigate yourself!