Add default disabled implementation to checkbox::StyleSheet

This commit is contained in:
Héctor Ramón Jiménez 2024-02-21 06:23:47 +01:00
parent 7a4e86a7ab
commit a0103a8693
No known key found for this signature in database
GPG key ID: 0BF4EC06CD8E5686

View file

@ -26,5 +26,20 @@ pub trait StyleSheet {
fn hovered(&self, style: &Self::Style, is_checked: bool) -> Appearance;
/// Produces the disabled [`Appearance`] of a checkbox.
fn disabled(&self, style: &Self::Style, is_checked: bool) -> Appearance;
fn disabled(&self, style: &Self::Style, is_checked: bool) -> Appearance {
let active = self.active(style, is_checked);
Appearance {
background: match active.background {
Background::Color(color) => Background::Color(Color {
a: color.a * 0.5,
..color
}),
Background::Gradient(gradient) => {
Background::Gradient(gradient.mul_alpha(0.5))
}
},
..active
}
}
}