Why the Slider doesn't get centered when using Layout::top_down(Align::Center) but a Label does? #1144
-
Here's the relevant part of the code. How can I center the Slider? impl eframe::epi::App for MyApp {
fn update(&mut self, ctx: &egui::CtxRef, _frame: &eframe::epi::Frame) {
egui::CentralPanel::default().show(ctx, |ui| {
ui.with_layout(Layout::top_down(Align::Center), |ui| {
ui.add(Label::new("test"));
ui.add(
Slider::new(&mut self.value, 0..=3600).show_value(true)
);
});
});
}
fn name(&self) -> &str {
"Test egui"
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
You can't - the slider is not an atomic widget (it contains many smaller widgets in it). It is a fundamental drawback of single-pass immediate mode GUI:s, and won't be solved until #843 is addressed |
Beta Was this translation helpful? Give feedback.
-
I assume this is still an issue? Or is it possible to center a set of widgets within the CentralPanel?
^^ this code somehow doesn't center the grid. Whatever I do it stays in the corner up left. |
Beta Was this translation helpful? Give feedback.
-
I interested in this |
Beta Was this translation helpful? Give feedback.
You can't - the slider is not an atomic widget (it contains many smaller widgets in it). It is a fundamental drawback of single-pass immediate mode GUI:s, and won't be solved until #843 is addressed