use crate::private::Sealed;
use iced::Alignment;
#[derive(Debug, Clone, Copy, Default)]
pub struct Horizontal;
impl Sealed for Horizontal {}
#[derive(Debug, Clone, Copy, Default)]
pub struct Vertical;
impl Sealed for Vertical {}
pub trait Direction: Sealed + Copy + Default {
type CrossAlign: Copy + Into<Alignment>;
fn default_align() -> Self::CrossAlign;
fn main_axis(width: f32, height: f32) -> f32;
fn cross_axis(width: f32, height: f32) -> f32;
fn is_horizontal() -> bool;
}
impl Direction for Horizontal {
type CrossAlign = iced::alignment::Vertical;
fn default_align() -> Self::CrossAlign {
iced::alignment::Vertical::Center
}
fn main_axis(width: f32, _height: f32) -> f32 {
width
}
fn cross_axis(_width: f32, height: f32) -> f32 {
height
}
fn is_horizontal() -> bool {
true
}
}
impl Direction for Vertical {
type CrossAlign = iced::alignment::Horizontal;
fn default_align() -> Self::CrossAlign {
iced::alignment::Horizontal::Center
}
fn main_axis(_width: f32, height: f32) -> f32 {
height
}
fn cross_axis(width: f32, _height: f32) -> f32 {
width
}
fn is_horizontal() -> bool {
false
}
}