#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum LayoutDirection {
Vertical,
Horizontal,
}
#[derive(Debug, Clone, PartialEq)]
pub enum LayoutConstraint {
Length(u16),
Percentage(u16),
Min(u16),
Max(u16),
Ratio(u32, u32),
}
pub trait UILayer {
type Area: Clone;
fn name(&self) -> &str;
fn direction(&self) -> LayoutDirection;
fn constraints(&self) -> &[LayoutConstraint];
fn apply(&self, area: Self::Area) -> Vec<Self::Area>;
fn split(&self, area: Self::Area) -> Vec<Self::Area> {
self.apply(area)
}
}
pub trait UILayoutPresets: UILayer {
fn three_panel() -> Self;
fn two_column(left_percent: u16) -> Self;
fn sidebar() -> Self
where
Self: Sized,
{
Self::two_column(20)
}
fn detail() -> Self
where
Self: Sized,
{
Self::two_column(80)
}
}