summaryrefslogtreecommitdiffstats
path: root/style/src/toggler.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2022-07-09 02:28:52 +0200
committerLibravatar GitHub <noreply@github.com>2022-07-09 02:28:52 +0200
commite053e25d2ccb17f7a162685a106a8bbd915a873f (patch)
tree5304f3ea2712e8889c7278ec5e57418f484d8f6c /style/src/toggler.rs
parent66eb6263003c1bbedd1fd14d6b12f172d20a6211 (diff)
parent7105db97a53d90adf429091298f31c90974d8f08 (diff)
downloadiced-e053e25d2ccb17f7a162685a106a8bbd915a873f.tar.gz
iced-e053e25d2ccb17f7a162685a106a8bbd915a873f.tar.bz2
iced-e053e25d2ccb17f7a162685a106a8bbd915a873f.zip
Merge pull request #1362 from iced-rs/theming
Theming
Diffstat (limited to 'style/src/toggler.rs')
-rw-r--r--style/src/toggler.rs45
1 files changed, 4 insertions, 41 deletions
diff --git a/style/src/toggler.rs b/style/src/toggler.rs
index c06a8cd1..4ee7db46 100644
--- a/style/src/toggler.rs
+++ b/style/src/toggler.rs
@@ -3,7 +3,7 @@ use iced_core::Color;
/// The appearance of a toggler.
#[derive(Debug)]
-pub struct Style {
+pub struct Appearance {
pub background: Color,
pub background_border: Option<Color>,
pub foreground: Color,
@@ -12,46 +12,9 @@ pub struct Style {
/// A set of rules that dictate the style of a toggler.
pub trait StyleSheet {
- fn active(&self, is_active: bool) -> Style;
+ type Style: Default + Copy;
- fn hovered(&self, is_active: bool) -> Style;
-}
-
-struct Default;
-
-impl StyleSheet for Default {
- fn active(&self, is_active: bool) -> Style {
- Style {
- background: if is_active {
- Color::from_rgb(0.0, 1.0, 0.0)
- } else {
- Color::from_rgb(0.7, 0.7, 0.7)
- },
- background_border: None,
- foreground: Color::WHITE,
- foreground_border: None,
- }
- }
-
- fn hovered(&self, is_active: bool) -> Style {
- Style {
- foreground: Color::from_rgb(0.95, 0.95, 0.95),
- ..self.active(is_active)
- }
- }
-}
-
-impl<'a> std::default::Default for Box<dyn StyleSheet + 'a> {
- fn default() -> Self {
- Box::new(Default)
- }
-}
+ fn active(&self, style: Self::Style, is_active: bool) -> Appearance;
-impl<'a, T> From<T> for Box<dyn StyleSheet + 'a>
-where
- T: 'a + StyleSheet,
-{
- fn from(style: T) -> Self {
- Box::new(style)
- }
+ fn hovered(&self, style: Self::Style, is_active: bool) -> Appearance;
}