1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use crate::PositioningAlgorithm;
use crate::common::Position;

/// #### Description
/// Positions the child relative to the viewport rather than the parent element
///
pub struct AbsolutePositioning;

impl AbsolutePositioning {
    /// #### Description
    /// Creates an absolute positioning algorithm
    ///
    /// #### Returns
    /// [Box]<[AbsolutePositioning]> - An absolute positioning algorithm
    ///
    pub fn new() -> Box<Self> {
        return Box::new(Self);
    }
}

impl PositioningAlgorithm for AbsolutePositioning {
    fn calculate_position(&self, child_position: Position) -> Position {
        return child_position;
    }

    fn set_parent_position(&mut self, _: Position) {
        // Due to the way this positioning algorithm works, this is uneeded, but
        // due to how the program is structured the positioning algorithm trait
        // requires this function, so this functions body will remain empty
    }
}