#[derive(Debug, Clone, Default, PartialEq, Eq, Hash)]
pub struct Alignment {
pub horizontal: Option<HorizontalAlignment>,
pub vertical: Option<VerticalAlignment>,
pub wrap_text: bool,
pub shrink_to_fit: bool,
pub text_rotation: Option<i16>,
}
impl Alignment {
pub fn new() -> Self {
Self::default()
}
pub fn horizontal(mut self, ha: HorizontalAlignment) -> Self {
self.horizontal = Some(ha);
self
}
pub fn vertical(mut self, va: VerticalAlignment) -> Self {
self.vertical = Some(va);
self
}
pub fn wrap_text(mut self, wrap: bool) -> Self {
self.wrap_text = wrap;
self
}
pub fn shrink_to_fit(mut self, shrink: bool) -> Self {
self.shrink_to_fit = shrink;
self
}
pub fn text_rotation(mut self, rotation: i16) -> Self {
self.text_rotation = Some(rotation);
self
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum HorizontalAlignment {
Left,
Center,
Right,
Fill,
Justify,
CenterContinuous,
Distributed,
}
impl std::fmt::Display for HorizontalAlignment {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
HorizontalAlignment::Left => write!(f, "left"),
HorizontalAlignment::Center => write!(f, "center"),
HorizontalAlignment::Right => write!(f, "right"),
HorizontalAlignment::Fill => write!(f, "fill"),
HorizontalAlignment::Justify => write!(f, "justify"),
HorizontalAlignment::CenterContinuous => write!(f, "centerContinuous"),
HorizontalAlignment::Distributed => write!(f, "distributed"),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum VerticalAlignment {
Top,
Center,
Bottom,
Justify,
Distributed,
}
impl std::fmt::Display for VerticalAlignment {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
VerticalAlignment::Top => write!(f, "top"),
VerticalAlignment::Center => write!(f, "center"),
VerticalAlignment::Bottom => write!(f, "bottom"),
VerticalAlignment::Justify => write!(f, "justify"),
VerticalAlignment::Distributed => write!(f, "distributed"),
}
}
}