diff options
author | 2024-07-11 07:58:33 +0200 | |
---|---|---|
committer | 2024-07-11 08:00:58 +0200 | |
commit | 8ae4e09db9badb801669c15408bc76e8675f9cc8 (patch) | |
tree | fc8681143c647742c15b2bb15cb5c27ff023c9ea /core | |
parent | 3c55e076688fd7453e5feb53fccf8139076af584 (diff) | |
download | iced-8ae4e09db9badb801669c15408bc76e8675f9cc8.tar.gz iced-8ae4e09db9badb801669c15408bc76e8675f9cc8.tar.bz2 iced-8ae4e09db9badb801669c15408bc76e8675f9cc8.zip |
Add support for embedded scrollbars for `scrollable`
Co-authored-by: dtzxporter <dtzxporter@users.noreply.github.com>
Diffstat (limited to '')
-rw-r--r-- | core/src/padding.rs | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/core/src/padding.rs b/core/src/padding.rs index a63f6e29..b8c941d8 100644 --- a/core/src/padding.rs +++ b/core/src/padding.rs @@ -1,4 +1,4 @@ -use crate::Size; +use crate::{Pixels, Size}; /// An amount of space to pad for each side of a box /// @@ -54,7 +54,7 @@ impl Padding { left: 0.0, }; - /// Create a Padding that is equal on all sides + /// Create a [`Padding`] that is equal on all sides. pub const fn new(padding: f32) -> Padding { Padding { top: padding, @@ -64,6 +64,38 @@ impl Padding { } } + /// Create some top [`Padding`]. + pub fn top(padding: impl Into<Pixels>) -> Self { + Self { + top: padding.into().0, + ..Self::ZERO + } + } + + /// Create some right [`Padding`]. + pub fn right(padding: impl Into<Pixels>) -> Self { + Self { + right: padding.into().0, + ..Self::ZERO + } + } + + /// Create some bottom [`Padding`]. + pub fn bottom(padding: impl Into<Pixels>) -> Self { + Self { + bottom: padding.into().0, + ..Self::ZERO + } + } + + /// Create some left [`Padding`]. + pub fn left(padding: impl Into<Pixels>) -> Self { + Self { + left: padding.into().0, + ..Self::ZERO + } + } + /// Returns the total amount of vertical [`Padding`]. pub fn vertical(self) -> f32 { self.top + self.bottom |