use crate::prelude::*;
class_names! {
#[doc = "Class name for the Disabled"]
DISABLED,
}
#[derive(Clone, Default)]
pub struct Disabled {
pub disabled: bool,
}
impl Declare for Disabled {
type Builder = FatObj<()>;
#[inline]
fn declarer() -> Self::Builder { FatObj::new(()) }
}
impl<'c> ComposeChild<'c> for Disabled {
type Child = Widget<'c>;
fn compose_child(this: impl StateWriter<Value = Self>, child: Self::Child) -> Widget<'c> {
fn_widget! {
let mut child = FatObj::new(child);
@FocusScope {
skip_descendants: pipe!($this.disabled()),
skip_host: pipe!($this.disabled()),
@IgnorePointer {
ignore: pipe!($this.disabled()).map(
|v| if v { IgnoreScope::Subtree } else { IgnoreScope::None }
),
@ $child { class: pipe!($this.disabled()).map(|v| v.then_some(DISABLED)) }
}
}
}
.into_widget()
}
}
impl Disabled {
fn disabled(&self) -> bool { self.disabled }
}