leftwm_layouts/geometry/reserve.rs
1use serde::{Deserialize, Serialize};
2
3/// Determines whether the space of a layouts' column should be reserved
4/// when there is no window inside the column. A value of [`Reserve::Reserve`] or
5/// [`Reserve::ReserveAndCenter`] will reserve the column space and make other
6/// column(s) avoid it entirely. While a value of [`Reserve::None`]
7/// makes other columns overtake the empty column space.
8#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
9pub enum Reserve {
10 /// No space will be reserved. Instead, the populated space
11 /// will take over the empty space. This is the default variant.
12 ///
13 /// ```txt
14 /// +--------------+
15 /// | |
16 /// | MAIN |
17 /// | |
18 /// +--------------+
19 /// ```
20 #[default]
21 None,
22
23 /// Empty space is reserved in-place
24 /// and won't be populated with other elements
25 ///
26 /// ```txt
27 /// +--------+-----+
28 /// | | |
29 /// | MAIN | |
30 /// | | |
31 /// +--------+-----+
32 /// ^
33 /// reserved empty space
34 /// ```
35 Reserve,
36
37 /// Empty space is reserved in terms of amount of space,
38 /// but not in terms of its position. Instead the populated
39 /// space will be centered, while the empty space is accounted
40 /// for on each side.
41 ///
42 /// ```txt
43 /// +--+--------+--+
44 /// | | | |
45 /// | | MAIN | |
46 /// | | | |
47 /// +--+--------+--+
48 /// ^ ^
49 /// reserved empty space
50 /// ```
51 ReserveAndCenter,
52}
53
54impl Reserve {
55 pub fn is_reserved(&self) -> bool {
56 match self {
57 Reserve::None => false,
58 Reserve::Reserve | Reserve::ReserveAndCenter => true,
59 }
60 }
61}
62
63#[cfg(test)]
64mod tests {}