diff options
Diffstat (limited to 'src/geom/dir.rs')
| -rw-r--r-- | src/geom/dir.rs | 79 |
1 files changed, 0 insertions, 79 deletions
diff --git a/src/geom/dir.rs b/src/geom/dir.rs deleted file mode 100644 index 48915471..00000000 --- a/src/geom/dir.rs +++ /dev/null @@ -1,79 +0,0 @@ -use super::*; - -/// The four directions into which content can be laid out. -#[derive(Copy, Clone, Eq, PartialEq, Hash)] -pub enum Dir { - /// Left to right. - LTR, - /// Right to left. - RTL, - /// Top to bottom. - TTB, - /// Bottom to top. - BTT, -} - -impl Dir { - /// The specific axis this direction belongs to. - pub const fn axis(self) -> Axis { - match self { - Self::LTR | Self::RTL => Axis::X, - Self::TTB | Self::BTT => Axis::Y, - } - } - - /// The side this direction starts at. - pub const fn start(self) -> Side { - match self { - Self::LTR => Side::Left, - Self::RTL => Side::Right, - Self::TTB => Side::Top, - Self::BTT => Side::Bottom, - } - } - - /// The side this direction ends at. - pub const fn end(self) -> Side { - match self { - Self::LTR => Side::Right, - Self::RTL => Side::Left, - Self::TTB => Side::Bottom, - Self::BTT => Side::Top, - } - } - - /// The inverse direction. - pub const fn inv(self) -> Self { - match self { - Self::LTR => Self::RTL, - Self::RTL => Self::LTR, - Self::TTB => Self::BTT, - Self::BTT => Self::TTB, - } - } - - /// Whether this direction points into the positive coordinate direction. - /// - /// The positive directions are left-to-right and top-to-bottom. - pub const fn is_positive(self) -> bool { - match self { - Self::LTR | Self::TTB => true, - Self::RTL | Self::BTT => false, - } - } -} - -impl Debug for Dir { - fn fmt(&self, f: &mut Formatter) -> fmt::Result { - f.pad(match self { - Self::LTR => "ltr", - Self::RTL => "rtl", - Self::TTB => "ttb", - Self::BTT => "btt", - }) - } -} - -cast! { - type Dir: "direction", -} |
