mirror of
https://github.com/emilk/egui.git
synced 2026-09-02 23:00:04 -04:00
Add ui.vertical_centered and ui.vertical_centered_justified
This commit is contained in:
@@ -9,6 +9,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
### Added ⭐
|
||||||
|
|
||||||
|
* `ui.vertical_centered` and `ui.vertical_centered_justified`
|
||||||
|
|
||||||
### Changed 🔧
|
### Changed 🔧
|
||||||
|
|
||||||
* `ui.image` now takes `impl Into<Vec2>` as a `size` argument
|
* `ui.image` now takes `impl Into<Vec2>` as a `size` argument
|
||||||
|
|||||||
@@ -963,6 +963,26 @@ impl Ui {
|
|||||||
self.with_layout(Layout::top_down(Align::Min), add_contents)
|
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>(
|
pub fn with_layout<R>(
|
||||||
&mut self,
|
&mut self,
|
||||||
layout: Layout,
|
layout: Layout,
|
||||||
|
|||||||
Reference in New Issue
Block a user