diff options
author | 2024-02-21 07:01:49 +0100 | |
---|---|---|
committer | 2024-02-21 07:01:49 +0100 | |
commit | c0c5a01079b39a1d831f0a80d6f2ee7f539a1673 (patch) | |
tree | 2d8991db5af4a961e274f1af4097bd14626d2727 /style | |
parent | 7a4e86a7ab36620e7cb0e172ca9c9ea246e1dfa0 (diff) | |
parent | 94fd336f4c849f698fee93cc8005298d5b7a68d6 (diff) | |
download | iced-c0c5a01079b39a1d831f0a80d6f2ee7f539a1673.tar.gz iced-c0c5a01079b39a1d831f0a80d6f2ee7f539a1673.tar.bz2 iced-c0c5a01079b39a1d831f0a80d6f2ee7f539a1673.zip |
Merge pull request #2273 from iced-rs/missing-default-styles
Default `disabled` style for `checkbox` and `hovered` style for `Svg`
Diffstat (limited to '')
-rw-r--r-- | style/src/checkbox.rs | 17 | ||||
-rw-r--r-- | style/src/svg.rs | 4 |
2 files changed, 19 insertions, 2 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 + } + } } diff --git a/style/src/svg.rs b/style/src/svg.rs index 5053f9f8..3fe5546b 100644 --- a/style/src/svg.rs +++ b/style/src/svg.rs @@ -22,5 +22,7 @@ pub trait StyleSheet { fn appearance(&self, style: &Self::Style) -> Appearance; /// Produces the hovered [`Appearance`] of a svg content. - fn hovered(&self, style: &Self::Style) -> Appearance; + fn hovered(&self, style: &Self::Style) -> Appearance { + self.appearance(style) + } } |