summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/src/padding.rs36
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