layer_shika_domain/value_objects/
popup_position.rs

1use crate::dimensions::LogicalRect;
2
3#[derive(Debug, Clone)]
4pub enum PopupPosition {
5    /// Absolute position in surface coordinates
6    Absolute { x: f32, y: f32 },
7
8    /// Relative to cursor position
9    Cursor { offset: Offset },
10
11    /// Relative to a UI element (rect)
12    Element {
13        rect: LogicalRect,
14        anchor: AnchorPoint,
15        alignment: Alignment,
16    },
17
18    /// Relative to parent popup
19    RelativeToParent {
20        anchor: AnchorPoint,
21        alignment: Alignment,
22        offset: Offset,
23    },
24
25    /// Centered on output
26    Centered { offset: Offset },
27}
28
29/// 9-point anchor system
30#[derive(Debug, Clone, Copy, PartialEq, Eq)]
31pub enum AnchorPoint {
32    TopLeft,
33    TopCenter,
34    TopRight,
35    CenterLeft,
36    Center,
37    CenterRight,
38    BottomLeft,
39    BottomCenter,
40    BottomRight,
41}
42
43/// How popup aligns relative to anchor
44#[derive(Debug, Clone, Copy, PartialEq, Eq)]
45pub enum Alignment {
46    /// Popup starts at anchor
47    Start,
48    /// Popup centers on anchor
49    Center,
50    /// Popup ends at anchor
51    End,
52}
53
54#[derive(Debug, Clone, Copy, Default, PartialEq)]
55pub struct Offset {
56    pub x: f32,
57    pub y: f32,
58}