#![warn(missing_copy_implementations)]
#[derive(Copy, Clone, PartialEq)]
pub enum Layout {
Freeform,
Horizontal,
Vertical,
HorizontalRev,
VerticalRev,
}
#[derive(Copy, Clone, PartialEq)]
pub enum AlignH {
Left,
Center,
Right,
}
#[derive(Copy, Clone, PartialEq)]
pub enum AlignV {
Top,
Middle,
Bottom,
}
pub use AlignH::*;
pub use AlignV::*;
pub type Alignment = (AlignH, AlignV);
pub const CENTER: Alignment = (Center, Middle);
#[derive(Copy, Clone, PartialEq)]
pub struct Padding {
pub right: f32,
pub bottom: f32,
pub left: f32,
pub top: f32,
}
impl Padding {
pub fn hv(horizontal: f32, vertical: f32) -> Self {
Self {
right: horizontal,
bottom: vertical,
left: horizontal,
top: vertical,
}
}
pub fn even(amount: f32) -> Self {
Self {
right: amount,
bottom: amount,
left: amount,
top: amount,
}
}
pub fn right(amount: f32) -> Self {
Self {
right: amount,
..Self::default()
}
}
pub fn bottom(amount: f32) -> Self {
Self {
bottom: amount,
..Self::default()
}
}
pub fn left(amount: f32) -> Self {
Self {
left: amount,
..Self::default()
}
}
pub fn top(amount: f32) -> Self {
Self {
top: amount,
..Self::default()
}
}
}
impl Default for Padding {
fn default() -> Self {
Self {
right: 0.0,
bottom: 0.0,
left: 0.0,
top: 0.0,
}
}
}
impl From<(f32, f32)> for Padding {
fn from((horizontal, vertical): (f32, f32)) -> Self {
Self::hv(horizontal, vertical)
}
}
impl From<f32> for Padding {
fn from(amount: f32) -> Self {
Self::even(amount)
}
}