From e2166ecad020662d246b364637efc4e6ee3bc1db Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Wed, 7 Sep 2022 11:56:11 -0400 Subject: wip: Custom palette for built in theme --- style/src/theme.rs | 9 ++++++++- style/src/theme/palette.rs | 8 +++++++- 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'style/src') diff --git a/style/src/theme.rs b/style/src/theme.rs index ea538c3a..7d47f1a1 100644 --- a/style/src/theme.rs +++ b/style/src/theme.rs @@ -1,5 +1,6 @@ pub mod palette; +use self::palette::Extended; pub use self::palette::Palette; use crate::application; @@ -20,10 +21,14 @@ use crate::toggler; use iced_core::{Background, Color}; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Clone, Copy, PartialEq)] pub enum Theme { Light, Dark, + Custom { + palette: Palette, + extended: Extended + } } impl Theme { @@ -31,6 +36,7 @@ impl Theme { match self { Self::Light => Palette::LIGHT, Self::Dark => Palette::DARK, + Self::Custom { palette, .. } => palette } } @@ -38,6 +44,7 @@ impl Theme { match self { Self::Light => &palette::EXTENDED_LIGHT, Self::Dark => &palette::EXTENDED_DARK, + Self::Custom { extended, .. } => extended, } } } diff --git a/style/src/theme/palette.rs b/style/src/theme/palette.rs index 4fb5e4c8..b3a10d28 100644 --- a/style/src/theme/palette.rs +++ b/style/src/theme/palette.rs @@ -58,6 +58,7 @@ impl Palette { }; } +#[derive(Debug, Clone, Copy, PartialEq)] pub struct Extended { pub background: Background, pub primary: Primary, @@ -95,7 +96,7 @@ impl Extended { } } -#[derive(Debug, Clone, Copy)] +#[derive(Debug, Clone, Copy, PartialEq)] pub struct Pair { pub color: Color, pub text: Color, @@ -110,6 +111,7 @@ impl Pair { } } +#[derive(Debug, Clone, Copy, PartialEq)] pub struct Background { pub base: Pair, pub weak: Pair, @@ -129,6 +131,7 @@ impl Background { } } +#[derive(Debug, Clone, Copy, PartialEq)] pub struct Primary { pub base: Pair, pub weak: Pair, @@ -148,6 +151,7 @@ impl Primary { } } +#[derive(Debug, Clone, Copy, PartialEq)] pub struct Secondary { pub base: Pair, pub weak: Pair, @@ -168,6 +172,7 @@ impl Secondary { } } +#[derive(Debug, Clone, Copy, PartialEq)] pub struct Success { pub base: Pair, pub weak: Pair, @@ -187,6 +192,7 @@ impl Success { } } +#[derive(Debug, Clone, Copy, PartialEq)] pub struct Danger { pub base: Pair, pub weak: Pair, -- cgit