Add align_x and align_y helpers to Scrollable
This commit is contained in:
parent
70f44a6e26
commit
bec3ca56c3
1 changed files with 26 additions and 0 deletions
|
|
@ -109,6 +109,32 @@ where
|
||||||
self
|
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`].
|
/// Sets the style of this [`Scrollable`].
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn style(mut self, style: impl Fn(&Theme, Status) -> Style + 'a) -> Self
|
pub fn style(mut self, style: impl Fn(&Theme, Status) -> Style + 'a) -> Self
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue