#[repr(u8)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Default, Hash)]
pub enum WindowState {
#[default]
Normal = 0,
Minimized = 1,
Maximized = 2,
Fullscreen = 3,
TiledLeft = 4,
TiledRight = 5,
TiledTop = 6,
TiledBottom = 7,
Hidden = 8,
}
impl WindowState {
#[inline]
pub fn from_u8(value: u8) -> Option<Self> {
match value {
0 => Some(Self::Normal),
1 => Some(Self::Minimized),
2 => Some(Self::Maximized),
3 => Some(Self::Fullscreen),
4 => Some(Self::TiledLeft),
5 => Some(Self::TiledRight),
6 => Some(Self::TiledTop),
7 => Some(Self::TiledBottom),
8 => Some(Self::Hidden),
_ => None,
}
}
#[inline]
pub const fn name(&self) -> &'static str {
match self {
Self::Normal => "Normal",
Self::Minimized => "Minimized",
Self::Maximized => "Maximized",
Self::Fullscreen => "Fullscreen",
Self::TiledLeft => "Tiled Left",
Self::TiledRight => "Tiled Right",
Self::TiledTop => "Tiled Top",
Self::TiledBottom => "Tiled Bottom",
Self::Hidden => "Hidden",
}
}
#[inline]
pub const fn is_visible(&self) -> bool {
!matches!(self, Self::Minimized | Self::Hidden)
}
#[inline]
pub const fn is_tiled(&self) -> bool {
matches!(
self,
Self::TiledLeft | Self::TiledRight | Self::TiledTop | Self::TiledBottom
)
}
}
#[repr(u8)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Default, Hash)]
pub enum WindowType {
#[default]
Normal = 0,
Dialog = 1,
Menu = 2,
Tooltip = 3,
Notification = 4,
Splash = 5,
Desktop = 6,
Dock = 7,
Dropdown = 8,
Popup = 9,
Dnd = 10,
}
impl WindowType {
#[inline]
pub fn from_u8(value: u8) -> Option<Self> {
match value {
0 => Some(Self::Normal),
1 => Some(Self::Dialog),
2 => Some(Self::Menu),
3 => Some(Self::Tooltip),
4 => Some(Self::Notification),
5 => Some(Self::Splash),
6 => Some(Self::Desktop),
7 => Some(Self::Dock),
8 => Some(Self::Dropdown),
9 => Some(Self::Popup),
10 => Some(Self::Dnd),
_ => None,
}
}
#[inline]
pub const fn name(&self) -> &'static str {
match self {
Self::Normal => "Normal",
Self::Dialog => "Dialog",
Self::Menu => "Menu",
Self::Tooltip => "Tooltip",
Self::Notification => "Notification",
Self::Splash => "Splash",
Self::Desktop => "Desktop",
Self::Dock => "Dock",
Self::Dropdown => "Dropdown",
Self::Popup => "Popup",
Self::Dnd => "Dnd",
}
}
#[inline]
pub const fn is_focusable(&self) -> bool {
matches!(self, Self::Normal | Self::Dialog)
}
#[inline]
pub const fn is_transient(&self) -> bool {
matches!(
self,
Self::Menu | Self::Tooltip | Self::Dropdown | Self::Popup | Self::Dnd
)
}
}
#[repr(u8)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum ResizeEdge {
Top = 1,
Bottom = 2,
Left = 4,
Right = 8,
TopLeft = 5, TopRight = 9, BottomLeft = 6, BottomRight = 10, }
impl ResizeEdge {
#[inline]
pub fn from_u8(value: u8) -> Option<Self> {
match value {
1 => Some(Self::Top),
2 => Some(Self::Bottom),
4 => Some(Self::Left),
8 => Some(Self::Right),
5 => Some(Self::TopLeft),
9 => Some(Self::TopRight),
6 => Some(Self::BottomLeft),
10 => Some(Self::BottomRight),
_ => None,
}
}
#[inline]
pub const fn has_top(&self) -> bool {
(*self as u8) & 1 != 0
}
#[inline]
pub const fn has_bottom(&self) -> bool {
(*self as u8) & 2 != 0
}
#[inline]
pub const fn has_left(&self) -> bool {
(*self as u8) & 4 != 0
}
#[inline]
pub const fn has_right(&self) -> bool {
(*self as u8) & 8 != 0
}
}