diff options
Diffstat (limited to 'widget')
-rw-r--r-- | widget/src/helpers.rs | 8 | ||||
-rw-r--r-- | widget/src/lazy/responsive.rs | 2 | ||||
-rw-r--r-- | widget/src/space.rs | 12 |
3 files changed, 17 insertions, 5 deletions
diff --git a/widget/src/helpers.rs b/widget/src/helpers.rs index e9898d67..400fced5 100644 --- a/widget/src/helpers.rs +++ b/widget/src/helpers.rs @@ -305,15 +305,15 @@ where /// Creates a new horizontal [`Space`] with the given [`Length`]. /// /// [`Space`]: crate::Space -pub fn horizontal_space(width: impl Into<Length>) -> Space { - Space::with_width(width) +pub fn horizontal_space() -> Space { + Space::with_width(Length::Fill) } /// Creates a new vertical [`Space`] with the given [`Length`]. /// /// [`Space`]: crate::Space -pub fn vertical_space(height: impl Into<Length>) -> Space { - Space::with_height(height) +pub fn vertical_space() -> Space { + Space::with_height(Length::Fill) } /// Creates a horizontal [`Rule`] with the given height. diff --git a/widget/src/lazy/responsive.rs b/widget/src/lazy/responsive.rs index 44312a21..313e1edb 100644 --- a/widget/src/lazy/responsive.rs +++ b/widget/src/lazy/responsive.rs @@ -50,7 +50,7 @@ where content: RefCell::new(Content { size: Size::ZERO, layout: None, - element: Element::new(horizontal_space(0)), + element: Element::new(horizontal_space().width(0)), }), } } diff --git a/widget/src/space.rs b/widget/src/space.rs index aeec91f9..35bb30c4 100644 --- a/widget/src/space.rs +++ b/widget/src/space.rs @@ -39,6 +39,18 @@ impl Space { height: height.into(), } } + + /// Sets the width of the [`Space`]. + pub fn width(mut self, width: impl Into<Length>) -> Self { + self.width = width.into(); + self + } + + /// Sets the height of the [`Space`]. + pub fn height(mut self, height: impl Into<Length>) -> Self { + self.height = height.into(); + self + } } impl<Message, Theme, Renderer> Widget<Message, Theme, Renderer> for Space |