From a0103a8693e3a6b3746dc4d4edda471a28848196 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 21 Feb 2024 06:23:47 +0100 Subject: Add default `disabled` implementation to `checkbox::StyleSheet` --- style/src/checkbox.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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 + } + } } -- cgit From a5363f788c1d442f0a35f2f450a1ea7de6230de2 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 21 Feb 2024 06:24:18 +0100 Subject: Add default `hovered` implementation to `svg::StyleSheet` --- style/src/svg.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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) + } } -- cgit From 94fd336f4c849f698fee93cc8005298d5b7a68d6 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 21 Feb 2024 06:36:53 +0100 Subject: Update `CHANGELOG` --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ef8cc66b..bea24a28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `extend` and `from_vec` methods for `Column` and `Row`. [#2264](https://github.com/iced-rs/iced/pull/2264) - `PartialOrd`, `Ord`, and `Hash` implementations for `keyboard::Modifiers`. [#2270](https://github.com/iced-rs/iced/pull/2270) - `clipboard` module in `advanced` module. [#2272](https://github.com/iced-rs/iced/pull/2272) +- Default `disabled` style for `checkbox` and `hovered` style for `Svg`. [#2273](https://github.com/iced-rs/iced/pull/2273) ### Fixed - Black images when using OpenGL backend in `iced_wgpu`. [#2259](https://github.com/iced-rs/iced/pull/2259) -- cgit