summaryrefslogtreecommitdiffstats
path: root/style
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector@hecrj.dev>2024-02-01 13:51:11 +0100
committerLibravatar GitHub <noreply@github.com>2024-02-01 13:51:11 +0100
commit759f0e922598504705b543185bc7140a652b726a (patch)
treea7f2eb4ddee8127ace2e7002091c502d22bbb1c6 /style
parentb95f3ab12f863f4de668e4e6f8a75b7d3acdf2b7 (diff)
parentb0d40d70a041ffaa07d94bea8fba11589c239725 (diff)
downloadiced-759f0e922598504705b543185bc7140a652b726a.tar.gz
iced-759f0e922598504705b543185bc7140a652b726a.tar.bz2
iced-759f0e922598504705b543185bc7140a652b726a.zip
Merge pull request #2109 from avsaase/feat/checkbox-disabled
Add option to disable checkbox
Diffstat (limited to 'style')
-rw-r--r--style/src/checkbox.rs3
-rw-r--r--style/src/theme.rs40
2 files changed, 41 insertions, 2 deletions
diff --git a/style/src/checkbox.rs b/style/src/checkbox.rs
index d96ea4ad..82c1766f 100644
--- a/style/src/checkbox.rs
+++ b/style/src/checkbox.rs
@@ -24,4 +24,7 @@ pub trait StyleSheet {
/// Produces the hovered [`Appearance`] of a checkbox.
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;
}
diff --git a/style/src/theme.rs b/style/src/theme.rs
index 8d1ff237..166410ae 100644
--- a/style/src/theme.rs
+++ b/style/src/theme.rs
@@ -319,7 +319,7 @@ impl checkbox::StyleSheet for Theme {
Checkbox::Secondary => checkbox_appearance(
palette.background.base.text,
palette.background.base,
- palette.background.base,
+ palette.background.strong,
is_checked,
),
Checkbox::Success => checkbox_appearance(
@@ -355,7 +355,7 @@ impl checkbox::StyleSheet for Theme {
Checkbox::Secondary => checkbox_appearance(
palette.background.base.text,
palette.background.weak,
- palette.background.base,
+ palette.background.strong,
is_checked,
),
Checkbox::Success => checkbox_appearance(
@@ -373,6 +373,42 @@ impl checkbox::StyleSheet for Theme {
Checkbox::Custom(custom) => custom.hovered(self, is_checked),
}
}
+
+ fn disabled(
+ &self,
+ style: &Self::Style,
+ is_checked: bool,
+ ) -> checkbox::Appearance {
+ let palette = self.extended_palette();
+
+ match style {
+ Checkbox::Primary => checkbox_appearance(
+ palette.primary.strong.text,
+ palette.background.weak,
+ palette.background.strong,
+ is_checked,
+ ),
+ Checkbox::Secondary => checkbox_appearance(
+ palette.background.strong.color,
+ palette.background.weak,
+ palette.background.weak,
+ is_checked,
+ ),
+ Checkbox::Success => checkbox_appearance(
+ palette.success.base.text,
+ palette.background.weak,
+ palette.success.weak,
+ is_checked,
+ ),
+ Checkbox::Danger => checkbox_appearance(
+ palette.danger.base.text,
+ palette.background.weak,
+ palette.danger.weak,
+ is_checked,
+ ),
+ Checkbox::Custom(custom) => custom.active(self, is_checked),
+ }
+ }
}
fn checkbox_appearance(