Add ui.vertical_centered and ui.vertical_centered_justified
This commit is contained in:
parent
273d466f19
commit
b508f931c2
2 changed files with 24 additions and 0 deletions
|
@ -9,6 +9,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||
|
||||
## Unreleased
|
||||
|
||||
### Added ⭐
|
||||
|
||||
* `ui.vertical_centered` and `ui.vertical_centered_justified`
|
||||
|
||||
### Changed 🔧
|
||||
|
||||
* `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)
|
||||
}
|
||||
|
||||
/// 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,
|
||||
|
|
Loading…
Reference in a new issue