From 1fd7a86ecc31ca86254466640acd15379af0918e Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Tue, 8 Apr 2025 15:58:49 -0700 Subject: [PATCH] row_col_toplevel_layout: Add a `new` method --- src/widgets/toplevels/mod.rs | 7 ++----- .../toplevels/toplevel_layout/row_col_toplevel_layout.rs | 4 ++++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/widgets/toplevels/mod.rs b/src/widgets/toplevels/mod.rs index 08a19ca..356f681 100644 --- a/src/widgets/toplevels/mod.rs +++ b/src/widgets/toplevels/mod.rs @@ -15,11 +15,8 @@ use toplevel_layout::{LayoutToplevel, RowColToplevelLayout, ToplevelLayout}; pub fn toplevels(children: Vec>) -> Toplevels { Toplevels { - layout: RowColToplevelLayout { - // TODO configurable - spacing: 16, - axis: Axis::Horizontal, - }, + // TODO configurable + layout: RowColToplevelLayout::new(Axis::Horizontal, 16), children, _msg: PhantomData, } diff --git a/src/widgets/toplevels/toplevel_layout/row_col_toplevel_layout.rs b/src/widgets/toplevels/toplevel_layout/row_col_toplevel_layout.rs index d9e176f..6557ee2 100644 --- a/src/widgets/toplevels/toplevel_layout/row_col_toplevel_layout.rs +++ b/src/widgets/toplevels/toplevel_layout/row_col_toplevel_layout.rs @@ -11,6 +11,10 @@ pub(crate) struct RowColToplevelLayout { } impl RowColToplevelLayout { + pub fn new(axis: Axis, spacing: u32) -> Self { + Self { axis, spacing } + } + // Get total requested main axis length if widget could have all the space pub fn requested_main_total(&self, toplevels: &[LayoutToplevel<'_, AxisSize>]) -> f32 { let total_spacing = self.spacing as usize * (toplevels.len().saturating_sub(1)).max(0);