Add support for embedded scrollbars for scrollable

Co-authored-by: dtzxporter <dtzxporter@users.noreply.github.com>
This commit is contained in:
Héctor Ramón Jiménez 2024-07-11 07:58:33 +02:00
parent 3c55e07668
commit 8ae4e09db9
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
4 changed files with 325 additions and 212 deletions

View file

@ -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