summaryrefslogtreecommitdiffstats
path: root/style
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-11-03 03:21:26 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-11-03 03:23:36 +0100
commit9966c6f8834220e62fd66766d2e11d8a36e334e2 (patch)
treea1fc8c1ace0457016ae8baa74cbceebb28c873ab /style
parent09a531cd4427ff5dc972621094f33de0f94a0919 (diff)
downloadiced-9966c6f8834220e62fd66766d2e11d8a36e334e2.tar.gz
iced-9966c6f8834220e62fd66766d2e11d8a36e334e2.tar.bz2
iced-9966c6f8834220e62fd66766d2e11d8a36e334e2.zip
Make `Theme::Custom` fields opaque
Diffstat (limited to 'style')
-rw-r--r--style/src/theme.rs28
1 files changed, 22 insertions, 6 deletions
diff --git a/style/src/theme.rs b/style/src/theme.rs
index 4e83758b..35945aca 100644
--- a/style/src/theme.rs
+++ b/style/src/theme.rs
@@ -25,18 +25,19 @@ use iced_core::{Background, Color};
pub enum Theme {
Light,
Dark,
- Custom {
- palette: Box<Palette>,
- extended: Box<Extended>,
- }
+ Custom(Custom),
}
impl Theme {
+ pub fn custom(palette: Palette) -> Self {
+ Self::Custom(Custom::new(palette))
+ }
+
pub fn palette(self) -> Palette {
match self {
Self::Light => Palette::LIGHT,
Self::Dark => Palette::DARK,
- Self::Custom { palette, .. } => *palette
+ Self::Custom(custom) => custom.palette,
}
}
@@ -44,7 +45,7 @@ impl Theme {
match self {
Self::Light => &palette::EXTENDED_LIGHT,
Self::Dark => &palette::EXTENDED_DARK,
- Self::Custom { extended, .. } => extended,
+ Self::Custom(custom) => &custom.extended,
}
}
}
@@ -55,6 +56,21 @@ impl Default for Theme {
}
}
+#[derive(Debug, Clone, PartialEq)]
+pub struct Custom {
+ palette: Palette,
+ extended: Extended,
+}
+
+impl Custom {
+ pub fn new(palette: Palette) -> Self {
+ Self {
+ palette,
+ extended: Extended::generate(palette),
+ }
+ }
+}
+
#[derive(Debug, Clone, Copy)]
pub enum Application {
Default,