Use derive(Default) for theme types
This commit is contained in:
parent
18fb74f200
commit
84a1edecea
1 changed files with 16 additions and 50 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue