#[repr(transparent)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct WindowFlags(pub u32);
impl WindowFlags {
pub const NONE: Self = Self(0);
pub const BORDERLESS: Self = Self(1 << 0);
pub const ALWAYS_ON_TOP: Self = Self(1 << 1);
pub const TRANSPARENT: Self = Self(1 << 2);
pub const FULLSCREEN: Self = Self(1 << 3);
pub const NO_RESIZE: Self = Self(1 << 4);
pub const NO_MINIMIZE: Self = Self(1 << 5);
pub const NO_MAXIMIZE: Self = Self(1 << 6);
pub const NO_CLOSE: Self = Self(1 << 7);
pub const BACKGROUND: Self = Self(1 << 8);
pub const OVERLAY: Self = Self(1 << 9);
pub const MODAL: Self = Self(1 << 10);
pub const SPLASH: Self = Self(1 << 11);
pub const ALWAYS_RECEIVE_INPUT: Self = Self(1 << 12);
pub const SKIP_TASKBAR: Self = Self(1 << 13);
pub const NO_FOCUS: Self = Self(1 << 14);
pub const HAS_SHADOW: Self = Self(1 << 15);
#[inline]
pub const fn from_bits(bits: u32) -> Self {
Self(bits)
}
#[inline]
pub const fn has(&self, flag: Self) -> bool {
(self.0 & flag.0) != 0
}
#[inline]
pub const fn with(&self, flag: Self) -> Self {
Self(self.0 | flag.0)
}
#[inline]
pub const fn without(&self, flag: Self) -> Self {
Self(self.0 & !flag.0)
}
#[inline]
pub const fn toggle(&self, flag: Self) -> Self {
Self(self.0 ^ flag.0)
}
#[inline]
pub const fn bits(&self) -> u32 {
self.0
}
#[inline]
pub const fn is_background(&self) -> bool {
self.has(Self::BACKGROUND)
}
#[inline]
pub const fn is_overlay(&self) -> bool {
self.has(Self::OVERLAY)
}
#[inline]
pub const fn has_decorations(&self) -> bool {
!self.has(Self::BORDERLESS)
}
}
impl core::ops::BitOr for WindowFlags {
type Output = Self;
#[inline]
fn bitor(self, rhs: Self) -> Self {
Self(self.0 | rhs.0)
}
}
impl core::ops::BitAnd for WindowFlags {
type Output = Self;
#[inline]
fn bitand(self, rhs: Self) -> Self {
Self(self.0 & rhs.0)
}
}
impl core::ops::BitOrAssign for WindowFlags {
#[inline]
fn bitor_assign(&mut self, rhs: Self) {
self.0 |= rhs.0;
}
}
impl core::ops::Not for WindowFlags {
type Output = Self;
#[inline]
fn not(self) -> Self {
Self(!self.0)
}
}