feat(flex-row): align_items, justify_items, justify_content, and min_item_width
This commit is contained in:
parent
289db87373
commit
cb6bc86e1e
2 changed files with 60 additions and 7 deletions
|
|
@ -25,8 +25,17 @@ pub struct FlexRow<'a, Message> {
|
|||
row_spacing: u16,
|
||||
/// Sets the width.
|
||||
width: Length,
|
||||
/// Sets minimum width of items that grow.
|
||||
#[setters(into)]
|
||||
min_item_width: Option<f32>,
|
||||
/// Sets the max width
|
||||
max_width: f32,
|
||||
/// Defines how content will be aligned horizontally.
|
||||
#[setters(skip)]
|
||||
align_items: Option<taffy::AlignItems>,
|
||||
/// Defines how content will be aligned vertically.
|
||||
#[setters(skip)]
|
||||
justify_items: Option<taffy::AlignItems>,
|
||||
/// Defines how the content will be justified.
|
||||
#[setters(into)]
|
||||
justify_content: Option<crate::widget::JustifyContent>,
|
||||
|
|
@ -40,11 +49,34 @@ impl<'a, Message> FlexRow<'a, Message> {
|
|||
column_spacing: 4,
|
||||
row_spacing: 4,
|
||||
width: Length::Shrink,
|
||||
min_item_width: None,
|
||||
max_width: f32::INFINITY,
|
||||
align_items: None,
|
||||
justify_items: None,
|
||||
justify_content: None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Defines how content will be aligned horizontally.
|
||||
pub fn align_items(mut self, alignment: iced::Alignment) -> Self {
|
||||
self.align_items = Some(match alignment {
|
||||
iced::Alignment::Center => taffy::AlignItems::Center,
|
||||
iced::Alignment::Start => taffy::AlignItems::Start,
|
||||
iced::Alignment::End => taffy::AlignItems::End,
|
||||
});
|
||||
self
|
||||
}
|
||||
|
||||
/// Defines how content will be aligned vertically.
|
||||
pub fn justify_items(mut self, alignment: iced::Alignment) -> Self {
|
||||
self.justify_items = Some(match alignment {
|
||||
iced::Alignment::Center => taffy::AlignItems::Center,
|
||||
iced::Alignment::Start => taffy::AlignItems::Start,
|
||||
iced::Alignment::End => taffy::AlignItems::End,
|
||||
});
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the space between each column and row.
|
||||
pub const fn spacing(mut self, spacing: u16) -> Self {
|
||||
self.column_spacing = spacing;
|
||||
|
|
@ -87,6 +119,9 @@ impl<'a, Message: 'static + Clone> Widget<Message, crate::Theme, Renderer>
|
|||
self.padding,
|
||||
f32::from(self.column_spacing),
|
||||
f32::from(self.row_spacing),
|
||||
self.min_item_width,
|
||||
self.align_items,
|
||||
self.justify_items,
|
||||
self.justify_content,
|
||||
&mut tree.children,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue