feat(flex-row): add justify_content method
This commit is contained in:
parent
1bc3012165
commit
7a6421a3e2
3 changed files with 11 additions and 1 deletions
|
|
@ -8,7 +8,7 @@ use iced_core::{Length, Padding, Point, Size};
|
|||
use taffy::geometry::Rect;
|
||||
use taffy::style::{AlignItems, Dimension, Display, Style};
|
||||
use taffy::style_helpers::length;
|
||||
use taffy::TaffyTree;
|
||||
use taffy::{AlignContent, TaffyTree};
|
||||
|
||||
#[allow(clippy::too_many_lines)]
|
||||
pub fn resolve<Message>(
|
||||
|
|
@ -18,6 +18,7 @@ pub fn resolve<Message>(
|
|||
padding: Padding,
|
||||
column_spacing: f32,
|
||||
row_spacing: f32,
|
||||
justify_content: Option<AlignContent>,
|
||||
tree: &mut [Tree],
|
||||
) -> Node {
|
||||
let limits = limits.shrink(padding);
|
||||
|
|
@ -43,6 +44,8 @@ pub fn resolve<Message>(
|
|||
height: Dimension::Auto,
|
||||
},
|
||||
|
||||
justify_content,
|
||||
|
||||
padding: Rect {
|
||||
left: length(padding.left),
|
||||
right: length(padding.right),
|
||||
|
|
|
|||
|
|
@ -27,6 +27,9 @@ pub struct FlexRow<'a, Message> {
|
|||
width: Length,
|
||||
/// Sets the max width
|
||||
max_width: f32,
|
||||
/// Defines how the content will be justified.
|
||||
#[setters(into)]
|
||||
justify_content: Option<crate::widget::JustifyContent>,
|
||||
}
|
||||
|
||||
impl<'a, Message> FlexRow<'a, Message> {
|
||||
|
|
@ -38,6 +41,7 @@ impl<'a, Message> FlexRow<'a, Message> {
|
|||
row_spacing: 4,
|
||||
width: Length::Shrink,
|
||||
max_width: f32::INFINITY,
|
||||
justify_content: None,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -83,6 +87,7 @@ impl<'a, Message: 'static + Clone> Widget<Message, crate::Theme, Renderer>
|
|||
self.padding,
|
||||
f32::from(self.column_spacing),
|
||||
f32::from(self.row_spacing),
|
||||
self.justify_content,
|
||||
&mut tree.children,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -231,6 +231,8 @@ pub use icon::{icon, Icon};
|
|||
#[cfg(feature = "animated-image")]
|
||||
pub mod frames;
|
||||
|
||||
pub use taffy::JustifyContent;
|
||||
|
||||
pub mod list;
|
||||
#[doc(inline)]
|
||||
pub use list::{list_column, ListColumn};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue