summaryrefslogtreecommitdiffstats
path: root/style
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-02-21 06:23:47 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-02-21 06:46:58 +0100
commita0103a8693e3a6b3746dc4d4edda471a28848196 (patch)
tree8c5977edf58683f4f4cfce58c594f88e39ecb635 /style
parent7a4e86a7ab36620e7cb0e172ca9c9ea246e1dfa0 (diff)
downloadiced-a0103a8693e3a6b3746dc4d4edda471a28848196.tar.gz
iced-a0103a8693e3a6b3746dc4d4edda471a28848196.tar.bz2
iced-a0103a8693e3a6b3746dc4d4edda471a28848196.zip
Add default `disabled` implementation to `checkbox::StyleSheet`
Diffstat (limited to 'style')
-rw-r--r--style/src/checkbox.rs17
1 files changed, 16 insertions, 1 deletions
diff --git a/style/src/checkbox.rs b/style/src/checkbox.rs
index 82c1766f..77093f69 100644
--- a/style/src/checkbox.rs
+++ b/style/src/checkbox.rs
@@ -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
+ }
+ }
}