layer_shika_domain/value_objects/
popup_positioning_mode.rs

1/// Alignment mode for popup positioning
2///
3/// Determines how a popup is aligned relative to its placement point.
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
5pub enum PopupPositioningMode {
6    /// Align popup's top-left corner to placement point
7    #[default]
8    TopLeft,
9    /// Center popup horizontally at placement point, top edge aligned
10    TopCenter,
11    /// Align popup's top-right corner to placement point
12    TopRight,
13    /// Center popup vertically at placement point, left edge aligned
14    CenterLeft,
15    /// Center popup both horizontally and vertically at placement point
16    Center,
17    /// Center popup vertically at placement point, right edge aligned
18    CenterRight,
19    /// Align popup's bottom-left corner to placement point
20    BottomLeft,
21    /// Center popup horizontally at placement point, bottom edge aligned
22    BottomCenter,
23    /// Align popup's bottom-right corner to placement point
24    BottomRight,
25}
26
27impl PopupPositioningMode {
28    #[must_use]
29    pub const fn center_x(self) -> bool {
30        matches!(self, Self::TopCenter | Self::Center | Self::BottomCenter)
31    }
32
33    #[must_use]
34    pub const fn center_y(self) -> bool {
35        matches!(self, Self::CenterLeft | Self::Center | Self::CenterRight)
36    }
37
38    #[must_use]
39    pub const fn from_flags(center_x: bool, center_y: bool) -> Self {
40        match (center_x, center_y) {
41            (false, false) => Self::TopLeft,
42            (true, false) => Self::TopCenter,
43            (false, true) => Self::CenterLeft,
44            (true, true) => Self::Center,
45        }
46    }
47}