#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub enum Constraint {
#[default]
Start,
End,
Both,
Center,
Scale,
}
impl Constraint {
pub const ALL: [Self; 5] = [
Self::Start,
Self::End,
Self::Both,
Self::Center,
Self::Scale,
];
#[must_use]
pub const fn name(self) -> &'static str {
match self {
Self::Start => "start",
Self::End => "end",
Self::Both => "both",
Self::Center => "center",
Self::Scale => "scale",
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct Constraints {
pub horizontal: Constraint,
pub vertical: Constraint,
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub enum Direction {
#[default]
Row,
Column,
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub enum Align {
#[default]
Start,
Center,
End,
SpaceBetween,
Stretch,
}
impl Align {
pub const ALL: [Self; 5] = [
Self::Start,
Self::Center,
Self::End,
Self::SpaceBetween,
Self::Stretch,
];
#[must_use]
pub const fn name(self) -> &'static str {
match self {
Self::Start => "start",
Self::Center => "center",
Self::End => "end",
Self::SpaceBetween => "space-between",
Self::Stretch => "stretch",
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct Padding {
pub top: f64,
pub right: f64,
pub bottom: f64,
pub left: f64,
}
impl Padding {
#[must_use]
pub const fn all(value: f64) -> Self {
Self {
top: value,
right: value,
bottom: value,
left: value,
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct AutoLayout {
pub direction: Direction,
pub gap: f64,
pub padding: Padding,
pub align: Align,
pub cross_align: Align,
pub wrap: bool,
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub enum Sizing {
#[default]
Fixed,
Fill,
Hug,
}
impl Sizing {
pub const ALL: [Self; 3] = [Self::Fixed, Self::Fill, Self::Hug];
#[must_use]
pub const fn name(self) -> &'static str {
match self {
Self::Fixed => "fixed",
Self::Fill => "fill",
Self::Hug => "hug",
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct LayoutChild {
pub width: Sizing,
pub height: Sizing,
pub absolute: bool,
}