Center toplevels if they don't fill space
This commit is contained in:
parent
8a4d4b6957
commit
e032b0b5ee
2 changed files with 5 additions and 1 deletions
|
|
@ -8,6 +8,7 @@ mod row_col_toplevel_layout;
|
|||
mod utils;
|
||||
pub(crate) use row_col_toplevel_layout::RowColToplevelLayout;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct LayoutToplevel<'a> {
|
||||
//toplevel: &'a crate::Toplevel,
|
||||
/// Preferred size of the child widget, if it fill the parent container
|
||||
|
|
|
|||
|
|
@ -31,7 +31,10 @@ impl ToplevelLayout for RowColToplevelLayout {
|
|||
let scale_factor = (self.axis.main(max_limit) / requested_main_total).min(1.0);
|
||||
let max_cross = self.axis.cross(max_limit);
|
||||
|
||||
let mut total_main = 0.0;
|
||||
// Add padding to center if total requested size doesn't fill available space
|
||||
let padding = (self.axis.main(max_limit) - requested_main_total).max(0.) / 2.;
|
||||
|
||||
let mut total_main = padding;
|
||||
let mut first = true;
|
||||
toplevels.iter().map(move |child| {
|
||||
let requested_main = self.axis.main(child.preferred_size);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue