summaryrefslogtreecommitdiffstats
path: root/widget
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector@hecrj.dev>2024-07-11 04:50:11 +0200
committerLibravatar GitHub <noreply@github.com>2024-07-11 04:50:11 +0200
commit12bebba6846eb81c2f3f95c5644944cc9b10a7f0 (patch)
treed27eb8282c56ddf060e16a421a47acf3a78ec834 /widget
parente3726df698c5232023a14f46387e90866bef24c6 (diff)
parentbec3ca56c305bfcf2e1d4305c9175824b9e40e7f (diff)
downloadiced-12bebba6846eb81c2f3f95c5644944cc9b10a7f0.tar.gz
iced-12bebba6846eb81c2f3f95c5644944cc9b10a7f0.tar.bz2
iced-12bebba6846eb81c2f3f95c5644944cc9b10a7f0.zip
Merge pull request #2499 from iced-rs/scrollable-alignment-helpers
Add `align_x` and `align_y` helpers to `Scrollable`
Diffstat (limited to 'widget')
-rw-r--r--widget/src/scrollable.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/widget/src/scrollable.rs b/widget/src/scrollable.rs
index 3ff1f8a1..62f8fcfe 100644
--- a/widget/src/scrollable.rs
+++ b/widget/src/scrollable.rs
@@ -109,6 +109,32 @@ where
self
}
+ /// Inverts the alignment of the horizontal direction of the [`Scrollable`], if applicable.
+ pub fn align_x(mut self, alignment: Alignment) -> Self {
+ match &mut self.direction {
+ Direction::Horizontal(horizontal)
+ | Direction::Both { horizontal, .. } => {
+ horizontal.alignment = alignment;
+ }
+ Direction::Vertical(_) => {}
+ }
+
+ self
+ }
+
+ /// Sets the alignment of the vertical direction of the [`Scrollable`], if applicable.
+ pub fn align_y(mut self, alignment: Alignment) -> Self {
+ match &mut self.direction {
+ Direction::Vertical(vertical)
+ | Direction::Both { vertical, .. } => {
+ vertical.alignment = alignment;
+ }
+ Direction::Horizontal(_) => {}
+ }
+
+ self
+ }
+
/// Sets the style of this [`Scrollable`].
#[must_use]
pub fn style(mut self, style: impl Fn(&Theme, Status) -> Style + 'a) -> Self