diff options
author | 2024-07-12 21:40:46 +0200 | |
---|---|---|
committer | 2024-07-12 21:40:46 +0200 | |
commit | 8cadd3b99485c344feb18b774c8e6fd6c1ea9dd7 (patch) | |
tree | 826fa9e0acdf3a4e003f882c94ff24a4ac9f50e4 /core/src/widget | |
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 'core/src/widget')
-rw-r--r-- | core/src/widget/text.rs | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/core/src/widget/text.rs b/core/src/widget/text.rs index 081407e5..990c5567 100644 --- a/core/src/widget/text.rs +++ b/core/src/widget/text.rs @@ -86,21 +86,27 @@ where self } + /// Centers the [`Text`], both horizontally and vertically. + pub fn center(self) -> Self { + self.align_x(alignment::Horizontal::Center) + .align_y(alignment::Vertical::Center) + } + /// Sets the [`alignment::Horizontal`] of the [`Text`]. - pub fn horizontal_alignment( + pub fn align_x( mut self, - alignment: alignment::Horizontal, + alignment: impl Into<alignment::Horizontal>, ) -> Self { - self.horizontal_alignment = alignment; + self.horizontal_alignment = alignment.into(); self } /// Sets the [`alignment::Vertical`] of the [`Text`]. - pub fn vertical_alignment( + pub fn align_y( mut self, - alignment: alignment::Vertical, + alignment: impl Into<alignment::Vertical>, ) -> Self { - self.vertical_alignment = alignment; + self.vertical_alignment = alignment.into(); self } |