Merge pull request #2852 from mtkennerly/feature/wrapped-row-vertical-spacing
Allow custom vertical spacing for wrapped rows
This commit is contained in:
commit
4b075b9731
1 changed files with 15 additions and 2 deletions
|
|
@ -167,7 +167,10 @@ where
|
|||
///
|
||||
/// The original alignment of the [`Row`] is preserved per row wrapped.
|
||||
pub fn wrap(self) -> Wrapping<'a, Message, Theme, Renderer> {
|
||||
Wrapping { row: self }
|
||||
Wrapping {
|
||||
row: self,
|
||||
vertical_spacing: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -372,6 +375,15 @@ pub struct Wrapping<
|
|||
Renderer = crate::Renderer,
|
||||
> {
|
||||
row: Row<'a, Message, Theme, Renderer>,
|
||||
vertical_spacing: Option<f32>,
|
||||
}
|
||||
|
||||
impl<Message, Theme, Renderer> Wrapping<'_, Message, Theme, Renderer> {
|
||||
/// Sets the vertical spacing _between_ lines.
|
||||
pub fn vertical_spacing(mut self, amount: impl Into<Pixels>) -> Self {
|
||||
self.vertical_spacing = Some(amount.into().0);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl<Message, Theme, Renderer> Widget<Message, Theme, Renderer>
|
||||
|
|
@ -403,6 +415,7 @@ where
|
|||
.shrink(self.row.padding);
|
||||
|
||||
let spacing = self.row.spacing;
|
||||
let vertical_spacing = self.vertical_spacing.unwrap_or(spacing);
|
||||
let max_width = limits.max().width;
|
||||
|
||||
let mut children: Vec<layout::Node> = Vec::new();
|
||||
|
|
@ -447,7 +460,7 @@ where
|
|||
|
||||
align(row_start..i, row_height, &mut children);
|
||||
|
||||
y += row_height + spacing;
|
||||
y += row_height + vertical_spacing;
|
||||
x = 0.0;
|
||||
row_start = i;
|
||||
row_height = 0.0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue