pub struct Padding {
pub left: u16,
pub right: u16,
pub top: u16,
pub bottom: u16,
}Expand description
Padding garnish.
This Padding is a fork of Ratatui::widgets::block::padding but
supports serde with the serde feature enabled
This concept is similar to CSS padding and CSS Margin depending on which garnishes follow it.
NOTE: Terminal cells are often taller than they are wide, so to make horizontal and vertical padding seem equal, doubling the horizontal padding is usually pretty good.
§Example
use ratatui_garnish::Padding;
Padding::uniform(1);
Padding::horizontal(2);
Padding::left(3);
Padding::proportional(4);
Padding::symmetric(5, 6);Fields§
§left: u16Left padding
right: u16Right padding
top: u16Top padding
bottom: u16Bottom padding
Implementations§
Source§impl Padding
impl Padding
Sourcepub const fn new(left: u16, right: u16, top: u16, bottom: u16) -> Self
pub const fn new(left: u16, right: u16, top: u16, bottom: u16) -> Self
Creates a new Padding by specifying every field individually.
Note: the order of the fields does not match the order of the CSS properties.
Sourcepub const fn horizontal(value: u16) -> Self
pub const fn horizontal(value: u16) -> Self
Creates a Padding with the same value for left and right.
Sourcepub const fn vertical(value: u16) -> Self
pub const fn vertical(value: u16) -> Self
Creates a Padding with the same value for top and bottom.
Sourcepub const fn proportional(value: u16) -> Self
pub const fn proportional(value: u16) -> Self
Creates a Padding that is visually proportional to the terminal.
This represents a padding of 2x the value for left and right and 1x the value for
top and bottom.
Trait Implementations§
Source§impl<'a, W> Extend<Padding> for GarnishedStatefulWidget<'a, W>
impl<'a, W> Extend<Padding> for GarnishedStatefulWidget<'a, W>
Source§fn extend<A: IntoIterator<Item = Padding>>(&mut self, iter: A)
fn extend<A: IntoIterator<Item = Padding>>(&mut self, iter: A)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl<'a, W> Extend<Padding> for GarnishedWidget<'a, W>
impl<'a, W> Extend<Padding> for GarnishedWidget<'a, W>
Source§fn extend<A: IntoIterator<Item = Padding>>(&mut self, iter: A)
fn extend<A: IntoIterator<Item = Padding>>(&mut self, iter: A)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl<'a> Extend<Padding> for Garnishes<'a>
impl<'a> Extend<Padding> for Garnishes<'a>
Source§fn extend<A: IntoIterator<Item = Padding>>(&mut self, iter: A)
fn extend<A: IntoIterator<Item = Padding>>(&mut self, iter: A)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl Ord for Padding
impl Ord for Padding
Source§impl PartialOrd for Padding
impl PartialOrd for Padding
Source§impl RenderModifier for Padding
impl RenderModifier for Padding
impl Copy for Padding
impl Eq for Padding
impl StructuralPartialEq for Padding
Auto Trait Implementations§
impl Freeze for Padding
impl RefUnwindSafe for Padding
impl Send for Padding
impl Sync for Padding
impl Unpin for Padding
impl UnwindSafe for Padding
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more