-
I have a grid with labels that contain numeric data. I'd like to align each label to the right of its cell, instead of the default left-alignment. Based on other questions here and elsewhere I've tried a few things but can't quite make it work. Code snippet (full code at https://gist.github.com/barometz/f3da951a16fc459f9db3d12d6c5751cd): ui.with_layout(egui::Layout::right_to_left(egui::Align::TOP), |ui| {
ui.label("lll")
});
ui.with_layout(egui::Layout::right_to_left(egui::Align::TOP), |ui| {
ui.label("rrr")
});
ui.end_row();
ui.with_layout(
egui::Layout::default().with_cross_align(egui::Align::RIGHT),
|ui| ui.label("lll"),
);
ui.with_layout(
egui::Layout::default().with_cross_align(egui::Align::RIGHT),
|ui| ui.label("rrr"),
);
ui.end_row(); Resulting UI: (I just saw the Table in egui_extras - I'll give that a shot tomorrow, seems like that might be a better fit) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Mostly resolved by using tables, which seems like a more sensible fit for the problem anyway: egui_extras::TableBuilder::new(ui)
.columns(egui_extras::Column::auto(), 5)
.striped(true)
.cell_layout(egui::Layout::default().with_cross_align(egui::Align::RIGHT)) This runs into some issues with the way columns are autosized (~resolved by |
Beta Was this translation helpful? Give feedback.
-
What if I want to align content of one column to left and another to right, like this?
|
Beta Was this translation helpful? Give feedback.
Mostly resolved by using tables, which seems like a more sensible fit for the problem anyway:
This runs into some issues with the way columns are autosized (~resolved by
ui.spacing_mut().item_spacing.x += 5.0;
), but that's a story for another day.