use bitflags::bitflags;
bitflags! {
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct BackdropSources: u8 {
const SURFACE = 1;
const COMPOSITOR = 2;
}
}
impl Default for BackdropSources {
fn default() -> Self {
Self::all()
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct BackdropBlur {
pub radius: f32,
pub sources: BackdropSources,
}
impl BackdropBlur {
pub fn new(radius: f32) -> Self {
Self {
radius,
sources: BackdropSources::default(),
}
}
pub fn sources(mut self, sources: BackdropSources) -> Self {
self.sources = sources;
self
}
pub(crate) fn asks_for_anything(&self) -> bool {
if self.sources.contains(BackdropSources::SURFACE) {
self.radius > 0.0
} else {
!self.sources.is_empty()
}
}
}
impl From<f32> for BackdropBlur {
fn from(radius: f32) -> Self {
Self::new(radius)
}
}
impl From<i32> for BackdropBlur {
fn from(radius: i32) -> Self {
Self::new(radius as f32)
}
}
impl From<f64> for BackdropBlur {
fn from(radius: f64) -> Self {
Self::new(radius as f32)
}
}
crate::reactive::converts!(
f32 => BackdropBlur,
f64 => BackdropBlur,
i32 => BackdropBlur,
);