fix: derive PartialEq for Theme
This commit is contained in:
parent
31d7c75098
commit
6699aa4756
5 changed files with 8 additions and 23 deletions
|
|
@ -23,7 +23,7 @@ lazy_static! {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Palette type
|
/// Palette type
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
|
||||||
pub enum CosmicPalette<C> {
|
pub enum CosmicPalette<C> {
|
||||||
/// Dark mode
|
/// Dark mode
|
||||||
Dark(CosmicPaletteInner<C>),
|
Dark(CosmicPaletteInner<C>),
|
||||||
|
|
@ -80,7 +80,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The palette for Cosmic Theme, from which all color properties are derived
|
/// The palette for Cosmic Theme, from which all color properties are derived
|
||||||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Default, Deserialize, Serialize, PartialEq, Eq)]
|
||||||
pub struct CosmicPaletteInner<C> {
|
pub struct CosmicPaletteInner<C> {
|
||||||
/// name of the palette
|
/// name of the palette
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use std::fmt;
|
||||||
use crate::{util::over, CosmicPalette};
|
use crate::{util::over, CosmicPalette};
|
||||||
|
|
||||||
/// Theme Container colors of a theme, can be a theme background container, primary container, or secondary container
|
/// Theme Container colors of a theme, can be a theme background container, primary container, or secondary container
|
||||||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Default, Deserialize, Serialize, PartialEq, Eq)]
|
||||||
pub struct Container<C> {
|
pub struct Container<C> {
|
||||||
/// the color of the container
|
/// the color of the container
|
||||||
pub base: C,
|
pub base: C,
|
||||||
|
|
@ -160,7 +160,7 @@ impl fmt::Display for ContainerType {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The colors for a widget of the Cosmic theme
|
/// The colors for a widget of the Cosmic theme
|
||||||
#[derive(Clone, PartialEq, Debug, Default, Deserialize, Serialize)]
|
#[derive(Clone, PartialEq, Debug, Default, Deserialize, Serialize, Eq)]
|
||||||
pub struct Component<C> {
|
pub struct Component<C> {
|
||||||
/// The base color of the widget
|
/// The base color of the widget
|
||||||
pub base: C,
|
pub base: C,
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ pub enum Layer {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Cosmic Theme data structure with all colors and its name
|
/// Cosmic Theme data structure with all colors and its name
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
|
||||||
pub struct Theme<C> {
|
pub struct Theme<C> {
|
||||||
/// name of the theme
|
/// name of the theme
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
|
@ -149,21 +149,6 @@ pub trait LayeredTheme {
|
||||||
fn set_layer(&mut self, layer: Layer);
|
fn set_layer(&mut self, layer: Layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO better eq check
|
|
||||||
impl<C> PartialEq for Theme<C>
|
|
||||||
where
|
|
||||||
C: Clone + fmt::Debug + Default + Into<Srgba> + From<Srgba> + Serialize + DeserializeOwned,
|
|
||||||
{
|
|
||||||
fn eq(&self, other: &Self) -> bool {
|
|
||||||
self.name == other.name
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<C> Eq for Theme<C> where
|
|
||||||
C: Clone + fmt::Debug + Default + Into<Srgba> + From<Srgba> + Serialize + DeserializeOwned
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<C> Theme<C> {
|
impl<C> Theme<C> {
|
||||||
/// version of the theme
|
/// version of the theme
|
||||||
pub fn version() -> u32 {
|
pub fn version() -> u32 {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use palette::Srgba;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// utility wrapper for serializing and deserializing colors with arbitrary CSS
|
/// utility wrapper for serializing and deserializing colors with arbitrary CSS
|
||||||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Default, Deserialize, Serialize, PartialEq)]
|
||||||
pub struct CssColor {
|
pub struct CssColor {
|
||||||
c: Color,
|
c: Color,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ lazy_static::lazy_static! {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Eq, PartialEq, Default)]
|
#[derive(Debug, Clone, PartialEq, Default)]
|
||||||
pub enum ThemeType {
|
pub enum ThemeType {
|
||||||
#[default]
|
#[default]
|
||||||
Dark,
|
Dark,
|
||||||
|
|
@ -68,7 +68,7 @@ pub enum ThemeType {
|
||||||
Custom(Arc<CosmicTheme>),
|
Custom(Arc<CosmicTheme>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Eq, PartialEq, Default)]
|
#[derive(Debug, Clone, PartialEq, Default)]
|
||||||
pub struct Theme {
|
pub struct Theme {
|
||||||
pub theme_type: ThemeType,
|
pub theme_type: ThemeType,
|
||||||
pub layer: cosmic_theme::Layer,
|
pub layer: cosmic_theme::Layer,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue