Skip to main content

settings_model/
dock_edge.rs

1//! The edge a panel kept at the screen's edges docks to, as the person's settings name it.
2
3use serde::{Deserialize, Serialize};
4
5/// Where something kept at the screen's edges waits (the pinned people
6/// overlay). Corners and the side and bottom edges; never the top edge.
7#[cfg_attr(feature = "model", derive(tilo_resource::Model))]
8#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
9#[serde(rename_all = "snake_case")]
10pub enum DockEdge {
11    Left,
12    Right,
13    Bottom,
14    BottomLeft,
15    BottomRight,
16}
17
18impl DockEdge {
19    pub const ALL: [Self; 5] = [
20        Self::Left,
21        Self::Right,
22        Self::Bottom,
23        Self::BottomLeft,
24        Self::BottomRight,
25    ];
26
27    #[must_use]
28    pub const fn label(self) -> &'static str {
29        match self {
30            Self::Left => "Left edge",
31            Self::Right => "Right edge",
32            Self::Bottom => "Bottom edge",
33            Self::BottomLeft => "Bottom-left corner",
34            Self::BottomRight => "Bottom-right corner",
35        }
36    }
37}