From 8ae4e09db9badb801669c15408bc76e8675f9cc8 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 11 Jul 2024 07:58:33 +0200 Subject: Add support for embedded scrollbars for `scrollable` Co-authored-by: dtzxporter --- core/src/padding.rs | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) (limited to 'core/src/padding.rs') 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) -> Self { + Self { + top: padding.into().0, + ..Self::ZERO + } + } + + /// Create some right [`Padding`]. + pub fn right(padding: impl Into) -> Self { + Self { + right: padding.into().0, + ..Self::ZERO + } + } + + /// Create some bottom [`Padding`]. + pub fn bottom(padding: impl Into) -> Self { + Self { + bottom: padding.into().0, + ..Self::ZERO + } + } + + /// Create some left [`Padding`]. + pub fn left(padding: impl Into) -> Self { + Self { + left: padding.into().0, + ..Self::ZERO + } + } + /// Returns the total amount of vertical [`Padding`]. pub fn vertical(self) -> f32 { self.top + self.bottom -- cgit