Skip to main content

ferroui_controls/
size_to_content.rs

1use bitflags::bitflags;
2
3bitflags! {
4    /// Determines how a window will size itself to fit its content.
5    #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
6    pub struct SizeToContent: i32 {
7        /// The window will not automatically size itself to fit its content.
8        const MANUAL = 0;
9
10        /// The window will size itself horizontally to fit its content.
11        const WIDTH = 1;
12
13        /// The window will size itself vertically to fit its content.
14        const HEIGHT = 2;
15
16        /// The window will size itself horizontally and vertically to fit
17        /// its content.
18        const WIDTH_AND_HEIGHT = 3;
19    }
20}
21
22#[cfg(test)]
23mod tests {
24    use super::*;
25
26    #[test]
27    fn values_match_the_reference_values() {
28        assert_eq!(SizeToContent::MANUAL.bits(), 0);
29        assert_eq!(SizeToContent::WIDTH.bits(), 1);
30        assert_eq!(SizeToContent::HEIGHT.bits(), 2);
31        assert_eq!(SizeToContent::WIDTH_AND_HEIGHT.bits(), 3);
32        assert_eq!(SizeToContent::WIDTH | SizeToContent::HEIGHT, SizeToContent::WIDTH_AND_HEIGHT);
33        assert_eq!(SizeToContent::default(), SizeToContent::MANUAL);
34    }
35}