From 1bc30121656a907a2c08bdc1f16ac81353a4734a Mon Sep 17 00:00:00 2001 From: Michael Aaron Murphy Date: Wed, 29 May 2024 23:41:48 +0200 Subject: [PATCH] improv(flex-row): add spacing method to set row and column spacing --- src/widget/flex_row/widget.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/widget/flex_row/widget.rs b/src/widget/flex_row/widget.rs index 02873e6e..2a445fae 100644 --- a/src/widget/flex_row/widget.rs +++ b/src/widget/flex_row/widget.rs @@ -17,6 +17,7 @@ pub struct FlexRow<'a, Message> { #[setters(skip)] children: Vec>, /// Sets the padding around the widget. + #[setters(into)] padding: Padding, /// Sets the space between each column of items. column_spacing: u16, @@ -29,7 +30,7 @@ pub struct FlexRow<'a, Message> { } impl<'a, Message> FlexRow<'a, Message> { - pub const fn new(children: Vec>) -> Self { + pub(crate) const fn new(children: Vec>) -> Self { Self { children, padding: Padding::ZERO, @@ -39,6 +40,13 @@ impl<'a, Message> FlexRow<'a, Message> { max_width: f32::INFINITY, } } + + /// Sets the space between each column and row. + pub const fn spacing(mut self, spacing: u16) -> Self { + self.column_spacing = spacing; + self.row_spacing = spacing; + self + } } impl<'a, Message: 'static + Clone> Widget