diff --git a/crates/egui/src/layout.rs b/crates/egui/src/layout.rs index 81fd5ec4..275c57b8 100644 --- a/crates/egui/src/layout.rs +++ b/crates/egui/src/layout.rs @@ -229,22 +229,10 @@ impl Layout { } } - /// For when you want to add a single widget to a layout, and that widget - /// should be centered horizontally and vertically. - #[inline(always)] - pub fn centered(main_dir: Direction) -> Self { - Self { - main_dir, - main_wrap: false, - main_align: Align::Center, - main_justify: false, - cross_align: Align::Center, - cross_justify: false, - } - } - /// For when you want to add a single widget to a layout, and that widget /// should use up all available space. + /// + /// Only one widget may be added to the inner `Ui`! #[inline(always)] pub fn centered_and_justified(main_dir: Direction) -> Self { Self { diff --git a/crates/egui/src/ui.rs b/crates/egui/src/ui.rs index cb4b9021..27f772f7 100644 --- a/crates/egui/src/ui.rs +++ b/crates/egui/src/ui.rs @@ -2007,12 +2007,14 @@ impl Ui { InnerResponse::new(inner, self.interact(rect, child_ui.id, Sense::hover())) } - /// This will make the next added widget centered in the available space. + #[deprecated = "Use ui.vertical_centered instead"] pub fn centered(&mut self, add_contents: impl FnOnce(&mut Self) -> R) -> InnerResponse { - self.with_layout_dyn(Layout::centered(Direction::TopDown), Box::new(add_contents)) + self.vertical_centered(add_contents) } /// This will make the next added widget centered and justified in the available space. + /// + /// Only one widget may be added to the inner `Ui`! pub fn centered_and_justified( &mut self, add_contents: impl FnOnce(&mut Self) -> R,