egui
egui copied to clipboard
Can't center inside of a grid both vertically and horizontally.
I'm totally not sure whether that's a bug, or anything, but I've read through the docs couple of times, and for example this code that seems to overdo it but convey what I want:
ui.with_layout(Layout::left_to_right(Align::Center).with_main_align(Align::Center).with_cross_align(Align::Center), |ui| {
ui.label(format!("{:?}", v));
});
Results in vertical alignment to center, and main alignment to left.
The only code I've found through trial and error that is capable of centering it horizontally is this:
ui.with_layout(Layout::top_down(Align::Center).with_cross_align(Align::Center), |ui| {
ui.label(format!("{:?}", v));
});
But of course, then it's vertically aligned on the very ceiling of the cell.
The crux of the problem is that this
ui.with_layout(Layout::left_to_right(Align::Center).with_main_align(Align::Center), |ui| {
ui.label(format!("{:?}", v));
});
centers vertically, not horizontally, inside Grid. (which seems to be default centering inside Grid along vertical axis)
It looks like alignment is a TODO for grid:
https://github.com/emilk/egui/blob/cd0f66b9ae661be737ce57f26fb305cf124f6b73/crates/egui/src/grid.rs#L175-L179
I'd like to be able to right align the first column.

Any update on this? I would like to align content in grid cells to the top.