Introduce support for disabling a checkbox
This commit is contained in:
parent
b95f3ab12f
commit
b5f1ca1695
14 changed files with 166 additions and 85 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.weak,
|
||||
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.weak,
|
||||
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(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue