summaryrefslogtreecommitdiffstats
path: root/style/src/theme.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-03-05 02:08:19 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-03-05 02:08:19 +0100
commit1f0a0c235a7729cf2d5716efeecb9c4dc972fdfa (patch)
tree77118b43726c9321d05190cb2e7963594e0f80a3 /style/src/theme.rs
parentf4a4845ddbdced81ae4ff60bfa19f0e602d84709 (diff)
downloadiced-1f0a0c235a7729cf2d5716efeecb9c4dc972fdfa.tar.gz
iced-1f0a0c235a7729cf2d5716efeecb9c4dc972fdfa.tar.bz2
iced-1f0a0c235a7729cf2d5716efeecb9c4dc972fdfa.zip
Simplify theming for `Checkbox` widget
Diffstat (limited to 'style/src/theme.rs')
-rw-r--r--style/src/theme.rs151
1 files changed, 0 insertions, 151 deletions
diff --git a/style/src/theme.rs b/style/src/theme.rs
index f967aebc..81303e68 100644
--- a/style/src/theme.rs
+++ b/style/src/theme.rs
@@ -4,7 +4,6 @@ pub mod palette;
pub use palette::Palette;
use crate::application;
-use crate::checkbox;
use crate::container;
use crate::core::widget::text;
use crate::menu;
@@ -284,156 +283,6 @@ impl<T: Fn(&Theme) -> application::Appearance> application::StyleSheet for T {
}
}
-/// The style of a checkbox.
-#[derive(Default)]
-pub enum Checkbox {
- /// The primary style.
- #[default]
- Primary,
- /// The secondary style.
- Secondary,
- /// The success style.
- Success,
- /// The danger style.
- Danger,
- /// A custom style.
- Custom(Box<dyn checkbox::StyleSheet<Style = Theme>>),
-}
-
-impl checkbox::StyleSheet for Theme {
- type Style = Checkbox;
-
- fn active(
- &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.base,
- palette.primary.strong,
- is_checked,
- ),
- Checkbox::Secondary => checkbox_appearance(
- palette.background.base.text,
- palette.background.base,
- palette.background.strong,
- is_checked,
- ),
- Checkbox::Success => checkbox_appearance(
- palette.success.base.text,
- palette.background.base,
- palette.success.base,
- is_checked,
- ),
- Checkbox::Danger => checkbox_appearance(
- palette.danger.base.text,
- palette.background.base,
- palette.danger.base,
- is_checked,
- ),
- Checkbox::Custom(custom) => custom.active(self, is_checked),
- }
- }
-
- fn hovered(
- &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.primary.base,
- is_checked,
- ),
- Checkbox::Secondary => checkbox_appearance(
- palette.background.base.text,
- palette.background.weak,
- palette.background.strong,
- is_checked,
- ),
- Checkbox::Success => checkbox_appearance(
- palette.success.base.text,
- palette.background.weak,
- palette.success.base,
- is_checked,
- ),
- Checkbox::Danger => checkbox_appearance(
- palette.danger.base.text,
- palette.background.weak,
- palette.danger.base,
- is_checked,
- ),
- 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(
- icon_color: Color,
- base: palette::Pair,
- accent: palette::Pair,
- is_checked: bool,
-) -> checkbox::Appearance {
- checkbox::Appearance {
- background: Background::Color(if is_checked {
- accent.color
- } else {
- base.color
- }),
- icon_color,
- border: Border {
- radius: 2.0.into(),
- width: 1.0,
- color: accent.color,
- },
- text_color: None,
- }
-}
-
/// The style of a container.
#[derive(Default)]
pub enum Container {