diff options
author | 2022-11-09 04:07:42 +0100 | |
---|---|---|
committer | 2022-11-09 04:07:42 +0100 | |
commit | 84a1edecea8ab7d7b8aa76b77f2f44042602dd67 (patch) | |
tree | 0ff8325c7e56f319b9fe82e59acfcc4ae59cfe8e /style | |
parent | 18fb74f20092b2703a90afdb01f39754445998da (diff) | |
download | iced-84a1edecea8ab7d7b8aa76b77f2f44042602dd67.tar.gz iced-84a1edecea8ab7d7b8aa76b77f2f44042602dd67.tar.bz2 iced-84a1edecea8ab7d7b8aa76b77f2f44042602dd67.zip |
Use `derive(Default)` for `theme` types
Diffstat (limited to 'style')
-rw-r--r-- | style/src/theme.rs | 66 |
1 files changed, 16 insertions, 50 deletions
diff --git a/style/src/theme.rs b/style/src/theme.rs index a5a78ab1..ca2d1904 100644 --- a/style/src/theme.rs +++ b/style/src/theme.rs @@ -23,8 +23,9 @@ use iced_core::{Background, Color, Vector}; use std::rc::Rc; -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Default)] pub enum Theme { + #[default] Light, Dark, Custom(Box<Custom>), @@ -52,12 +53,6 @@ impl Theme { } } -impl Default for Theme { - fn default() -> Self { - Self::Light - } -} - #[derive(Debug, Clone, Copy, PartialEq)] pub struct Custom { palette: Palette, @@ -73,17 +68,13 @@ impl Custom { } } +#[derive(Default)] pub enum Application { + #[default] Default, Custom(Box<dyn application::StyleSheet<Style = Theme>>), } -impl Default for Application { - fn default() -> Self { - Self::Default - } -} - impl application::StyleSheet for Theme { type Style = Application; @@ -117,7 +108,9 @@ impl From<fn(&Theme) -> application::Appearance> for Application { /* * Button */ +#[derive(Default)] pub enum Button { + #[default] Primary, Secondary, Positive, @@ -126,12 +119,6 @@ pub enum Button { Custom(Box<dyn button::StyleSheet<Style = Theme>>), } -impl Default for Button { - fn default() -> Self { - Self::Primary - } -} - impl button::StyleSheet for Theme { type Style = Button; @@ -223,7 +210,9 @@ impl button::StyleSheet for Theme { /* * Checkbox */ +#[derive(Default)] pub enum Checkbox { + #[default] Primary, Secondary, Success, @@ -231,12 +220,6 @@ pub enum Checkbox { Custom(Box<dyn checkbox::StyleSheet<Style = Theme>>), } -impl Default for Checkbox { - fn default() -> Self { - Self::Primary - } -} - impl checkbox::StyleSheet for Theme { type Style = Checkbox; @@ -336,18 +319,14 @@ fn checkbox_appearance( /* * Container */ +#[derive(Default)] pub enum Container { + #[default] Transparent, Box, Custom(Box<dyn container::StyleSheet<Style = Theme>>), } -impl Default for Container { - fn default() -> Self { - Self::Transparent - } -} - impl From<fn(&Theme) -> container::Appearance> for Container { fn from(f: fn(&Theme) -> container::Appearance) -> Self { Self::Custom(Box::new(f)) @@ -729,19 +708,15 @@ impl pane_grid::StyleSheet for Theme { /* * Progress Bar */ +#[derive(Default)] pub enum ProgressBar { + #[default] Primary, Success, Danger, Custom(Box<dyn progress_bar::StyleSheet<Style = Theme>>), } -impl Default for ProgressBar { - fn default() -> Self { - Self::Primary - } -} - impl From<fn(&Theme) -> progress_bar::Appearance> for ProgressBar { fn from(f: fn(&Theme) -> progress_bar::Appearance) -> Self { Self::Custom(Box::new(f)) @@ -784,17 +759,13 @@ impl progress_bar::StyleSheet for fn(&Theme) -> progress_bar::Appearance { /* * Rule */ +#[derive(Default)] pub enum Rule { + #[default] Default, Custom(Box<dyn rule::StyleSheet<Style = Theme>>), } -impl Default for Rule { - fn default() -> Self { - Self::Default - } -} - impl From<fn(&Theme) -> rule::Appearance> for Rule { fn from(f: fn(&Theme) -> rule::Appearance) -> Self { Self::Custom(Box::new(f)) @@ -895,18 +866,13 @@ impl scrollable::StyleSheet for Theme { /* * Text */ -#[derive(Clone, Copy)] +#[derive(Clone, Copy, Default)] pub enum Text { + #[default] Default, Color(Color), } -impl Default for Text { - fn default() -> Self { - Self::Default - } -} - impl From<Color> for Text { fn from(color: Color) -> Self { Text::Color(color) |