diff options
author | 2024-07-12 21:40:46 +0200 | |
---|---|---|
committer | 2024-07-12 21:40:46 +0200 | |
commit | 8cadd3b99485c344feb18b774c8e6fd6c1ea9dd7 (patch) | |
tree | 826fa9e0acdf3a4e003f882c94ff24a4ac9f50e4 /widget/src/row.rs | |
parent | be06060117da061ad8cad94ab0830c06def6b147 (diff) | |
parent | 3f480d3d18c41188bf40ead0a3dc4497316f11ae (diff) | |
download | iced-8cadd3b99485c344feb18b774c8e6fd6c1ea9dd7.tar.gz iced-8cadd3b99485c344feb18b774c8e6fd6c1ea9dd7.tar.bz2 iced-8cadd3b99485c344feb18b774c8e6fd6c1ea9dd7.zip |
Merge pull request #2504 from iced-rs/view-ergonomics
Improved `view` ergonomics
Diffstat (limited to '')
-rw-r--r-- | widget/src/row.rs | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/widget/src/row.rs b/widget/src/row.rs index c8fcdb61..3feeaa7e 100644 --- a/widget/src/row.rs +++ b/widget/src/row.rs @@ -1,4 +1,5 @@ //! Distribute content horizontally. +use crate::core::alignment::{self, Alignment}; use crate::core::event::{self, Event}; use crate::core::layout::{self, Layout}; use crate::core::mouse; @@ -6,8 +7,8 @@ use crate::core::overlay; use crate::core::renderer; use crate::core::widget::{Operation, Tree}; use crate::core::{ - Alignment, Clipboard, Element, Length, Padding, Pixels, Rectangle, Shell, - Size, Vector, Widget, + Clipboard, Element, Length, Padding, Pixels, Rectangle, Shell, Size, + Vector, Widget, }; /// A container that distributes its contents horizontally. @@ -17,7 +18,7 @@ pub struct Row<'a, Message, Theme = crate::Theme, Renderer = crate::Renderer> { padding: Padding, width: Length, height: Length, - align_items: Alignment, + align: Alignment, clip: bool, children: Vec<Element<'a, Message, Theme, Renderer>>, } @@ -60,7 +61,7 @@ where padding: Padding::ZERO, width: Length::Shrink, height: Length::Shrink, - align_items: Alignment::Start, + align: Alignment::Start, clip: false, children, } @@ -95,8 +96,8 @@ where } /// Sets the vertical alignment of the contents of the [`Row`] . - pub fn align_items(mut self, align: Alignment) -> Self { - self.align_items = align; + pub fn align_y(mut self, align: impl Into<alignment::Vertical>) -> Self { + self.align = Alignment::from(align.into()); self } @@ -199,7 +200,7 @@ where self.height, self.padding, self.spacing, - self.align_items, + self.align, &self.children, &mut tree.children, ) |