#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub struct Insets {
pub top: u16,
pub right: u16,
pub bottom: u16,
pub left: u16,
}
impl Insets {
pub const ZERO: Insets = Insets {
top: 0,
right: 0,
bottom: 0,
left: 0,
};
pub fn new() -> Self {
Self::ZERO
}
pub fn all(n: u16) -> Self {
Self {
top: n,
right: n,
bottom: n,
left: n,
}
}
pub fn symmetric(vertical: u16, horizontal: u16) -> Self {
Self {
top: vertical,
right: horizontal,
bottom: vertical,
left: horizontal,
}
}
pub fn top(mut self, v: u16) -> Self {
self.top = v;
self
}
pub fn bottom(mut self, v: u16) -> Self {
self.bottom = v;
self
}
pub fn left(mut self, v: u16) -> Self {
self.left = v;
self
}
pub fn right(mut self, v: u16) -> Self {
self.right = v;
self
}
pub fn horizontal(&self) -> u16 {
self.left + self.right
}
pub fn vertical(&self) -> u16 {
self.top + self.bottom
}
}