epaint/
direction.rs

1/// A cardinal direction, one of [`LeftToRight`](Direction::LeftToRight), [`RightToLeft`](Direction::RightToLeft), [`TopDown`](Direction::TopDown), [`BottomUp`](Direction::BottomUp).
2#[derive(Clone, Copy, Debug, PartialEq, Eq)]
3#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
4pub enum Direction {
5    LeftToRight,
6    RightToLeft,
7    TopDown,
8    BottomUp,
9}
10
11impl Direction {
12    #[inline(always)]
13    pub fn is_horizontal(self) -> bool {
14        match self {
15            Self::LeftToRight | Self::RightToLeft => true,
16            Self::TopDown | Self::BottomUp => false,
17        }
18    }
19
20    #[inline(always)]
21    pub fn is_vertical(self) -> bool {
22        match self {
23            Self::LeftToRight | Self::RightToLeft => false,
24            Self::TopDown | Self::BottomUp => true,
25        }
26    }
27}