summaryrefslogtreecommitdiffstats
path: root/core/src/widget
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/widget')
-rw-r--r--core/src/widget/text.rs18
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
}