use embedded_graphics::geometry::Size;
pub(crate) type NodeIndex = usize;
pub(crate) trait SizeExt {
fn inflate(self, by: Size) -> Self;
fn deflate(self, by: Size) -> Self;
}
impl SizeExt for Size {
fn inflate(self, by: Size) -> Self {
Self::new(self.width.saturating_add(by.width), self.height.saturating_add(by.height))
}
fn deflate(self, by: Size) -> Self {
self.saturating_sub(by)
}
}
pub(crate) const fn to_i32(value: u32) -> i32 {
if value > i32::MAX as u32 { i32::MAX } else { value as i32 }
}
#[derive(Clone, Copy)]
pub(crate) struct TextRange {
pub offset: usize,
pub len: usize,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Gap(pub(crate) Size);
impl From<u32> for Gap {
fn from(value: u32) -> Self {
Self(Size::new(value, value))
}
}
impl From<Size> for Gap {
fn from(value: Size) -> Self {
Self(value)
}
}
impl From<(u32, u32)> for Gap {
fn from((horizontal, vertical): (u32, u32)) -> Self {
Self(Size::new(horizontal, vertical))
}
}