1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-02 14:50:03 -04:00

Add ui.vertical_centered and ui.vertical_centered_justified

This commit is contained in:
Emil Ernerfeldt
2020-12-15 14:26:28 +01:00
parent 273d466f19
commit b508f931c2
2 changed files with 24 additions and 0 deletions

View File

@@ -963,6 +963,26 @@ impl Ui {
self.with_layout(Layout::top_down(Align::Min), add_contents)
}
/// Start a ui with vertical layout.
/// Widgets will be centered.
pub fn vertical_centered<R>(
&mut self,
add_contents: impl FnOnce(&mut Ui) -> R,
) -> (R, Response) {
self.with_layout(Layout::top_down(Align::Center), add_contents)
}
/// Start a ui with vertical layout.
/// Widgets will be centered and justified (fill full width).
pub fn vertical_centered_justified<R>(
&mut self,
add_contents: impl FnOnce(&mut Ui) -> R,
) -> (R, Response) {
self.with_layout(
Layout::top_down(Align::Center).with_cross_justify(true),
add_contents,
)
}
pub fn with_layout<R>(
&mut self,
layout: Layout,