#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
#[non_exhaustive]
pub enum HoverButton {
#[default]
None,
Close,
Minimize,
Maximize,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Dirty(u32);
impl Dirty {
pub const NONE: Self = Self(0);
pub const TITLE: Self = Self(1 << 0);
pub const FOCUS: Self = Self(1 << 1);
pub const HOVER: Self = Self(1 << 2);
pub const GEOMETRY: Self = Self(1 << 3);
pub const ANIMATION: Self = Self(1 << 4);
pub const ALL: Self = Self(u32::MAX);
#[must_use]
pub const fn intersects(self, other: Self) -> bool {
self.0 & other.0 != 0
}
#[must_use]
pub const fn union(self, other: Self) -> Self {
Self(self.0 | other.0)
}
#[must_use]
pub const fn is_empty(self) -> bool {
self.0 == 0
}
}
pub const PROGRESS_UNSET: f32 = -1.0;
#[derive(Debug, Clone, PartialEq)]
#[allow(
clippy::exhaustive_structs,
reason = "built by callers with `..Default::default()`, which a new field does not break"
)]
pub struct WindowState {
pub title: String,
pub focused: bool,
pub hover: HoverButton,
pub dirty: Dirty,
pub focus_progress: f32,
pub hover_progress: f32,
}
impl Default for WindowState {
fn default() -> Self {
Self {
title: String::new(),
focused: false,
hover: HoverButton::None,
dirty: Dirty::ALL,
focus_progress: PROGRESS_UNSET,
hover_progress: PROGRESS_UNSET,
}
}
}