#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct Alignment {
pub horizontal : Horizontal,
pub vertical : Vertical
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum Horizontal {
Left,
Center,
Right
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum Vertical {
Top,
Middle,
Bottom
}
impl Alignment {
#[inline]
pub const fn tile() -> Self {
Alignment {
horizontal: Horizontal::Left,
vertical: Vertical::Top
}
}
#[inline]
pub const fn pixel() -> Self {
Alignment {
horizontal: Horizontal::Left,
vertical: Vertical::Bottom
}
}
#[inline]
pub const fn middle_center() -> Self {
Alignment {
horizontal: Horizontal::Center,
vertical: Vertical::Middle
}
}
#[inline]
pub const fn new (horizontal : Horizontal, vertical : Vertical) -> Self {
Alignment { horizontal, vertical }
}
}
impl Default for Alignment {
fn default() -> Self {
Self::tile()
}
}
impl Horizontal {
#[inline]
pub const fn right_sign (&self) -> i32 {
match self {
Horizontal::Left | Horizontal::Center => 1,
Horizontal::Right => -1
}
}
#[inline]
pub const fn left_sign (&self) -> i32 {
match self {
Horizontal::Left | Horizontal::Center => -1,
Horizontal::Right => 1
}
}
}
impl Vertical {
#[inline]
pub const fn up_sign (&self) -> i32 {
match self {
Vertical::Bottom | Vertical::Middle => 1,
Vertical::Top => -1
}
}
#[inline]
pub const fn down_sign (&self) -> i32 {
match self {
Vertical::Bottom | Vertical::Middle => -1,
Vertical::Top => 1
}
}
}