Add support for asymmetrical padding

This commit is contained in:
Ben LeFevre 2020-11-23 17:19:21 +00:00 committed by Héctor Ramón
parent a9eb591628
commit fe0a27c56d
27 changed files with 339 additions and 195 deletions

View file

@ -6,7 +6,7 @@ use crate::mouse;
use crate::overlay;
use crate::touch;
use crate::{
Align, Clipboard, Column, Element, Hasher, Layout, Length, Point,
Align, Clipboard, Column, Element, Hasher, Layout, Length, Padding, Point,
Rectangle, Size, Vector, Widget,
};
@ -51,9 +51,14 @@ impl<'a, Message, Renderer: self::Renderer> Scrollable<'a, Message, Renderer> {
self
}
/// Sets the padding of the [`Scrollable`].
pub fn padding(mut self, units: u16) -> Self {
self.content = self.content.padding(units);
/// Sets the [`Padding`] of the [`Scrollable`].
///```ignore
/// Scrollable::new(/*...*/).padding(20); // 20px on all sides
/// Scrollable::new(/*...*/).padding([10, 20]); // top/bottom, left/right
/// Scrollable::new(/*...*/).padding([5, 10, 15, 20]); // top, right, bottom, left
/// ```
pub fn padding<P: Into<Padding>>(mut self, padding: P) -> Self {
self.content = self.content.padding(padding);
self
}